Skip to content

Commit 485b34a

Browse files
Hook up pio version string in Bazel build
1 parent 14896b6 commit 485b34a

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

test/kitchen_sink/BUILD.bazel

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
load("//bazel:defs.bzl", "compatible_with_rp2")
1+
load("//bazel:defs.bzl", "compatible_with_rp2", "pico_generate_pio_header")
22
load("//bazel/util:transition.bzl", "kitchen_sink_test_binary")
33

44
package(default_visibility = ["//visibility:public"])
@@ -21,6 +21,11 @@ cc_library(
2121
includes = ["."],
2222
)
2323

24+
pico_generate_pio_header(
25+
name = "trivial_pio_test",
26+
srcs = ["trivial.pio"],
27+
)
28+
2429
cc_library(
2530
name = "kitchen_sink_common",
2631
testonly = True,

tools/pioasm/BUILD.bazel

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
load("@bazel_skylib//rules:expand_template.bzl", "expand_template")
2+
13
package(default_visibility = ["//visibility:public"])
24

35
# TODO: No support for building the parser.
@@ -19,6 +21,7 @@ cc_library(
1921
"pio_disassembler.h",
2022
"pio_enums.h",
2123
"pio_types.h",
24+
":version",
2225
],
2326
copts = select({
2427
"@rules_cc//cc/compiler:msvc-cl": ["/std:c++20"],
@@ -63,6 +66,15 @@ cc_library(
6366
alwayslink = True,
6467
)
6568

69+
expand_template(
70+
name = "version",
71+
template = "version.h.in",
72+
substitutions = {
73+
"${PIOASM_VERSION_STRING}": module_version() if module_version() != None else "0.0.1-WORKSPACE",
74+
},
75+
out = "gen/version.h",
76+
)
77+
6678
cc_binary(
6779
name = "pioasm",
6880
deps = [

0 commit comments

Comments
 (0)