Skip to content

Commit

Permalink
[Bazel] Get MSVC working (#157)
Browse files Browse the repository at this point in the history
Fixes the Windows MSVC build for Picotool.
  • Loading branch information
armandomontanez authored Oct 30, 2024
1 parent 3ea1bb5 commit f41f7fa
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
19 changes: 16 additions & 3 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ otp_header_parse(
name = "otp_header",
src = "@pico-sdk//src/rp2350/hardware_regs:otp_data_header",
out = "rp2350.json.h",
target_compatible_with = select({
"@rules_cc//cc/compiler:msvc-cl": ["@platforms//:incompatible"],
"//conditions:default": [],
}),
)

cc_binary(
Expand All @@ -56,10 +60,14 @@ cc_binary(
"main.cpp",
"otp.cpp",
"otp.h",
"rp2350.json.h",
"rp2350.rom.h",
"xip_ram_perms.cpp",
],
] + select({
# MSVC can't handle long strings, so use this manually generated
# header instead.
"@rules_cc//cc/compiler:msvc-cl": [],
"//conditions:default": ["rp2350.json.h"],
}),
copts = select({
"@rules_cc//cc/compiler:msvc-cl": [
"/std:c++20",
Expand Down Expand Up @@ -106,5 +114,10 @@ cc_binary(
"@pico-sdk//src/rp2350/hardware_regs:otp_data",
"@pico-sdk//src/rp2_common/pico_bootrom:pico_bootrom_headers",
"@pico-sdk//src/rp2_common/pico_stdio_usb:reset_interface_headers",
],
] + select({
# MSVC can't handle long strings, so use this manually generated
# header instead.
"@rules_cc//cc/compiler:msvc-cl": ["//otp_header_parser:pre_generated_otp_header"],
"//conditions:default": [],
}),
)
1 change: 1 addition & 0 deletions bintool/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ cc_library(
"metadata.h",
],
copts = select({
"@rules_cc//cc/compiler:msvc-cl": ["/std:c++20"],
"@platforms//os:windows": [],
"//conditions:default": [
"-Wno-unused-variable",
Expand Down
6 changes: 6 additions & 0 deletions otp_header_parser/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
package(default_visibility = ["//visibility:public"])

cc_library(
name = "pre_generated_otp_header",
includes = ["."],
hdrs = ["rp2350.json.h"],
)

cc_binary(
name = "otp_header_parser",
srcs = ["otp_header_parse.cpp"],
Expand Down

0 comments on commit f41f7fa

Please sign in to comment.