bazel: allow offline build of major versions 5 and 6 (#41575)
* bazel: allow offline build of major versions 5 and 6; add variant download_data * bazel: add maintainer LydDeb * bazel: install offline only; remove variant download_data * bazel: fix variable name: resource_dico --> resource_dictionary * bazel: fix style * bazel: fix the build of version 4 * bazel: add comment about resources * bazel: access to resource stages with self.stage * bazel: add except to solve AttributeError: 'Stage' object has no attribute 'resource' --------- Co-authored-by: LydDeb <lyderic.debusschere@eolen.com>
This commit is contained in:
parent
c45714fd3c
commit
fe4a4ddcf9
@ -18,6 +18,8 @@ class Bazel(Package):
|
||||
homepage = "https://bazel.build/"
|
||||
url = "https://github.com/bazelbuild/bazel/releases/download/3.1.0/bazel-3.1.0-dist.zip"
|
||||
|
||||
maintainers("LydDeb")
|
||||
|
||||
tags = ["build-tools"]
|
||||
|
||||
license("Apache-2.0")
|
||||
@ -120,6 +122,39 @@ class Bazel(Package):
|
||||
|
||||
executables = ["^bazel$"]
|
||||
|
||||
# Download resources to perform offline build with bazel.
|
||||
# The following URLs and sha256 are in the file distdir_deps.bzl at the root of bazel sources.
|
||||
resource_dictionary = {}
|
||||
resource_dictionary["bazel_skylib"] = {
|
||||
"url": "https://github.com/bazelbuild/bazel-skylib/releases/download/1.0.1/bazel-skylib-1.0.1.tar.gz",
|
||||
"sha256": "f1c8360c01fcf276778d3519394805dc2a71a64274a3a0908bc9edff7b5aebc8",
|
||||
"when": "@4:6",
|
||||
}
|
||||
resource_dictionary["zulu_11_56_19"] = {
|
||||
"url": "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu11.56.19-ca-jdk11.0.15-linux_x64.tar.gz",
|
||||
"sha256": "e064b61d93304012351242bf0823c6a2e41d9e28add7ea7f05378b7243d34247",
|
||||
"when": "@6",
|
||||
}
|
||||
resource_dictionary["zulu_11_50_19"] = {
|
||||
"url": "https://mirror.bazel.build/openjdk/azul-zulu11.50.19-ca-jdk11.0.12/zulu11.50.19-ca-jdk11.0.12-linux_x64.tar.gz",
|
||||
"sha256": "b8e8a63b79bc312aa90f3558edbea59e71495ef1a9c340e38900dd28a1c579f3",
|
||||
"when": "@5",
|
||||
}
|
||||
resource_dictionary["zulu_11_37_17"] = {
|
||||
"url": "https://mirror.bazel.build/openjdk/azul-zulu11.37.17-ca-jdk11.0.6/zulu11.37.17-ca-jdk11.0.6-linux_x64.tar.gz",
|
||||
"sha256": "360626cc19063bc411bfed2914301b908a8f77a7919aaea007a977fa8fb3cde1",
|
||||
"when": "@4",
|
||||
}
|
||||
for resource_name in resource_dictionary.keys():
|
||||
resource(
|
||||
when=resource_dictionary[resource_name]["when"],
|
||||
name=resource_name,
|
||||
url=resource_dictionary[resource_name]["url"],
|
||||
sha256=resource_dictionary[resource_name]["sha256"],
|
||||
destination="archive",
|
||||
expand=False,
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def determine_version(cls, exe):
|
||||
output = Executable(exe)("version", output=str, error=str)
|
||||
@ -132,14 +167,24 @@ def setup_build_environment(self, env):
|
||||
env.set("BAZEL_LINKOPTS", "")
|
||||
env.set("BAZEL_LINKLIBS", "-lstdc++")
|
||||
|
||||
env.set(
|
||||
"EXTRA_BAZEL_ARGS",
|
||||
# Spack's logs don't handle colored output well
|
||||
"--color=no --host_javabase=@local_jdk//:jdk"
|
||||
# Enable verbose output for failures
|
||||
" --verbose_failures --jobs={0}".format(make_jobs),
|
||||
# .WARNING: Option 'host_javabase' is deprecated
|
||||
# Use local java installation
|
||||
args = "--color=no --define=ABSOLUTE_JAVABASE={0} --verbose_failures --jobs={1}".format(
|
||||
self.spec["java"].prefix, make_jobs
|
||||
)
|
||||
|
||||
resource_stages = self.stage[1:]
|
||||
for _resource in resource_stages:
|
||||
try:
|
||||
resource_name = _resource.resource.name
|
||||
if self.spec.satisfies(self.resource_dictionary[resource_name]["when"]):
|
||||
archive_path = _resource.source_path
|
||||
args += " --distdir={0}".format(archive_path)
|
||||
except AttributeError:
|
||||
continue
|
||||
|
||||
env.set("EXTRA_BAZEL_ARGS", args)
|
||||
|
||||
@run_before("install")
|
||||
def bootstrap(self):
|
||||
bash = which("bash")
|
||||
|
Loading…
Reference in New Issue
Block a user