Skip to content

Commit

Permalink
testing/java: make cc toolchain available
Browse files Browse the repository at this point in the history
rules_java builds native C code (zlib) as part of the toolchains //java_tools/zlib:zlib
  • Loading branch information
malt3 committed Jan 29, 2025
1 parent 1f77620 commit 03fba0e
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 3 deletions.
1 change: 1 addition & 0 deletions testing/java/.bazelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import %workspace%/../../.bazelrc.remote-cache
import %workspace%/../../.bazelrc.common
import %workspace%/../../.bazelrc.cc
import %workspace%/../../.bazelrc.java
20 changes: 17 additions & 3 deletions testing/java/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
module(name = "rules_nixpkgs_java_testing")

bazel_dep(name = "rules_nixpkgs_java")
bazel_dep(name = "rules_nixpkgs_cc")
local_path_override(
module_name = "rules_nixpkgs_java",
path = "../../toolchains/java",
module_name = "rules_nixpkgs_cc",
path = "../../toolchains/cc",
)

bazel_dep(name = "rules_nixpkgs_core")
Expand All @@ -12,7 +12,14 @@ local_path_override(
path = "../../core",
)

bazel_dep(name = "rules_nixpkgs_java")
local_path_override(
module_name = "rules_nixpkgs_java",
path = "../../toolchains/java",
)

bazel_dep(name = "bazel_skylib", version = "1.7.1")
bazel_dep(name = "rules_cc", version = "0.0.9")

# TODO[AH] Remove these transitive dependencies once nixpkgs_java_configure has
# become a module extension in rules_nixpkgs_java.
Expand All @@ -25,7 +32,14 @@ single_version_override(
)

non_module_deps = use_extension("//:non_module_deps.bzl", "non_module_deps")

# The Java toolchain requires a CC toolchain.
use_repo(non_module_deps, "nixpkgs")
use_repo(non_module_deps, "nixpkgs_config_cc")
use_repo(non_module_deps, "nixpkgs_config_cc_info")
use_repo(non_module_deps, "nixpkgs_config_cc_toolchains")
register_toolchains("@nixpkgs_config_cc_toolchains//:all")

use_repo(non_module_deps, "nixpkgs_java_runtime")
use_repo(non_module_deps, "nixpkgs_java_runtime_toolchain")
register_toolchains("@nixpkgs_java_runtime_toolchain//:all")
5 changes: 5 additions & 0 deletions testing/java/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ local_repository(
path = "../../toolchains/java",
)

local_repository(
name = "rules_nixpkgs_cc",
path = "../../toolchains/cc",
)

local_repository(
name = "rules_nixpkgs_core",
path = "../../core",
Expand Down
7 changes: 7 additions & 0 deletions testing/java/tests/nixpkgs_repositories.bzl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
load("@rules_nixpkgs_core//:nixpkgs.bzl", "nixpkgs_local_repository")
load("@rules_nixpkgs_cc//:cc.bzl", "nixpkgs_cc_configure")
load("@rules_nixpkgs_java//:java.bzl", "nixpkgs_java_configure")

def nixpkgs_repositories(*, bzlmod):
Expand All @@ -8,6 +9,12 @@ def nixpkgs_repositories(*, bzlmod):
nix_file_deps = ["//:flake.lock"],
)

nixpkgs_cc_configure(
name = "nixpkgs_config_cc",
repository = "@nixpkgs",
register = not bzlmod,
)

nixpkgs_java_configure(
name = "nixpkgs_java_runtime",
attribute_path = "jdk11.home",
Expand Down

0 comments on commit 03fba0e

Please sign in to comment.