Skip to content

Commit

Permalink
bazel: Enable the layering check by default
Browse files Browse the repository at this point in the history
However, disable it for any package which currently does not build with
the layering check enabled. We will burn down this list, but enabling
the layering check for those modules that do build with it will prevent
backsliding.

I decided to disable the check on a package-by-package basis because
digging down into the targets seemed too finnicky. This way, the
workflow for the OWNERS of the individual modules (which approximately
correspond to packages) is to remove one line, get the compiler to be
happy, and send a CL.

This change was auto-generated by buildifier (see bug for details),
except for changes to the following files:

* .bazelrc
* REPO.bazel
* pw_fuzzer/fuzztest.bazelrc
* pw_toolchain/host_clang/BUILD.bazel

Bug: 219091175
Change-Id: Ie9a39620ffdd5fd1406b9d38145e3530f4479c5e
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/261293
Commit-Queue: Ted Pudlik <tpudlik@google.com>
Docs-Not-Needed: Ted Pudlik <tpudlik@google.com>
Lint: Lint 🤖 <android-build-ayeaye@system.gserviceaccount.com>
Reviewed-by: Armando Montanez <amontanez@google.com>
  • Loading branch information
tpudlik authored and CQ Bot Account committed Jan 21, 2025
1 parent e61919c commit c079d32
Show file tree
Hide file tree
Showing 127 changed files with 525 additions and 121 deletions.
14 changes: 14 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,17 @@ build --features=internal_strict_warnings
coverage --experimental_generate_llvm_lcov
coverage --combined_report=lcov

# Enable layering check support.
#
# NOTE: this _does not_ by itself enable the layering check; that's done in
# REPO.bazel. This flag only ensures the module maps for sysroot and toolchain
# headers (needed for the layering check to not produce false positives) are
# constructed. Module map construction is gated behind a flag because the
# approach we take does not work in Bazel versions older than 8.0.0, so some
# downstream projects using Pigweed's toolchains would be broken if this flag
# was removed and always set to true in the toolchain definition.
common --//pw_toolchain/host_clang:layering_check

# Java related flags
# ==================
# Workaround for https://github.com/bazelbuild/rules_jvm_external/issues/445.
Expand Down Expand Up @@ -194,6 +205,9 @@ build:microbit --platforms=//targets/microbit
common:googletest --//pw_unit_test:backend=//pw_unit_test:googletest
common:googletest --//pw_unit_test:main=@com_google_googletest//:gtest_main
common:googletest --platforms=//pw_unit_test:googletest_platform
# TODO: https://pwbug.dev/390709187 - Re-enable layering check once the layering
# issues in the googletest backend are fixed.
common:googletest --features=-layering_check

# Remote execution config definitions
# ===================================
Expand Down
26 changes: 26 additions & 0 deletions REPO.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright 2025 The Pigweed Authors
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
"""Repository-wide configuration for Pigweed.

See https://bazel.build/external/overview#repo.bazel. This file is used in
particular to enable toolchain features that we want to enable for all Pigweed
targets, but not for any external dependencies also compiled with Bazel.
"""

repo(
# Any C++ toolchain features enabled here will be enabled when compiling
# Pigweed, but not when compiling any dependencies hosted in external
# repositories.
features = ["layering_check"],
)
5 changes: 4 additions & 1 deletion pw_allocator/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ load("@rules_python//sphinxdocs:sphinx_docs_library.bzl", "sphinx_docs_library")
load("//pw_build:compatibility.bzl", "incompatible_with_mcu")
load("//pw_unit_test:pw_cc_test.bzl", "pw_cc_test")

package(default_visibility = ["//visibility:public"])
package(
default_visibility = ["//visibility:public"],
features = ["-layering_check"],
)

licenses(["notice"])

Expand Down
5 changes: 4 additions & 1 deletion pw_allocator/benchmarks/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ load(
"pw_cc_test",
)

package(default_visibility = ["//visibility:public"])
package(
default_visibility = ["//visibility:public"],
features = ["-layering_check"],
)

licenses(["notice"])

Expand Down
5 changes: 4 additions & 1 deletion pw_allocator/block/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@

load("//pw_unit_test:pw_cc_test.bzl", "pw_cc_test")

package(default_visibility = ["//visibility:public"])
package(
default_visibility = ["//visibility:public"],
features = ["-layering_check"],
)

licenses(["notice"])

Expand Down
5 changes: 4 additions & 1 deletion pw_allocator/bucket/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@

load("//pw_unit_test:pw_cc_test.bzl", "pw_cc_test")

package(default_visibility = ["//visibility:public"])
package(
default_visibility = ["//visibility:public"],
features = ["-layering_check"],
)

licenses(["notice"])

Expand Down
5 changes: 4 additions & 1 deletion pw_allocator/examples/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ load("//pw_build:compatibility.bzl", "incompatible_with_mcu")
load("//pw_build:pw_cc_binary.bzl", "pw_cc_binary")
load("//pw_unit_test:pw_cc_test.bzl", "pw_cc_test")

package(default_visibility = ["//visibility:public"])
package(
default_visibility = ["//visibility:public"],
features = ["-layering_check"],
)

licenses(["notice"])

Expand Down
5 changes: 4 additions & 1 deletion pw_allocator/size_report/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@

load("//pw_build:pw_cc_binary.bzl", "pw_cc_binary")

package(default_visibility = ["//visibility:public"])
package(
default_visibility = ["//visibility:public"],
features = ["-layering_check"],
)

licenses(["notice"])

Expand Down
5 changes: 4 additions & 1 deletion pw_assert_log/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
load("@rules_python//sphinxdocs:sphinx_docs_library.bzl", "sphinx_docs_library")
load("//pw_build:compatibility.bzl", "incompatible_with_mcu")

package(default_visibility = ["//visibility:public"])
package(
default_visibility = ["//visibility:public"],
features = ["-layering_check"],
)

licenses(["notice"])

Expand Down
5 changes: 4 additions & 1 deletion pw_assert_tokenized/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
load("@rules_python//sphinxdocs:sphinx_docs_library.bzl", "sphinx_docs_library")
load("//pw_build:compatibility.bzl", "incompatible_with_mcu")

package(default_visibility = ["//visibility:public"])
package(
default_visibility = ["//visibility:public"],
features = ["-layering_check"],
)

licenses(["notice"])

Expand Down
5 changes: 4 additions & 1 deletion pw_async/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ load("//pw_build:compatibility.bzl", "incompatible_with_mcu")
load("//pw_build:pw_facade.bzl", "pw_facade")
load("//pw_unit_test:pw_cc_test.bzl", "pw_cc_test")

package(default_visibility = ["//visibility:public"])
package(
default_visibility = ["//visibility:public"],
features = ["-layering_check"],
)

licenses(["notice"])

Expand Down
5 changes: 4 additions & 1 deletion pw_async2/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ load(
)
load("//pw_unit_test:pw_cc_test.bzl", "pw_cc_test")

package(default_visibility = ["//visibility:public"])
package(
default_visibility = ["//visibility:public"],
features = ["-layering_check"],
)

licenses(["notice"])

Expand Down
5 changes: 4 additions & 1 deletion pw_async2/examples/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ load("//pw_build:compatibility.bzl", "incompatible_with_mcu")
load("//pw_build:pw_cc_binary.bzl", "pw_cc_binary")
load("//pw_unit_test:pw_cc_test.bzl", "pw_cc_test")

package(default_visibility = ["//visibility:public"])
package(
default_visibility = ["//visibility:public"],
features = ["-layering_check"],
)

licenses(["notice"])

Expand Down
5 changes: 4 additions & 1 deletion pw_async2_basic/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
load("@rules_python//sphinxdocs:sphinx_docs_library.bzl", "sphinx_docs_library")
load("//pw_build:compatibility.bzl", "incompatible_with_mcu")

package(default_visibility = ["//visibility:public"])
package(
default_visibility = ["//visibility:public"],
features = ["-layering_check"],
)

licenses(["notice"])

Expand Down
5 changes: 4 additions & 1 deletion pw_async2_epoll/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
load("@rules_python//sphinxdocs:sphinx_docs_library.bzl", "sphinx_docs_library")
load("//pw_build:compatibility.bzl", "incompatible_with_mcu")

package(default_visibility = ["//visibility:public"])
package(
default_visibility = ["//visibility:public"],
features = ["-layering_check"],
)

licenses(["notice"])

Expand Down
5 changes: 4 additions & 1 deletion pw_async_basic/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ load("@rules_python//sphinxdocs:sphinx_docs_library.bzl", "sphinx_docs_library")
load("//pw_build:compatibility.bzl", "incompatible_with_mcu")
load("//pw_unit_test:pw_cc_test.bzl", "pw_cc_test")

package(default_visibility = ["//visibility:public"])
package(
default_visibility = ["//visibility:public"],
features = ["-layering_check"],
)

licenses(["notice"])

Expand Down
2 changes: 2 additions & 0 deletions pw_async_basic/size_report/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

load("//pw_build:pw_cc_binary.bzl", "pw_cc_binary")

package(features = ["-layering_check"])

licenses(["notice"])

pw_cc_binary(
Expand Down
5 changes: 4 additions & 1 deletion pw_blob_store/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ load("@rules_python//sphinxdocs:sphinx_docs_library.bzl", "sphinx_docs_library")
load("//pw_build:compatibility.bzl", "incompatible_with_mcu")
load("//pw_unit_test:pw_cc_test.bzl", "pw_cc_test")

package(default_visibility = ["//visibility:public"])
package(
default_visibility = ["//visibility:public"],
features = ["-layering_check"],
)

licenses(["notice"])

Expand Down
5 changes: 4 additions & 1 deletion pw_blob_store/size_report/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@

load("//pw_build:pw_cc_binary.bzl", "pw_cc_binary")

package(default_visibility = ["//visibility:public"])
package(
default_visibility = ["//visibility:public"],
features = ["-layering_check"],
)

licenses(["notice"])

Expand Down
5 changes: 4 additions & 1 deletion pw_bluetooth/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ load("@rules_python//sphinxdocs:sphinx_docs_library.bzl", "sphinx_docs_library")
load("//pw_build:compatibility.bzl", "incompatible_with_mcu")
load("//pw_unit_test:pw_cc_test.bzl", "pw_cc_test")

package(default_visibility = ["//visibility:public"])
package(
default_visibility = ["//visibility:public"],
features = ["-layering_check"],
)

licenses(["notice"])

Expand Down
5 changes: 4 additions & 1 deletion pw_bluetooth_hci/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ load("//pw_build:compatibility.bzl", "incompatible_with_mcu")
load("//pw_fuzzer:fuzzer.bzl", "pw_cc_fuzz_test")
load("//pw_unit_test:pw_cc_test.bzl", "pw_cc_test")

package(default_visibility = ["//visibility:public"])
package(
default_visibility = ["//visibility:public"],
features = ["-layering_check"],
)

licenses(["notice"])

Expand Down
5 changes: 4 additions & 1 deletion pw_bluetooth_profiles/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ load("@rules_python//sphinxdocs:sphinx_docs_library.bzl", "sphinx_docs_library")
load("//pw_build:compatibility.bzl", "incompatible_with_mcu")
load("//pw_unit_test:pw_cc_test.bzl", "pw_cc_test")

package(default_visibility = ["//visibility:public"])
package(
default_visibility = ["//visibility:public"],
features = ["-layering_check"],
)

licenses(["notice"])

Expand Down
5 changes: 4 additions & 1 deletion pw_bluetooth_proxy/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ load("@rules_python//sphinxdocs:sphinx_docs_library.bzl", "sphinx_docs_library")
load("//pw_build:compatibility.bzl", "incompatible_with_mcu")
load("//pw_unit_test:pw_cc_test.bzl", "pw_cc_test")

package(default_visibility = ["//visibility:public"])
package(
default_visibility = ["//visibility:public"],
features = ["-layering_check"],
)

licenses(["notice"])

Expand Down
5 changes: 4 additions & 1 deletion pw_bluetooth_proxy/size_report/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@

load("//pw_build:pw_cc_binary.bzl", "pw_cc_binary")

package(default_visibility = ["//visibility:public"])
package(
default_visibility = ["//visibility:public"],
features = ["-layering_check"],
)

licenses(["notice"])

Expand Down
5 changes: 4 additions & 1 deletion pw_bluetooth_sapphire/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ load("@rules_python//sphinxdocs:sphinx_docs_library.bzl", "sphinx_docs_library")
load("//pw_build:compatibility.bzl", "incompatible_with_mcu")
load("//pw_unit_test:pw_cc_test.bzl", "pw_cc_test")

package(default_visibility = ["//pw_bluetooth_sapphire:__subpackages__"])
package(
default_visibility = ["//pw_bluetooth_sapphire:__subpackages__"],
features = ["-layering_check"],
)

cc_library(
name = "config",
Expand Down
5 changes: 4 additions & 1 deletion pw_bluetooth_sapphire/host/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@

# Note, this file is not copybara'd from upstream Fuchsia.

package(default_visibility = ["//visibility:public"])
package(
default_visibility = ["//visibility:public"],
features = ["-layering_check"],
)

cc_library(
name = "stack",
Expand Down
5 changes: 4 additions & 1 deletion pw_bluetooth_sapphire/host/att/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ load("@rules_python//sphinxdocs:sphinx_docs_library.bzl", "sphinx_docs_library")
load("//pw_build:compatibility.bzl", "incompatible_with_mcu")
load("//pw_unit_test:pw_cc_test.bzl", "pw_cc_test")

package(default_visibility = ["//visibility:public"])
package(
default_visibility = ["//visibility:public"],
features = ["-layering_check"],
)

# Basic target with protocol definitions and no logic, suitable for test
# emulation.
Expand Down
5 changes: 4 additions & 1 deletion pw_bluetooth_sapphire/host/common/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
load("//pw_fuzzer:fuzzer.bzl", "pw_cc_fuzz_test")
load("//pw_unit_test:pw_cc_test.bzl", "pw_cc_test")

package(default_visibility = ["//visibility:public"])
package(
default_visibility = ["//visibility:public"],
features = ["-layering_check"],
)

cc_library(
name = "common",
Expand Down
5 changes: 4 additions & 1 deletion pw_bluetooth_sapphire/host/gap/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ load("//pw_build:compatibility.bzl", "incompatible_with_mcu")
load("//pw_fuzzer:fuzzer.bzl", "pw_cc_fuzz_test")
load("//pw_unit_test:pw_cc_test.bzl", "pw_cc_test")

package(default_visibility = ["//visibility:public"])
package(
default_visibility = ["//visibility:public"],
features = ["-layering_check"],
)

cc_library(
name = "definitions",
Expand Down
5 changes: 4 additions & 1 deletion pw_bluetooth_sapphire/host/gatt/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@

load("//pw_unit_test:pw_cc_test.bzl", "pw_cc_test")

package(default_visibility = ["//visibility:public"])
package(
default_visibility = ["//visibility:public"],
features = ["-layering_check"],
)

# Basic target with protocol definitions and no logic, suitable for test
# emulation.
Expand Down
5 changes: 4 additions & 1 deletion pw_bluetooth_sapphire/host/hci-spec/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@

load("//pw_unit_test:pw_cc_test.bzl", "pw_cc_test")

package(default_visibility = ["//visibility:public"])
package(
default_visibility = ["//visibility:public"],
features = ["-layering_check"],
)

cc_library(
name = "hci-spec",
Expand Down
Loading

0 comments on commit c079d32

Please sign in to comment.