mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-28 08:33:54 +00:00
eeede61892
Bazel 5 is going to be a second long term support release. Changes from bazel_4: - compile java_tools (such as ijar) using nix-provided jdk - local jvm and jdk are now passed using --tool_java_runtime_version, --tool_java_runtime_version and --extra_toolchains flags see https://docs.bazel.build/versions/5.0.0/bazel-and-java.html for details - update-srcDeps.py: distdir_tar function renamed to _distdir_tar to properly parse bazel query output executed against bazel 5 sources - bazel_5.updater: uses bazel_4 to generate src-deps.json. This change was required to handle json.decode calls in bazel 5 dependencies - protobuf-test and java-test adjusted to take into consideration both jdk 8 (for Bazel < 5.0.0) and jdk 11 (for Bazel >= 5.0.0) https://blog.bazel.build/2022/01/19/bazel-5.0.html https://github.com/bazelbuild/bazel/releases/tag/5.0.0
63 lines
1.5 KiB
Nix
63 lines
1.5 KiB
Nix
{
|
|
bazel
|
|
, bazelTest
|
|
, bazel-examples
|
|
, gccStdenv
|
|
, lib
|
|
, openjdk8
|
|
, jdk11_headless
|
|
, runLocal
|
|
, runtimeShell
|
|
, writeScript
|
|
, writeText
|
|
, distDir
|
|
}:
|
|
|
|
let
|
|
|
|
toolsBazel = writeScript "bazel" ''
|
|
#! ${runtimeShell}
|
|
|
|
export CXX='${gccStdenv.cc}/bin/g++'
|
|
export LD='${gccStdenv.cc}/bin/ld'
|
|
export CC='${gccStdenv.cc}/bin/gcc'
|
|
|
|
# XXX: hack for macosX, this flags disable bazel usage of xcode
|
|
# See: https://github.com/bazelbuild/bazel/issues/4231
|
|
export BAZEL_USE_CPP_ONLY_TOOLCHAIN=1
|
|
|
|
exec "$BAZEL_REAL" "$@"
|
|
'';
|
|
|
|
workspaceDir = runLocal "our_workspace" {} (''
|
|
cp -r ${bazel-examples}/java-tutorial $out
|
|
find $out -type d -exec chmod 755 {} \;
|
|
''
|
|
+ (lib.optionalString gccStdenv.isDarwin ''
|
|
mkdir $out/tools
|
|
cp ${toolsBazel} $out/tools/bazel
|
|
''));
|
|
|
|
testBazel = bazelTest {
|
|
name = "bazel-test-java";
|
|
inherit workspaceDir;
|
|
bazelPkg = bazel;
|
|
buildInputs = [ (if lib.strings.versionOlder bazel.version "5.0.0" then openjdk8 else jdk11_headless) ];
|
|
bazelScript = ''
|
|
${bazel}/bin/bazel \
|
|
run \
|
|
--distdir=${distDir} \
|
|
--verbose_failures \
|
|
--curses=no \
|
|
--sandbox_debug \
|
|
//:ProjectRunner \
|
|
'' + lib.optionalString (lib.strings.versionOlder bazel.version "5.0.0") ''
|
|
--host_javabase='@local_jdk//:jdk' \
|
|
--java_toolchain='@bazel_tools//tools/jdk:toolchain_hostjdk8' \
|
|
--javabase='@local_jdk//:jdk' \
|
|
'';
|
|
};
|
|
|
|
in testBazel
|
|
|