Skip to content

Commit 4bd60b2

Browse files
authored
Clean up buildifier (#168)
* Clean up build files
1 parent 718d945 commit 4bd60b2

8 files changed

Lines changed: 38 additions & 47 deletions

File tree

.github/workflows/bazel.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838

3939
- name: Bazel format
4040
shell: bash
41-
run: ./ci/linting/buildifier.sh
41+
run: bazel run //:buildifier.check
4242

4343
- name: Build
4444
shell: bash

BUILD

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
load("@rules_shell//shell:sh_binary.bzl", "sh_binary")
1+
load("@buildifier_prebuilt//:rules.bzl", "buildifier")
22
load("@rules_cc//cc:defs.bzl", "cc_library")
33

44
package(default_visibility = ["//visibility:public"])
@@ -53,17 +53,26 @@ config_setting(
5353
constraint_values = ["@platforms//os:windows"],
5454
)
5555

56-
# Buildifier
56+
buildifier(
57+
name = "buildifier.fix",
58+
diff_command = "diff",
59+
exclude_patterns = [
60+
"./.git/*",
61+
"./.clwb/*",
62+
],
63+
lint_mode = "fix",
64+
mode = "fix",
65+
)
5766

58-
sh_binary(
59-
name = "buildifier",
60-
srcs = select(
61-
{
62-
":linux": ["@buildifier_linux//file"],
63-
":macos": ["@buildifier_macos//file"],
64-
":windows": ["@buildifier_windows//file"],
65-
},
66-
),
67+
buildifier(
68+
name = "buildifier.check",
69+
diff_command = "diff",
70+
exclude_patterns = [
71+
"./.git/*",
72+
"./.clwb/*",
73+
],
74+
lint_mode = "warn",
75+
mode = "diff",
6776
)
6877

6978
# Aspect-based clang-format

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

77
## [Unreleased]
8-
- Nothing yet
8+
9+
- Upgraded buildifier
10+
[#168](https://github.com/tzaeschke/phtree-cpp/pull/168)
911

1012
## [1.7.0] - 2025-03-01
1113
### Changed

MODULE.bazel

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -13,37 +13,4 @@ bazel_dep(name = "googletest", version = "1.17.0.bcr.2")
1313
bazel_dep(name = "spdlog", version = "1.17.0")
1414
bazel_dep(name = "google_benchmark", version = "1.9.5")
1515

16-
# Development environment tooling
17-
http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
18-
19-
http_file = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_file")
20-
21-
BUILDIFIER_VERSION = "0.29.0"
22-
23-
http_file(
24-
name = "buildifier_linux",
25-
executable = True,
26-
sha256 = "4c985c883eafdde9c0e8cf3c8595b8bfdf32e77571c369bf8ddae83b042028d6",
27-
urls = ["https://github.com/bazelbuild/buildtools/releases/download/{version}/buildifier".format(version = BUILDIFIER_VERSION)],
28-
)
29-
30-
http_file(
31-
name = "buildifier_macos",
32-
executable = True,
33-
sha256 = "9b108decaa9a624fbac65285e529994088c5d15fecc1a30866afc03a48619245",
34-
urls = ["https://github.com/bazelbuild/buildtools/releases/download/{version}/buildifier.mac".format(version = BUILDIFIER_VERSION)],
35-
)
36-
37-
http_file(
38-
name = "buildifier_windows",
39-
executable = True,
40-
sha256 = "dc5d6ed5e3e0dbe9955f7606939c627af5a2be7f9bdd8814e77a22109164394f",
41-
urls = ["https://github.com/bazelbuild/buildtools/releases/download/{version}/buildifier.exe".format(version = BUILDIFIER_VERSION)],
42-
)
43-
44-
http_archive(
45-
name = "bazel_compilation_database",
46-
sha256 = "bb1b812396e2ee36a50a13b03ae6833173ce643e8a4bd50731067d0b4e5c6e86",
47-
strip_prefix = "bazel-compilation-database-0.3.5",
48-
url = "https://github.com/grailbio/bazel-compilation-database/archive/0.3.5.tar.gz",
49-
)
16+
bazel_dep(name = "buildifier_prebuilt", version = "8.2.1", dev_dependency = True)

MODULE.bazel.lock

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

ReleaseHowTo.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,20 @@
44
## Verify code
55

66
### Run tests
7+
```shell
78
CC=gcc bazel test ... --config=asan
89
CC=clang bazel test ... --config=asan
910
CC=clang bazel test ... --config=msan
1011
CC=clang bazel test ... --config=ubsan
12+
```
1113

1214
Record versions: e.g. gcc 13.3, clang 18.1.3
1315

16+
```shell
17+
bazel run //:buildifier.check
18+
bazel run //:buildifier.fix
19+
```
20+
1421
### Run examples
1522
```shell
1623
bazel run //examples:example

third_party/gtest/BUILD

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
#
3333
# Bazel Build for Google C++ Testing Framework(Google Test)
3434

35+
load("@rules_cc//cc:cc_library.bzl", "cc_library")
36+
3537
package(default_visibility = ["//visibility:public"])
3638

3739
licenses(["notice"])

third_party/spdlog/BUILD

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
load("@rules_cc//cc:cc_library.bzl", "cc_library")
2+
13
licenses(["notice"])
24

35
cc_library(

0 commit comments

Comments
 (0)