Build a version of Bazel with a bundled OpenJDK inside the binary.

We're using Azul Systems, Inc.'s ZuluĀ® OpenJDK build[1], as it's a good
vanilla build of OpenJDK available for our three most important
platforms:

  zulu8.20.0.5-jdk8.0.121-linux_x64.tar.gz
  zulu8.20.0.5-jdk8.0.121-macosx_x64.zip
  zulu8.20.0.5-jdk8.0.121-win_x64.zip

You can build & run a Bazel binary with an embedded JDK by simple doing:

  bazel build //src:bazel_with_jdk
  bazel-bin/src/bazel_with_jdk info

The "bazel license" command prints the license of the embedded OpenJDK.

We mirror the binaries and sources of the OpenJDK used for bundling on
this website:

https://bazel-mirror.storage.googleapis.com/openjdk/index.html

RELNOTES: Bazel can now be built with a bundled version of the OpenJDK.
This makes it possible to use Bazel on systems without a JDK, or where
the installed JDK is too old.

[1] http://www.azul.com/downloads/zulu/

--
PiperOrigin-RevId: 150440467
MOS_MIGRATED_REVID=150440467
diff --git a/src/BUILD b/src/BUILD
index fb39187..416ffb0 100644
--- a/src/BUILD
+++ b/src/BUILD
@@ -40,6 +40,7 @@
     }),
 ) for suffix, embedded_tools in {
     "": [":embedded_tools"],
+    "_with_jdk": [":embedded_tools_with_jdk"],
     "_notools": [],
 }.items()]
 
@@ -127,8 +128,8 @@
     ],
 )
 
-genrule(
-    name = "embedded_tools",
+[genrule(
+    name = "embedded_tools" + suffix,
     srcs = [
         ":create_embedded_tools.sh",
         "//tools:embedded_tools_srcs",
@@ -171,14 +172,33 @@
         "//conditions:default": [
             "//src/java_tools/buildjar/java/com/google/devtools/build/java/turbine:turbine_deploy.jar",
         ],
-    }),
-    outs = ["embedded_tools.zip"],
+    }) + (select({
+        ":darwin": [
+            "@openjdk_macos//file",
+        ],
+        ":darwin_x86_64": [
+            "@openjdk_macos//file",
+        ],
+        ":windows": [
+            "@openjdk_win//file",
+        ],
+        ":windows_msvc": [
+            "@openjdk_win//file",
+        ],
+        "//conditions:default": [
+            "@openjdk_linux//file",
+        ],
+    }) if (suffix == "_with_jdk") else []),
+    outs = ["embedded_tools" + suffix + ".zip"],
     cmd = "$(location :create_embedded_tools.sh) $@ $(SRCS)",
-)
+) for suffix in [
+    "",
+    "_with_jdk",
+]]
 
 [genrule(
     name = "package-zip" + suffix,
-    srcs = ([":embedded_tools.zip"] if embed else []) + [
+    srcs = ([":embedded_tools" + suffix + ".zip"] if embed else []) + [
         # The script assumes that the embedded tools zip (if exists) is the
         # first item here, the deploy jar the second and install base key is the
         # third
@@ -199,6 +219,7 @@
 ) for suffix, embed in [
     ("", True),
     ("_notools", False),
+    ("_with_jdk", True),
 ]]
 
 [genrule(
@@ -223,6 +244,7 @@
 ) for suffix in [
     "",
     "_notools",
+    "_with_jdk",
 ]]
 
 # Build an executable named `bazel.exe`.
@@ -243,6 +265,7 @@
 ) for suffix in [
     "",
     "_notools",
+    "_with_jdk",
 ]]
 
 config_setting(