git: cde108d7b316 - main - lang/spidermonkey91: fix build with Python 3.11

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

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

commit cde108d7b316aafbe4a077034fe6eeb68969b7af
Author:     Charlie Li <vishwin@FreeBSD.org>
AuthorDate: 2023-03-29 12:54:34 +0000
Commit:     Charlie Li <vishwin@FreeBSD.org>
CommitDate: 2023-03-29 12:57:31 +0000

    lang/spidermonkey91: 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
    
    Requested by: fluffy
---
 lang/spidermonkey91/Makefile | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/lang/spidermonkey91/Makefile b/lang/spidermonkey91/Makefile
index a7a0594ff002..e47ca2abafe2 100644
--- a/lang/spidermonkey91/Makefile
+++ b/lang/spidermonkey91/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 \
@@ -22,7 +21,7 @@ LIB_DEPENDS=	libffi.so:devel/libffi \
 		libnspr4.so:devel/nspr
 
 USES=		compiler:c++17-lang gmake localbase pathfix pkgconfig \
-		python:3.7-3.10,build readline tar:xz
+		python:build readline tar:xz
 USE_LDCONFIG=	yes
 SP_VER=		91
 HAS_CONFIGURE=	yes
@@ -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 \
@@ -78,11 +77,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