git: 5c481f617d09 - main - devel/xtensa-esp-elf: Add espressif bin wrappers

From: Craig Leres <leres_at_FreeBSD.org>
Date: Wed, 16 Oct 2024 04:12:29 UTC
The branch main has been updated by leres:

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

commit 5c481f617d09312d3604a16765fcb296c5835bef
Author:     Craig Leres <leres@FreeBSD.org>
AuthorDate: 2024-10-16 04:12:09 +0000
Commit:     Craig Leres <leres@FreeBSD.org>
CommitDate: 2024-10-16 04:12:09 +0000

    devel/xtensa-esp-elf: Add espressif bin wrappers
    
    Build and install the espressif rust based wrapper.
    
    According to upstream, the target xtensa cpu is set via the
    XTENSA_GNU_CONFIG environment variable for gcc 12 and later.
    
    In addition to esp32 the esp32s2 and esp32s3 target cpus are now
    supported.
    
    While we're here, change to USE_GCC=yes:build.
    
    PR:             281951
---
 devel/xtensa-esp-elf/Makefile  | 81 +++++++++++++++++++++++++++++++++------
 devel/xtensa-esp-elf/distinfo  |  8 +++-
 devel/xtensa-esp-elf/pkg-descr |  3 +-
 devel/xtensa-esp-elf/pkg-plist | 87 ++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 166 insertions(+), 13 deletions(-)

diff --git a/devel/xtensa-esp-elf/Makefile b/devel/xtensa-esp-elf/Makefile
index 13a912009845..e0b40e46da29 100644
--- a/devel/xtensa-esp-elf/Makefile
+++ b/devel/xtensa-esp-elf/Makefile
@@ -1,5 +1,6 @@
 PORTNAME=	xtensa-esp-elf
 DISTVERSION=	13.2.0_20240530
+PORTREVISION=	1
 CATEGORIES=	devel
 MASTER_SITES=	https://github.com/espressif/crosstool-NG/releases/download/esp-${DISTVERSION}/:source1 \
 		GNU/gmp:source2 \
@@ -17,36 +18,41 @@ DISTFILES=	${DISTNAME}${EXTRACT_SUFX}:source1 \
 		mpfr-4.2.1.zip:source5 \
 		zlib-1.2.13.tar.xz:source6 \
 		zstd-1.5.5.tar.gz:source7
-EXTRACT_ONLY=	${DISTNAME}${EXTRACT_SUFX}
+EXTRACT_ONLY=	${DISTNAME}${EXTRACT_SUFX} \
+		espressif-esp-toolchain-bin-wrappers-${TAG_WRAPPERS}_GH0.tar.gz \
+		rust/crates/lazy_static-1.4.0.crate \
+		rust/crates/libc-0.2.147.crate
 
 MAINTAINER=	leres@FreeBSD.org
 COMMENT=	Espressif ESP toolchain
-WWW=		https://docs.espressif.com/projects/esp-idf/en/stable/esp32/get-started/
+WWW=		https://docs.espressif.com/projects/esp-idf/en/v5.3.1/esp32/get-started/
 
 LICENSE=	GPLv2 LGPL21
 LICENSE_COMB=	multi
 
-BUILD_DEPENDS=	bash:shells/bash \
+BUILD_DEPENDS=	${LOCALBASE}/bin/grep:textproc/gnugrep \
+		${LOCALBASE}/include/libintl.h:devel/gettext-runtime \
+		bash:shells/bash \
 		gawk:lang/gawk \
 		gpatch:devel/patch \
-		${LOCALBASE}/bin/grep:textproc/gnugrep \
-		${LOCALBASE}/include/libintl.h:devel/gettext-runtime \
 		gsed:textproc/gsed \
 		help2man:misc/help2man \
 		makeinfo:print/texinfo
 
-USES=		autoreconf:build bison gmake libtool python
-USE_GCC=	yes
+USES=		autoreconf:build bison cargo gmake libtool python
+USE_GCC=	yes:build
 USE_GITHUB=	nodefault
 
 NO_MTREE=	yes
 GH_ACCOUNT=	espressif
 GH_PROJECT=	binutils-gdb:github1 \
 		gcc:github2 \
-		newlib-esp32:github3
+		newlib-esp32:github3 \
+		esp-toolchain-bin-wrappers:github4
 GH_TAGNAME=	esp-2.41.0_${ESPDATE}:github1 \
 		esp-${GCCVER}_${ESPDATE}:github2 \
-		esp-4.3.0_${ESPDATE}:github3
+		esp-4.3.0_${ESPDATE}:github3 \
+		${TAG_WRAPPERS}:github4
 BINARY_ALIAS=	g++=${CXX} gcc=${CC} python=${PYTHON_VERSION}
 BUILD_ENV=	CT_ALLOW_BUILD_AS_ROOT_SURE=1 \
 		CT_FORBID_DOWNLOAD=y \
@@ -55,11 +61,30 @@ BUILD_ENV=	CT_ALLOW_BUILD_AS_ROOT_SURE=1 \
 		LDFLAGS=-I${PREFIX}/lib \
 		${MAKE_ENV:MPATH=*}
 
+CARGO_BUILD=		no
+CARGO_CONFIGURE=	no
+CARGO_INSTALL=		no
+CARGO_TEST=		no
+CARGO_TARGET_DIR=	${WRKSRC2}/target
+CARGO_VENDOR_DIR=	${WRKSRC2}/cargo-crates
+CARGO_CRATES=	lazy_static-1.4.0 \
+		libc-0.2.147
+CARGO_CARGOTOML=	${WRKSRC2}/Cargo.toml
+CARGO_CARGOLOCK=	${WRKSRC2}/Cargo.lock
+WRKSRC2=	${WRKDIR}/esp-toolchain-bin-wrappers-${TAG_WRAPPERS}/gnu-xtensa-toolchian
+
 ESPVER=		${DISTNAME:tl:S/-src$//:S/-esp-/-/}
 ESPDATE=	20240305
 GCCVER=		13.2.0
-PLIST_SUB=	PKGBASE=$(PKGBASE) GCCVER=$(GCCVER)
+PLIST_SUB=	PKGBASE=$(PKGBASE) \
+		GCCVER=$(GCCVER)
+TAG_WRAPPERS=	62776e9
 TARBALLS=	${BUILD_WRKSRC}/.build/tarballs
+XTENSA_CHIPS=	esp32 esp32s2 esp32s3
+XTENSA_WRAPPED= addr2line ar as c++ cc c++filt cpp elfedit g++ gcc \
+		gcc-${GCCVER} gcc-ar gcc-nm gcc-ranlib gcov gcov-dump \
+		gcov-tool gprof ld ld.bfd lto-dump nm objcopy objdump \
+		ranlib readelf size strings strip
 
 post-extract:
 	${MKDIR} ${TARBALLS}
@@ -94,7 +119,22 @@ do-configure:
 	    ./configure --prefix=${WRKDIR}/ct-ng --exec-prefix=${WRKDIR}/ct-ng
 	cd ${BUILD_WRKSRC} && \
 	    ${SETENV} -uMAKELEVEL -uMAKEFLAGS -u.MAKE.LEVEL.ENV ${BUILD_ENV} \
-	    ${MAKE_CMD} install && ${SETENV} ${BUILD_ENV} ./ct-ng xtensa-esp-elf
+	    ${MAKE_CMD} install && \
+	    ${SETENV} ${BUILD_ENV} ./ct-ng xtensa-esp-elf
+
+	# xtensa-toolchian-wrapper
+	${MKDIR} ${WRKDIR}/.cargo
+	: > ${WRKDIR}/.cargo/config.toml
+	${ECHO_CMD} "[source.cargo]" >> ${WRKDIR}/.cargo/config.toml
+	${ECHO_CMD} "directory = '${CARGO_VENDOR_DIR}'" >> \
+	    ${WRKDIR}/.cargo/config.toml
+	${ECHO_CMD} "[source.crates-io]" >> ${WRKDIR}/.cargo/config.toml
+	${ECHO_CMD} "replace-with = 'cargo'" >> ${WRKDIR}/.cargo/config.toml
+	@cd ${WRKSRC2} && ${CARGO_CARGO_RUN} update \
+	    --manifest-path ${CARGO_CARGOTOML} \
+	    --verbose \
+	    --verbose \
+	    ${CARGO_UPDATE_ARGS}
 
 do-build:
 	cd ${BUILD_WRKSRC} && ${SETENV} ${BUILD_ENV} ./ct-ng build
@@ -103,6 +143,13 @@ do-build:
 	    ${RM} build.log.bz2 lib/charset.alias && \
 	    ${CHMOD} -w . lib
 
+	# xtensa-toolchian-wrapper
+	cd ${WRKSRC2} && ${CARGO_CARGO_RUN} build \
+	    --manifest-path ${CARGO_CARGOTOML} \
+	    --verbose \
+	    --verbose \
+	    ${CARGO_BUILD_ARGS}
+
 do-install:
 	cd ${BUILD_WRKSRC}/builds/${PORTNAME} && \
 	    ${COPYTREE_BIN} . ${STAGEDIR}${PREFIX}/${PKGBASE}
@@ -113,4 +160,16 @@ do-install:
 	    ${STAGEDIR}${PREFIX}/${PKGBASE}/${PORTNAME}/bin -type f | \
 	    ${XARGS} ${CHMOD} +x
 
+	# xtensa-toolchian-wrapper
+	${INSTALL_PROGRAM} ${WRKSRC2}/target/x86_64-unknown-freebsd/release/xtensa-toolchian-wrapper \
+	    ${STAGEDIR}${PREFIX}/${PKGBASE}/bin
+.for chip in ${XTENSA_CHIPS}
+.for wrap in ${XTENSA_WRAPPED}
+	${LN} -f \
+	    ${STAGEDIR}${PREFIX}/${PKGBASE}/bin/xtensa-toolchian-wrapper \
+	    ${STAGEDIR}${PREFIX}/${PKGBASE}/bin/xtensa-${chip}-elf-${wrap}
+.endfor
+.endfor
+	${RM} ${STAGEDIR}${PREFIX}/${PKGBASE}/bin/xtensa-toolchian-wrapper
+
 .include <bsd.port.mk>
diff --git a/devel/xtensa-esp-elf/distinfo b/devel/xtensa-esp-elf/distinfo
index 572b182eaee4..5c27f8a475a8 100644
--- a/devel/xtensa-esp-elf/distinfo
+++ b/devel/xtensa-esp-elf/distinfo
@@ -1,4 +1,4 @@
-TIMESTAMP = 1727046054
+TIMESTAMP = 1727977760
 SHA256 (crosstool-NG-esp-13.2.0_20240530-src.tar.xz) = 6e439b150bfd7cc3446b39c285e1eeebfb71c6e6a0132f5cf1082e5552e5b9d1
 SIZE (crosstool-NG-esp-13.2.0_20240530-src.tar.xz) = 1123972
 SHA256 (gmp-6.2.1.tar.bz2) = eae9326beb4158c386e39a356818031bd28f3124cf915f8c5b1dc4c7a36b4d7c
@@ -13,9 +13,15 @@ SHA256 (zlib-1.2.13.tar.xz) = d14c38e313afc35a9a8760dadf26042f51ea0f5d154b0630a3
 SIZE (zlib-1.2.13.tar.xz) = 1296496
 SHA256 (zstd-1.5.5.tar.gz) = 9c4396cc829cfae319a6e2615202e82aad41372073482fce286fac78646d3ee4
 SIZE (zstd-1.5.5.tar.gz) = 2368543
+SHA256 (rust/crates/lazy_static-1.4.0.crate) = e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646
+SIZE (rust/crates/lazy_static-1.4.0.crate) = 10443
+SHA256 (rust/crates/libc-0.2.147.crate) = b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3
+SIZE (rust/crates/libc-0.2.147.crate) = 686772
 SHA256 (espressif-binutils-gdb-esp-2.41.0_20240305_GH0.tar.gz) = 75cc712f35b0a2f95e53d9bf54629bd66759f7225dc222392f210ca4ac5facb6
 SIZE (espressif-binutils-gdb-esp-2.41.0_20240305_GH0.tar.gz) = 65669754
 SHA256 (espressif-gcc-esp-13.2.0_20240305_GH0.tar.gz) = 2dfa982c84d22e90974eff546311d2b97bc92d8da50eccd625b1e44a9766fc1b
 SIZE (espressif-gcc-esp-13.2.0_20240305_GH0.tar.gz) = 137893692
 SHA256 (espressif-newlib-esp32-esp-4.3.0_20240305_GH0.tar.gz) = d1ed55a0e7d56e33100ddb4bf78ca5e9b14757d2b0815e65594fd401cc2b091d
 SIZE (espressif-newlib-esp32-esp-4.3.0_20240305_GH0.tar.gz) = 12030406
+SHA256 (espressif-esp-toolchain-bin-wrappers-62776e9_GH0.tar.gz) = b981f9ca4f36570b3a5d81dd2384c96a05da95bb8ac502b561a66a5847a6704c
+SIZE (espressif-esp-toolchain-bin-wrappers-62776e9_GH0.tar.gz) = 10109
diff --git a/devel/xtensa-esp-elf/pkg-descr b/devel/xtensa-esp-elf/pkg-descr
index 05d71b9ea016..d0b247037cd3 100644
--- a/devel/xtensa-esp-elf/pkg-descr
+++ b/devel/xtensa-esp-elf/pkg-descr
@@ -1,4 +1,5 @@
 The Espressif ESP toolchain to support Arduino and FreeRTOS projects.
 
 This version produces a gcc 13.2.0 based toolchain for use with
-versions 5.2.2, 5.3.0, and 5.3.1 of the esp-idf.
+versions 5.2.2, 5.3.0, and 5.3.1 of the esp-idf and esp32, esp32s2
+and esp32s3 target cpus.
diff --git a/devel/xtensa-esp-elf/pkg-plist b/devel/xtensa-esp-elf/pkg-plist
index 38612ed32320..749499f21c2e 100644
--- a/devel/xtensa-esp-elf/pkg-plist
+++ b/devel/xtensa-esp-elf/pkg-plist
@@ -28,6 +28,93 @@
 %%PKGBASE%%/bin/%%PKGBASE%%-size
 %%PKGBASE%%/bin/%%PKGBASE%%-strings
 %%PKGBASE%%/bin/%%PKGBASE%%-strip
+%%PKGBASE%%/bin/xtensa-esp32-elf-addr2line
+%%PKGBASE%%/bin/xtensa-esp32-elf-ar
+%%PKGBASE%%/bin/xtensa-esp32-elf-as
+%%PKGBASE%%/bin/xtensa-esp32-elf-c++
+%%PKGBASE%%/bin/xtensa-esp32-elf-c++filt
+%%PKGBASE%%/bin/xtensa-esp32-elf-cc
+%%PKGBASE%%/bin/xtensa-esp32-elf-cpp
+%%PKGBASE%%/bin/xtensa-esp32-elf-elfedit
+%%PKGBASE%%/bin/xtensa-esp32-elf-g++
+%%PKGBASE%%/bin/xtensa-esp32-elf-gcc
+%%PKGBASE%%/bin/xtensa-esp32-elf-gcc-%%GCCVER%%
+%%PKGBASE%%/bin/xtensa-esp32-elf-gcc-ar
+%%PKGBASE%%/bin/xtensa-esp32-elf-gcc-nm
+%%PKGBASE%%/bin/xtensa-esp32-elf-gcc-ranlib
+%%PKGBASE%%/bin/xtensa-esp32-elf-gcov
+%%PKGBASE%%/bin/xtensa-esp32-elf-gcov-dump
+%%PKGBASE%%/bin/xtensa-esp32-elf-gcov-tool
+%%PKGBASE%%/bin/xtensa-esp32-elf-gprof
+%%PKGBASE%%/bin/xtensa-esp32-elf-ld
+%%PKGBASE%%/bin/xtensa-esp32-elf-ld.bfd
+%%PKGBASE%%/bin/xtensa-esp32-elf-lto-dump
+%%PKGBASE%%/bin/xtensa-esp32-elf-nm
+%%PKGBASE%%/bin/xtensa-esp32-elf-objcopy
+%%PKGBASE%%/bin/xtensa-esp32-elf-objdump
+%%PKGBASE%%/bin/xtensa-esp32-elf-ranlib
+%%PKGBASE%%/bin/xtensa-esp32-elf-readelf
+%%PKGBASE%%/bin/xtensa-esp32-elf-size
+%%PKGBASE%%/bin/xtensa-esp32-elf-strings
+%%PKGBASE%%/bin/xtensa-esp32-elf-strip
+%%PKGBASE%%/bin/xtensa-esp32s2-elf-addr2line
+%%PKGBASE%%/bin/xtensa-esp32s2-elf-ar
+%%PKGBASE%%/bin/xtensa-esp32s2-elf-as
+%%PKGBASE%%/bin/xtensa-esp32s2-elf-c++
+%%PKGBASE%%/bin/xtensa-esp32s2-elf-c++filt
+%%PKGBASE%%/bin/xtensa-esp32s2-elf-cc
+%%PKGBASE%%/bin/xtensa-esp32s2-elf-cpp
+%%PKGBASE%%/bin/xtensa-esp32s2-elf-elfedit
+%%PKGBASE%%/bin/xtensa-esp32s2-elf-g++
+%%PKGBASE%%/bin/xtensa-esp32s2-elf-gcc
+%%PKGBASE%%/bin/xtensa-esp32s2-elf-gcc-%%GCCVER%%
+%%PKGBASE%%/bin/xtensa-esp32s2-elf-gcc-ar
+%%PKGBASE%%/bin/xtensa-esp32s2-elf-gcc-nm
+%%PKGBASE%%/bin/xtensa-esp32s2-elf-gcc-ranlib
+%%PKGBASE%%/bin/xtensa-esp32s2-elf-gcov
+%%PKGBASE%%/bin/xtensa-esp32s2-elf-gcov-dump
+%%PKGBASE%%/bin/xtensa-esp32s2-elf-gcov-tool
+%%PKGBASE%%/bin/xtensa-esp32s2-elf-gprof
+%%PKGBASE%%/bin/xtensa-esp32s2-elf-ld
+%%PKGBASE%%/bin/xtensa-esp32s2-elf-ld.bfd
+%%PKGBASE%%/bin/xtensa-esp32s2-elf-lto-dump
+%%PKGBASE%%/bin/xtensa-esp32s2-elf-nm
+%%PKGBASE%%/bin/xtensa-esp32s2-elf-objcopy
+%%PKGBASE%%/bin/xtensa-esp32s2-elf-objdump
+%%PKGBASE%%/bin/xtensa-esp32s2-elf-ranlib
+%%PKGBASE%%/bin/xtensa-esp32s2-elf-readelf
+%%PKGBASE%%/bin/xtensa-esp32s2-elf-size
+%%PKGBASE%%/bin/xtensa-esp32s2-elf-strings
+%%PKGBASE%%/bin/xtensa-esp32s2-elf-strip
+%%PKGBASE%%/bin/xtensa-esp32s3-elf-addr2line
+%%PKGBASE%%/bin/xtensa-esp32s3-elf-ar
+%%PKGBASE%%/bin/xtensa-esp32s3-elf-as
+%%PKGBASE%%/bin/xtensa-esp32s3-elf-c++
+%%PKGBASE%%/bin/xtensa-esp32s3-elf-c++filt
+%%PKGBASE%%/bin/xtensa-esp32s3-elf-cc
+%%PKGBASE%%/bin/xtensa-esp32s3-elf-cpp
+%%PKGBASE%%/bin/xtensa-esp32s3-elf-elfedit
+%%PKGBASE%%/bin/xtensa-esp32s3-elf-g++
+%%PKGBASE%%/bin/xtensa-esp32s3-elf-gcc
+%%PKGBASE%%/bin/xtensa-esp32s3-elf-gcc-%%GCCVER%%
+%%PKGBASE%%/bin/xtensa-esp32s3-elf-gcc-ar
+%%PKGBASE%%/bin/xtensa-esp32s3-elf-gcc-nm
+%%PKGBASE%%/bin/xtensa-esp32s3-elf-gcc-ranlib
+%%PKGBASE%%/bin/xtensa-esp32s3-elf-gcov
+%%PKGBASE%%/bin/xtensa-esp32s3-elf-gcov-dump
+%%PKGBASE%%/bin/xtensa-esp32s3-elf-gcov-tool
+%%PKGBASE%%/bin/xtensa-esp32s3-elf-gprof
+%%PKGBASE%%/bin/xtensa-esp32s3-elf-ld
+%%PKGBASE%%/bin/xtensa-esp32s3-elf-ld.bfd
+%%PKGBASE%%/bin/xtensa-esp32s3-elf-lto-dump
+%%PKGBASE%%/bin/xtensa-esp32s3-elf-nm
+%%PKGBASE%%/bin/xtensa-esp32s3-elf-objcopy
+%%PKGBASE%%/bin/xtensa-esp32s3-elf-objdump
+%%PKGBASE%%/bin/xtensa-esp32s3-elf-ranlib
+%%PKGBASE%%/bin/xtensa-esp32s3-elf-readelf
+%%PKGBASE%%/bin/xtensa-esp32s3-elf-size
+%%PKGBASE%%/bin/xtensa-esp32s3-elf-strings
+%%PKGBASE%%/bin/xtensa-esp32s3-elf-strip
 %%PKGBASE%%/lib/bfd-plugins/libdep.so
 %%PKGBASE%%/lib/bfd-plugins/liblto_plugin.so
 %%PKGBASE%%/lib/gcc/%%PKGBASE%%/%%GCCVER%%/crtbegin.o