tangled
alpha
login
or
join now
pyrox.dev
/
nixpkgs
lol
0
fork
atom
overview
issues
pulls
pipelines
bazel_7: Cleanup tests a bit
Guillaume Maudoux
2 years ago
bc3cba38
bfbc35e0
+94
-7
2 changed files
expand all
collapse all
unified
split
pkgs
development
tools
build-managers
bazel
bazel_7
java-test.nix
tests.nix
+89
pkgs/development/tools/build-managers/bazel/bazel_7/java-test.nix
···
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
···
1
+
{ bazel
2
+
, bazelTest
3
+
, bazel-examples
4
+
, stdenv
5
+
, symlinkJoin
6
+
, callPackage
7
+
, darwin
8
+
, extraBazelArgs ? ""
9
+
, lib
10
+
, openjdk8
11
+
, jdk11_headless
12
+
, runLocal
13
+
, runtimeShell
14
+
, writeScript
15
+
, writeText
16
+
, repoCache ? "unused"
17
+
, distDir
18
+
}:
19
+
20
+
let
21
+
22
+
localDistDir = callPackage ./bazel-repository-cache.nix {
23
+
lockfile = ./cpp-test-MODULE.bazel.lock;
24
+
25
+
# Take all the rules_ deps, bazel_ deps and their transitive dependencies,
26
+
# but none of the platform-specific binaries, as they are large and useless.
27
+
requiredDepNamePredicate = name:
28
+
null == builtins.match ".*(macos|osx|linux|win|apple|android|maven).*" name
29
+
&& null != builtins.match "(platforms|com_google_|protobuf|rules_|bazel_).*" name ;
30
+
};
31
+
32
+
mergedDistDir = symlinkJoin {
33
+
name = "mergedDistDir";
34
+
paths = [ localDistDir distDir ];
35
+
};
36
+
37
+
toolsBazel = writeScript "bazel" ''
38
+
#! ${runtimeShell}
39
+
40
+
export CXX='${stdenv.cc}/bin/clang++'
41
+
export LD='${darwin.cctools}/bin/ld'
42
+
export LIBTOOL='${darwin.cctools}/bin/libtool'
43
+
export CC='${stdenv.cc}/bin/clang'
44
+
45
+
# XXX: hack for macosX, this flags disable bazel usage of xcode
46
+
# See: https://github.com/bazelbuild/bazel/issues/4231
47
+
export BAZEL_USE_CPP_ONLY_TOOLCHAIN=1
48
+
49
+
exec "$BAZEL_REAL" "$@"
50
+
'';
51
+
52
+
workspaceDir = runLocal "our_workspace" {} (''
53
+
cp -r ${bazel-examples}/java-tutorial $out
54
+
find $out -type d -exec chmod 755 {} \;
55
+
cp ${./cpp-test-MODULE.bazel} $out/MODULE.bazel
56
+
cp ${./cpp-test-MODULE.bazel.lock} $out/MODULE.bazel.lock
57
+
''
58
+
+ (lib.optionalString stdenv.isDarwin ''
59
+
mkdir $out/tools
60
+
cp ${toolsBazel} $out/tools/bazel
61
+
''));
62
+
63
+
testBazel = bazelTest {
64
+
name = "bazel-test-java";
65
+
inherit workspaceDir;
66
+
bazelPkg = bazel;
67
+
buildInputs = [ (if lib.strings.versionOlder bazel.version "5.0.0" then openjdk8 else jdk11_headless) ];
68
+
bazelScript = ''
69
+
${bazel}/bin/bazel \
70
+
run \
71
+
--announce_rc \
72
+
${lib.optionalString (lib.strings.versionOlder "5.0.0" bazel.version)
73
+
"--toolchain_resolution_debug='@bazel_tools//tools/jdk:(runtime_)?toolchain_type'"
74
+
} \
75
+
--distdir=${mergedDistDir} \
76
+
--repository_cache=${mergedDistDir} \
77
+
--verbose_failures \
78
+
--curses=no \
79
+
--strict_java_deps=off \
80
+
//:ProjectRunner \
81
+
'' + lib.optionalString (lib.strings.versionOlder bazel.version "5.0.0") ''
82
+
--host_javabase='@local_jdk//:jdk' \
83
+
--java_toolchain='@bazel_tools//tools/jdk:toolchain_hostjdk8' \
84
+
--javabase='@local_jdk//:jdk' \
85
+
'' + extraBazelArgs;
86
+
};
87
+
88
+
in testBazel
89
+
+5
-7
pkgs/development/tools/build-managers/bazel/bazel_7/tests.nix
···
6
, recurseIntoAttrs
7
, runCommandCC
8
, stdenv
9
-
, fetchurl
10
# inputs
11
, Foundation
12
, bazel_self
13
, lr
14
, xe
15
-
, bazel-watcher
16
, lockfile
17
-
, repoCache
18
}:
19
let
20
inherit (stdenv.hostPlatform) isDarwin;
···
133
inherit Foundation;
134
inherit bazel;
135
distDir = testsDistDir;
136
-
extraBazelArgs = "";
137
repoCache = testsRepoCache;
138
};
139
in
···
146
};
147
}) // {
148
bashTools = callBazelTest ../bash-tools-test.nix { };
149
-
cpp = callBazelTest ./cpp-test.nix { };
150
-
java = callBazelTest ../java-test.nix {
151
-
extraBazelArgs = "--noenable_bzlmod";
152
};
0
153
pythonBinPath = callBazelTest ../python-bin-path-test.nix { };
154
protobuf = callBazelTest ./protobuf-test.nix { };
155
}
···
6
, recurseIntoAttrs
7
, runCommandCC
8
, stdenv
0
9
# inputs
10
, Foundation
11
, bazel_self
12
, lr
13
, xe
0
14
, lockfile
15
+
, ...
16
}:
17
let
18
inherit (stdenv.hostPlatform) isDarwin;
···
131
inherit Foundation;
132
inherit bazel;
133
distDir = testsDistDir;
134
+
extraBazelArgs = "--noenable_bzlmod";
135
repoCache = testsRepoCache;
136
};
137
in
···
144
};
145
}) // {
146
bashTools = callBazelTest ../bash-tools-test.nix { };
147
+
cpp = callBazelTest ./cpp-test.nix {
148
+
extraBazelArgs = "";
0
149
};
150
+
java = callBazelTest ./java-test.nix { };
151
pythonBinPath = callBazelTest ../python-bin-path-test.nix { };
152
protobuf = callBazelTest ./protobuf-test.nix { };
153
}