commit:     4b7c1923fca6533a51be68bfbacc793469a521d4
Author:     Ionen Wolkens <ionen <AT> gentoo <DOT> org>
AuthorDate: Tue May 10 07:06:43 2022 +0000
Commit:     Ionen Wolkens <ionen <AT> gentoo <DOT> org>
CommitDate: Fri May 13 02:29:29 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=4b7c1923

dev-util/mingw64-runtime: build tools for CHOST and add widl

Non-native USE=tools never made much sense, If a package is
cross-compiling for mingw using e.g. widl, it'll need to be able
to run the tool. This also prevents build failure (bug #644556)
during bootstrap given this won't be trying to link with mingw
(note that can cross-emerge mingw64-runtime for old behavior).

wrt widl, it is provided by wine but that is a heavy dependency and
some upstreams (e.g. vkd3d-proton) default to using *-w64-mingw32-widl
instead -- small tool so may as well install it.

Closes: https://bugs.gentoo.org/644556
Signed-off-by: Ionen Wolkens <ionen <AT> gentoo.org>

 .../mingw64-runtime-10.0.0-r1.ebuild               | 33 +++++++++++++++++++---
 .../mingw64-runtime-8.0.0-r3.ebuild                | 33 +++++++++++++++++++---
 .../mingw64-runtime-9.0.0-r2.ebuild                | 33 +++++++++++++++++++---
 3 files changed, 87 insertions(+), 12 deletions(-)

diff --git a/dev-util/mingw64-runtime/mingw64-runtime-10.0.0-r1.ebuild 
b/dev-util/mingw64-runtime/mingw64-runtime-10.0.0-r1.ebuild
index 8c12697778ba..61ebf16b4393 100644
--- a/dev-util/mingw64-runtime/mingw64-runtime-10.0.0-r1.ebuild
+++ b/dev-util/mingw64-runtime/mingw64-runtime-10.0.0-r1.ebuild
@@ -33,8 +33,32 @@ pkg_setup() {
                die "Invalid configuration, please see: 
https://wiki.gentoo.org/wiki/Mingw";
 }
 
+mingw-foreach_tool() {
+       use !tools || use headers-only && return
+
+       local tool
+       for tool in gendef genidl widl; do
+               # not using top-level --with-tools given it skips widl
+               pushd mingw-w64-tools/${tool} || die
+               "${@}"
+               popd >/dev/null || die
+       done
+}
+
 src_configure() {
-       CHOST=${CTARGET}
+       # native tools, see #644556
+       local toolsconf=(
+               --prefix="${EPREFIX}"/usr
+       )
+       # normally only widl is prefixed, but avoids clash with other targets
+       ${MW_CROSS} && toolsconf+=( --program-prefix=${CTARGET}- )
+
+       mingw-foreach_tool econf "${toolsconf[@]}"
+
+       MW_LDFLAGS=${LDFLAGS} # keep non-stripped for gendef not respecting it
+
+       # cross-compiling from here
+       local CHOST=${CTARGET}
        strip-unsupported-flags
 
        # Normally mingw64 does not use dynamic linker.
@@ -62,7 +86,6 @@ src_configure() {
                conf+=(
                        $(use_enable idl)
                        $(use_with libraries)
-                       $(use_with tools)
                )
 
                # prefer tuple to determine if should do 32 or 64bits, but fall
@@ -91,13 +114,15 @@ src_configure() {
 
 src_compile() {
        use headers-only || emake -C ../headers install
-
-       default
+       emake
+       mingw-foreach_tool emake LDFLAGS="${MW_LDFLAGS}"
 }
 
 src_install() {
        default
 
+       mingw-foreach_tool emake DESTDIR="${D}" install
+
        if ${MW_CROSS}; then
                # gcc is configured to look at specific hard-coded paths for 
mingw #419601
                dosym usr /usr/${CTARGET}/mingw

diff --git a/dev-util/mingw64-runtime/mingw64-runtime-8.0.0-r3.ebuild 
b/dev-util/mingw64-runtime/mingw64-runtime-8.0.0-r3.ebuild
index f287baeaa601..cde42642c57b 100644
--- a/dev-util/mingw64-runtime/mingw64-runtime-8.0.0-r3.ebuild
+++ b/dev-util/mingw64-runtime/mingw64-runtime-8.0.0-r3.ebuild
@@ -35,8 +35,32 @@ pkg_setup() {
                die "Invalid configuration, please see: 
https://wiki.gentoo.org/wiki/Mingw";
 }
 
+mingw-foreach_tool() {
+       use !tools || use headers-only && return
+
+       local tool
+       for tool in gendef genidl widl; do
+               # not using top-level --with-tools given it skips widl
+               pushd mingw-w64-tools/${tool} || die
+               "${@}"
+               popd >/dev/null || die
+       done
+}
+
 src_configure() {
-       CHOST=${CTARGET}
+       # native tools, see #644556
+       local toolsconf=(
+               --prefix="${EPREFIX}"/usr
+       )
+       # normally only widl is prefixed, but avoids clash with other targets
+       ${MW_CROSS} && toolsconf+=( --program-prefix=${CTARGET}- )
+
+       mingw-foreach_tool econf "${toolsconf[@]}"
+
+       MW_LDFLAGS=${LDFLAGS} # keep non-stripped for gendef not respecting it
+
+       # cross-compiling from here
+       local CHOST=${CTARGET}
        strip-unsupported-flags
 
        # Normally mingw64 does not use dynamic linker.
@@ -64,7 +88,6 @@ src_configure() {
                conf+=(
                        $(use_enable idl)
                        $(use_with libraries)
-                       $(use_with tools)
                )
 
                # prefer tuple to determine if should do 32 or 64bits, but fall
@@ -93,13 +116,15 @@ src_configure() {
 
 src_compile() {
        use headers-only || emake -C ../headers install
-
-       default
+       emake
+       mingw-foreach_tool emake LDFLAGS="${MW_LDFLAGS}"
 }
 
 src_install() {
        default
 
+       mingw-foreach_tool emake DESTDIR="${D}" install
+
        if ${MW_CROSS}; then
                # gcc is configured to look at specific hard-coded paths for 
mingw #419601
                dosym usr /usr/${CTARGET}/mingw

diff --git a/dev-util/mingw64-runtime/mingw64-runtime-9.0.0-r2.ebuild 
b/dev-util/mingw64-runtime/mingw64-runtime-9.0.0-r2.ebuild
index 8c12697778ba..61ebf16b4393 100644
--- a/dev-util/mingw64-runtime/mingw64-runtime-9.0.0-r2.ebuild
+++ b/dev-util/mingw64-runtime/mingw64-runtime-9.0.0-r2.ebuild
@@ -33,8 +33,32 @@ pkg_setup() {
                die "Invalid configuration, please see: 
https://wiki.gentoo.org/wiki/Mingw";
 }
 
+mingw-foreach_tool() {
+       use !tools || use headers-only && return
+
+       local tool
+       for tool in gendef genidl widl; do
+               # not using top-level --with-tools given it skips widl
+               pushd mingw-w64-tools/${tool} || die
+               "${@}"
+               popd >/dev/null || die
+       done
+}
+
 src_configure() {
-       CHOST=${CTARGET}
+       # native tools, see #644556
+       local toolsconf=(
+               --prefix="${EPREFIX}"/usr
+       )
+       # normally only widl is prefixed, but avoids clash with other targets
+       ${MW_CROSS} && toolsconf+=( --program-prefix=${CTARGET}- )
+
+       mingw-foreach_tool econf "${toolsconf[@]}"
+
+       MW_LDFLAGS=${LDFLAGS} # keep non-stripped for gendef not respecting it
+
+       # cross-compiling from here
+       local CHOST=${CTARGET}
        strip-unsupported-flags
 
        # Normally mingw64 does not use dynamic linker.
@@ -62,7 +86,6 @@ src_configure() {
                conf+=(
                        $(use_enable idl)
                        $(use_with libraries)
-                       $(use_with tools)
                )
 
                # prefer tuple to determine if should do 32 or 64bits, but fall
@@ -91,13 +114,15 @@ src_configure() {
 
 src_compile() {
        use headers-only || emake -C ../headers install
-
-       default
+       emake
+       mingw-foreach_tool emake LDFLAGS="${MW_LDFLAGS}"
 }
 
 src_install() {
        default
 
+       mingw-foreach_tool emake DESTDIR="${D}" install
+
        if ${MW_CROSS}; then
                # gcc is configured to look at specific hard-coded paths for 
mingw #419601
                dosym usr /usr/${CTARGET}/mingw

Reply via email to