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