From 0c9c98086bc674493410e37bb7520234d422ee31 Mon Sep 17 00:00:00 2001 From: Nikita Kniazev Date: Tue, 21 May 2024 15:03:38 +0300 Subject: [PATCH] bootstrap: embed manifest only when targeting windows (#384) Fixes bfgroup/b2/issues/382 --- src/engine/build.sh | 13 ++++++++++--- src/engine/config_toolset.bat | 5 +++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/engine/build.sh b/src/engine/build.sh index c2a6640af1..9a1e0b1a05 100755 --- a/src/engine/build.sh +++ b/src/engine/build.sh @@ -506,9 +506,16 @@ mod_version.cpp \ if test_true ${B2_DEBUG_OPT} ; then B2_CXXFLAGS="${B2_CXXFLAGS_DEBUG}" else B2_CXXFLAGS="${B2_CXXFLAGS_RELEASE} -DNDEBUG" fi - if [ -z "$B2_DONT_EMBED_MANIFEST" ] && [ -x "$(command -v windres)" ] ; then - B2_CXXFLAGS="${B2_CXXFLAGS} -Wl,res.o" - ( B2_VERBOSE_OPT=${TRUE} echo_run windres --input res.rc --output res.o ) + if [ -z "$B2_DONT_EMBED_MANIFEST" ] ; then + case "$(${B2_CXX} ${B2_CXXFLAGS} -dumpmachine 2>/dev/null)" in + *-windows*|*-mingw*|*-msys*|*-cygnus*|*-cygwin*) + WINDRES="$(${B2_CXX} ${B2_CXXFLAGS} -print-prog-name=windres 2>/dev/null)" + ;; + esac + if [ -n "${WINDRES}" ] ; then + B2_CXXFLAGS="${B2_CXXFLAGS} -Wl,res.o" + ( B2_VERBOSE_OPT=${TRUE} echo_run ${WINDRES} --input res.rc --output res.o ) + fi fi ( B2_VERBOSE_OPT=${TRUE} echo_run ${B2_CXX} ${B2_CXXFLAGS} ${B2_SOURCES} -o b2 ) } diff --git a/src/engine/config_toolset.bat b/src/engine/config_toolset.bat index 8b5e3091a1..a2419ace04 100644 --- a/src/engine/config_toolset.bat +++ b/src/engine/config_toolset.bat @@ -259,7 +259,8 @@ goto :eof :Embed_Minafest_Via_Windres if not defined B2_DONT_EMBED_MANIFEST ( - where windres >NUL 2>NUL - if errorlevel 1 ( call; ) else ( set "B2_CXX=windres --input res.rc --output res.o && %B2_CXX% -Wl,res.o" ) + for /f %%i in ('%B2_CXX% --print-prog-name=windres 2^>NUL') do ( + set "B2_CXX="%%i" --input res.rc --output res.o && %B2_CXX% -Wl,res.o" + ) ) goto :eof