2020-04-24 23:36:52 +00:00
|
|
|
{
|
|
|
|
bazel
|
|
|
|
, bazelTest
|
|
|
|
, bazel-examples
|
|
|
|
, gccStdenv
|
|
|
|
, lib
|
|
|
|
, openjdk8
|
2022-01-26 04:04:25 +00:00
|
|
|
, jdk11_headless
|
2020-04-24 23:36:52 +00:00
|
|
|
, 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 {
|
2021-02-13 14:23:35 +00:00
|
|
|
name = "bazel-test-java";
|
2020-04-24 23:36:52 +00:00
|
|
|
inherit workspaceDir;
|
|
|
|
bazelPkg = bazel;
|
2022-01-26 04:04:25 +00:00
|
|
|
buildInputs = [ (if lib.strings.versionOlder bazel.version "5.0.0" then openjdk8 else jdk11_headless) ];
|
2020-04-24 23:36:52 +00:00
|
|
|
bazelScript = ''
|
|
|
|
${bazel}/bin/bazel \
|
|
|
|
run \
|
|
|
|
--distdir=${distDir} \
|
|
|
|
--verbose_failures \
|
2021-12-21 02:18:32 +00:00
|
|
|
--curses=no \
|
|
|
|
--sandbox_debug \
|
2022-01-26 04:04:25 +00:00
|
|
|
//: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' \
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
in testBazel
|
|
|
|
|