Skip to content

Commit

Permalink
workspace: Updates Bazel build files to work in CI
Browse files Browse the repository at this point in the history
No-Docs-Update-Reason: Fixes build files.
Change-Id: I596ba5b567cbe6625d378695e0c59a15db974578
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/54680
Reviewed-by: Keir Mierle <[email protected]>
Reviewed-by: Akira Baruah <[email protected]>
Commit-Queue: Keir Mierle <[email protected]>
  • Loading branch information
silvergasp authored and CQ Bot Account committed Jul 29, 2021
1 parent 3c86dc9 commit f91e763
Show file tree
Hide file tree
Showing 31 changed files with 221 additions and 93 deletions.
51 changes: 35 additions & 16 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ load("@cipd_deps//:cipd_init.bzl", "cipd_init")

cipd_init()

# Setup python support.
# Set up Python support.
# Required by: rules_fuzzing.
# Used in modules: None.
http_archive(
Expand All @@ -42,7 +42,7 @@ http_archive(
],
)

# Set up Starlark library
# Set up Starlark library.
# Required by: io_bazel_rules_go, com_google_protobuf.
# Used in modules: None.
# This must be instantiated before com_google_protobuf as protobuf_deps() pulls
Expand All @@ -61,7 +61,20 @@ load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")

bazel_skylib_workspace()

# Sets up host hermetic host toolchain.
# Set up upstream googletest and googlemock.
# Required by: Pigweed.
# Used in modules: //pw_analog, //pw_i2c.
http_archive(
name = "com_google_googletest",
sha256 = "9dc9157a9a1551ec7a7e43daea9a694a0bb5fb8bec81235d8a1e6ef64c716dcb",
strip_prefix = "googletest-release-1.10.0",
urls = [
"https://mirror.bazel.build/github.com/google/googletest/archive/release-1.10.0.tar.gz",
"https://github.com/google/googletest/archive/release-1.10.0.tar.gz",
],
)

# Set up host hermetic host toolchain.
# Required by: All cc targets.
# Used in modules: All cc targets.
git_repository(
Expand All @@ -78,7 +91,7 @@ load("@rules_cc_toolchain//cc_toolchain:cc_toolchain.bzl", "register_cc_toolchai

register_cc_toolchains()

# Set up protobuf rules
# Set up Protobuf rules.
# Required by: pigweed, com_github_bazelbuild_buildtools.
# Used in modules: //pw_protobuf.
http_archive(
Expand All @@ -92,9 +105,9 @@ load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")

protobuf_deps()

# Setup tools to build custom grpc rules.
# Set up tools to build custom GRPC rules.
# Required by: pigweed.
# Used in modules: //pw_protobuf
# Used in modules: //pw_protobuf.
http_archive(
name = "rules_proto_grpc",
sha256 = "5f0f2fc0199810c65a2de148a52ba0aff14d631d4e8202f41aff6a9d590a471b",
Expand All @@ -112,15 +125,18 @@ rules_proto_grpc_toolchains()

rules_proto_grpc_repos()

# Set up build_bazel_rules_nodejs.
# Set up Bazel platforms.
# Required by: pigweed.
# Used in modules: //pw_web_ui.
# Used in modules: //pw_build, (Assorted modules via select statements).
git_repository(
name = "platforms",
commit = "d4c9d7f51a7c403814b60f66d20eeb425fbaaacb",
remote = "https://github.com/bazelbuild/platforms.git",
)

# Set up NodeJs rules.
# Required by: pigweed.
# Used in modules: //pw_web_ui.
http_archive(
name = "build_bazel_rules_nodejs",
sha256 = "8f5f192ba02319254aaf2cdcca00ec12eaafeb979a80a1e946773c520ae0a2c9",
Expand All @@ -142,6 +158,9 @@ yarn_install(
yarn_lock = "//:yarn.lock",
)

# Set up web-testing rules.
# Required by: pigweed.
# Used in modules: //pw_web_ui.
http_archive(
name = "io_bazel_rules_webtesting",
sha256 = "9bb461d5ef08e850025480bab185fd269242d4e533bca75bfb748001ceb343c3",
Expand All @@ -162,7 +181,7 @@ browser_repositories(
firefox = True,
)

# Setup embedded C/C++ toolchains.
# Set up embedded C/C++ toolchains.
# Required by: pigweed.
# Used in modules: //pw_polyfill, //pw_build (all pw_cc* targets).
git_repository(
Expand Down Expand Up @@ -214,7 +233,7 @@ register_gcc_arm_none_toolchain()
# Registers platforms for use with toolchain resolution
register_execution_platforms("//pw_build/platforms:all")

# Setup Golang toolchain rules
# Set up Golang toolchain rules.
# Required by: bazel_gazelle, com_github_bazelbuild_buildtools.
# Used in modules: None.
http_archive(
Expand All @@ -236,9 +255,9 @@ go_rules_dependencies()

go_register_toolchains()

# Setup bazel package manager for golang
# Set up bazel package manager for golang.
# Required by: com_github_bazelbuild_buildtools.
# Used in modules: None
# Used in modules: None.
http_archive(
name = "bazel_gazelle",
sha256 = "b85f48fa105c4403326e9525ad2b2cc437babaa6e15a3fc0b1dbab0ab064bc7c",
Expand All @@ -252,8 +271,8 @@ load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")

gazelle_dependencies()

# Setup bazel buildtools (bazel linter and formatter)
# Required by: pigweed
# Set up bazel buildtools (bazel linter and formatter).
# Required by: pigweed.
# Used in modules: //:all (bazel specific tools).
http_archive(
name = "com_github_bazelbuild_buildtools",
Expand All @@ -270,9 +289,9 @@ pigweed_config(
build_file = "//targets:default_config.BUILD",
)

# Setup rules_fuzzing for fuzz tests.
# Set up rules for fuzz testing.
# Required by: pigweed.
# Used in modules: pw_protobuf, pw_tokenizer, pw_fuzzer.
# Used in modules: //pw_protobuf, //pw_tokenizer, //pw_fuzzer.
http_archive(
name = "rules_fuzzing",
sha256 = "94f25c7a18db0502ace26a3ef7d0a25fd7c195c4e9770ddd1b1ec718e8936091",
Expand Down
4 changes: 2 additions & 2 deletions pw_analog/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ pw_cc_library(
],
includes = ["public"],
deps = [
"$dir_pw_third_party/googletest",
":microvolt_input",
"@com_google_googletest//:gtest",
],
)

Expand All @@ -67,8 +67,8 @@ pw_cc_library(
],
includes = ["public"],
deps = [
"$dir_pw_third_party/googletest",
":analog_input",
"@com_google_googletest//:gtest",
],
)

Expand Down
4 changes: 2 additions & 2 deletions pw_assert/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ pw_cc_test(
],
deps = [
":facade",
":pw_assert",
"//pw_assert",
"//pw_preprocessor",
"//pw_span",
"//pw_string",
Expand All @@ -78,7 +78,7 @@ pw_cc_test(
"assert_backend_compile_test_c.c",
],
deps = [
":pw_assert",
"//pw_assert",
"//pw_unit_test",
],
)
1 change: 1 addition & 0 deletions pw_assert_log/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ pw_cc_library(
"public_overrides",
],
deps = [
"//pw_log",
"//pw_preprocessor",
],
)
Expand Down
3 changes: 2 additions & 1 deletion pw_blob_store/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ pw_cc_library(
deps = [
"//pw_checksum",
"//pw_containers",
"//pw_kvs",
"//pw_log",
"//pw_span",
"//pw_status",
"//pw_stream",
],
)

Expand All @@ -49,7 +51,6 @@ pw_cc_test(
"//pw_kvs:fake_flash",
"//pw_kvs:fake_flash_test_key_value_store",
"//pw_log",
"//pw_random",
"//pw_unit_test",
],
)
Expand Down
24 changes: 23 additions & 1 deletion pw_build/pigweed.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,36 @@ def _add_cc_and_c_targets(target, kwargs):

target(**cc_kwargs)

def _has_pw_assert_dep(deps):
pw_assert_targets = ["//pw_assert", "//pw_assert:pw_assert"]
pw_assert_targets.append(["@pigweed" + t for t in pw_assert_targets])
for dep in deps:
if dep in pw_assert_targets:
return True
return False

def pw_cc_binary(**kwargs):
kwargs["deps"] = kwargs.get("deps", [])

# TODO(pwbug/440): Remove this implicit dependency once we have a better
# way to handle the facades without introducing a circular dependency into
# the build.
if not _has_pw_assert_dep(kwargs["deps"]):
kwargs["deps"].append("@pigweed//pw_assert")
_add_cc_and_c_targets(native.cc_binary, kwargs)

def pw_cc_library(**kwargs):
_add_cc_and_c_targets(native.cc_library, kwargs)

def pw_cc_test(**kwargs):
kwargs["deps"] = kwargs.get("deps", []) + ["//pw_unit_test:main"]
kwargs["deps"] = kwargs.get("deps", []) + \
["//pw_unit_test:main"]

# TODO(pwbug/440): Remove this implicit dependency once we have a better
# way to handle the facades without introducing a circular dependency into
# the build.
if not _has_pw_assert_dep(kwargs["deps"]):
kwargs["deps"].append("@pigweed//pw_assert")
_add_cc_and_c_targets(native.cc_test, kwargs)

def pw_cc_facade(**kwargs):
Expand Down
5 changes: 4 additions & 1 deletion pw_checksum/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ pw_cc_library(
"public/pw_checksum/crc32.h",
],
includes = ["public"],
deps = ["//pw_span"],
deps = [
"//pw_bytes",
"//pw_span",
],
)

pw_cc_test(
Expand Down
1 change: 1 addition & 0 deletions pw_function/size_report/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ pw_cc_binary(
pw_cc_binary(
name = "callable_size",
srcs = ["callable_size.cc"],
defines = ["_BASE=1"],
deps = [
"//pw_bloat:bloat_this_binary",
"//pw_function",
Expand Down
1 change: 0 additions & 1 deletion pw_hdlc/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ pw_cc_library(
"encoder.cc",
"public/pw_hdlc/internal/encoder.h",
"public/pw_hdlc/internal/protocol.h",
"rpc_packets.cc",
],
hdrs = [
"public/pw_hdlc/decoder.h",
Expand Down
2 changes: 2 additions & 0 deletions pw_hex_dump/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ pw_cc_library(
"//pw_bytes",
"//pw_span",
"//pw_status",
"//pw_string",
],
)

Expand All @@ -45,6 +46,7 @@ pw_cc_test(
],
deps = [
":pw_hex_dump",
"//pw_log",
"//pw_unit_test",
],
)
4 changes: 1 addition & 3 deletions pw_i2c/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ pw_cc_test(
],
deps = [
":address",
"//pw_assert",
"//pw_unit_test",
],
)
Expand All @@ -115,8 +114,8 @@ pw_cc_library(
],
includes = ["public"],
deps = [
"$dir_pw_third_party/googletest",
":initiator",
"@com_google_googletest//:gtest",
],
)

Expand Down Expand Up @@ -150,7 +149,6 @@ pw_cc_test(
],
deps = [
":register_device",
"//pw_assert",
"//pw_unit_test",
],
)
Loading

0 comments on commit f91e763

Please sign in to comment.