blob: 4204efdfe7273d3370084c110946bb5a93dc6f49 [file] [log] [blame]
load("@bazel_skylib//rules:run_binary.bzl", "run_binary")
package(default_visibility = ["//visibility:public"])
# PICO_BAZEL_CONFIG: PICO_SDK_VERSION_STRING, SDK version, type=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, group=pico_base
PICO_SDK_VERSION_MAJOR = int(_version_parts[0])
# PICO_BAZEL_CONFIG: PICO_SDK_VERSION_MINOR, SDK minor version number, type=int, 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, 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, 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, group=pico_base
# PICO_BUILD_DEFINE: PICO_SDK_VERSION_MINOR, SDK minor version number, type=int, group=pico_base
# PICO_BUILD_DEFINE: PICO_SDK_VERSION_REVISION, SDK version revision, type=int, group=pico_base
# PICO_BUILD_DEFINE: PICO_SDK_VERSION_PRE_RELEASE_ID, optional SDK pre-release version identifier, type=string, group=pico_base
# PICO_BUILD_DEFINE: PICO_SDK_VERSION_STRING, SDK version, type=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"],
)
alias(
name = "platform_defs",
actual = select({
"//bazel/constraint:host": "//src/host/pico_platform:platform_defs",
"//conditions:default": "//src/rp2_common/pico_platform:platform_defs",
}),
)
alias(
name = "pico_platform",
actual = select({
"//bazel/constraint:host": "//src/host/pico_platform:pico_platform",
"//conditions:default": "//src/rp2_common/pico_platform:pico_platform",
}),
)
# PICO_BAZEL_CONFIG: PICO_NO_HARDWARE, OPTION: Whether the build is not targeting an RP2040 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 device, type=bool, default=1 when PICO_PLATFORM is host, 0 otherwise, group=build
# PICO_BAZEL_CONFIG: PICO_ON_DEVICE, OPTION: Whether the build is targeting an RP2040 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 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",
],
}),
)
cc_library(
name = "pico_base_interface",
hdrs = [
"include/pico.h",
"include/pico/assert.h",
"include/pico/config.h",
"include/pico/error.h",
"include/pico/types.h",
],
includes = ["include"],
# Be extra careful about who references this for now; if users depend on
# this but not `pico_base` they'll end up with undefined symbols.
# It's generally safe for anything that circularly depends on
# //src/common/pico_base:pico_base to be added to this allowlist because
# that implicitly means the transitive dependencies of pico_base will get
# linked in.
visibility = [
"//src/common/pico_binary_info:__pkg__",
"//src/common/pico_sync:__pkg__",
"//src/common/pico_time:__pkg__",
"//src/common/pico_util:__pkg__",
"//src/host/hardware_timer:__pkg__",
"//src/host/pico_platform:__pkg__",
"//src/rp2_common/boot_stage2:__pkg__",
"//src/rp2_common/hardware_claim:__pkg__",
"//src/rp2_common/hardware_clocks:__pkg__",
"//src/rp2_common/hardware_gpio:__pkg__",
"//src/rp2_common/hardware_irq:__pkg__",
"//src/rp2_common/hardware_pll:__pkg__",
"//src/rp2_common/hardware_resets:__pkg__",
"//src/rp2_common/hardware_sync:__pkg__",
"//src/rp2_common/hardware_timer:__pkg__",
"//src/rp2_common/hardware_watchdog:__pkg__",
"//src/rp2_common/hardware_xosc:__pkg__",
"//src/rp2_common/pico_bootrom:__pkg__",
"//src/rp2_common/pico_malloc:__pkg__",
"//src/rp2_common/pico_platform:__pkg__",
"//src/rp2_common/pico_printf:__pkg__",
"//src/rp2_common/pico_runtime:__pkg__",
"//src/rp2_common/pico_standard_link:__pkg__",
],
deps = [
":common_sdk_defines",
":version",
"//bazel/config:PICO_CONFIG_HEADER",
],
)
cc_library(
name = "pico_base",
implementation_deps = select({
"//bazel/constraint:host": [],
"//conditions:default": [
"//src/rp2_common/pico_platform:platform_link_deps",
],
}),
deps = [
# :pico_platform creates circular dependencies, so break them
# via an intermediate.
":pico_platform",
":pico_base_interface",
],
)