Skip to content

Commit ae37735

Browse files
committed
wip
1 parent 37e9b2f commit ae37735

File tree

4 files changed

+32
-3
lines changed

4 files changed

+32
-3
lines changed

.bazelrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ common --action_env="BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1"
88
common --announce_rc
99
common --color=yes
1010
common --curses=yes
11-
common --incompatible_strict_action_env
11+
#common --incompatible_strict_action_env
1212
common --ui_actions_shown=20
1313
common --progress_in_terminal_title
1414
common --enable_platform_specific_config
@@ -37,4 +37,5 @@ test --test_output=errors
3737
test --test_summary=detailed
3838
test --test_verbose_timeout_warnings
3939

40+
import %workspace%/tools/shell_executable.bazelrc
4041
try-import %workspace%/user.bazelrc

tools/BUILD.bazel

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ load("@hedron_compile_commands//:refresh_compile_commands.bzl", "refresh_compile
33
load("@platforms//host:constraints.bzl", "HOST_CONSTRAINTS")
44
load("@rules_multirun//:defs.bzl", "multirun")
55
load("@rules_shell//shell:sh_binary.bzl", "sh_binary")
6+
load("@bazel_skylib//rules:diff_test.bzl", "diff_test")
67

78
buildifier(
89
name = "buildifier.check",
@@ -20,7 +21,7 @@ genrule(
2021
name = "gen-clang-format",
2122
outs = ["clang-format.bash"],
2223
cmd = """
23-
echo "#!/bin/bash" > $@
24+
echo "#!/usr/bin/env bash" > $@
2425
echo "cd \\$$BUILD_WORKSPACE_DIRECTORY" >> $@
2526
echo "exec bazelisk build \\$$@ //..." >> $@
2627
""",
@@ -67,7 +68,7 @@ genrule(
6768
name = "gen-clang-tidy",
6869
outs = ["clang-tidy.bash"],
6970
cmd = """
70-
echo "#!/bin/bash" > $@
71+
echo "#!/usr/bin/env bash" > $@
7172
echo "cd \\$$BUILD_WORKSPACE_DIRECTORY" >> $@
7273
echo "exec bazelisk build {options} \\$${{@:-//...}}" >> $@
7374
""".format(
@@ -106,3 +107,24 @@ refresh_compile_commands(
106107
"//...": "--extra_toolchains=@llvm_toolchain//:all",
107108
},
108109
)
110+
111+
genrule(
112+
name = "actual_bazelrc",
113+
outs = ["actual.bazelrc"],
114+
srcs = [
115+
"bazel-wrapper/flake.nix",
116+
"bazel-wrapper/flake.lock",
117+
],
118+
cmd = """
119+
mkdir nix
120+
cp -L ./tools/bazel-wrapper/flake.nix ./tools/bazel-wrapper/flake.lock ./nix
121+
file=$$(nix build ./nix#shellExecutable --print-out-paths)
122+
cp "$$file" $@
123+
""",
124+
)
125+
126+
diff_test(
127+
name = "shell_executable.bazelrc_diff_test",
128+
file1 = "shell_executable.bazelrc",
129+
file2 = ":actual_bazelrc",
130+
)

tools/bazel-wrapper/flake.nix

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,19 @@
2020
bash
2121
bazelisk
2222
coreutils
23+
diffutils
2324
findutils
2425
gnugrep
26+
gnused
2527
nix
2628
]
2729
++ lib.optionals stdenv.isDarwin [
2830
darwin.cctools
2931
];
3032
in {
33+
shellExecutable = pkgs.writeText
34+
"shell_executable.bazelrc"
35+
"common --shell_executable ${pkgs.lib.getExe pkgs.bash}";
3136
default = pkgs.writeShellApplication {
3237
name = "bazel-wrapper";
3338
runtimeInputs = tools;

tools/shell_executable.bazelrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
common --shell_executable /nix/store/0nxvi9r5ymdlr2p24rjj9qzyms72zld1-bash-interactive-5.2p37/bin/bash

0 commit comments

Comments
 (0)