Skip to content

Commit 4179b83

Browse files
committed
fix README generation
Add `//example:all_files` as a dependency of `//scripts:readme.update` to ensure that the snippets are inserted to the README when updated. This commit also removes the use of repo rule `@local_config_info` as there no longer a need to obtain the local workspace root directory. Change-Id: I798a59231f7f109e6c3e18c1edacae8de897d911
1 parent a46efb2 commit 4179b83

7 files changed

Lines changed: 28 additions & 82 deletions

File tree

WORKSPACE.bazel

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,10 +244,6 @@ py_library(
244244
),
245245
)
246246

247-
load("//tools:local_config_info.bzl", "local_config_info")
248-
249-
local_config_info(name = "local_config_info")
250-
251247
RULES_BUILD_ERROR_COMMIT = "4ea1a4fa702b16389c7eb3b695ef97a23dfe9330"
252248

253249
http_archive(

example/BUILD.bazel

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,3 +155,12 @@ multirun(
155155
":described_predicates_20_log.update",
156156
],
157157
)
158+
159+
filegroup(
160+
name = "all_files",
161+
srcs = glob([
162+
"*.cpp",
163+
"*.log",
164+
]),
165+
visibility = ["//scripts:__pkg__"],
166+
)

rules/BUILD.bazel

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
exports_files(
22
["copy_to_workspace.bash"],
3-
visibility = ["//example:__pkg__"],
3+
visibility = [
4+
"//example:__pkg__",
5+
"//scripts:__pkg__",
6+
],
47
)

rules/lcov.bzl

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ Rule for generating a coverage report
33
"""
44

55
load("@bazel_skylib//rules:write_file.bzl", "write_file")
6-
load("@local_config_info//:defs.bzl", "BAZEL_BIN")
76

87
def lcov(
98
name,
@@ -66,7 +65,7 @@ def lcov(
6665
]
6766

6867
coverage_command = " ".join(
69-
["{bazel} coverage {bazel_common_opts}"] +
68+
["bazel coverage {bazel_common_opts}"] +
7069
coverage_opts + instrumented + test_targets,
7170
)
7271

@@ -86,7 +85,7 @@ def lcov(
8685
"lcov_tool=\"$(pwd)/${{1}}\"",
8786
"",
8887
"cd $BUILD_WORKSPACE_DIRECTORY",
89-
"output_path=\"$({bazel} info {bazel_common_opts} output_path)\"",
88+
"output_path=\"$(bazel info {bazel_common_opts} output_path)\"",
9089
"coverage_report=\"${{output_path}}/_coverage/_coverage_report.dat\"",
9190
"",
9291
coverage_command + " || true",
@@ -97,7 +96,6 @@ def lcov(
9796

9897
content = [
9998
line.format(
100-
bazel = BAZEL_BIN,
10199
bazel_common_opts = "",
102100
)
103101
for line in content

scripts/BUILD.bazel

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
load("@rules_python//python:defs.bzl", "py_binary")
22
load("@bazel_skylib//rules:diff_test.bzl", "diff_test")
3-
load("@local_config_info//:defs.bzl", "BAZEL_WORKSPACE_ROOT")
43

54
py_binary(
65
name = "markdown-update",
@@ -14,35 +13,27 @@ genrule(
1413
srcs = ["README.md.tmpl"],
1514
outs = ["README.md.generated"],
1615
cmd = """
17-
export BUILD_WORKSPACE_DIRECTORY={workspace_dir}
1816
$(execpath :markdown-update) $(rootpath :README.md.tmpl)> $@
19-
""".format(
20-
workspace_dir = BAZEL_WORKSPACE_ROOT,
21-
),
22-
tags = ["manual"],
23-
tools = [":markdown-update"],
24-
visibility = ["//visibility:private"],
25-
)
26-
27-
genrule(
28-
name = "readme.update_sh",
29-
srcs = ["README.md.tmpl"],
30-
outs = ["readme.update.sh"],
31-
cmd = """
32-
set -euo pipefail
33-
echo "set -euo pipefail" > $@
34-
echo "" >> $@
35-
echo "cd \\$$BUILD_WORKSPACE_DIRECTORY" >> $@
36-
echo "$(execpath :markdown-update) $(rootpath :README.md.tmpl) > README.md" >> $@
3717
""",
3818
tags = ["manual"],
39-
tools = [":markdown-update"],
19+
tools = [
20+
":markdown-update",
21+
"//example:all_files",
22+
],
4023
visibility = ["//visibility:private"],
4124
)
4225

4326
sh_binary(
4427
name = "readme.update",
45-
srcs = [":readme.update.sh"],
28+
srcs = ["//rules:copy_to_workspace.bash"],
29+
args = [
30+
"$(rootpath :gen_readme)",
31+
"$(rootpath //:README.md)",
32+
],
33+
data = [
34+
":gen_readme",
35+
"//:README.md",
36+
],
4637
)
4738

4839
diff_test(

scripts/markdown-update.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
# -*- coding: utf-8 -*-
33

44
import argparse
5-
import os
65
from pathlib import Path
76
import sys
87

@@ -13,12 +12,9 @@
1312
parser.add_argument("filename")
1413
args = parser.parse_args()
1514

16-
os.chdir(os.environ.get("BUILD_WORKSPACE_DIRECTORY"))
17-
1815
with open(Path(args.filename), "r") as f:
1916
indoc = f.read()
2017

2118
outdoc = get_code_emb()(indoc)
2219

2320
sys.stdout.buffer.write(outdoc.encode())
24-

tools/local_config_info.bzl

Lines changed: 0 additions & 47 deletions
This file was deleted.

0 commit comments

Comments
 (0)