1load("@bazel_skylib//rules:run_binary.bzl", "run_binary") 2 3package(default_visibility = ["//visibility:public"]) 4 5# PICO_BAZEL_CONFIG: PICO_SDK_VERSION_STRING, SDK version string, type=string, default=Current SDK version string, group=pico_base 6PICO_SDK_VERSION_STRING = module_version() if module_version() != None else "0.0.1-WORKSPACE" 7 8_version_parts = PICO_SDK_VERSION_STRING.split(".") 9 10# PICO_BAZEL_CONFIG: PICO_SDK_VERSION_MAJOR, SDK major version number, type=int, default=Current SDK major version, group=pico_base 11PICO_SDK_VERSION_MAJOR = int(_version_parts[0]) 12 13# PICO_BAZEL_CONFIG: PICO_SDK_VERSION_MINOR, SDK minor version number, type=int, default=Current SDK minor version, group=pico_base 14PICO_SDK_VERSION_MINOR = int(_version_parts[1]) 15 16_revision_parts = _version_parts[2].split("-") 17 18# PICO_BAZEL_CONFIG: PICO_SDK_VERSION_REVISION, SDK version revision, type=int, default=Current SDK revision, group=pico_base 19PICO_SDK_VERSION_REVISION = int(_revision_parts[0]) 20 21# PICO_BAZEL_CONFIG: PICO_SDK_VERSION_PRE_RELEASE_ID, Optional SDK pre-release version identifier, default=Current SDK pre-release identifier, type=string, group=pico_base 22PICO_SDK_VERSION_PRE_RELEASE_ID = _revision_parts[1] if len(_revision_parts) > 1 else None 23 24run_binary( 25 name = "version_header", 26 srcs = ["include/pico/version.h.in"], 27 outs = ["generated_include/pico/version.h"], 28 args = [ 29 "--version-string={}".format(PICO_SDK_VERSION_STRING), 30 "--template=$(location include/pico/version.h.in)", 31 "--output=$(location generated_include/pico/version.h)", 32 ], 33 tool = "//bazel:generate_version_header", 34 visibility = ["//visibility:private"], 35) 36 37# PICO_BUILD_DEFINE: PICO_SDK_VERSION_MAJOR, SDK major version number, type=int, default=Current SDK major version, group=pico_base 38# PICO_BUILD_DEFINE: PICO_SDK_VERSION_MINOR, SDK minor version number, type=int, default=Current SDK minor version, group=pico_base 39# PICO_BUILD_DEFINE: PICO_SDK_VERSION_REVISION, SDK version revision, type=int, default=Current SDK revision, group=pico_base 40# PICO_BUILD_DEFINE: PICO_SDK_VERSION_PRE_RELEASE_ID, Optional SDK pre-release version identifier, default=Current SDK pre-release identifier, type=string, group=pico_base 41# PICO_BUILD_DEFINE: PICO_SDK_VERSION_STRING, SDK version string, type=string, default=Current SDK version string, group=pico_base 42cc_library( 43 name = "version", 44 hdrs = ["generated_include/pico/version.h"], 45 defines = [ 46 'PICO_SDK_VERSION_STRING=\\"{}\\"'.format(PICO_SDK_VERSION_STRING), 47 "PICO_SDK_VERSION_MAJOR={}".format(PICO_SDK_VERSION_MAJOR), 48 "PICO_SDK_VERSION_MINOR={}".format(PICO_SDK_VERSION_MINOR), 49 "PICO_SDK_VERSION_REVISION={}".format(PICO_SDK_VERSION_REVISION), 50 ] + [] if PICO_SDK_VERSION_PRE_RELEASE_ID == None else ['PICO_SDK_VERSION_PRE_RELEASE_ID=\\"{}\\"'.format(PICO_SDK_VERSION_PRE_RELEASE_ID)], 51 includes = ["generated_include"], 52) 53 54# PICO_BAZEL_CONFIG: PICO_NO_HARDWARE, Option as to whether the build is not targeting an RP2040 or RP2350 device, type=bool, default=1 when PICO_PLATFORM is host, 0 otherwise, group=build 55# PICO_BUILD_DEFINE: PICO_NO_HARDWARE, Whether the build is not targeting an RP2040 or RP2350 device, type=bool, default=1 when PICO_PLATFORM is host, 0 otherwise, group=build 56# PICO_BAZEL_CONFIG: PICO_ON_DEVICE, Option as to whether the build is targeting an RP2040 or RP2350 device, type=bool, default=0 when PICO_PLATFORM is host, 1 otherwise, group=build 57# PICO_BUILD_DEFINE: PICO_ON_DEVICE, Whether the build is targeting an RP2040 or RP2350 device, type=bool, default=0 when PICO_PLATFORM is host, 1 otherwise, group=build 58# PICO_BUILD is undocumented in CMake. 59cc_library( 60 name = "common_sdk_defines", 61 defines = select({ 62 "//bazel/constraint:host": [ 63 "PICO_ON_DEVICE=0", 64 "PICO_NO_HARDWARE=1", 65 "PICO_BUILD=1", 66 ], 67 "//conditions:default": [ 68 "PICO_ON_DEVICE=1", 69 "PICO_NO_HARDWARE=0", 70 "PICO_BUILD=1", 71 ], 72 }) + select({ 73 "//bazel/constraint:rp2040": ["PICO_RP2040=1"], 74 "//bazel/constraint:rp2350": ["PICO_RP2350=1"], 75 "//conditions:default": [], 76 }), 77) 78 79# While this provides the "pico.h" header, nearly everything should 80# instead depend on `//src/rp2_common:pico_platform` to get these headers. If 81# you try to depend on just `pico_base_headers`, you'll end up with missing 82# symbols. 83cc_library( 84 name = "pico_base_headers", 85 hdrs = [ 86 "include/pico.h", 87 "include/pico/assert.h", 88 "include/pico/config.h", 89 "include/pico/error.h", 90 "include/pico/types.h", 91 ], 92 includes = ["include"], 93 visibility = [ 94 "//src/common:__subpackages__", 95 "//src/host/hardware_sync:__pkg__", 96 "//src/host/hardware_timer:__pkg__", 97 "//src/host/pico_platform:__pkg__", 98 "//src/rp2040/boot_stage2:__pkg__", 99 "//src/rp2040/pico_platform:__pkg__", 100 "//src/rp2350/boot_stage2:__pkg__", 101 "//src/rp2350/pico_platform:__pkg__", 102 "//src/rp2_common/hardware_base:__pkg__", 103 "//src/rp2_common/hardware_boot_lock:__pkg__", 104 "//src/rp2_common/hardware_clocks:__pkg__", 105 "//src/rp2_common/hardware_gpio:__pkg__", 106 "//src/rp2_common/hardware_pll:__pkg__", 107 "//src/rp2_common/hardware_resets:__pkg__", 108 "//src/rp2_common/hardware_sync:__pkg__", 109 "//src/rp2_common/hardware_sync_spin_lock:__pkg__", 110 "//src/rp2_common/hardware_ticks:__pkg__", 111 "//src/rp2_common/hardware_timer:__pkg__", 112 "//src/rp2_common/hardware_watchdog:__pkg__", 113 "//src/rp2_common/hardware_xosc:__pkg__", 114 "//src/rp2_common/pico_crt0:__pkg__", 115 "//src/rp2_common/pico_printf:__pkg__", 116 "//src/rp2_common/pico_runtime:__pkg__", 117 "//src/rp2_common/pico_runtime_init:__pkg__", 118 "//src/rp2_common/pico_time_adapter:__pkg__", 119 "@picotool//:__subpackages__", 120 ], 121 deps = [ 122 ":common_sdk_defines", 123 ":version", 124 "//bazel/config:PICO_CONFIG_HEADER", 125 "//src:pico_platform_internal", 126 ], 127) 128