Skip to content

Commit

Permalink
feat: add pipelining to zinc
Browse files Browse the repository at this point in the history
  • Loading branch information
timothyklim committed Jun 12, 2024
1 parent d9e5617 commit df13c48
Show file tree
Hide file tree
Showing 8 changed files with 1,672 additions and 82 deletions.
8 changes: 1 addition & 7 deletions .bazelrc_shared
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@ common --announce_rc
common --color=yes

build --experimental_strict_action_env

build --java_language_version=17
build --java_runtime_version=17
build --tool_java_language_version=17
build --tool_java_runtime_version=17

build --extra_toolchains=@local_jdk//:all

build --strategy=ScalaCompile=worker
Expand All @@ -24,4 +18,4 @@ test --jvmopt='-Dfile.encoding=UTF-8'
test --test_env='LC_ALL=en_US.UTF-8'
test --test_env='LANG=en_US.UTF-8'
test --jvmopt='-Dsun.jnu.encoding=UTF-8'
test --jvmopt='-Dfile.encoding=UTF-8'
test --jvmopt='-Dfile.encoding=UTF-8'
14 changes: 7 additions & 7 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

83 changes: 17 additions & 66 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,74 +2,25 @@
description = "Bazel rules_scala flake";

inputs = {
nixpkgs.url = "nixpkgs/release-23.11";
nixpkgs.url = "nixpkgs/release-24.05";
flake-utils.url = "github:numtide/flake-utils";
};

outputs = { self, nixpkgs, flake-utils }:
with flake-utils.lib; eachSystem [
system.aarch64-darwin
system.aarch64-linux
system.x86_64-darwin
system.x86_64-linux
]
(system:
let
pkgs = import nixpkgs {
inherit system;

overlays = [
(self: super: with super; rec {
remote_java_tools = stdenv.mkDerivation {
name = "remote_java_tools_linux";
src = fetchzip {
url = "https://github.com/bazelbuild/java_tools/releases/download/java_v12.6/java_tools_linux-v12.6.zip";
stripRoot = false;
hash = "sha256-p/x9F0PY5evOJepFJWDExs5whWYWF2RZjM6VsRABNyg=";
};

nativeBuildInputs = [ unzip ] ++ lib.optionals stdenv.isLinux [ autoPatchelfHook ];
buildInputs = [ gcc-unwrapped ];

buildPhase = ''
mkdir $out
'';

installPhase = ''
cp -Ra * $out/
touch $out/WORKSPACE
'';
};
jdk = super.openjdk17_headless;
bazelrc = writeText "bazelrc" ''
startup --server_javabase=${jdk.home}
build --override_repository=${remote_java_tools.name}=${remote_java_tools}
fetch --override_repository=${remote_java_tools.name}=${remote_java_tools}
query --override_repository=${remote_java_tools.name}=${remote_java_tools}
# load default location for the system wide configuration
try-import /etc/bazel.bazelrc
'';
bazel = stdenv.mkDerivation {
name = "bazel_custom";
phases = [ "installPhase" ];
installPhase = ''
mkdir -p $out/bin
cat <<'EOF' > $out/bin/bazel
#!/bin/sh
set -e
${bazel_6}/bin/bazel --bazelrc=${bazelrc} $@
EOF
chmod +x $out/bin/bazel
'';
};
})
];
};
in
rec {
devShell = pkgs.callPackage ./shell.nix { };
formatter = nixpkgs.legacyPackages.${system}.nixpkgs-fmt;
});
with flake-utils.lib; with system; eachSystem [ aarch64-darwin aarch64-linux x86_64-linux ] (system:
let
pkgs = import nixpkgs {
inherit system;

overlays = [
(self: super: with super; rec {
jdk = super.openjdk21_headless;
})
];
};
in
rec {
devShell = pkgs.callPackage ./shell.nix { };
formatter = nixpkgs.legacyPackages.${system}.nixpkgs-fmt;
});
}
5 changes: 5 additions & 0 deletions scala/workers/zinc/compile/main/ZincRunner.scala
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,11 @@ object ZincRunner extends WorkerMain[ZincRunner.Arguments]:

val setup =
val incOptions = IncOptions.create()
.withEnabled(true)
.withPipelining(true)
// .withStrictMode(true)
// .withRelationsDebug(true)
// .withApiDebug(true)
val skip = false
val zincFile: Path = null

Expand Down
1 change: 1 addition & 0 deletions scala3/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ toolchain(
repository_ctx.file("BUILD.bazel", build_content.format(
scala_version = scala_version,
enable_semanticdb = repository_ctx.attr.enable_semanticdb,
enable_diagnostics = repository_ctx.attr.enable_diagnostics,
semanticdb_bundle_in_jar = repository_ctx.attr.semanticdb_bundle_in_jar,
is_zinc = repository_ctx.attr.is_zinc,
zinc_log_level = repository_ctx.attr.zinc_log_level,
Expand Down
5 changes: 3 additions & 2 deletions shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ with pkgs;

let
stdenv = if pkgs.stdenv.hostPlatform.isDarwin then pkgs.llvmPackages_16.stdenv else pkgs.stdenv;
in mkShell.override { inherit stdenv; } {
in
mkShell {
name = "rules_scala-env";
nativeBuildInputs = [ jdk ];
buildInputs = [ bash bazel bazel-buildtools python3 just fd nixpkgs-fmt ];
buildInputs = [ bash bazel_7 bazel-buildtools python3 just fd nixpkgs-fmt ];
LOCALE_ARCHIVE = lib.optionals stdenv.isLinux "${glibcLocales}/lib/locale/locale-archive";
}
6 changes: 6 additions & 0 deletions tests/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
###############################################################################
# Bazel now uses Bzlmod by default to manage external dependencies.
# Please consider migrating your external dependencies from WORKSPACE to MODULE.bazel.
#
# For more details, please check https://github.com/bazelbuild/bazel/issues/18958
###############################################################################
Loading

0 comments on commit df13c48

Please sign in to comment.