From ede7476726d5f8ec86bceef09685483544fe2aa7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?= Date: Tue, 24 Jun 2025 13:51:52 +0700 Subject: [PATCH] New package: bazel-8.2.1 --- srcpkgs/bazel/patches/gettid.patch | 29 ++++++++++++ srcpkgs/bazel/patches/java.patch | 12 +++++ srcpkgs/bazel/patches/musl.patch | 48 ++++++++++++++++++++ srcpkgs/bazel/patches/no-jdk.patch | 57 +++++++++++++++++++++++ srcpkgs/bazel/template | 72 ++++++++++++++++++++++++++++++ 5 files changed, 218 insertions(+) create mode 100644 srcpkgs/bazel/patches/gettid.patch create mode 100644 srcpkgs/bazel/patches/java.patch create mode 100644 srcpkgs/bazel/patches/musl.patch create mode 100644 srcpkgs/bazel/patches/no-jdk.patch create mode 100644 srcpkgs/bazel/template diff --git a/srcpkgs/bazel/patches/gettid.patch b/srcpkgs/bazel/patches/gettid.patch new file mode 100644 index 00000000000..a680d831a54 --- /dev/null +++ b/srcpkgs/bazel/patches/gettid.patch @@ -0,0 +1,29 @@ +--- a/src/main/java/net/starlark/java/eval/cpu_profiler_posix.cc ++++ b/src/main/java/net/starlark/java/eval/cpu_profiler_posix.cc +@@ -41,7 +41,7 @@ Java_net_starlark_java_eval_CpuProfiler_ + + static int fd; // the write end of the profile event pipe + +-pid_t gettid(void) { ++pid_t sys_gettid(void) { + #ifdef __linux__ + return (pid_t)syscall(SYS_gettid); + #else // darwin +@@ -63,7 +63,7 @@ void onsigprof(int sig) { + } + + // Send an event containing the int32be-encoded OS thread ID. +- pid_t tid = gettid(); ++ pid_t tid = sys_gettid(); + uint32_t tid_be = htonl(tid); + int r = write(fd, (void *)&tid_be, sizeof tid_be); + if (r < 0) { +@@ -100,7 +100,7 @@ void onsigprof(int sig) { + // static native jint gettid(); + extern "C" JNIEXPORT jint JNICALL + Java_net_starlark_java_eval_CpuProfiler_gettid(JNIEnv *env, jclass clazz) { +- return gettid(); ++ return sys_gettid(); + } + + // makeFD: return new FileDescriptor(fd) diff --git a/srcpkgs/bazel/patches/java.patch b/srcpkgs/bazel/patches/java.patch new file mode 100644 index 00000000000..d61e60082e6 --- /dev/null +++ b/srcpkgs/bazel/patches/java.patch @@ -0,0 +1,12 @@ +--- a/scripts/packages/bazel.sh ++++ b/scripts/packages/bazel.sh +@@ -104,7 +104,8 @@ function get_workspace_root() { + + get_workspace_root + +-readonly wrapper_dir="$(dirname "$(get_realpath "${BASH_SOURCE[0]}")")" ++export JAVA_HOME=/usr/lib/jvm/openjdk21 ++readonly wrapper_dir="/usr/libexec/bazel" + readonly os_arch_suffix="$(uname -s | tr '[:upper:]' '[:lower:]')-$(uname -m)" + + function get_bazel_version() { diff --git a/srcpkgs/bazel/patches/musl.patch b/srcpkgs/bazel/patches/musl.patch new file mode 100644 index 00000000000..4089fd22cd9 --- /dev/null +++ b/srcpkgs/bazel/patches/musl.patch @@ -0,0 +1,48 @@ +--- a/src/main/native/unix_jni.h ++++ b/src/main/native/unix_jni.h +@@ -26,7 +26,8 @@ + + namespace blaze_jni { + +-#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) ++#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) || \ ++ (defined(__linux__) && !defined(__GLIBC__)) + // stat64 is deprecated on OS X/BSD. + typedef struct stat portable_stat_struct; + #define portable_stat ::stat +--- a/src/main/native/unix_jni_linux.cc ++++ b/src/main/native/unix_jni_linux.cc +@@ -12,6 +12,7 @@ + // See the License for the specific language governing permissions and + // limitations under the License. + ++#include + #include + #include + #include +@@ -45,7 +46,11 @@ std::string ErrorMessage(int error_numbe + + int portable_fstatat( + int dirfd, char *name, portable_stat_struct *statbuf, int flags) { ++#ifdef __GLIBC__ + return fstatat64(dirfd, name, statbuf, flags); ++#else ++ return fstatat(dirfd, name, statbuf, flags); ++#endif + } + + uint64_t StatEpochMilliseconds(const portable_stat_struct &statbuf, +--- a/src/tools/singlejar/port.h ++++ b/src/tools/singlejar/port.h +@@ -34,6 +34,11 @@ typedef off_t off64_t; + typedef __int64 off64_t; + #elif defined(__OpenBSD__) + typedef int64_t off64_t; ++#elif defined(__linux__) ++#include ++#ifndef __GLIBC__ ++typedef off_t off64_t; ++#endif + #endif + static_assert(sizeof(off64_t) == 8, "File offset type must be 64-bit"); + diff --git a/srcpkgs/bazel/patches/no-jdk.patch b/srcpkgs/bazel/patches/no-jdk.patch new file mode 100644 index 00000000000..5ec5c62f094 --- /dev/null +++ b/srcpkgs/bazel/patches/no-jdk.patch @@ -0,0 +1,57 @@ +--- a/.bazelrc ++++ b/.bazelrc +@@ -94,3 +94,5 @@ test:ci-windows --test_env=JAVA_HOME + test:ci-windows --test_env=TEST_INSTALL_BASE=C:/b/bazeltest_install_base + test:ci-windows --test_env=REPOSITORY_CACHE=C:/b/bazeltest_repo_cache + test:ci-windows --test_tag_filters=-no_windows,-slow ++ ++common --extra_toolchains=//xbps_src:non_prebuilt_java_21_toolchain_definition +--- 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__", +@@ -105,12 +105,12 @@ genrule( + outs = ["bazel.fish"], + cmd = " ".join([ + "$(location :generate_fish_completion)", +- "--bazel=$(location //src:bazel)", ++ "--bazel=$(location //src:bazel_nojdk)", + "--output=$@", + ]), + tools = [ + ":generate_fish_completion", +- "//src:bazel", ++ "//src:bazel_nojdk", + ], + visibility = ["//scripts/packages:__subpackages__"], + ) +--- /dev/null ++++ b/xbps_src/BUILD.bazel +@@ -0,0 +1,11 @@ ++load("@rules_java//toolchains:default_java_toolchain.bzl", "default_java_toolchain") ++ ++default_java_toolchain( ++ name = "non_prebuilt_java_21_toolchain", ++ header_compiler_direct = "@remote_java_tools//:TurbineDirect", ++ ijar = "//third_party/ijar:ijar", ++ java_runtime = "@local_jdk//:jdk", ++ singlejar = "//src/tools/singlejar:singlejar", ++ source_version = "21", ++ target_version = "21", ++) diff --git a/srcpkgs/bazel/template b/srcpkgs/bazel/template new file mode 100644 index 00000000000..5eca737f937 --- /dev/null +++ b/srcpkgs/bazel/template @@ -0,0 +1,72 @@ +# Template file for 'bazel' +pkgname=bazel +version=8.2.1 +revision=1 +hostmakedepends="protobuf python3 unzip openjdk21 which perl grpc zip tar" +makedepends="protobuf-devel libprotoc-devel grpc-devel libarchive-devel + zlib-devel" +depends="openjdk21" +short_desc="Google's build system" +maintainer="Đoàn Trần Công Danh " +license="Apache-2.0" +homepage="https://bazel.build/" +distfiles="https://github.com/bazelbuild/bazel/releases/download/${version}/bazel-${version}-dist.zip" +checksum="b12b95cc02cc5ee19ff7a6a7f71f9496631f937c8e13a8f53ee0ff7b7700bc16" +nostrip=yes +python_version=3 + +nocross=yes + +case "$XBPS_TARGET_MACHINE" in + aarch64*) _cpu=aarch64 ;; + armv7*) _cpu=armv7 ;; + arm*) _cpu=arm ;; + x86_64*) _cpu=x86_64 ;; + i686*) _cpu=i386 ;; + ppc64le*) _cpu=ppc64le ;; + ppc64*) _cpu=ppc ;; + ppc*) _cpu=ppc32 ;; + riscv64*) _cpu=riscv64 ;; + *) broken="not supported" ;; +esac + +do_build() { + local flag + local _bazel_opts="-s --verbose_failures" + for flag in $CFLAGS; do + _bazel_opts+=" --conlyopt=$flag" + # For -fstack-protector ... + _bazel_opts+=" --linkopt=$flag" + done + for flag in $CXXFLAGS; do + _bazel_opts+=" --cxxopt=$flag" + _bazel_opts+=" --linkopt=$flag" + done + for flag in $LDFLAGS; do + _bazel_opts+=" --linkopt=$flag" + done + + _bazel_opts+=" --java_runtime_version=local_jdk" + _bazel_opts+=" --tool_java_runtime_version=local_jdk" + + export JAVA_HOME="/usr/lib/jvm/openjdk21" + + EMBED_LABEL=${version} \ + EXTRA_BAZEL_ARGS="$_bazel_opts" \ + ./compile.sh + ./output/bazel build //scripts:bash_completion + ./output/bazel build //scripts:fish_completion + ./output/bazel shutdown + + cp bazel-bin/scripts/bazel-complete.bash output/ + cp bazel-bin/scripts/bazel.fish output/ + cp scripts/zsh_completion/_bazel output/ + chmod -R u+rwX /tmp +} + +do_install() { + vbin output/bazel + vcompletion output/bazel-complete.bash bash + vcompletion output/bazel.fish fish + vcompletion output/_bazel zsh +}