testing/bazel5: new aport

This commit is contained in:
Wolf 2022-07-20 02:02:11 +02:00 committed by psykose
parent 6b7a0855b0
commit ab4d30bbfd
5 changed files with 242 additions and 0 deletions

View File

@ -0,0 +1,35 @@
From ace6bb4b6fa0ff09d38bd31c26c21dd81aaadca6 Mon Sep 17 00:00:00 2001
From: Wolf <wolf@wolfsden.cz>
Date: Wed, 20 Jul 2022 02:00:52 +0200
Subject: [PATCH 1/4] Do not use prebuilt binaries
Prebuilt binaries (ijar, singlejar) for linux are glibc specific,
meaning they do not work on alpine. Change the select to use _cc_binary
version instead.
---
tools/jdk/BUILD.tools | 2 --
1 file changed, 2 deletions(-)
diff --git a/tools/jdk/BUILD.tools b/tools/jdk/BUILD.tools
index ad3e61e41a..7586fc22de 100644
--- a/tools/jdk/BUILD.tools
+++ b/tools/jdk/BUILD.tools
@@ -168,7 +168,6 @@ alias(
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",
@@ -198,7 +197,6 @@ alias(
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",
--
2.36.2

View File

@ -0,0 +1,75 @@
From 75a294bc20878ece2b45359a9c06db644744112f Mon Sep 17 00:00:00 2001
From: Wolf <wolf@wolfsden.cz>
Date: Wed, 20 Jul 2022 02:00:52 +0200
Subject: [PATCH 2/4] Prefer local_jdk instead of remote_jdk11
---
.../devtools/build/lib/rules/java/JavaOptions.java | 2 +-
tools/jdk/BUILD.tools | 2 +-
tools/jdk/default_java_toolchain.bzl | 10 +++++-----
3 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/JavaOptions.java b/src/main/java/com/google/devtools/build/lib/rules/java/JavaOptions.java
index 7794ef22c1..693f640131 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/java/JavaOptions.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/java/JavaOptions.java
@@ -511,7 +511,7 @@ public class JavaOptions extends FragmentOptions {
@Option(
name = "tool_java_runtime_version",
- defaultValue = "remotejdk_11",
+ defaultValue = "local_jdk",
documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
effectTags = {OptionEffectTag.UNKNOWN},
help = "The Java runtime version used to execute tools during the build")
diff --git a/tools/jdk/BUILD.tools b/tools/jdk/BUILD.tools
index 7586fc22de..8edd0f9619 100644
--- a/tools/jdk/BUILD.tools
+++ b/tools/jdk/BUILD.tools
@@ -328,7 +328,7 @@ alias(
alias(
name = "host_jdk",
- actual = ":remote_jdk11",
+ actual = "@local_jdk//:jdk",
)
bootclasspath(
diff --git a/tools/jdk/default_java_toolchain.bzl b/tools/jdk/default_java_toolchain.bzl
index af3a646a44..da137ed26d 100644
--- a/tools/jdk/default_java_toolchain.bzl
+++ b/tools/jdk/default_java_toolchain.bzl
@@ -98,7 +98,7 @@ DEFAULT_TOOLCHAIN_CONFIGURATION = dict(
"@remote_java_tools//:java_compiler_jar",
"@remote_java_tools//:jdk_compiler_jar",
],
- java_runtime = "@bazel_tools//tools/jdk:remote_jdk11",
+ java_runtime = "@local_jdk//:jdk",
)
# The 'vanilla' toolchain is an unsupported alternative to the default.
@@ -137,9 +137,9 @@ PREBUILT_TOOLCHAIN_CONFIGURATION = dict(
"@remote_java_tools//:java_compiler_jar",
"@remote_java_tools//:jdk_compiler_jar",
],
- ijar = ["@bazel_tools//tools/jdk:ijar_prebuilt_binary"],
- singlejar = ["@bazel_tools//tools/jdk:prebuilt_singlejar"],
- java_runtime = "@bazel_tools//tools/jdk:remote_jdk11",
+ ijar = ["@remote_java_tools//:ijar_cc_binary"],
+ singlejar = ["@remote_java_tools//:singlejar_cc_bin"],
+ java_runtime = "@local_jdk//:jdk",
)
# The new toolchain is using all the tools from sources.
@@ -158,7 +158,7 @@ NONPREBUILT_TOOLCHAIN_CONFIGURATION = dict(
],
ijar = ["@remote_java_tools//:ijar_cc_binary"],
singlejar = ["@remote_java_tools//:singlejar_cc_bin"],
- java_runtime = "@bazel_tools//tools/jdk:remote_jdk11",
+ java_runtime = "@local_jdk//:jdk",
)
def default_java_toolchain(name, configuration = DEFAULT_TOOLCHAIN_CONFIGURATION, toolchain_definition = True, **kwargs):
--
2.36.2

View File

@ -0,0 +1,28 @@
From a4491ac9103c6e02631fce120594e5797130271d Mon Sep 17 00:00:00 2001
From: Wolf <wolf@wolfsden.cz>
Date: Wed, 20 Jul 2022 02:00:53 +0200
Subject: [PATCH 3/4] Make generate_bash_completion compatible with busybox
Under busybox, expr does not accept -- (since it is not defined to take
any options, I would say it makes sense), so remove it from the script
generating bash completion.
---
scripts/generate_bash_completion.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/generate_bash_completion.sh b/scripts/generate_bash_completion.sh
index 778810570c..46a3965f85 100755
--- a/scripts/generate_bash_completion.sh
+++ b/scripts/generate_bash_completion.sh
@@ -34,7 +34,7 @@ die() {
}
get_optarg() {
- expr -- "${1}" : "[^=]*=\\(.*\\)"
+ expr "${1}" : "[^=]*=\\(.*\\)"
}
append=
--
2.36.2

View File

@ -0,0 +1,34 @@
From d958b7c41d5e26ba2fb1382d8ede2de61f87e292 Mon Sep 17 00:00:00 2001
From: Wolf <wolf@wolfsden.cz>
Date: Wed, 20 Jul 2022 02:00:53 +0200
Subject: [PATCH 4/4] Use nojdk bazel for generating the bash completion
---
scripts/BUILD | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/scripts/BUILD b/scripts/BUILD
index c477439950..7fc19a58e0 100644
--- a/scripts/BUILD
+++ b/scripts/BUILD
@@ -12,7 +12,7 @@ genrule(
outs = ["bazel-complete.bash"],
cmd = " ".join([
"$(location :generate_bash_completion.sh)",
- "--bazel=$(location //src:bazel)",
+ "--bazel=$(location //src:bazel_nojdk)",
"--output=$@",
"--prepend=$(location bazel-complete-header.bash)",
"--prepend=$(location bazel-complete-template.bash)",
@@ -20,7 +20,7 @@ genrule(
output_to_bindir = 1,
tools = [
":generate_bash_completion.sh",
- "//src:bazel",
+ "//src:bazel_nojdk",
],
visibility = ["//scripts/packages:__subpackages__"],
)
--
2.36.2

70
testing/bazel5/APKBUILD Normal file
View File

@ -0,0 +1,70 @@
# Maintainer: Gray Wolf <wolf@wolfsden.cz>
pkgname=bazel5
pkgver=5.3.1
pkgrel=0
pkgdesc="Bazel is an open-source build and test tool"
url="https://bazel.build/"
# 1. Copy arch line from openjdk11, since we depend on it
# 2. aarch64, ppc64le times out in CI, 1h is not enough
arch="all !x86 !armhf !armv7 !riscv64 !s390x !aarch64 !ppc64le"
license="Apache-2.0"
depends="bash openjdk11-jdk"
makedepends="linux-headers python3 unzip zip"
# Bazel binary is thin C++ client with zip file embedded into the binary,
# stripping breaks that: https://github.com/bazelbuild/bazel/issues/11842
options="!strip"
provides="bazel=$pkgver-r$pkgrel"
subpackages="$pkgname-bash-completion"
source="
https://github.com/bazelbuild/bazel/releases/download/$pkgver/bazel-$pkgver-dist.zip
0001-Do-not-use-prebuilt-binaries.patch
0002-Prefer-local_jdk-instead-of-remote_jdk11.patch
0003-Make-generate_bash_completion-compatible-with-busybo.patch
0004-Use-nojdk-bazel-for-generating-the-bash-completion.patch
"
builddir="$srcdir/"
build() {
EMBED_LABEL=$pkgver-$pkgrel \
EXTRA_BAZEL_ARGS=--tool_java_runtime_version=local_jdk \
./compile.sh
./output/bazel build //scripts:bazel-complete.bash
cp bazel-bin/scripts/bazel-complete.bash output/
./output/bazel clean --expunge
}
check() {
# shellcheck disable=SC2046
./output/bazel build $(\
./output/bazel query --noshow_progress '//examples/...' \
| grep -vF \
-e /android/ \
-e /windows/ \
-e :hello-error-prone \
)
./output/bazel test \
//examples/cpp:hello-success_test \
//examples/java-native/src/test/java/com/example/myproject:custom \
//examples/java-native/src/test/java/com/example/myproject:hello \
//examples/java-starlark/src/test/java/com/example/myproject:pass \
//examples/py_native:test \
//examples/shell:test
./output/bazel clean --expunge
}
package() {
install -Dm 755 -t "$pkgdir/usr/bin" output/bazel
install -Dm 644 output/bazel-complete.bash \
"$pkgdir/usr/share/bash-completion/completions/bazel"
}
sha512sums="
fc226fd3cc8389f311e881151a59f0b88d6d8b69619d4fc72f684c0be539269d59511fc2796ffaab3ec8b1d8f67848058fbe18a5c7ebdd3f83c4cb0a0182e664 bazel-5.3.1-dist.zip
5b7709629f1f4a4604abbf626c17b0a83f3ddcb8e71a05d253eb592e1006027d693d58d67d35deb941ed1e0e60fa8d1f3229b59f844fa7e3eca866cafc2354f2 0001-Do-not-use-prebuilt-binaries.patch
b5b6aeb5d8b097bd6f58d441f801dce9b3f2ed7706623d0c8650582a421509e4c843b6e298affeb3256dded4f706a56502847b391ec666ac882362d34529ad25 0002-Prefer-local_jdk-instead-of-remote_jdk11.patch
a422b45f90733157c14f3c4c54a88acd1ad49053b043a90a37c67e6d5342acb9685c467c642c232fc5cc6c80ec35a8187284da06d36e8084f0583e86e73a9130 0003-Make-generate_bash_completion-compatible-with-busybo.patch
fb51b7caf1b05c3f531bbbbdb4fe76666c07f423d66ab0826a0590f09b71e67197d46a36c307d1690845f8055c523c27f00a21e890b7457b402d68ba1a12b085 0004-Use-nojdk-bazel-for-generating-the-bash-completion.patch
"