| # Copyright 2024 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("@pigweed//pw_build:merge_flags.bzl", "flags_from_dict") |
| load("@pigweed//pw_build:pigweed.bzl", "pw_cc_test") |
| load("@zephyr//:cc.bzl", "zephyr_cc_binary", "zephyr_cc_library") |
| load("@zephyr//:defs.bzl", "dts_cc_library") |
| |
| package(default_visibility = ["//visibility:public"]) |
| |
| label_flag( |
| name = "pw_assert_backend_impl", |
| build_setting_default = "@pigweed//pw_assert_log:assert_backend", |
| ) |
| |
| # dts_library( |
| # name = "app_overlay", |
| # dts_parent = "@zephyr//boards/native/native_sim:native_sim", |
| # overlay = "app.overlay", |
| # ) |
| |
| dts_cc_library( |
| name = "app_host_dts", |
| dts_lib = "@zephyr//boards/native/native_sim:native_sim", |
| target_compatible_with = ["@zephyr//boards/native:board_name_native_sim"], |
| # dts_lib = ":app_overlay", |
| ) |
| |
| dts_cc_library( |
| name = "app_tdk_robokit1", |
| bindings = ["@zephyr//dts:bindings"], |
| dts_lib = "@zephyr//boards/tdk/robokit1:robokit1", |
| target_compatible_with = ["@zephyr//boards/tdk:tdk_robokit1"], |
| ) |
| |
| filegroup( |
| name = "autoconf_file", |
| srcs = ["generated/zephyr/autoconf.h"], |
| ) |
| |
| cc_library( |
| name = "autoconf", |
| srcs = [ |
| ":autoconf_file", |
| "generated/zephyr/kobj-types-enum.h", |
| ], |
| includes = ["generated"], |
| ) |
| |
| platform( |
| name = "robokit1", |
| flags = flags_from_dict({ |
| "@zephyr//:autoconf_library": ":autoconf", |
| "@zephyr//:autoconf_file": ":autoconf_file", |
| "@kconfig//:CONFIG_MULTITHREADING": True, |
| "@kconfig//:CONFIG_TIMESLICING": True, |
| "@kconfig//:CONFIG_XIP": True, |
| "@kconfig//:CONFIG_SYS_CLOCK_EXISTS": True, |
| "@kconfig//:CONFIG_KERNEL_MEM_POOL": True, |
| }), |
| parents = ["@zephyr//boards/tdk:robokit1"], |
| ) |
| |
| zephyr_cc_library( |
| name = "app_main", |
| srcs = ["hello_dts.cc"] |
| ) |
| |
| zephyr_cc_binary( |
| name = "app", |
| srcs = [ |
| "@zephyr//lib/cpp/abi:cpp_dtors.c", # CONFIG_STATIC_INIT_GNU |
| "@zephyr//subsys/tracing:tracing_none.c", # NOT CONFIG_PERCEPIO_TRACERECORDER AND |
| # NOT CONFIG_TRACING_CTF AND |
| # NOT CONFIG_SEGGER_SYSTEMVIEW AND |
| # NOT CONFIG_TRACING_TEST AND |
| # NOT CONFIG_TRACING_USER |
| "generated/configs.c", # Should be generated in misc/ |
| ], |
| defines = select({ |
| "@platforms//cpu:armv7e-m": [ |
| "CONFIG_ARM=1", |
| "CONFIG_BUILD_OUTPUT_HEX=1", |
| "CONFIG_ARM_MPU=1", |
| "CONFIG_HW_STACK_PROTECTION=1", |
| "CONFIG_WDT_DISABLE_AT_BOOT=1", |
| "CONFIG_CONSOLE=1", |
| "CONFIG_UART_CONSOLE=1", |
| "CONFIG_SERIAL=1", |
| ], |
| "@platforms//cpu:x86_64": [ |
| "CONFIG_ARCH_POSIX=1", |
| ], |
| }), |
| deps = [ |
| ":app_main", |
| "@pigweed//pw_assert:assert_backend_impl", |
| "@pigweed//pw_assert:check_backend_impl", |
| "@pigweed//pw_log", |
| "@pigweed//pw_log:backend_impl", |
| "@pigweed//pw_sys_io", |
| "@zephyr", |
| "@zephyr//:autoconf_library", |
| "@zephyr//:dts_cc_library", |
| "@zephyr//arch/common", |
| "@zephyr//arch/common:isr_tables", # CONFIG_GEN_ISR_TABLES |
| "@zephyr//drivers/clock_control", # CONFIG_CLOCK_CONTROL |
| "@zephyr//drivers/console:uart_console", # CONFIG_UART_CONSOLE |
| "@zephyr//drivers/gpio:sam", # CONFIG_GPIO_SAM |
| "@zephyr//drivers/pinctrl:sam", # CONFIG_PINCTRL_SAM |
| "@zephyr//drivers/watchdog", # CONFIG_WATCHDOG |
| "@zephyr//lib/libc/picolibc", # CONFIG_PICOLIBC |
| "@zephyr//lib/heap", |
| "@zephyr//lib/os", |
| ] + select({ |
| "@platforms//cpu:armv7e-m": [ |
| "@zephyr//arch/arm/core/cortex_m", |
| "@zephyr//drivers/timer:cortex_m_systick", |
| # "@pigweed//pw_toolchain/arm_gcc:arm_none_eabi_gcc_support", |
| # "@pigweed//targets/stm32f429i_disc1:basic_linker_script", |
| # "@pigweed//targets/stm32f429i_disc1:pre_init", |
| ], |
| }) + select({ |
| "@zephyr//boards/tdk:tdk_robokit1": [ |
| # "@zephyr//boards/tdk/robokit1:devicetree_generated", |
| "@zephyr//include:posix", |
| "@zephyr//drivers/serial:atmel_sam_uart", |
| ], |
| "@zephyr//boards/native:board_name_native_sim": [ |
| ":app_host_dts", |
| "@zephyr//include:posix", |
| ], |
| }), |
| ) |
| |
| pw_cc_test( |
| name = "test", |
| srcs = [ |
| "native_sim_test.cc", |
| ], |
| copts = [ |
| "-DCONFIG_ARCH_POSIX=1", |
| ], |
| deps = [ |
| ":app_host_dts", |
| "@zephyr", |
| "@zephyr//include:posix", |
| ], |
| ) |