Skip to content

Commit 80fef02

Browse files
authored
Migrate buildifier to MODULE [IO-410] (#163)
Migration of the tool `buildifier` from `WORKSPACE` to `MODULE.bazel`. With this change the `rules_swiftnav` repo is migrated to Bazel 7, however this does not affect any downstream repos, as tested in `starling-core` with Bazel 6 ([PR](swift-nav/starling-core#1024)). A test in `starling-core` with Bazel 7 is also [successful](swift-nav/starling-core#983).
1 parent accdbd1 commit 80fef02

File tree

17 files changed

+301
-864
lines changed

17 files changed

+301
-864
lines changed

.bazeliskrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
USE_BAZEL_VERSION=6.2.0
1+
USE_BAZEL_VERSION=7.6.1

BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
load("@com_github_bazelbuild_buildtools//buildifier:def.bzl", "buildifier")
1+
load("@buildifier_prebuilt//:rules.bzl", "buildifier")
22

33
buildifier(
44
name = "buildifier",

MODULE.bazel

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
# Copyright (C) 2022 Swift Navigation Inc.
2+
# Contact: Swift Navigation <[email protected]>
3+
#
4+
# This source is subject to the license found in the file 'LICENSE' which must
5+
# be be distributed together with this source. All other rights reserved.
6+
#
7+
# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
8+
# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
9+
# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
10+
111
module(
212
name = "rules_swiftnav",
313
version = "0.1.0",
@@ -47,3 +57,10 @@ register_toolchains(
4757

4858
yocto_generic_ext = use_extension("@rules_swiftnav//cc/toolchains/yocto_generic:yocto_generic_extension.bzl", "yocto_generic_extension")
4959
use_repo(yocto_generic_ext, "yocto_generic")
60+
61+
# Register the buildifier toolchain
62+
bazel_dep(
63+
name = "buildifier_prebuilt",
64+
version = "8.2.0.2",
65+
dev_dependency = True,
66+
)

MODULE.bazel.lock

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

WORKSPACE.bazel

Lines changed: 0 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +0,0 @@
1-
# Copyright (C) 2022 Swift Navigation Inc.
2-
# Contact: Swift Navigation <[email protected]>
3-
#
4-
# This source is subject to the license found in the file 'LICENSE' which must
5-
# be be distributed together with this source. All other rights reserved.
6-
#
7-
# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
8-
# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
9-
# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
10-
11-
workspace(name = "rules_swiftnav")
12-
13-
# Everything below this comment is for buildifier
14-
15-
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
16-
17-
# buildifier is written in Go and hence needs rules_go to be built.
18-
# See https://github.com/bazelbuild/rules_go for the up to date setup instructions.
19-
http_archive(
20-
name = "io_bazel_rules_go",
21-
sha256 = "d6b2513456fe2229811da7eb67a444be7785f5323c6708b38d851d2b51e54d83",
22-
urls = [
23-
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.30.0/rules_go-v0.30.0.zip",
24-
"https://github.com/bazelbuild/rules_go/releases/download/v0.30.0/rules_go-v0.30.0.zip",
25-
],
26-
)
27-
28-
load("@io_bazel_rules_go//go:deps.bzl", "go_rules_dependencies")
29-
30-
go_rules_dependencies()
31-
32-
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains")
33-
34-
go_register_toolchains(version = "1.17.2")
35-
36-
http_archive(
37-
name = "bazel_gazelle",
38-
sha256 = "de69a09dc70417580aabf20a28619bb3ef60d038470c7cf8442fafcf627c21cb",
39-
urls = [
40-
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.24.0/bazel-gazelle-v0.24.0.tar.gz",
41-
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.24.0/bazel-gazelle-v0.24.0.tar.gz",
42-
],
43-
)
44-
45-
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")
46-
47-
# If you use WORKSPACE.bazel, use the following line instead of the bare gazelle_dependencies():
48-
gazelle_dependencies(go_repository_default_config = "@//:WORKSPACE.bazel")
49-
50-
http_archive(
51-
name = "com_google_protobuf",
52-
sha256 = "3bd7828aa5af4b13b99c191e8b1e884ebfa9ad371b0ce264605d347f135d2568",
53-
strip_prefix = "protobuf-3.19.4",
54-
urls = [
55-
"https://github.com/protocolbuffers/protobuf/archive/v3.19.4.tar.gz",
56-
],
57-
)
58-
59-
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
60-
61-
protobuf_deps()
62-
63-
http_archive(
64-
name = "com_github_bazelbuild_buildtools",
65-
sha256 = "ae34c344514e08c23e90da0e2d6cb700fcd28e80c02e23e4d5715dddcb42f7b3",
66-
strip_prefix = "buildtools-4.2.2",
67-
urls = [
68-
"https://github.com/bazelbuild/buildtools/archive/refs/tags/4.2.2.tar.gz",
69-
],
70-
)

cc/toolchains/gcc_arm_embedded/config.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
load("@bazel_tools//tools/cpp:cc_toolchain_config_lib.bzl", "feature", "flag_group", "flag_set", "tool_path", "with_feature_set")
21
load("@bazel_tools//tools/build_defs/cc:action_names.bzl", "ACTION_NAMES")
2+
load("@bazel_tools//tools/cpp:cc_toolchain_config_lib.bzl", "feature", "flag_group", "flag_set", "tool_path", "with_feature_set")
33

44
def _impl(ctx):
55
SDK_PATH_PREFIX = "wrappers/arm-none-eabi-{}"

cc/toolchains/gcc_arm_gnu_8_3/config.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
load("@bazel_tools//tools/cpp:cc_toolchain_config_lib.bzl", "feature", "flag_group", "flag_set", "tool_path", "with_feature_set")
21
load("@bazel_tools//tools/build_defs/cc:action_names.bzl", "ACTION_NAMES")
2+
load("@bazel_tools//tools/cpp:cc_toolchain_config_lib.bzl", "feature", "flag_group", "flag_set", "tool_path", "with_feature_set")
33

44
def _impl(ctx):
55
SDK_PATH_PREFIX = "wrappers/aarch64-linux-gnu-{}"

cc/toolchains/llvm/swift_custom_features.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ Bug fixes, ports of features from newer versions, etc.. should be put as they
1313
appear in upstream in unix_cc_toolchain_config.bzl.
1414
"""
1515

16+
load("@bazel_tools//tools/build_defs/cc:action_names.bzl", "ACTION_NAMES")
1617
load(
1718
"@bazel_tools//tools/cpp:cc_toolchain_config_lib.bzl",
1819
"feature",
1920
"flag_group",
2021
"flag_set",
2122
"with_feature_set",
2223
)
23-
load("@bazel_tools//tools/build_defs/cc:action_names.bzl", "ACTION_NAMES")
2424

2525
_all_compile_actions = [
2626
ACTION_NAMES.c_compile,

cc/toolchains/llvm/unix_cc_toolchain_config.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
"""A Starlark cc_toolchain configuration rule"""
1616

17+
load("@bazel_tools//tools/build_defs/cc:action_names.bzl", "ACTION_NAMES")
1718
load(
1819
"@bazel_tools//tools/cpp:cc_toolchain_config_lib.bzl",
1920
"action_config",
@@ -27,7 +28,6 @@ load(
2728
"variable_with_value",
2829
"with_feature_set",
2930
)
30-
load("@bazel_tools//tools/build_defs/cc:action_names.bzl", "ACTION_NAMES")
3131
load(
3232
"swift_custom_features.bzl",
3333
"c11_standard_feature",

cc/toolchains/llvm_x86_64_windows/config.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
load("@bazel_tools//tools/cpp:cc_toolchain_config_lib.bzl", "feature", "flag_group", "flag_set", "tool_path", "with_feature_set")
21
load("@bazel_tools//tools/build_defs/cc:action_names.bzl", "ACTION_NAMES")
2+
load("@bazel_tools//tools/cpp:cc_toolchain_config_lib.bzl", "feature", "flag_group", "flag_set", "tool_path", "with_feature_set")
33

44
def _impl(ctx):
55
SDK_PATH_PREFIX = "wrappers/x86_64-w64-mingw32uwp-{}"

0 commit comments

Comments
 (0)