| # Copyright 2023 The Pigweed Authors |
| # |
| # Licensed under the Apache License, Version 2.0 (the "License"); you may not |
| # use this file except in compliance with the License. You may obtain a copy of |
| # the License at |
| # |
| # https://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, software |
| # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| # License for the specific language governing permissions and limitations under |
| # the License. |
| |
| load("@bazel_skylib//rules:native_binary.bzl", "native_binary") |
| load("//targets:transition.bzl", "rp2040_binary", "stm32_binary") |
| |
| cc_binary( |
| name = "blinky", |
| srcs = ["main.cc"], |
| malloc = select({ |
| "//conditions:default": "@bazel_tools//tools/cpp:malloc", |
| "@pico-sdk//bazel/constraint:rp2": "@pigweed//pw_malloc", |
| "@platforms//cpu:armv7e-m": "@pigweed//pw_malloc", |
| }), |
| deps = [ |
| "//libraries/pw_board_led", |
| "@pigweed//pw_assert:backend_impl", |
| "@pigweed//pw_chrono:system_clock", |
| "@pigweed//pw_chrono:system_timer", |
| "@pigweed//pw_log", |
| "@pigweed//pw_log:backend_impl", |
| "@pigweed//pw_system:init", |
| "@pigweed//pw_system:io", |
| "@pigweed//pw_system:rpc_server", |
| "@pigweed//pw_system:target_hooks", |
| "@pigweed//pw_system:work_queue", |
| ] + select({ |
| "//conditions:default": [ |
| "@pigweed//targets/host_device_simulator:boot", |
| ], |
| "@pico-sdk//bazel/constraint:rp2": [ |
| "@pico-sdk//src/common/pico_stdlib:pico_stdlib", |
| "@pigweed//pw_tokenizer:linker_script", |
| "@pigweed//pw_toolchain/arm_gcc:arm_none_eabi_gcc_support", |
| "@pigweed//targets/rp2040:pre_init", |
| ], |
| "@platforms//cpu:armv7e-m": [ |
| "//targets/stm32f429i_disc1_stm32cube:linker_script", |
| "@pigweed//pw_tokenizer:linker_script", |
| "@pigweed//pw_toolchain/arm_gcc:arm_none_eabi_gcc_support", |
| "@pigweed//targets/stm32f429i_disc1_stm32cube:pre_init", |
| ], |
| }), |
| ) |
| |
| stm32_binary( |
| name = "blinky.elf", |
| binary = ":blinky", |
| # Visible to the flasher. |
| visibility = ["//tools:__pkg__"], |
| ) |
| |
| rp2040_binary( |
| name = "rp2040_blinky.elf", |
| binary = ":blinky", |
| # Visible to the flasher. |
| visibility = ["//tools:__pkg__"], |
| ) |
| |
| native_binary( |
| name = "flash_stm32", |
| src = "//tools:flash_device", |
| # TODO: https://github.com/bazelbuild/bazel-skylib/issues/399 - out should |
| # be optional. |
| # |
| # We use the .exe extension for the symlink because it's required on Windows |
| # and tolerated on other platforms. |
| out = "flash_stm32.exe", |
| args = [ |
| "--device", |
| "STM32-Discovery", |
| "$(rootpath //examples/01_blinky:blinky.elf)", |
| ], |
| data = [":blinky.elf"], |
| ) |
| |
| native_binary( |
| name = "console", |
| src = "//tools:console", |
| out = "console.exe", |
| args = [ |
| "-d", |
| "/dev/ttyACM0", |
| "-b", |
| "115200", |
| "--token-databases", |
| "$(rootpath //examples/01_blinky:blinky.elf)", |
| ], |
| data = [":blinky.elf"], |
| ) |