Skip to content

Commit d965918

Browse files
committed
Merge remote-tracking branch 'origin/main' into martin4861/bazel-compiler-flags-with-tests
2 parents eeead94 + 3ba8dac commit d965918

File tree

56 files changed

+1673
-1018
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+1673
-1018
lines changed

.bazelignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
examples/

.github/workflows/ci.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323

2424
- name: Run format
2525
run: |
26-
bazel run //:buildifier
26+
bazel run //tools/buildifier:buildifier
2727
git diff --exit-code
2828
2929
example-small-world:
@@ -47,5 +47,6 @@ jobs:
4747
4848
- name: Run format
4949
run: |
50-
bazel run //:buildifier
50+
cd examples/small_world
51+
bazel run //tools/buildifier:buildifier
5152
git diff --exit-code

BUILD.bazel

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +0,0 @@
1-
load("@buildifier_prebuilt//:rules.bzl", "buildifier")
2-
3-
buildifier(
4-
name = "buildifier",
5-
)

MODULE.bazel

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,18 @@
1010

1111
module(
1212
name = "rules_swiftnav",
13-
version = "0.9.0",
13+
version = "0.11.0",
1414
compatibility_level = 1,
1515
)
1616

1717
# Core Bazel dependencies
18-
bazel_dep(name = "bazel_skylib", version = "1.7.1")
19-
bazel_dep(name = "platforms", version = "0.0.11")
20-
bazel_dep(name = "rules_cc", version = "0.1.1")
21-
bazel_dep(name = "rules_pkg", version = "1.0.1")
22-
bazel_dep(name = "rules_oci", version = "1.0.0")
18+
bazel_dep(name = "bazel_skylib", version = "1.8.2")
19+
bazel_dep(name = "platforms", version = "1.0.0")
20+
bazel_dep(name = "rules_cc", version = "0.2.14")
21+
bazel_dep(name = "rules_pkg", version = "1.1.0")
22+
bazel_dep(name = "rules_oci", version = "1.8.0")
23+
bazel_dep(name = "rules_shell", version = "0.6.1")
24+
bazel_dep(name = "rules_python", version = "1.6.3")
2325

2426
# Register module extensions
2527
swift_cc_toolchain_ext = use_extension("@rules_swiftnav//cc:extensions.bzl", "swift_cc_toolchain_extension")
@@ -67,6 +69,6 @@ use_repo(yocto_generic_ext, "yocto_generic")
6769
# Register the buildifier toolchain
6870
bazel_dep(
6971
name = "buildifier_prebuilt",
70-
version = "8.2.0.2",
72+
version = "8.2.1",
7173
dev_dependency = True,
7274
)

MODULE.bazel.lock

Lines changed: 367 additions & 38 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cc/BUILD.bazel

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
load("@bazel_skylib//lib:selects.bzl", "selects")
1212
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag", "string_flag")
13+
load("@rules_python//python:py_binary.bzl", "py_binary")
1314

1415
exports_files(
1516
glob(["*.bzl"]),
@@ -30,15 +31,15 @@ config_setting(
3031
)
3132

3233
bool_flag(
33-
name = "strong_stack_protector",
34-
build_setting_default = False,
35-
visibility = ["//visibility:public"],
34+
name = "strong_stack_protector",
35+
build_setting_default = False,
36+
visibility = ["//visibility:public"],
3637
)
3738

3839
config_setting(
39-
name = "_strong_stack_protector",
40-
flag_values = {":strong_stack_protector": "true"},
41-
visibility = ["//visibility:public"],
40+
name = "_strong_stack_protector",
41+
flag_values = {":strong_stack_protector": "true"},
42+
visibility = ["//visibility:public"],
4243
)
4344

4445
# Enable warnings in tests for deprecated declarations with --@rules_swiftnav//cc:tests_warn_deprecated_declarations=true
@@ -174,7 +175,6 @@ config_setting(
174175
visibility = ["//visibility:public"],
175176
)
176177

177-
178178
selects.config_setting_group(
179179
name = "enable_symbolizer_x86_64_linux",
180180
match_all = [
@@ -230,10 +230,10 @@ py_binary(
230230
)
231231

232232
py_binary(
233-
name = "checktags",
234-
srcs = [
235-
"checktags.py",
236-
],
237-
args = [],
238-
visibility = ["//visibility:public"],
233+
name = "checktags",
234+
srcs = [
235+
"checktags.py",
236+
],
237+
args = [],
238+
visibility = ["//visibility:public"],
239239
)

cc/cc_static_library.bzl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,5 +132,4 @@ cc_static_library = rule(
132132
),
133133
},
134134
toolchains = ["@bazel_tools//tools/cpp:toolchain_type"],
135-
incompatible_use_toolchain_transition = True,
136135
)

cc/check_allowed_cc_deps.bzl

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ DependencyLevelInfo = provider(
1616
fields = {
1717
"level": "Dependency level (0=internal, 1=prod, 2=safe, None=no level)",
1818
"portable": "Whether the target is portable",
19-
"label": "The target's label"
20-
}
19+
"label": "The target's label",
20+
},
2121
)
2222

2323
def _get_coding_level_from_tags(tags):
@@ -76,7 +76,7 @@ def _check_allowed_cc_deps_impl(target, ctx):
7676
return [DependencyLevelInfo(
7777
level = None,
7878
portable = current_portable,
79-
label = label_str
79+
label = label_str,
8080
)]
8181

8282
# Check dependencies
@@ -104,7 +104,7 @@ def _check_allowed_cc_deps_impl(target, ctx):
104104
target.label,
105105
_level_to_str(current_level),
106106
dep_info.label,
107-
_level_to_str(dep_level)
107+
_level_to_str(dep_level),
108108
)
109109
fail(error_msg)
110110

@@ -113,30 +113,31 @@ def _check_allowed_cc_deps_impl(target, ctx):
113113
error_msg = ("ERROR: Target {} is marked as portable but depends on {} which is not portable. " +
114114
"Portable targets can only depend on other portable targets.").format(
115115
target.label,
116-
dep_info.label
116+
dep_info.label,
117117
)
118118
fail(error_msg)
119119

120120
# Return provider for this target
121121
return [DependencyLevelInfo(
122122
level = current_level,
123123
portable = current_portable,
124-
label = label_str
124+
label = label_str,
125125
)]
126126

127127
check_allowed_cc_deps = aspect(
128128
implementation = _check_allowed_cc_deps_impl,
129129
attr_aspects = ["deps"],
130-
attrs = {}
130+
attrs = {},
131131
)
132132

133133
def _validate_allowed_deps_rule_impl(ctx):
134134
"""Rule that applies the validation aspect to specified targets."""
135+
135136
# This rule doesn't produce any output, it just triggers the aspect
136137
output = ctx.actions.declare_file(ctx.label.name + ".validation")
137138
ctx.actions.write(
138139
output = output,
139-
content = "Allowed C/C++ dependency validation passed\n"
140+
content = "Allowed C/C++ dependency validation passed\n",
140141
)
141142
return [DefaultInfo(files = depset([output]))]
142143

@@ -145,10 +146,10 @@ validate_allowed_cc_deps = rule(
145146
attrs = {
146147
"targets": attr.label_list(
147148
aspects = [check_allowed_cc_deps],
148-
doc = "Targets to validate"
149-
)
149+
doc = "Targets to validate",
150+
),
150151
},
151-
doc = "Validates allowed C/C++ dependencies for specified targets"
152+
doc = "Validates allowed C/C++ dependencies for specified targets",
152153
)
153154

154155
def validate_all_allowed_cc_deps(name, targets = ["//..."]):
@@ -161,5 +162,5 @@ def validate_all_allowed_cc_deps(name, targets = ["//..."]):
161162
validate_allowed_cc_deps(
162163
name = name,
163164
targets = targets,
164-
tags = ["manual"] # Don't build by default, only when explicitly requested
165+
tags = ["manual"], # Don't build by default, only when explicitly requested
165166
)

cc/defs.bzl

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
"""Swift wrappers for native cc rules."""
1212

13+
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test")
1314
load("//stamp:stamp_file.bzl", "stamp_file")
1415
load(":cc_static_library.bzl", _cc_static_library = "cc_static_library")
1516
load(":copts.bzl", "DEFAULT_COPTS", "GCC5_COPTS", "GCC6_COPTS")
@@ -246,7 +247,7 @@ def swift_c_library(**kwargs):
246247

247248
kwargs["linkstatic"] = _link_static(kwargs.get("linkstatic", True))
248249

249-
native.cc_library(**kwargs)
250+
cc_library(**kwargs)
250251

251252
def swift_cc_library(**kwargs):
252253
"""Wraps cc_library to enforce standards for a production c++ library.
@@ -299,7 +300,7 @@ def swift_cc_library(**kwargs):
299300

300301
kwargs["linkstatic"] = _link_static(kwargs.get("linkstatic", True))
301302

302-
native.cc_library(**kwargs)
303+
cc_library(**kwargs)
303304

304305
def swift_c_tool_library(**kwargs):
305306
"""Wraps cc_library to enforce standards for a non-production c library.
@@ -343,7 +344,7 @@ def swift_c_tool_library(**kwargs):
343344

344345
kwargs["linkstatic"] = _link_static(kwargs.get("linkstatic", True))
345346

346-
native.cc_library(**kwargs)
347+
cc_library(**kwargs)
347348

348349
def swift_cc_tool_library(**kwargs):
349350
"""Wraps cc_library to enforce standards for a non-production c++ library.
@@ -390,7 +391,7 @@ def swift_cc_tool_library(**kwargs):
390391

391392
kwargs["linkstatic"] = _link_static(kwargs.get("linkstatic", True))
392393

393-
native.cc_library(**kwargs)
394+
cc_library(**kwargs)
394395

395396
def swift_c_binary(**kwargs):
396397
"""Wraps cc_binary to enforce standards for a production c binary.
@@ -438,7 +439,7 @@ def swift_c_binary(**kwargs):
438439

439440
kwargs["linkstatic"] = _link_static(kwargs.get("linkstatic", True))
440441

441-
native.cc_binary(**kwargs)
442+
cc_binary(**kwargs)
442443

443444
def swift_cc_binary(**kwargs):
444445
"""Wraps cc_binary to enforce standards for a production c++ binary.
@@ -488,7 +489,7 @@ def swift_cc_binary(**kwargs):
488489

489490
kwargs["tags"] = [BINARY] + kwargs.get("tags", [])
490491

491-
native.cc_binary(**kwargs)
492+
cc_binary(**kwargs)
492493

493494
def swift_c_tool(**kwargs):
494495
"""Wraps cc_binary to enforce standards for a non-production c binary.
@@ -531,7 +532,7 @@ def swift_c_tool(**kwargs):
531532

532533
kwargs["env"] = _symbolizer_env(kwargs.get("env", {}))
533534

534-
native.cc_binary(**kwargs)
535+
cc_binary(**kwargs)
535536

536537
def swift_cc_tool(**kwargs):
537538
"""Wraps cc_binary to enforce standards for a non-production c++ binary.
@@ -577,7 +578,7 @@ def swift_cc_tool(**kwargs):
577578

578579
kwargs["env"] = _symbolizer_env(kwargs.get("env", {}))
579580

580-
native.cc_binary(**kwargs)
581+
cc_binary(**kwargs)
581582

582583
def swift_c_test_library(**kwargs):
583584
"""Wraps cc_library to enforce Swift test library conventions.
@@ -604,7 +605,7 @@ def swift_c_test_library(**kwargs):
604605
kwargs["tags"] = [TEST_LIBRARY] + kwargs.get("tags", [])
605606
kwargs["target_compatible_with"] = kwargs.get("target_compatible_with", []) + _test_compatible_with()
606607

607-
native.cc_library(**kwargs)
608+
cc_library(**kwargs)
608609

609610
def swift_cc_test_library(**kwargs):
610611
"""Wraps cc_library to enforce Swift test library conventions.
@@ -635,7 +636,7 @@ def swift_cc_test_library(**kwargs):
635636

636637
kwargs["linkstatic"] = _link_static(kwargs.get("linkstatic", True))
637638

638-
native.cc_library(**kwargs)
639+
cc_library(**kwargs)
639640

640641
def swift_c_test(name, type, **kwargs):
641642
"""Wraps cc_test to enforce Swift testing conventions for C code.
@@ -690,7 +691,7 @@ def swift_c_test(name, type, **kwargs):
690691
kwargs["tags"] = [TEST, type] + kwargs.get("tags", [])
691692
kwargs["target_compatible_with"] = kwargs.get("target_compatible_with", []) + _test_compatible_with()
692693

693-
native.cc_test(**kwargs)
694+
cc_test(**kwargs)
694695

695696
def swift_cc_test(name, type, **kwargs):
696697
"""Wraps cc_test to enforce Swift testing conventions.
@@ -742,4 +743,4 @@ def swift_cc_test(name, type, **kwargs):
742743
kwargs["tags"] = [TEST, type] + kwargs.get("tags", [])
743744
kwargs["target_compatible_with"] = kwargs.get("target_compatible_with", []) + _test_compatible_with()
744745

745-
native.cc_test(**kwargs)
746+
cc_test(**kwargs)

0 commit comments

Comments
 (0)