blob: a8bb7c78899595f49d0dabc4a97c3b4242eb5b05 [file] [log] [blame]
load(
"@bazel_tools//tools/jdk:default_java_toolchain.bzl",
"DEFAULT_TOOLCHAIN_CONFIGURATION",
"PREBUILT_TOOLCHAIN_CONFIGURATION",
"VANILLA_TOOLCHAIN_CONFIGURATION",
"bootclasspath",
"default_java_toolchain",
"java_runtime_files",
)
load(
"//tools/jdk:java_toolchain_alias.bzl",
"java_host_runtime_alias",
"java_runtime_alias",
"java_runtime_version_alias",
"java_toolchain_alias",
)
load("//tools/python:private/defs.bzl", "py_binary", "py_test")
package(default_visibility = ["//visibility:public"])
# Used to distinguish toolchains used for Java development, ie the JavaToolchainProvider.
toolchain_type(name = "toolchain_type")
# Used to distinguish toolchains used for Java execution, ie the JavaRuntimeInfo.
toolchain_type(name = "runtime_toolchain_type")
# Points to toolchain[":runtime_toolchain_type"] (was :legacy_current_java_runtime)
java_runtime_alias(name = "current_java_runtime")
# Host configuration of ":current_java_runtime"
java_host_runtime_alias(name = "current_host_java_runtime")
# Points to toolchain[":toolchain_type"] (was :legacy_current_java_toolchain)
java_toolchain_alias(name = "current_java_toolchain")
# Aliases value of --plugins flag as a JavaPluginInfo
java_plugins_flag_alias(
name = "java_plugins_flag_alias",
)
# This is necessary to get the *host* Java runtime. Depending on
# //tools/jdk:current_java_runtime from an attribute with the host transition
# does not work because the dependency is determined based on the configuration
# *before* the transition.
alias(
name = "java_runtime_alias",
actual = "//tools/jdk:current_java_runtime",
)
# These individual jni_* targets are exposed for legacy reasons.
# Most users should depend on :jni.
java_runtime_files(
name = "jni_header",
srcs = ["include/jni.h"],
)
java_runtime_files(
name = "jni_md_header-darwin",
srcs = ["include/darwin/jni_md.h"],
)
java_runtime_files(
name = "jni_md_header-linux",
srcs = ["include/linux/jni_md.h"],
)
java_runtime_files(
name = "jni_md_header-windows",
srcs = ["include/win32/jni_md.h"],
)
java_runtime_files(
name = "jni_md_header-freebsd",
srcs = ["include/freebsd/jni_md.h"],
)
java_runtime_files(
name = "jni_md_header-openbsd",
srcs = ["include/openbsd/jni_md.h"],
)
# The Java native interface. Depend on this package if you #include <jni.h>.
#
# See test_jni in third_party/bazel/src/test/shell/bazel/bazel_java_test.sh for
# an example of using Bazel to build a Java program that calls a C function.
#
# TODO(ilist): use //src:condition:linux when released in Bazel
cc_library(
name = "jni",
hdrs = [":jni_header"] + select({
"//src/conditions:linux_aarch64": [":jni_md_header-linux"],
"//src/conditions:linux_ppc64le": [":jni_md_header-linux"],
"//src/conditions:linux_s390x": [":jni_md_header-linux"],
"//src/conditions:linux_mips64": [":jni_md_header-linux"],
"//src/conditions:linux_riscv64": [":jni_md_header-linux"],
"//src/conditions:linux_x86_64": [":jni_md_header-linux"],
"//src/conditions:darwin": [":jni_md_header-darwin"],
"//src/conditions:freebsd": [":jni_md_header-freebsd"],
"//src/conditions:openbsd": [":jni_md_header-openbsd"],
"//src/conditions:windows": [":jni_md_header-windows"],
"//conditions:default": [],
}),
includes = ["include"] + select({
"//src/conditions:linux_aarch64": ["include/linux"],
"//src/conditions:linux_ppc64le": ["include/linux"],
"//src/conditions:linux_s390x": ["include/linux"],
"//src/conditions:linux_mips64": ["include/linux"],
"//src/conditions:linux_riscv64": ["include/linux"],
"//src/conditions:linux_x86_64": ["include/linux"],
"//src/conditions:darwin": ["include/darwin"],
"//src/conditions:freebsd": ["include/freebsd"],
"//src/conditions:openbsd": ["include/openbsd"],
"//src/conditions:windows": ["include/win32"],
"//conditions:default": [],
}),
)
alias(
name = "java",
actual = "@local_jdk//:java",
)
alias(
name = "jar",
actual = "@local_jdk//:jar",
)
alias(
name = "javadoc",
actual = "@local_jdk//:javadoc",
)
[
(
alias(
name = "ijar_prebuilt_binary_%s" % OS,
actual = "@remote_java_tools_%s//:ijar_prebuilt_binary" % OS,
visibility = ["//visibility:private"],
),
alias(
name = "prebuilt_singlejar_%s" % OS,
actual = "@remote_java_tools_%s//:prebuilt_singlejar" % OS,
visibility = ["//visibility:private"],
),
)
for OS in [
"linux",
"darwin",
"windows",
]
]
# On Windows, executables end in ".exe", but the label we reach it through
# must be platform-independent. Thus, we create a little filegroup that
# contains the appropriate platform-dependent file.
alias(
name = "ijar",
actual = ":ijar_prebuilt_binary_or_cc_binary",
)
alias(
name = "ijar_prebuilt_binary_or_cc_binary",
actual = select({
"//src/conditions:linux_x86_64": ":ijar_prebuilt_binary_linux",
"//src/conditions:darwin": ":ijar_prebuilt_binary_darwin",
"//src/conditions:windows": ":ijar_prebuilt_binary_windows",
"//conditions:default": "@remote_java_tools//:ijar_cc_binary",
}),
)
alias(
name = "ijar_prebuilt_binary",
actual = select({
"//src/conditions:linux_x86_64": ":ijar_prebuilt_binary_linux",
"//src/conditions:darwin": ":ijar_prebuilt_binary_darwin",
"//src/conditions:windows": ":ijar_prebuilt_binary_windows",
}),
)
# On Windows, Java implementation of singlejar is used. We create a little
# filegroup that contains the appropriate platform-dependent file.
# Once https://github.com/bazelbuild/bazel/issues/2241 is fixed (that is,
# the native singlejar is used on windows), this file group can be reused since
# on Windows, executables end in ".exe", but the label we reach it through
# must be platform-independent.
alias(
name = "singlejar",
actual = ":singlejar_prebuilt_or_cc_binary",
)
alias(
name = "singlejar_prebuilt_or_cc_binary",
actual = select({
"//src/conditions:linux_x86_64": ":prebuilt_singlejar_linux",
"//src/conditions:darwin": ":prebuilt_singlejar_darwin",
"//src/conditions:windows": ":prebuilt_singlejar_windows",
"//conditions:default": "@remote_java_tools//:singlejar_cc_bin",
}),
)
alias(
name = "prebuilt_singlejar",
actual = select({
"//src/conditions:linux_x86_64": ":prebuilt_singlejar_linux",
"//src/conditions:darwin": ":prebuilt_singlejar_darwin",
"//src/conditions:windows": ":prebuilt_singlejar_windows",
}),
)
exports_files([
"BUILD.java_tools",
"jdk.BUILD",
])
alias(
name = "genclass",
actual = "@remote_java_tools//:GenClass",
)
alias(
name = "GenClass_deploy.jar",
actual = "@remote_java_tools//:GenClass",
)
alias(
name = "turbine_direct",
actual = "@remote_java_tools//:TurbineDirect",
)
alias(
name = "turbine_direct_binary_deploy.jar",
actual = "@remote_java_tools//:TurbineDirect",
)
alias(
name = "javabuilder",
actual = "@remote_java_tools//:JavaBuilder",
)
alias(
name = "JavaBuilder_deploy.jar",
actual = "@remote_java_tools//:JavaBuilder",
)
alias(
name = "vanillajavabuilder",
actual = "@remote_java_tools//:VanillaJavaBuilder",
)
alias(
name = "JacocoCoverageRunner",
actual = "@remote_java_tools//:jacoco_coverage_runner",
)
alias(
name = "JacocoCoverage",
actual = "@remote_java_tools//:jacoco_coverage_runner",
)
java_import(
name = "TestRunner",
jars = ["@remote_java_tools//:Runner"],
)
alias(
name = "TestRunner_deploy.jar",
actual = "@remote_java_tools//:Runner",
)
alias(
name = "proguard",
actual = "@remote_java_tools//:proguard",
)
BOOTCLASS_JARS = [
"rt.jar",
"resources.jar",
"jsse.jar",
"jce.jar",
"charsets.jar",
]
# TODO(cushon): this isn't compatible with JDK 9
alias(
name = "bootclasspath",
actual = "@local_jdk//:bootclasspath",
)
alias(
name = "jre",
actual = "@local_jdk//:jre",
)
alias(
name = "jdk",
actual = "@local_jdk//:jdk",
)
alias(
name = "host_jdk",
actual = ":remote_jdk11",
)
bootclasspath(
name = "platformclasspath",
src = "DumpPlatformClassPath.java",
host_javabase = "current_java_runtime",
target_javabase = "current_java_runtime",
)
default_java_toolchain(
name = "toolchain",
configuration = DEFAULT_TOOLCHAIN_CONFIGURATION,
toolchain_definition = False,
)
alias(
name = "remote_toolchain",
actual = ":toolchain",
)
RELEASES = (8, 9, 10, 11)
[
default_java_toolchain(
name = "toolchain_java%d" % release,
configuration = DEFAULT_TOOLCHAIN_CONFIGURATION,
source_version = "%s" % release,
target_version = "%s" % release,
)
for release in RELEASES
]
# A toolchain that targets java 14.
default_java_toolchain(
name = "toolchain_jdk_14",
configuration = dict(),
java_runtime = "@bazel_tools//tools/jdk:remotejdk_14",
source_version = "14",
target_version = "14",
)
# A toolchain that targets java 15.
default_java_toolchain(
name = "toolchain_jdk_15",
configuration = dict(),
java_runtime = "@bazel_tools//tools/jdk:remotejdk_15",
source_version = "15",
target_version = "15",
)
# A toolchain that targets java 16.
default_java_toolchain(
name = "toolchain_jdk_16",
configuration = dict(),
java_runtime = "@bazel_tools//tools/jdk:remotejdk_16",
source_version = "16",
target_version = "16",
)
# A toolchain that targets java 17.
default_java_toolchain(
name = "toolchain_jdk_17",
configuration = dict(),
java_runtime = "@bazel_tools//tools/jdk:remotejdk_17",
source_version = "17",
target_version = "17",
)
# A toolchain that targets java 18.
default_java_toolchain(
name = "toolchain_jdk_18",
configuration = dict(),
java_runtime = "@bazel_tools//tools/jdk:remotejdk_18",
source_version = "18",
target_version = "18",
)
default_java_toolchain(
name = "prebuilt_toolchain",
configuration = PREBUILT_TOOLCHAIN_CONFIGURATION,
toolchain_definition = False,
)
filegroup(
name = "bzl_srcs",
srcs = glob(["*.bzl"]),
visibility = ["//tools:__pkg__"],
)
py_binary(
name = "proguard_whitelister",
srcs = [
"proguard_whitelister.py",
],
deps = [
"//third_party/py/abseil",
],
)
py_test(
name = "proguard_whitelister_test",
srcs = ["proguard_whitelister_test.py"],
data = ["proguard_whitelister_test_input.pgcfg"],
deps = [
":proguard_whitelister",
],
)
# Aliases for JDKs, so that they are only downloaded when needed.
_JDKS = [
"remotejdk11_macos",
"remotejdk11_macos_aarch64",
"remotejdk11_win",
"remotejdk11_win_arm64",
"remotejdk11_linux_aarch64",
"remotejdk11_linux",
"remotejdk11_linux_ppc64le",
"remotejdk11_linux_s390x",
] + [
"remotejdk%s_%s" % (version, os)
for os in ("linux", "linux_aarch64", "macos", "macos_aarch64", "win", "win_arm64")
for version in ("17", "18")
]
[
alias(
name = JDK,
actual = "@%s//:jdk" % JDK,
visibility = ["//visibility:private"],
)
for JDK in _JDKS
]
# A JDK 11 for use as a --host_javabase.
java_runtime_version_alias(
name = "remote_jdk11",
runtime_version = "remotejdk_11",
visibility = ["//visibility:public"],
)
java_runtime_version_alias(
name = "remotejdk_15",
runtime_version = "remotejdk_15",
visibility = ["//visibility:public"],
)
java_runtime_version_alias(
name = "remotejdk_16",
runtime_version = "remotejdk_16",
visibility = ["//visibility:public"],
)
java_runtime_version_alias(
name = "remotejdk_17",
runtime_version = "remotejdk_17",
visibility = ["//visibility:public"],
)
java_runtime_version_alias(
name = "remotejdk_18",
runtime_version = "remotejdk_18",
visibility = ["//visibility:public"],
)
java_runtime_version_alias(
name = "jdk_8",
runtime_version = "8",
visibility = ["//visibility:public"],
)