forked from raspberrypi/pico-sdk
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBUILD.bazel
More file actions
137 lines (125 loc) · 6.55 KB
/
Copy pathBUILD.bazel
File metadata and controls
137 lines (125 loc) · 6.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
load("@bazel_skylib//rules:run_binary.bzl", "run_binary")
load("@rules_cc//cc:cc_library.bzl", "cc_library")
package(default_visibility = ["//visibility:public"])
# PICO_BAZEL_CONFIG: PICO_SDK_VERSION_STRING, SDK version string, type=string, default=Current SDK version string, group=pico_base
PICO_SDK_VERSION_STRING = module_version() if module_version() != None else "0.0.1-WORKSPACE"
_version_parts = PICO_SDK_VERSION_STRING.split(".")
# PICO_BAZEL_CONFIG: PICO_SDK_VERSION_MAJOR, SDK major version number, type=int, default=Current SDK major version, group=pico_base
PICO_SDK_VERSION_MAJOR = int(_version_parts[0])
# PICO_BAZEL_CONFIG: PICO_SDK_VERSION_MINOR, SDK minor version number, type=int, default=Current SDK minor version, group=pico_base
PICO_SDK_VERSION_MINOR = int(_version_parts[1])
_revision_parts = _version_parts[2].split("-")
# PICO_BAZEL_CONFIG: PICO_SDK_VERSION_REVISION, SDK version revision, type=int, default=Current SDK revision, group=pico_base
PICO_SDK_VERSION_REVISION = int(_revision_parts[0])
# 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
PICO_SDK_VERSION_PRE_RELEASE_ID = _revision_parts[1] if len(_revision_parts) > 1 else None
run_binary(
name = "version_header",
srcs = ["include/pico/version.h.in"],
outs = ["generated_include/pico/version.h"],
args = [
"--version-string={}".format(PICO_SDK_VERSION_STRING),
"--template=$(location include/pico/version.h.in)",
"--output=$(location generated_include/pico/version.h)",
],
tool = "//bazel:generate_version_header",
visibility = ["//visibility:private"],
)
# PICO_BUILD_DEFINE: PICO_SDK_VERSION_MAJOR, SDK major version number, type=int, default=Current SDK major version, group=pico_base
# PICO_BUILD_DEFINE: PICO_SDK_VERSION_MINOR, SDK minor version number, type=int, default=Current SDK minor version, group=pico_base
# PICO_BUILD_DEFINE: PICO_SDK_VERSION_REVISION, SDK version revision, type=int, default=Current SDK revision, group=pico_base
# 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
# PICO_BUILD_DEFINE: PICO_SDK_VERSION_STRING, SDK version string, type=string, default=Current SDK version string, group=pico_base
cc_library(
name = "version",
hdrs = ["generated_include/pico/version.h"],
defines = [
'PICO_SDK_VERSION_STRING=\\"{}\\"'.format(PICO_SDK_VERSION_STRING),
"PICO_SDK_VERSION_MAJOR={}".format(PICO_SDK_VERSION_MAJOR),
"PICO_SDK_VERSION_MINOR={}".format(PICO_SDK_VERSION_MINOR),
"PICO_SDK_VERSION_REVISION={}".format(PICO_SDK_VERSION_REVISION),
] + [] if PICO_SDK_VERSION_PRE_RELEASE_ID == None else ['PICO_SDK_VERSION_PRE_RELEASE_ID=\\"{}\\"'.format(PICO_SDK_VERSION_PRE_RELEASE_ID)],
includes = ["generated_include"],
)
# 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
# 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
# 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
# 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
# PICO_BUILD is undocumented in CMake.
cc_library(
name = "common_sdk_defines",
defines = select({
"//bazel/constraint:host": [
"PICO_ON_DEVICE=0",
"PICO_NO_HARDWARE=1",
"PICO_BUILD=1",
],
"//conditions:default": [
"PICO_ON_DEVICE=1",
"PICO_NO_HARDWARE=0",
"PICO_BUILD=1",
],
}) + select({
"//bazel/constraint:rp2040": ["PICO_RP2040=1"],
"//bazel/constraint:rp2350": ["PICO_RP2350=1"],
"//conditions:default": [],
}) + select({
"//bazel/constraint:pico_binary_type_no_flash": ["PICO_NO_FLASH=1"],
"//bazel/constraint:pico_binary_type_copy_to_ram": ["PICO_COPY_TO_RAM=1"],
"//bazel/constraint:pico_binary_type_blocked_ram": ["PICO_USE_BLOCKED_RAM=1"],
"//conditions:default": [],
}),
)
# While this provides the "pico.h" header, nearly everything should
# instead depend on `//src/rp2_common:pico_platform` to get these headers. If
# you try to depend on just `pico_base_headers`, you'll end up with missing
# symbols.
cc_library(
name = "pico_base_headers",
hdrs = [
"include/pico.h",
"include/pico/assert.h",
"include/pico/config.h",
"include/pico/error.h",
"include/pico/types.h",
],
includes = ["include"],
visibility = [
"//src/common:__subpackages__",
"//src/host/hardware_irq:__pkg__",
"//src/host/hardware_sync:__pkg__",
"//src/host/hardware_timer:__pkg__",
"//src/host/pico_platform:__pkg__",
"//src/host/pico_unique_id:__pkg__",
"//src/rp2040/boot_stage2:__pkg__",
"//src/rp2040/pico_platform:__pkg__",
"//src/rp2350/boot_stage2:__pkg__",
"//src/rp2350/pico_platform:__pkg__",
"//src/rp2_common/hardware_base:__pkg__",
"//src/rp2_common/hardware_boot_lock:__pkg__",
"//src/rp2_common/hardware_clocks:__pkg__",
"//src/rp2_common/hardware_gpio:__pkg__",
"//src/rp2_common/hardware_pll:__pkg__",
"//src/rp2_common/hardware_resets:__pkg__",
"//src/rp2_common/hardware_sync:__pkg__",
"//src/rp2_common/hardware_sync_spin_lock:__pkg__",
"//src/rp2_common/hardware_ticks:__pkg__",
"//src/rp2_common/hardware_timer:__pkg__",
"//src/rp2_common/hardware_watchdog:__pkg__",
"//src/rp2_common/hardware_rosc:__pkg__",
"//src/rp2_common/hardware_xosc:__pkg__",
"//src/rp2_common/pico_crt0:__pkg__",
"//src/rp2_common/pico_platform_common:__pkg__",
"//src/rp2_common/pico_printf:__pkg__",
"//src/rp2_common/pico_runtime:__pkg__",
"//src/rp2_common/pico_runtime_init:__pkg__",
"//src/rp2_common/pico_time_adapter:__pkg__",
"@picotool//:__subpackages__",
],
deps = [
":common_sdk_defines",
":version",
"//bazel/config:PICO_CONFIG_HEADER",
"//src:pico_platform_internal",
],
)