blob: 64bfc42b240782b036e4099ab1f20527a2fe9fbc [file] [log] [blame]
package(default_visibility = ["//visibility:public"])
licenses(["notice"]) # Apache 2.0
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_proto_library")
load("@rules_java//java:defs.bzl", "java_binary", "java_import", "java_toolchain")
java_toolchain(
name = "toolchain",
bootclasspath = ["@bazel_tools//tools/jdk:platformclasspath"],
compatible_javacopts = {
# Restrict protos to Java 7 so that they are compatible with Android.
"proto": [
"-source",
"7",
"-target",
"7",
],
},
forcibly_disable_header_compilation = 0,
genclass = [":GenClass"],
header_compiler = [":Turbine"],
header_compiler_direct = [":TurbineDirect"],
ijar = [":ijar"],
jacocorunner = ":jacoco_coverage_runner_filegroup",
javabuilder = [":JavaBuilder"],
javac = [":javac_jar"],
javac_supports_workers = 1,
jvm_opts = [
# Allow JavaBuilder to access internal javac APIs.
"--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
"--add-opens=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
# override the javac in the JDK.
"--patch-module=java.compiler=$(location :java_compiler_jar)",
"--patch-module=jdk.compiler=$(location :jdk_compiler_jar)",
# quiet warnings from com.google.protobuf.UnsafeUtil,
# see: https://github.com/google/protobuf/issues/3781
# and: https://github.com/bazelbuild/bazel/issues/5599
"--add-opens=java.base/java.nio=ALL-UNNAMED",
"--add-opens=java.base/java.lang=ALL-UNNAMED",
],
misc = [
"-XDskipDuplicateBridges=true",
"-g",
"-parameters",
],
singlejar = [":singlejar"],
source_version = "8",
target_version = "8",
tools = [
":java_compiler_jar",
":jdk_compiler_jar",
],
)
# A toolchain that targets java JAVA_LANGUAGE_LEVEL.
java_toolchain(
name = "toolchain_jdk_JAVA_LANGUAGE_LEVEL",
bootclasspath = ["@bazel_tools//tools/jdk:platformclasspath"],
compatible_javacopts = {
# Restrict protos to Java 7 so that they are compatible with Android.
"proto": [
"-source",
"7",
"-target",
"7",
],
},
forcibly_disable_header_compilation = 0,
genclass = [":GenClass"],
header_compiler = [":Turbine"],
header_compiler_direct = [":TurbineDirect"],
ijar = [":ijar"],
jacocorunner = ":jacoco_coverage_runner_filegroup",
javabuilder = [":JavaBuilder"],
javac = [":javac_jar"],
javac_supports_workers = 1,
jvm_opts = [
# Allow JavaBuilder to access internal javac APIs.
"--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
"--add-opens=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
# override the javac in the JDK.
"--patch-module=java.compiler=$(location :java_compiler_jar)",
"--patch-module=jdk.compiler=$(location :jdk_compiler_jar)",
# quiet warnings from com.google.protobuf.UnsafeUtil,
# see: https://github.com/google/protobuf/issues/3781
# and: https://github.com/bazelbuild/bazel/issues/5599
"--add-opens=java.base/java.nio=ALL-UNNAMED",
"--add-opens=java.base/java.lang=ALL-UNNAMED",
],
misc = [
"-XDskipDuplicateBridges=true",
"-g",
"-parameters",
],
singlejar = [":singlejar"],
source_version = "JAVA_LANGUAGE_LEVEL",
target_version = "JAVA_LANGUAGE_LEVEL",
tools = [
":java_compiler_jar",
":jdk_compiler_jar",
],
)
# The new toolchain is using all the pre-built tools, including
# singlejar and ijar, even on remote execution. This toolchain
# should be used only when host and execution platform are the
# same, otherwise the binaries will not work on the execution
# platform.
java_toolchain(
name = "prebuilt_toolchain",
bootclasspath = ["@bazel_tools//tools/jdk:platformclasspath"],
compatible_javacopts = {
# Restrict protos to Java 7 so that they are compatible with Android.
"proto": [
"-source",
"7",
"-target",
"7",
],
},
forcibly_disable_header_compilation = 0,
genclass = [":GenClass"],
header_compiler = [":Turbine"],
header_compiler_direct = [":TurbineDirect"],
ijar = [":ijar_prebuilt_binary"],
jacocorunner = ":jacoco_coverage_runner_filegroup",
javabuilder = [":JavaBuilder"],
javac = [":javac_jar"],
javac_supports_workers = 1,
jvm_opts = [
# Allow JavaBuilder to access internal javac APIs.
"--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
"--add-opens=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
# override the javac in the JDK.
"--patch-module=java.compiler=$(location :java_compiler_jar)",
"--patch-module=jdk.compiler=$(location :jdk_compiler_jar)",
# quiet warnings from com.google.protobuf.UnsafeUtil,
# see: https://github.com/google/protobuf/issues/3781
# and: https://github.com/bazelbuild/bazel/issues/5599
"--add-opens=java.base/java.nio=ALL-UNNAMED",
"--add-opens=java.base/java.lang=ALL-UNNAMED",
],
misc = [
"-XDskipDuplicateBridges=true",
"-g",
"-parameters",
],
singlejar = [":prebuilt_singlejar"],
source_version = "8",
target_version = "8",
tools = [
":java_compiler_jar",
":jdk_compiler_jar",
],
)
filegroup(
name = "ExperimentalRunner",
srcs = ["java_tools/ExperimentalRunner_deploy.jar"],
)
filegroup(
name = "GenClass",
srcs = ["java_tools/GenClass_deploy.jar"],
)
filegroup(
name = "jacoco_coverage_runner_filegroup",
srcs = ["java_tools/JacocoCoverage_jarjar_deploy.jar"],
)
java_import(
name = "jacoco_coverage_runner",
jars = ["java_tools/JacocoCoverage_jarjar_deploy.jar"],
)
filegroup(
name = "JacocoCoverage",
srcs = ["java_tools/JacocoCoverage_jarjar_deploy.jar"],
)
filegroup(
name = "JavaBuilder",
srcs = ["java_tools/JavaBuilder_deploy.jar"],
)
filegroup(
name = "Runner",
srcs = ["java_tools/Runner_deploy.jar"],
)
filegroup(
name = "VanillaJavaBuilder",
srcs = ["java_tools/VanillaJavaBuilder_deploy.jar"],
)
filegroup(
name = "SingleJar",
srcs = ["java_tools/bazel-singlejar_deploy.jar"],
)
filegroup(
name = "JarJar",
srcs = ["java_tools/jarjar_command_deploy.jar"],
)
filegroup(
name = "Turbine",
srcs = ["java_tools/turbine_deploy.jar"],
)
filegroup(
name = "TurbineDirect",
srcs = ["java_tools/turbine_direct_binary_deploy.jar"],
)
filegroup(
name = "javac_jar",
srcs = ["java_tools/javac-9+181-r4173-1.jar"],
)
filegroup(
name = "jdk_compiler_jar",
srcs = ["java_tools/jdk_compiler.jar"],
)
filegroup(
name = "java_compiler_jar",
srcs = ["java_tools/java_compiler.jar"],
)
java_import(
name = "jacoco-agent",
jars = ["java_tools/third_party/java/jacoco/org.jacoco.agent-0.8.3.jar"],
srcjar = "java_tools/third_party/java/jacoco/org.jacoco.agent-0.8.3-src.jar",
)
java_import(
name = "jacoco-core",
jars = ["java_tools/third_party/java/jacoco/org.jacoco.core-0.8.3.jar"],
srcjar = "java_tools/third_party/java/jacoco/org.jacoco.core-0.8.3-src.jar",
exports = [
":asm",
":asm-commons",
":asm-tree",
],
)
filegroup(
name = "jacoco-core-jars",
srcs = ["java_tools/third_party/java/jacoco/org.jacoco.core-0.8.3.jar"],
)
java_import(
name = "jacoco-report",
jars = ["java_tools/third_party/java/jacoco/org.jacoco.report-0.8.3.jar"],
srcjar = "java_tools/third_party/java/jacoco/org.jacoco.report-sources.jar",
exports = [
":asm",
":jacoco-core",
],
)
java_import(
name = "bazel-jacoco-agent",
jars = ["java_tools/third_party/java/jacoco/jacocoagent-0.8.3.jar"],
)
java_import(
name = "bazel-jacoco-agent-neverlink",
jars = ["java_tools/third_party/java/jacoco/jacocoagent-0.8.3.jar"],
neverlink = 1,
)
java_import(
name = "asm",
jars = ["java_tools/third_party/java/jacoco/asm-7.0.jar"],
srcjar = "java_tools/third_party/java/jacoco/asm-7.0-sources.jar",
)
java_import(
name = "asm-commons",
jars = ["java_tools/third_party/java/jacoco/asm-commons-7.0.jar"],
srcjar = "java_tools/third_party/java/jacoco/asm-commons-7.0-sources.jar",
runtime_deps = [":asm-tree"],
)
java_import(
name = "asm-tree",
jars = ["java_tools/third_party/java/jacoco/asm-tree-7.0.jar"],
srcjar = "java_tools/third_party/java/jacoco/asm-tree-7.0-sources.jar",
runtime_deps = [":asm"],
)
config_setting(
name = "remote",
values = {"define": "EXECUTOR=remote"},
)
config_setting(
name = "linux_x86_64",
values = {"cpu": "k8"},
)
config_setting(
name = "darwin",
values = {"cpu": "darwin"},
)
config_setting(
name = "darwin_x86_64",
values = {"cpu": "darwin_x86_64"},
)
config_setting(
name = "windows",
values = {"cpu": "x64_windows"},
)
config_setting(
name = "freebsd",
values = {"cpu": "freebsd"},
visibility = ["//visibility:public"],
)
alias(
name = "singlejar",
actual = select({
"//:remote": ":singlejar_cc_bin",
"//conditions:default": ":singlejar_prebuilt_or_cc_binary",
}),
)
alias(
name = "singlejar_prebuilt_or_cc_binary",
actual = select({
":linux_x86_64": "java_tools/src/tools/singlejar/singlejar_local",
":darwin": "java_tools/src/tools/singlejar/singlejar_local",
":darwin_x86_64": "java_tools/src/tools/singlejar/singlejar_local",
":windows": "java_tools/src/tools/singlejar/singlejar_local.exe",
"//conditions:default": "singlejar_cc_bin",
}),
)
alias(
name = "prebuilt_singlejar",
actual = select({
":windows": "java_tools/src/tools/singlejar/singlejar_local.exe",
"//conditions:default": "java_tools/src/tools/singlejar/singlejar_local",
}),
)
alias(
name = "ijar",
actual = select({
":remote": ":ijar_cc_binary",
"//conditions:default": ":prebuilt_binary_or_cc_binary",
}),
)
alias(
name = "prebuilt_binary_or_cc_binary",
actual = select({
":linux_x86_64": ":ijar_prebuilt_binary",
":darwin": ":ijar_prebuilt_binary",
":darwin_x86_64": ":ijar_prebuilt_binary",
":windows": ":ijar_prebuilt_binary",
"//conditions:default": ":ijar_cc_binary",
}),
)
filegroup(
name = "ijar_prebuilt_binary",
srcs = select({
":windows": ["java_tools/ijar/ijar.exe"],
"//conditions:default": ["java_tools/ijar/ijar"],
}),
)
cc_library(
name = "malloc",
)
cc_binary(
name = "ijar_cc_binary",
srcs = [
"java_tools/ijar/classfile.cc",
"java_tools/ijar/ijar.cc",
],
# Remove dependency on @bazel_tools//tools/cpp:malloc, which avoid /Iexternal/tools being used
# in compiling actions.
malloc = ":malloc",
deps = [":zip"],
)
cc_library(
name = "zip",
srcs = [
"java_tools/ijar/zip.cc",
] + select({
":windows": [
"java_tools/ijar/mapped_file_windows.cc",
],
"//conditions:default": [
"java_tools/ijar/mapped_file_unix.cc",
],
}),
hdrs = [
"java_tools/ijar/common.h",
"java_tools/ijar/mapped_file.h",
"java_tools/ijar/zip.h",
],
include_prefix = "third_party",
strip_include_prefix = "java_tools",
deps = [
":platform_utils",
":zlib_client",
] + select({
":windows": [
":errors",
":filesystem",
":logging",
":strings",
],
"//conditions:default": [
],
}),
)
cc_library(
name = "platform_utils",
srcs = ["java_tools/ijar/platform_utils.cc"],
hdrs = [
"java_tools/ijar/common.h",
"java_tools/ijar/platform_utils.h",
],
include_prefix = "third_party",
strip_include_prefix = "java_tools",
visibility = ["//visibility:private"],
deps = [
":errors",
":filesystem",
":logging",
],
)
cc_library(
name = "cpp_util",
hdrs = [
"java_tools/src/main/cpp/util/errors.h",
"java_tools/src/main/cpp/util/file.h",
"java_tools/src/main/cpp/util/file_platform.h",
"java_tools/src/main/cpp/util/md5.h",
"java_tools/src/main/cpp/util/numbers.h",
"java_tools/src/main/cpp/util/path.h",
"java_tools/src/main/cpp/util/path_platform.h",
"java_tools/src/main/cpp/util/port.h",
],
strip_include_prefix = "java_tools",
visibility = ["//visibility:public"],
deps = [
":blaze_exit_code",
":errors",
":filesystem",
":md5",
":numbers",
":port",
":strings",
],
)
cc_library(
name = "md5",
srcs = ["java_tools/src/main/cpp/util/md5.cc"],
hdrs = ["java_tools/src/main/cpp/util/md5.h"],
strip_include_prefix = "java_tools",
)
cc_library(
name = "numbers",
srcs = ["java_tools/src/main/cpp/util/numbers.cc"],
hdrs = ["java_tools/src/main/cpp/util/numbers.h"],
strip_include_prefix = "java_tools",
deps = [":strings"],
)
cc_library(
name = "filesystem",
srcs = [
"java_tools/src/main/cpp/util/file.cc",
"java_tools/src/main/cpp/util/path.cc",
] + select({
":windows": [
"java_tools/src/main/cpp/util/file_windows.cc",
"java_tools/src/main/cpp/util/path_windows.cc",
],
"//conditions:default": [
"java_tools/src/main/cpp/util/file_posix.cc",
"java_tools/src/main/cpp/util/path_posix.cc",
],
}),
hdrs = [
"java_tools/src/main/cpp/util/file.h",
"java_tools/src/main/cpp/util/file_platform.h",
"java_tools/src/main/cpp/util/path.h",
"java_tools/src/main/cpp/util/path_platform.h",
],
strip_include_prefix = "java_tools",
deps = [
":blaze_exit_code",
":errors",
":logging",
":strings",
] + select({
":windows": [":lib-file"],
"//conditions:default": [],
}),
)
cc_library(
name = "lib-file",
srcs = [
"java_tools/src/main/native/windows/file.cc",
"java_tools/src/main/native/windows/util.cc",
],
hdrs = [
"java_tools/src/main/native/windows/file.h",
"java_tools/src/main/native/windows/util.h",
],
strip_include_prefix = "java_tools",
)
cc_library(
name = "lib-util",
srcs = ["java_tools/src/main/native/windows/util.cc"],
hdrs = ["java_tools/src/main/native/windows/util.h"],
strip_include_prefix = "java_tools",
)
cc_library(
name = "errors",
srcs = select({
":windows": ["java_tools/src/main/cpp/util/errors_windows.cc"],
"//conditions:default": ["java_tools/src/main/cpp/util/errors_posix.cc"],
}),
hdrs = ["java_tools/src/main/cpp/util/errors.h"],
strip_include_prefix = "java_tools",
deps = [
":logging",
":port",
":strings",
],
)
cc_library(
name = "strings",
srcs = ["java_tools/src/main/cpp/util/strings.cc"],
hdrs = ["java_tools/src/main/cpp/util/strings.h"],
# Automatically propagate the symbol definition to rules depending on this.
defines = [
"BLAZE_OPENSOURCE",
],
strip_include_prefix = "java_tools",
deps = [":blaze_exit_code"],
)
cc_library(
name = "blaze_exit_code",
hdrs = ["java_tools/src/main/cpp/util/exit_code.h"],
strip_include_prefix = "java_tools",
)
cc_library(
name = "port",
srcs = ["java_tools/src/main/cpp/util/port.cc"],
hdrs = ["java_tools/src/main/cpp/util/port.h"],
strip_include_prefix = "java_tools",
)
cc_library(
name = "logging",
srcs = ["java_tools/src/main/cpp/util/logging.cc"],
hdrs = ["java_tools/src/main/cpp/util/logging.h"],
strip_include_prefix = "java_tools",
deps = [
":blaze_exit_code",
":strings",
],
)
cc_library(
name = "zlib_client",
srcs = ["java_tools/ijar/zlib_client.cc"],
hdrs = [
"java_tools/ijar/common.h",
"java_tools/ijar/zlib_client.h",
],
include_prefix = "third_party",
strip_include_prefix = "java_tools",
deps = ["//java_tools/zlib"],
)
##################### singlejar
cc_binary(
name = "singlejar_cc_bin",
srcs = [
"java_tools/src/tools/singlejar/singlejar_main.cc",
],
linkopts = select({
":freebsd": ["-lm"],
"//conditions:default": [],
}),
linkstatic = 1,
# Remove dependency on @bazel_tools//tools/cpp:malloc, which avoid /Iexternal/tools being used
# in compiling actions.
malloc = ":malloc",
visibility = ["//visibility:public"],
deps = [
":options",
":output_jar",
"//java_tools/zlib",
],
)
cc_binary(
name = "singlejar_local",
srcs = [
"java_tools/src/tools/singlejar/singlejar_local_main.cc",
],
linkopts = select({
":freebsd": ["-lm"],
"//conditions:default": [],
}),
linkstatic = 1,
visibility = ["//visibility:public"],
deps = [
":combiners",
":desugar_checking",
":options",
":output_jar",
"//java_tools/zlib",
],
)
cc_library(
name = "combiners",
srcs = [
"java_tools/src/tools/singlejar/combiners.cc",
],
hdrs = [
"java_tools/src/tools/singlejar/combiners.h",
":transient_bytes",
":zip_headers",
],
strip_include_prefix = "java_tools",
deps = [
"//java_tools/zlib",
],
)
proto_library(
name = "desugar_deps_proto",
srcs = ["java_tools/src/main/protobuf/desugar_deps.proto"],
)
cc_proto_library(
name = "desugar_deps_cc_proto",
deps = [":desugar_deps_proto"],
)
cc_library(
name = "desugar_checking",
srcs = ["java_tools/src/tools/singlejar/desugar_checking.cc"],
hdrs = ["java_tools/src/tools/singlejar/desugar_checking.h"],
strip_include_prefix = "java_tools",
deps = [
":combiners",
":desugar_deps_cc_proto",
],
)
cc_library(
name = "diag",
hdrs = ["java_tools/src/tools/singlejar/diag.h"],
strip_include_prefix = "java_tools",
visibility = ["//visibility:private"],
)
cc_library(
name = "singlejar_port",
hdrs = ["java_tools/src/tools/singlejar/port.h"],
strip_include_prefix = "java_tools",
visibility = ["//visibility:private"],
)
cc_library(
name = "mapped_file",
srcs = ["java_tools/src/tools/singlejar/mapped_file.cc"],
hdrs = ["java_tools/src/tools/singlejar/mapped_file.h"] +
select({
":windows": ["java_tools/src/tools/singlejar/mapped_file_windows.inc"],
"//conditions:default": ["java_tools/src/tools/singlejar/mapped_file_posix.inc"],
}),
strip_include_prefix = "java_tools",
visibility = ["//visibility:private"],
deps = [
":cpp_util",
":diag",
":singlejar_port",
],
)
cc_library(
name = "input_jar",
srcs = [
"java_tools/src/tools/singlejar/input_jar.cc",
],
hdrs = [
"java_tools/src/tools/singlejar/input_jar.h",
"java_tools/src/tools/singlejar/zip_headers.h",
],
strip_include_prefix = "java_tools",
deps = [
":diag",
":mapped_file",
],
)
cc_library(
name = "options",
srcs = [
"java_tools/src/tools/singlejar/options.cc",
"java_tools/src/tools/singlejar/options.h",
],
hdrs = ["java_tools/src/tools/singlejar/options.h"],
strip_include_prefix = "java_tools",
deps = [
":diag",
":token_stream",
],
)
cc_library(
name = "output_jar",
srcs = [
"java_tools/src/tools/singlejar/output_jar.cc",
"java_tools/src/tools/singlejar/output_jar.h",
":zip_headers",
],
hdrs = ["java_tools/src/tools/singlejar/output_jar.h"],
strip_include_prefix = "java_tools",
deps = [
":combiners",
":cpp_util",
":diag",
":input_jar",
":mapped_file",
":options",
":singlejar_port",
"//java_tools/zlib",
],
)
cc_library(
name = "token_stream",
hdrs = ["java_tools/src/tools/singlejar/token_stream.h"],
strip_include_prefix = "java_tools",
deps = [
":diag",
":filesystem",
],
)
filegroup(
name = "transient_bytes",
srcs = [
"java_tools/src/tools/singlejar/diag.h",
"java_tools/src/tools/singlejar/transient_bytes.h",
"java_tools/src/tools/singlejar/zlib_interface.h",
":zip_headers",
],
)
filegroup(
name = "zip_headers",
srcs = ["java_tools/src/tools/singlejar/zip_headers.h"],
)
################### Proguard ###################
java_import(
name = "proguard_import",
jars = ["java_tools/third_party/java/proguard/proguard.jar"],
)
java_binary(
name = "proguard",
main_class = "proguard.ProGuard",
visibility = ["//visibility:public"],
runtime_deps = [":proguard_import"],
)