Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 28 Mar 2026 19:07:42 +0000
From:      Yuri Victorovich <yuri@FreeBSD.org>
To:        ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org
Subject:   git: 886e2a2d1b24 - main - devel/bazel7: New port: Fast and correct build system
Message-ID:  <69c826fe.1bfb6.a61e163@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch main has been updated by yuri:

URL: https://cgit.FreeBSD.org/ports/commit/?id=886e2a2d1b2459c46ee9daeebef525160d893358

commit 886e2a2d1b2459c46ee9daeebef525160d893358
Author:     Yuri Victorovich <yuri@FreeBSD.org>
AuthorDate: 2026-03-28 19:01:35 +0000
Commit:     Yuri Victorovich <yuri@FreeBSD.org>
CommitDate: 2026-03-28 19:07:35 +0000

    devel/bazel7: New port: Fast and correct build system
    
    PR:             294033
---
 devel/Makefile                                     |  1 +
 devel/bazel7/Makefile                              | 83 ++++++++++++++++++++++
 devel/bazel7/distinfo                              |  3 +
 .../files/patch-scripts_bootstrap_BUILD.bootstrap  | 13 ++++
 .../files/patch-scripts_bootstrap_bootstrap.sh     | 11 +++
 .../files/patch-scripts_bootstrap_buildenv.sh      | 11 +++
 .../files/patch-src_main_cpp_blaze_util_bsd.cc     | 11 +++
 .../bazel7/files/patch-src_tools_singlejar_port.h  | 14 ++++
 .../patch-tools_cpp_bsd_cc_toolchain_config.bzl    | 11 +++
 devel/bazel7/pkg-descr                             |  5 ++
 devel/bazel7/pkg-plist                             |  2 +
 11 files changed, 165 insertions(+)

diff --git a/devel/Makefile b/devel/Makefile
index a792940edc0f..774b5d707726 100644
--- a/devel/Makefile
+++ b/devel/Makefile
@@ -299,6 +299,7 @@
     SUBDIR += bazel
     SUBDIR += bazel-buildtools
     SUBDIR += bazel5
+    SUBDIR += bazel7
     SUBDIR += bbparse
     SUBDIR += bcc
     SUBDIR += bcpp
diff --git a/devel/bazel7/Makefile b/devel/bazel7/Makefile
new file mode 100644
index 000000000000..b159d91c0e25
--- /dev/null
+++ b/devel/bazel7/Makefile
@@ -0,0 +1,83 @@
+PORTNAME=	bazel
+DISTVERSION=	7.7.0
+CATEGORIES=	devel java
+MASTER_SITES=	https://github.com/bazelbuild/${PORTNAME}/releases/download/${DISTVERSION}/
+PKGNAMESUFFIX=	7
+DISTNAME=	bazel-${DISTVERSION}-dist
+
+MAINTAINER=	yuri@FreeBSD.org
+COMMENT=	Fast and correct build system
+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
+
+BINARY_ALIAS=	python3=${PYTHON_CMD}
+
+# 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_VERSION} >> ${WRKSRC}/scripts/packages/bazel.bazelrc
+	@${ECHO_CMD} build --tool_java_runtime_version=${JAVA_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|--action_env=PATH \\|--action_env=PATH=${WRKDIR}/.bin:${LOCALBASE}/bin:/usr/bin:/usr/sbin:/bin:/sbin \\|' \
+		${WRKSRC}/compile.sh
+	@${REINPLACE_CMD} -e 's|%%JAVA_HOME%%|${JAVA_HOME}|' \
+		${WRKSRC}/src/main/cpp/blaze_util_bsd.cc
+
+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} \
+	PATH="${PATH}" \
+	BAZEL_SH=${LOCALBASE}/bin/bash \
+	JAVA_HOME=${JAVA_HOME} \
+	JAVA_VERSION=${JAVA_VERSION} \
+	TMPDIR=${WRKDIR}/bazel_tmp \
+	EMBED_LABEL='${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_VERSION}  --tool_java_language_version=${JAVA_VERSION}' \
+	BAZEL_DEV_VERSION_OVERRIDE=${PORTVERSION} \
+	${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/bazel7/distinfo b/devel/bazel7/distinfo
new file mode 100644
index 000000000000..aaf1a11a9bdf
--- /dev/null
+++ b/devel/bazel7/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1774224394
+SHA256 (bazel-7.7.0-dist.zip) = 277946818c77fff70be442864cecc41faac862b6f2d0d37033e2da0b1fee7e0f
+SIZE (bazel-7.7.0-dist.zip) = 257612181
diff --git a/devel/bazel7/files/patch-scripts_bootstrap_BUILD.bootstrap b/devel/bazel7/files/patch-scripts_bootstrap_BUILD.bootstrap
new file mode 100644
index 000000000000..838172fa54b8
--- /dev/null
+++ b/devel/bazel7/files/patch-scripts_bootstrap_BUILD.bootstrap
@@ -0,0 +1,13 @@
+--- scripts/bootstrap/BUILD.bootstrap.orig	1979-12-31 23:00:00 UTC
++++ scripts/bootstrap/BUILD.bootstrap
+@@ -20,8 +20,8 @@ default_java_toolchain(
+         "-XX:TieredStopAtLevel=1",
+     ],
+     singlejar = ["//src/tools/singlejar:singlejar"],
+-    source_version = "8",
++    source_version = "21",
+     tags = ["manual"],
+-    target_version = "8",
++    target_version = "21",
+     visibility = ["//visibility:public"],
+ )
diff --git a/devel/bazel7/files/patch-scripts_bootstrap_bootstrap.sh b/devel/bazel7/files/patch-scripts_bootstrap_bootstrap.sh
new file mode 100644
index 000000000000..76d7ca9ec5d6
--- /dev/null
+++ b/devel/bazel7/files/patch-scripts_bootstrap_bootstrap.sh
@@ -0,0 +1,11 @@
+--- scripts/bootstrap/bootstrap.sh.orig	2020-10-07 21:26:37 UTC
++++ scripts/bootstrap/bootstrap.sh
+@@ -33,7 +33,7 @@ fi
+ 
+ _BAZEL_ARGS="--spawn_strategy=standalone \
+       --nojava_header_compilation \
+-      --strategy=Javac=worker --worker_quit_after_build --ignore_unsupported_sandboxing \
++      --strategy=Javac=standalone --ignore_unsupported_sandboxing --curses=no \
+       --compilation_mode=opt \
+       --distdir=derived/distdir \
+       --java_toolchain=//src/java_tools/buildjar:bootstrap_toolchain \
diff --git a/devel/bazel7/files/patch-scripts_bootstrap_buildenv.sh b/devel/bazel7/files/patch-scripts_bootstrap_buildenv.sh
new file mode 100644
index 000000000000..e7dbf357e0f4
--- /dev/null
+++ b/devel/bazel7/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/bazel7/files/patch-src_main_cpp_blaze_util_bsd.cc b/devel/bazel7/files/patch-src_main_cpp_blaze_util_bsd.cc
new file mode 100644
index 000000000000..2effc8c23604
--- /dev/null
+++ b/devel/bazel7/files/patch-src_main_cpp_blaze_util_bsd.cc
@@ -0,0 +1,11 @@
+--- src/main/cpp/blaze_util_bsd.cc.orig       1979-12-31 23: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-1.8.0"
+ #else
diff --git a/devel/bazel7/files/patch-src_tools_singlejar_port.h b/devel/bazel7/files/patch-src_tools_singlejar_port.h
new file mode 100644
index 000000000000..92fd5f40f22b
--- /dev/null
+++ b/devel/bazel7/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/bazel7/files/patch-tools_cpp_bsd_cc_toolchain_config.bzl b/devel/bazel7/files/patch-tools_cpp_bsd_cc_toolchain_config.bzl
new file mode 100644
index 000000000000..70aa7b2961ac
--- /dev/null
+++ b/devel/bazel7/files/patch-tools_cpp_bsd_cc_toolchain_config.bzl
@@ -0,0 +1,11 @@
+--- tools/cpp/bsd_cc_toolchain_config.bzl-	2025-01-24 22:37:03.813550000 +0000
++++ tools/cpp/bsd_cc_toolchain_config.bzl	2025-01-24 22:37:35.606076000 +0000
+@@ -108,6 +108,8 @@
+                         flags = [
+                             "-no-canonical-prefixes",
+                             "-Wno-builtin-macro-redefined",
++                            "-Wno-gnu-offsetof-extensions",
++                            "-Wno-c23-extensions",
+                             "-D__DATE__=\"redacted\"",
+                             "-D__TIMESTAMP__=\"redacted\"",
+                             "-D__TIME__=\"redacted\"",
diff --git a/devel/bazel7/pkg-descr b/devel/bazel7/pkg-descr
new file mode 100644
index 000000000000..cd7c043b1543
--- /dev/null
+++ b/devel/bazel7/pkg-descr
@@ -0,0 +1,5 @@
+Bazel is Google's build tool, designed for fast, scalable,
+multi-language builds. 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/bazel7/pkg-plist b/devel/bazel7/pkg-plist
new file mode 100644
index 000000000000..d157c119f36f
--- /dev/null
+++ b/devel/bazel7/pkg-plist
@@ -0,0 +1,2 @@
+bin/bazel
+@sample %%ETCDIR%%/bazel.bazelrc.sample


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?69c826fe.1bfb6.a61e163>