Date: Sun, 05 Apr 2026 05:30:24 +0000 From: Xin LI <delphij@FreeBSD.org> To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org Subject: git: 0130386c6903 - main - devel/bazel9: Add new port for Bazel 9 LTS. Message-ID: <69d1f370.2025e.5e9b1844@gitrepo.freebsd.org>
index | next in thread | raw e-mail
The branch main has been updated by delphij: URL: https://cgit.FreeBSD.org/ports/commit/?id=0130386c6903257df345990069a5aa8edcb0a848 commit 0130386c6903257df345990069a5aa8edcb0a848 Author: Xin LI <delphij@FreeBSD.org> AuthorDate: 2026-04-05 05:29:56 +0000 Commit: Xin LI <delphij@FreeBSD.org> CommitDate: 2026-04-05 05:29:56 +0000 devel/bazel9: Add new port for Bazel 9 LTS. --- devel/Makefile | 1 + devel/bazel9/Makefile | 89 ++++++++++++++++++++++ devel/bazel9/distinfo | 3 + devel/bazel9/files/patch-MODULE.bazel | 15 ++++ .../files/patch-scripts_bootstrap_buildenv.sh | 11 +++ .../files/patch-src_main_cpp_blaze__util__bsd.cc | 11 +++ .../bazel9/files/patch-src_tools_singlejar_port.h | 14 ++++ ...llowlists_function__transition__allowlist_BUILD | 14 ++++ ...ch-tools_python_python__bootstrap__template.txt | 11 +++ devel/bazel9/files/rules_python_freebsd.patch.in | 12 +++ devel/bazel9/files/toolchain_local-BUILD | 43 +++++++++++ devel/bazel9/pkg-descr | 5 ++ devel/bazel9/pkg-plist | 2 + 13 files changed, 231 insertions(+) diff --git a/devel/Makefile b/devel/Makefile index ff9cfb1077f8..c1334af1a9d1 100644 --- a/devel/Makefile +++ b/devel/Makefile @@ -301,6 +301,7 @@ SUBDIR += bazel5 SUBDIR += bazel7 SUBDIR += bazel8 + SUBDIR += bazel9 SUBDIR += bbparse SUBDIR += bcc SUBDIR += bcpp diff --git a/devel/bazel9/Makefile b/devel/bazel9/Makefile new file mode 100644 index 000000000000..665e767b8406 --- /dev/null +++ b/devel/bazel9/Makefile @@ -0,0 +1,89 @@ +PORTNAME= bazel +DISTVERSION= 9.0.1 +CATEGORIES= devel java +MASTER_SITES= https://github.com/bazelbuild/${PORTNAME}/releases/download/${DISTVERSION}/ +PKGNAMESUFFIX= 9 +DISTNAME= bazel-${DISTVERSION}-dist + +MAINTAINER= delphij@FreeBSD.org +COMMENT= Fast and correct build system (LTS 9) +WWW= https://bazel.build/ + +LICENSE= APACHE20 +LICENSE_FILE= ${WRKSRC}/LICENSE + +NOT_FOR_ARCHS= i386 + +BUILD_DEPENDS= bash:shells/bash \ + zip:archivers/zip + +USES= cpe java python shebangfix zip +CPE_VENDOR= google +JAVA_VERSION= 21+ +JAVA_VENDOR= openjdk + +SHEBANG_REGEX= .*(sh|txt|_stub|stub_.*|bazel|get_workspace_status|protobuf_support|_so) + +CONFLICTS_INSTALL= bazel[0-9]* + +# The bazel binary is also a zip archive (extracted by the elf part), it must not be stripped +STRIP= + +NO_WRKSUBDIR= YES + +.include <bsd.port.pre.mk> + +.if ${ARCH} == "aarch64" +BAZEL_JAVAC_OPTS+= "-J-Xmx1g -J-Xms128m" +.endif + +# Have the location of the system-wide rc file reside ${ETCDIR}. +# Also adapt the sample file to disable persistent java workers as they +# do not work reliably on FreeBSD. +post-patch: + @${REINPLACE_CMD} -e "s|/etc/bazel.bazelrc|${ETCDIR}/bazel.bazelrc|" \ + ${WRKSRC}/src/main/cpp/BUILD + @${ECHO_CMD} build --strategy=Javac=standalone >> ${WRKSRC}/scripts/packages/bazel.bazelrc + @${ECHO_CMD} build --java_runtime_version=${JAVA_PORT_VERSION} >> ${WRKSRC}/scripts/packages/bazel.bazelrc + @${ECHO_CMD} build --tool_java_runtime_version=${JAVA_PORT_VERSION} >> ${WRKSRC}/scripts/packages/bazel.bazelrc + @${ECHO_CMD} build --action_env=PATH=/bin:/usr/bin/:${LOCALBASE}/bin >> ${WRKSRC}/scripts/packages/bazel.bazelrc + @${REINPLACE_CMD} \ + -e 's|^\(PYTHON_BIN=.*\)|if [ "%VERSION%" = "3" ] ; then PYTHON_BIN=${PYTHON_CMD}; else \1 ; fi|' \ + ${WRKSRC}/tools/python/pywrapper_template.txt + @${REINPLACE_CMD} -e 's|%%PREFIX%%|${PREFIX}|' \ + ${WRKSRC}/tools/python/python_bootstrap_template.txt + @${REINPLACE_CMD} -e 's|%%JAVA_HOME%%|${JAVA_HOME}|' \ + ${WRKSRC}/src/main/cpp/blaze_util_bsd.cc + @${MKDIR} ${WRKSRC}/toolchain_local + @${CP} ${FILESDIR}/toolchain_local-BUILD ${WRKSRC}/toolchain_local/BUILD + @${CP} ${FILESDIR}/rules_python_freebsd.patch.in \ + ${WRKSRC}/toolchain_local/rules_python_freebsd.patch + @${REINPLACE_CMD} -e 's|%%PYTHON_CMD%%|${PYTHON_CMD}|' \ + ${WRKSRC}/toolchain_local/BUILD \ + ${WRKSRC}/toolchain_local/rules_python_freebsd.patch + +do-build: + @${MKDIR} ${WRKDIR}/bazel_tmp + (if [ -z "$${SOURCE_DATE_EPOCH}" ] ; \ + then SOURCE_DATE_EPOCH=`grep TIMESTAMP ${DISTINFO_FILE} \ + | ${SED} -e 's/[^0-9]//g'`; \ + fi ; \ + cd ${WRKSRC} && \ + ${SETENV} BAZEL_SH=${LOCALBASE}/bin/bash \ + JAVA_HOME=${JAVA_HOME} \ + JAVA_VERSION=${JAVA_PORT_VERSION} \ + TMPDIR=${WRKDIR}/bazel_tmp \ + EMBED_LABEL='${PORTVERSION}' \ + BAZEL_DEV_VERSION_OVERRIDE='${PORTVERSION}' \ + PATH=${LOCALBASE}/bin:$$PATH \ + SOURCE_DATE_EPOCH=$${SOURCE_DATE_EPOCH} \ + BAZEL_JAVAC_OPTS=${BAZEL_JAVAC_OPTS} \ + EXTRA_BAZEL_ARGS='--host_javabase=@local_jdk//:jdk --tool_java_runtime_version=local_jdk --java_language_version=${JAVA_PORT_VERSION} --tool_java_language_version=${JAVA_PORT_VERSION} --extra_toolchains=//toolchain_local:freebsd_python3_toolchain,//toolchain_local:local_jdk_21_runtime,//toolchain_local:local_jdk_21_bootstrap --action_env=PATH=${LOCALBASE}/bin:/bin:/usr/bin:/sbin:/usr/sbin --host_linkopt=-lm --linkopt=-lm' \ + ${LOCALBASE}/bin/bash ./compile.sh) + +do-install: + ${INSTALL_PROGRAM} ${WRKSRC}/output/bazel ${STAGEDIR}${PREFIX}/bin + @${MKDIR} ${STAGEDIR}${ETCDIR} + ${INSTALL_DATA} ${WRKSRC}/scripts/packages/bazel.bazelrc ${STAGEDIR}${ETCDIR}/bazel.bazelrc.sample + +.include <bsd.port.post.mk> diff --git a/devel/bazel9/distinfo b/devel/bazel9/distinfo new file mode 100644 index 000000000000..24348a21f74b --- /dev/null +++ b/devel/bazel9/distinfo @@ -0,0 +1,3 @@ +TIMESTAMP = 1773193153 +SHA256 (bazel-9.0.1-dist.zip) = 3f336b4510a8210f954fa3a7d6cfbd271b6f9d639732fdc11c000b6fbfca3fbe +SIZE (bazel-9.0.1-dist.zip) = 221129348 diff --git a/devel/bazel9/files/patch-MODULE.bazel b/devel/bazel9/files/patch-MODULE.bazel new file mode 100644 index 000000000000..e6d209272b4a --- /dev/null +++ b/devel/bazel9/files/patch-MODULE.bazel @@ -0,0 +1,15 @@ +--- MODULE.bazel.orig 2026-04-05 02:28:47 UTC ++++ MODULE.bazel +@@ -132,6 +132,12 @@ local_path_override( + path = "./third_party/remoteapis", + ) + ++single_version_override( ++ module_name = "rules_python", ++ patch_strip = 1, ++ patches = ["//toolchain_local:rules_python_freebsd.patch"], ++) ++ + # ========================================= + # Java dependencies + # ========================================= diff --git a/devel/bazel9/files/patch-scripts_bootstrap_buildenv.sh b/devel/bazel9/files/patch-scripts_bootstrap_buildenv.sh new file mode 100644 index 000000000000..e7dbf357e0f4 --- /dev/null +++ b/devel/bazel9/files/patch-scripts_bootstrap_buildenv.sh @@ -0,0 +1,11 @@ +--- scripts/bootstrap/buildenv.sh.orig 2020-10-07 21:26:37 UTC ++++ scripts/bootstrap/buildenv.sh +@@ -230,7 +230,7 @@ function clear_log() { + rm -f ${phasefile} + } + +-LEAVES="\xF0\x9F\x8D\x83" ++LEAVES="[LEAVES]" + INFO="\033[32mINFO\033[0m:" + WARNING="\033[31mWARN\033[0m:" + diff --git a/devel/bazel9/files/patch-src_main_cpp_blaze__util__bsd.cc b/devel/bazel9/files/patch-src_main_cpp_blaze__util__bsd.cc new file mode 100644 index 000000000000..a7998bdb06b9 --- /dev/null +++ b/devel/bazel9/files/patch-src_main_cpp_blaze__util__bsd.cc @@ -0,0 +1,11 @@ +--- src/main/cpp/blaze_util_bsd.cc.orig 1980-01-01 08:00:00 UTC ++++ src/main/cpp/blaze_util_bsd.cc +@@ -14,7 +14,7 @@ + + #if defined(__FreeBSD__) + # define HAVE_PROCSTAT +-# define STANDARD_JAVABASE "/usr/local/openjdk8" ++# define STANDARD_JAVABASE "%%JAVA_HOME%%" + #elif defined(__OpenBSD__) + # define STANDARD_JAVABASE "/usr/local/jdk-17" + #else diff --git a/devel/bazel9/files/patch-src_tools_singlejar_port.h b/devel/bazel9/files/patch-src_tools_singlejar_port.h new file mode 100644 index 000000000000..92fd5f40f22b --- /dev/null +++ b/devel/bazel9/files/patch-src_tools_singlejar_port.h @@ -0,0 +1,14 @@ +--- src/tools/singlejar/port.h.orig 1979-12-31 23:00:00 UTC ++++ src/tools/singlejar/port.h +@@ -28,6 +28,11 @@ + #include <sys/types.h> + #include <time.h> + ++#ifndef _OFF64_T_DECLARED ++typedef off_t off64_t; ++#define _OFF64_T_DECLARED ++#endif ++ + #if defined(__APPLE__) + typedef off_t off64_t; + #elif defined(_WIN32) diff --git a/devel/bazel9/files/patch-tools_allowlists_function__transition__allowlist_BUILD b/devel/bazel9/files/patch-tools_allowlists_function__transition__allowlist_BUILD new file mode 100644 index 000000000000..8ebce3d8f6d7 --- /dev/null +++ b/devel/bazel9/files/patch-tools_allowlists_function__transition__allowlist_BUILD @@ -0,0 +1,14 @@ +--- tools/allowlists/function_transition_allowlist/BUILD.orig 1980-01-01 00:00:00 UTC ++++ tools/allowlists/function_transition_allowlist/BUILD +@@ -1,6 +1,11 @@ + # Description: + # Package group restricting access to starlark-defined transitions + ++package_group( ++ name = "function_transition_allowlist", ++ packages = ["public"], ++) ++ + filegroup( + name = "srcs", + srcs = glob(["**"]), diff --git a/devel/bazel9/files/patch-tools_python_python__bootstrap__template.txt b/devel/bazel9/files/patch-tools_python_python__bootstrap__template.txt new file mode 100644 index 000000000000..9c1875289cb5 --- /dev/null +++ b/devel/bazel9/files/patch-tools_python_python__bootstrap__template.txt @@ -0,0 +1,11 @@ +--- tools/python/python_bootstrap_template.txt.orig 2026-04-04 05:35:35 UTC ++++ tools/python/python_bootstrap_template.txt +@@ -76,7 +76,7 @@ def SearchPath(name): + + def SearchPath(name): + """Finds a file in a given search path.""" +- search_path = os.getenv('PATH', os.defpath).split(os.pathsep) ++ search_path = os.getenv('PATH', os.defpath + ":%%PREFIX%%/bin").split(os.pathsep) + for directory in search_path: + if directory: + path = os.path.join(directory, name) diff --git a/devel/bazel9/files/rules_python_freebsd.patch.in b/devel/bazel9/files/rules_python_freebsd.patch.in new file mode 100644 index 000000000000..68c9402a3006 --- /dev/null +++ b/devel/bazel9/files/rules_python_freebsd.patch.in @@ -0,0 +1,12 @@ +--- a/python/private/py_executable.bzl ++++ b/python/private/py_executable.bzl +@@ -903,8 +903,8 @@ + is_for_zip = True, + venv = venv, + ) + else: +- ctx.actions.write(prelude, "#!/usr/bin/env python3\n") ++ ctx.actions.write(prelude, "#!%%PYTHON_CMD%%\n") + + ctx.actions.run_shell( + command = "cat {prelude} {zip} > {output}".format( diff --git a/devel/bazel9/files/toolchain_local-BUILD b/devel/bazel9/files/toolchain_local-BUILD new file mode 100644 index 000000000000..e03f8e6e66ea --- /dev/null +++ b/devel/bazel9/files/toolchain_local-BUILD @@ -0,0 +1,43 @@ +load("@rules_python//python:py_runtime.bzl", "py_runtime") +load("@rules_python//python:py_runtime_pair.bzl", "py_runtime_pair") + +package(default_visibility = ["//visibility:public"]) + +exports_files(["rules_python_freebsd.patch"]) + +config_setting( + name = "remotejdk_21_setting", + values = {"java_runtime_version": "remotejdk_21"}, +) + +toolchain( + name = "local_jdk_21_runtime", + target_settings = [":remotejdk_21_setting"], + toolchain_type = "@bazel_tools//tools/jdk:runtime_toolchain_type", + toolchain = "@local_jdk//:jdk", +) + +toolchain( + name = "local_jdk_21_bootstrap", + target_settings = [":remotejdk_21_setting"], + toolchain_type = "@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type", + toolchain = "@local_jdk//:jdk", +) + +py_runtime( + name = "freebsd_py3_runtime", + interpreter_path = "%%PYTHON_CMD%%", + python_version = "PY3", + stub_shebang = "#!%%PYTHON_CMD%%", +) + +py_runtime_pair( + name = "freebsd_py_runtime_pair", + py3_runtime = ":freebsd_py3_runtime", +) + +toolchain( + name = "freebsd_python3_toolchain", + toolchain = ":freebsd_py_runtime_pair", + toolchain_type = "@rules_python//python:toolchain_type", +) diff --git a/devel/bazel9/pkg-descr b/devel/bazel9/pkg-descr new file mode 100644 index 000000000000..0d72f338ae0b --- /dev/null +++ b/devel/bazel9/pkg-descr @@ -0,0 +1,5 @@ +Bazel is Google's open-source build and test tool. +Bazel has built-in support for building both client and server +software, including client applications for both Android and iOS +platforms. It also provides an extensible framework that you can +use to develop your own build rules. diff --git a/devel/bazel9/pkg-plist b/devel/bazel9/pkg-plist new file mode 100644 index 000000000000..d157c119f36f --- /dev/null +++ b/devel/bazel9/pkg-plist @@ -0,0 +1,2 @@ +bin/bazel +@sample %%ETCDIR%%/bazel.bazelrc.samplehome | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?69d1f370.2025e.5e9b1844>
