Skip to content
Open

wip #58

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ common --action_env="BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1"
common --announce_rc
common --color=yes
common --curses=yes
common --incompatible_strict_action_env
#common --incompatible_strict_action_env
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably want to remove this

common --ui_actions_shown=20
common --progress_in_terminal_title
common --enable_platform_specific_config
Expand Down Expand Up @@ -37,4 +37,5 @@ test --test_output=errors
test --test_summary=detailed
test --test_verbose_timeout_warnings

import %workspace%/tools/shell_executable.bazelrc
try-import %workspace%/user.bazelrc
26 changes: 24 additions & 2 deletions tools/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ load("@hedron_compile_commands//:refresh_compile_commands.bzl", "refresh_compile
load("@platforms//host:constraints.bzl", "HOST_CONSTRAINTS")
load("@rules_multirun//:defs.bzl", "multirun")
load("@rules_shell//shell:sh_binary.bzl", "sh_binary")
load("@bazel_skylib//rules:diff_test.bzl", "diff_test")

buildifier(
name = "buildifier.check",
Expand All @@ -20,7 +21,7 @@ genrule(
name = "gen-clang-format",
outs = ["clang-format.bash"],
cmd = """
echo "#!/bin/bash" > $@
echo "#!/usr/bin/env bash" > $@
echo "cd \\$$BUILD_WORKSPACE_DIRECTORY" >> $@
echo "exec bazelisk build \\$$@ //..." >> $@
""",
Expand Down Expand Up @@ -67,7 +68,7 @@ genrule(
name = "gen-clang-tidy",
outs = ["clang-tidy.bash"],
cmd = """
echo "#!/bin/bash" > $@
echo "#!/usr/bin/env bash" > $@
echo "cd \\$$BUILD_WORKSPACE_DIRECTORY" >> $@
echo "exec bazelisk build {options} \\$${{@:-//...}}" >> $@
""".format(
Expand Down Expand Up @@ -106,3 +107,24 @@ refresh_compile_commands(
"//...": "--extra_toolchains=@llvm_toolchain//:all",
},
)

genrule(
name = "actual_bazelrc",
outs = ["actual.bazelrc"],
srcs = [
"bazel-wrapper/flake.nix",
"bazel-wrapper/flake.lock",
],
cmd = """
mkdir nix
cp -L ./tools/bazel-wrapper/flake.nix ./tools/bazel-wrapper/flake.lock ./nix
file=$$(nix build ./nix#shellExecutable --print-out-paths)
cp "$$file" $@
""",
)

diff_test(
name = "shell_executable.bazelrc_diff_test",
file1 = "shell_executable.bazelrc",
file2 = ":actual_bazelrc",
)
5 changes: 5 additions & 0 deletions tools/bazel-wrapper/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,19 @@
bash
bazelisk
coreutils
diffutils
findutils
gnugrep
gnused
nix
]
++ lib.optionals stdenv.isDarwin [
darwin.cctools
];
in {
shellExecutable = pkgs.writeText
"shell_executable.bazelrc"
"common --shell_executable ${pkgs.lib.getExe pkgs.bash}";
default = pkgs.writeShellApplication {
name = "bazel-wrapper";
runtimeInputs = tools;
Expand Down
1 change: 1 addition & 0 deletions tools/shell_executable.bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
common --shell_executable /nix/store/0nxvi9r5ymdlr2p24rjj9qzyms72zld1-bash-interactive-5.2p37/bin/bash
Loading