git: e3bb4afb6c91 - main - lang/zig-devel: use pre-built docs for faster builds

From: Dave Cottlehuber <dch_at_FreeBSD.org>
Date: Tue, 17 May 2022 14:08:00 UTC
The branch main has been updated by dch:

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

commit e3bb4afb6c91d2a7fb981f14f4880f635665a8bd
Author:     Dave Cottlehuber <dch@FreeBSD.org>
AuthorDate: 2022-05-17 14:07:51 +0000
Commit:     Dave Cottlehuber <dch@FreeBSD.org>
CommitDate: 2022-05-17 14:07:51 +0000

    lang/zig-devel: use pre-built docs for faster builds
    
    Switch to pre-built docs, as this more than halves the build time and
    also enables BUILD_AS_NON_ROOT with poudriere.
    
    Sponsored by:   SkunkWerks, GmbH
---
 lang/zig-devel/Makefile | 33 ++++++++++-----------------------
 lang/zig-devel/distinfo |  4 +++-
 2 files changed, 13 insertions(+), 24 deletions(-)

diff --git a/lang/zig-devel/Makefile b/lang/zig-devel/Makefile
index 8c0d21160c6a..8a1e810907e1 100644
--- a/lang/zig-devel/Makefile
+++ b/lang/zig-devel/Makefile
@@ -4,6 +4,8 @@ CATEGORIES=	lang
 MASTER_SITES=	https://ziglang.org/download/${DISTVERSION}/ \
 		https://ziglang.org/builds/
 PKGNAMESUFFIX=	-devel
+# fetch prebuilt platform-independent docs
+DISTFILES=	${DISTNAME}${EXTRACT_SUFX} zig-freebsd-x86_64-${DISTVERSION}${EXTRACT_SUFX}
 
 MAINTAINER=	dch@FreeBSD.org
 COMMENT=	Language designed for robustness, optimality, and maintainability
@@ -20,10 +22,10 @@ CONFLICTS=	zig
 
 USES=		cmake compiler:c++11-lang localbase:ldflags tar:xz
 
-OPTIONS_DEFINE=		STATIC
-OPTIONS_DEFAULT=	STATIC
+OPTIONS_DEFINE=		STATIC DOCS
+OPTIONS_DEFAULT=	STATIC DOCS
 
-STATIC_DESC=	sets ZIG_STATIC to avoid 800MiB LLVM dependencies
+STATIC_DESC=	sets ZIG_STATIC to avoid 800MiB LLVM runtime dependency
 
 STATIC_RUN_DEPENDS_OFF=	llvm${_LLVM_VER}>=0:devel/llvm${_LLVM_VER}
 STATIC_CMAKE_BOOL=	CMAKE_SKIP_INSTALL_RPATH ZIG_STATIC
@@ -35,30 +37,15 @@ _ZIG_BIN=	${STAGEDIR}${PREFIX}/bin/zig
 post-configure-STATIC-on:
 	@${REINPLACE_CMD} 's/-Wl,-Bdynamic//' ${BUILD_WRKSRC}/build.ninja
 
-post-build:
-# Produce the experimental std lib documentation.
-	${MKDIR}  ${WRKDIR}/cache ${WRKDIR}/doc
-	${WRKDIR}/.build/zig test ${WRKSRC}/lib/std/std.zig \
-		--cache-dir ${WRKDIR}/cache \
-		--global-cache-dir ${WRKDIR}/cache \
-		--zig-lib-dir ${WRKSRC}/lib \
-		-femit-docs=${WRKDIR}/doc \
-		-fno-emit-bin
-	${RM} ${WRKSRC}/lib/zig/std/zig-cache
-
-post-install:
+post-install-DOCS-on:
 	${MKDIR} ${STAGEDIR}${DOCSDIR}/std
-# langref cannot be generated until after install target has run
-	(cd ${WRKSRC} && ${_ZIG_BIN} run \
-		./doc/docgen.zig -- ${_ZIG_BIN} \
-		./doc/langref.html.in ${STAGEDIR}${DOCSDIR}/langref.html \
-		&& ${RM} ${STAGEDIR}/lib/zig/std/zig-cache)
-	${REINPLACE_CMD} -i '' -e 's|${STAGEDIR}||' ${STAGEDIR}${DOCSDIR}/langref.html
-.for f in data.js main.js index.html
-	${INSTALL_MAN} ${WRKDIR}/doc/${f} ${STAGEDIR}${DOCSDIR}/std/
+.for f in langref.html std/data.js std/main.js std/index.html
+	${INSTALL_MAN} ${WRKDIR}/zig-freebsd-x86_64-${DISTVERSION}/doc/${f} \
+		${STAGEDIR}${DOCSDIR}/${f}
 .endfor
 
 do-test:
+	mkdir ${WRKDIR}/cache
 	(cd ${WRKSRC} && ${_ZIG_BIN} build test-behavior \
 		--cache-dir ${WRKDIR}/cache \
 		--global-cache-dir ${WRKDIR}/cache \
diff --git a/lang/zig-devel/distinfo b/lang/zig-devel/distinfo
index 891c6c5adf9e..abcc5f3df262 100644
--- a/lang/zig-devel/distinfo
+++ b/lang/zig-devel/distinfo
@@ -1,3 +1,5 @@
-TIMESTAMP = 1645628395
+TIMESTAMP = 1652525714
 SHA256 (zig-0.9.1.tar.xz) = 38cf4e84481f5facc766ba72783e7462e08d6d29a5d47e3b75c8ee3142485210
 SIZE (zig-0.9.1.tar.xz) = 13940828
+SHA256 (zig-freebsd-x86_64-0.9.1.tar.xz) = 4e06009bd3ede34b72757eec1b5b291b30aa0d5046dadd16ecb6b34a02411254
+SIZE (zig-freebsd-x86_64-0.9.1.tar.xz) = 39028848