Skip to content

Commit 25326d2

Browse files
committed
Test LRE fixes
1 parent def1bc4 commit 25326d2

File tree

3 files changed

+33
-21
lines changed

3 files changed

+33
-21
lines changed

flake.nix

+7
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@
3535

3636
customStdenv = import ./tools/llvmStdenv.nix { inherit pkgs; };
3737

38+
# TODO(aaronmondal): This doesn't work with rules_rust yet.
39+
customClang = pkgs.callPackage ./tools/customClang.nix {
40+
inherit pkgs;
41+
stdenv = customStdenv;
42+
};
43+
3844
craneLib = crane.lib.${system};
3945

4046
src = pkgs.lib.cleanSourceWith {
@@ -128,6 +134,7 @@
128134
# Additional tools from within our development environment.
129135
local-image-test
130136
generate-toolchains
137+
customClang
131138
] ++ maybeDarwinDeps;
132139
shellHook = ''
133140
# Generate the .pre-commit-config.yaml symlink when entering the

local-remote-execution/image.nix

+4-21
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,10 @@
22

33
let
44
customStdenv = import ../tools/llvmStdenv.nix { inherit pkgs; };
5-
6-
# Bazel expects a single frontend for both C and C++. That works for GCC but
7-
# not for clang. This wrapper selects `clang` or `clang++` depending on file
8-
# ending.
9-
# TODO(aaronmondal): The necessity of this is a bug.
10-
# See: https://github.com/NixOS/nixpkgs/issues/216047
11-
# and https://github.com/NixOS/nixpkgs/issues/150655
12-
customClang = pkgs.writeShellScriptBin "customClang" ''
13-
#! ${customStdenv.shell}
14-
function isCxx() {
15-
if [ $# -eq 0 ]; then false
16-
elif [ "$1" == '-xc++' ]; then true
17-
elif [[ -f "$1" && "$1" =~ [.](hh|H|hp|hxx|hpp|HPP|h[+]{2}|tcc|cc|cp|cxx|cpp|CPP|c[+]{2}|C)$ ]]; then true
18-
else isCxx "''${@:2}"; fi
19-
}
20-
if isCxx "$@"; then
21-
exec "${customStdenv.cc}/bin/clang++" "$@"
22-
else
23-
exec "${customStdenv.cc}/bin/clang" "$@"
24-
fi
25-
'';
5+
customClang = pkgs.callPackage ../tools/customClang.nix {
6+
inherit pkgs;
7+
stdenv = customStdenv;
8+
};
269
in
2710

2811
# TODO(aaronmondal): Bazel and a few other tools in this container are only

tools/customClang.nix

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{ pkgs, stdenv }:
2+
3+
# Bazel expects a single frontend for both C and C++. That works for GCC but
4+
# not for clang. This wrapper selects `clang` or `clang++` depending on file
5+
# ending.
6+
# TODO(aaronmondal): The necessity of this is a bug.
7+
# See: https://github.com/NixOS/nixpkgs/issues/216047
8+
# and https://github.com/NixOS/nixpkgs/issues/150655
9+
pkgs.writeShellScriptBin "customClang" ''
10+
#! ${stdenv.shell}
11+
function isCxx() {
12+
if [ $# -eq 0 ]; then false
13+
elif [ "$1" == '-xc++' ]; then true
14+
elif [[ -f "$1" && "$1" =~ [.](hh|H|hp|hxx|hpp|HPP|h[+]{2}|tcc|cc|cp|cxx|cpp|CPP|c[+]{2}|C)$ ]]; then true
15+
else isCxx "''${@:2}"; fi
16+
}
17+
if isCxx "$@"; then
18+
exec "${stdenv.cc}/bin/clang++" "$@"
19+
else
20+
exec "${stdenv.cc}/bin/clang" "$@"
21+
fi
22+
''

0 commit comments

Comments
 (0)