git: d8ac6c8bc77f - main - lang/spidermonkey{78,102}: fix build with Python 3.11

From: Charlie Li <vishwin_at_FreeBSD.org>
Date: Wed, 29 Mar 2023 00:57:52 UTC
The branch main has been updated by vishwin:

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

commit d8ac6c8bc77ffb66fbb1d4a9cd8fb698114ae231
Author:     Charlie Li <vishwin@FreeBSD.org>
AuthorDate: 2023-03-29 00:46:46 +0000
Commit:     Charlie Li <vishwin@FreeBSD.org>
CommitDate: 2023-03-29 00:46:46 +0000

    lang/spidermonkey{78,102}: fix build with Python 3.11
    
    open(), io.open() et al no longer accept 'U' ("universal newline")
    in the file mode; the flag had been deprecated since Python 3.3. [0]
    Failed during configure.
    
    While here, remove duplicate Python dependency line and use root
    configure script.
    
    References:
    [0] https://docs.python.org/3/whatsnew/3.11.html#porting-to-python-3-11
---
 lang/spidermonkey102/Makefile | 16 +++++++++-------
 lang/spidermonkey78/Makefile  |  9 +++++----
 2 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/lang/spidermonkey102/Makefile b/lang/spidermonkey102/Makefile
index f29e41ca64d6..a7b178eea542 100644
--- a/lang/spidermonkey102/Makefile
+++ b/lang/spidermonkey102/Makefile
@@ -13,8 +13,7 @@ WWW=		https://spidermonkey.dev/
 LICENSE=	MPL20
 LICENSE_FILE=	${WRKSRC}/LICENSE
 
-BUILD_DEPENDS=	${LOCALBASE}/bin/python${PYTHON3_DEFAULT}:lang/python${PYTHON3_DEFAULT:S/.//g} \
-		${RUST_DEFAULT}>=1.35:lang/${RUST_DEFAULT} \
+BUILD_DEPENDS=	${RUST_DEFAULT}>=1.35:lang/${RUST_DEFAULT} \
 		autoconf2.13:devel/autoconf2.13 \
 		rust-cbindgen>=0.8.7:devel/rust-cbindgen
 LIB_DEPENDS=	libffi.so:devel/libffi \
@@ -30,9 +29,9 @@ HAS_CONFIGURE=	yes
 WRKSRC=			${WRKDIR}/firefox-${DISTVERSION}/
 PATCH_WRKSRC=		${WRKDIR}/firefox-${DISTVERSION}/
 CONFIGURE_OUTSOURCE=	yes
-CONFIGURE_SCRIPT=	../firefox-${DISTVERSION}/js/src/configure
 
-CONFIGURE_ARGS=	--disable-debug \
+CONFIGURE_ARGS=	--enable-application=js \
+		--disable-debug \
 		--disable-debug-symbols \
 		--disable-jemalloc \
 		--disable-tests \
@@ -77,11 +76,14 @@ CONFIGURE_ENV+=	LLVM_CONFIG=llvm-config${LLVM_DEFAULT} \
 BUILD_DEPENDS+=	${LOCALBASE}/bin/clang${LLVM_DEFAULT}:devel/llvm${LLVM_DEFAULT}
 .endif
 
-pre-configure:
-	(cd ${WRKSRC}/js/src/ && ${LOCALBASE}/bin/autoconf2.13)
-
 post-patch:
 	@${REINPLACE_CMD} -e 's|%%LOCALBASE%%|${LOCALBASE}|g' ${WRKSRC}/js/moz.configure
+	@${FIND} ${WRKSRC}/python/mozbuild -name *.py -exec \
+		${REINPLACE_CMD} 's|"rU"|"r"|g' {} \;
+
+pre-configure:
+	(cd ${WRKSRC} && ${LOCALBASE}/bin/autoconf2.13)
+	(cd ${WRKSRC}/js/src/ && ${LOCALBASE}/bin/autoconf2.13)
 
 post-install:
 	${RM} ${STAGEDIR}${PREFIX}/lib/libjs_static.ajs
diff --git a/lang/spidermonkey78/Makefile b/lang/spidermonkey78/Makefile
index 4588ec31f255..539818c29fb3 100644
--- a/lang/spidermonkey78/Makefile
+++ b/lang/spidermonkey78/Makefile
@@ -13,8 +13,7 @@ WWW=		https://spidermonkey.dev/
 LICENSE=	MPL20
 LICENSE_FILE=	${WRKSRC}/LICENSE
 
-BUILD_DEPENDS=	${LOCALBASE}/bin/python${PYTHON3_DEFAULT}:lang/python${PYTHON3_DEFAULT:S/.//g} \
-		${RUST_DEFAULT}>=1.35:lang/${RUST_DEFAULT} \
+BUILD_DEPENDS=	${RUST_DEFAULT}>=1.35:lang/${RUST_DEFAULT} \
 		autoconf2.13:devel/autoconf2.13 \
 		rust-cbindgen>=0.8.7:devel/rust-cbindgen
 LIB_DEPENDS=	libffi.so:devel/libffi \
@@ -30,9 +29,9 @@ HAS_CONFIGURE=	yes
 WRKSRC=			${WRKDIR}/firefox-${DISTVERSION}
 PATCH_WRKSRC=		${WRKDIR}/firefox-${DISTVERSION}/
 CONFIGURE_OUTSOURCE=	yes
-CONFIGURE_SCRIPT=	../firefox-${DISTVERSION}/js/src/configure
 
-CONFIGURE_ARGS=	--disable-debug \
+CONFIGURE_ARGS=	--enable-application=js \
+		--disable-debug \
 		--disable-debug-symbols \
 		--disable-gold \
 		--disable-jemalloc \
@@ -80,6 +79,8 @@ BUILD_DEPENDS+=	${LOCALBASE}/bin/clang${LLVM_DEFAULT}:devel/llvm${LLVM_DEFAULT}
 
 post-patch:
 	@${REINPLACE_CMD} -e 's|%%LOCALBASE%%|${LOCALBASE}|g' ${WRKSRC}/js/moz.configure
+	@${FIND} ${WRKSRC}/build/pymake ${WRKSRC}/python/mozbuild -name *.py -exec \
+		${REINPLACE_CMD} "s|'rU'|'r'|g" {} \;
 
 post-install:
 	${RM} ${STAGEDIR}${PREFIX}/lib/libjs_static.ajs