From 9e2c3594ccbd3ef45beab57cba6796f97f06906c Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Thu, 27 Jul 2023 12:20:18 +0100 Subject: win32: fail early if UTF8 isn't supported When the UTF8 manifest is included in the binary and ACP isn't UTF8 fail at once. This avoids raising false hopes if the binary is run on Window 7/8. On Windows XP it won't even run. When the busybox applet is run without arguments always report the build-time configuration of globbing and the UTF8 manifest. --- examples/mswin-build/mkprerelease | 16 ++++++++++++---- examples/mswin-build/mkrelease | 34 ++++++++++++++++++---------------- libbb/appletlib.c | 31 ++++++++++++++++++++----------- 3 files changed, 50 insertions(+), 31 deletions(-) diff --git a/examples/mswin-build/mkprerelease b/examples/mswin-build/mkprerelease index 45f64fa72..1cace46a3 100755 --- a/examples/mswin-build/mkprerelease +++ b/examples/mswin-build/mkprerelease @@ -29,13 +29,13 @@ for i in $TARGETS do if [ $i = "build_pre_64" ] then - CONFIG=mingw64_defconfig; + CONFIG=mingw64_defconfig elif [ $i = "build_pre_64u" ] then - CONFIG=mingw64u_defconfig; + CONFIG=mingw64u_defconfig elif [ $i = "build_pre_32" ] then - CONFIG=mingw32_defconfig; + CONFIG=mingw32_defconfig fi (cd $i; git checkout master; make ${CONFIG}) @@ -44,8 +44,16 @@ done # perform build for i in $TARGETS do + BITS=64 + if [ $i = "build_pre_32" ] + then + BITS=32; + fi + ( cd $i - make -j $(nproc) EXTRAVERSION="-$(git describe --match=FRP | sed 's/FRP/PRE/')" + GCCV=$(rpm -q --qf '%{name} %{version}-%{release}\n' mingw${BITS}-gcc) + CRTV=$(rpm -q --qf '%{name} %{version}-%{release}\n' mingw${BITS}-crt) + make -j $(nproc) EXTRAVERSION="-$(git describe --match=FRP | sed 's/FRP/PRE/')" MINGW_VER="$GCCV; $CRTV" ) done diff --git a/examples/mswin-build/mkrelease b/examples/mswin-build/mkrelease index 7ce9094f6..956cba0c1 100755 --- a/examples/mswin-build/mkrelease +++ b/examples/mswin-build/mkrelease @@ -2,7 +2,7 @@ # # Build 32- and 64-bit busybox binaries for release # -TARGETS="build_32 build_64" +TARGETS="build_32 build_64 build_64u" if [ ! -d busybox-w32 ] then @@ -20,15 +20,23 @@ done # apply default configuration for i in $TARGETS do - BITS=32 if [ $i = "build_64" ] then - BITS=64; + CONFIG=mingw64_defconfig + BITS=64 + elif [ $i = "build_64u" ] + then + CONFIG=mingw64u_defconfig + BITS=64 + elif [ $i = "build_32" ] + then + CONFIG=mingw32_defconfig + BITS=32 fi ( cd $i - make mingw${BITS}_defconfig + make ${CONFIG} # link time optimisation, fortify, stack protection sed -e 's/^CONFIG_EXTRA_CFLAGS="\(.*\)"$/CONFIG_EXTRA_CFLAGS="\1 -flto -fstack-protector --param=ssp-buffer-size=4"/' \ -e 's/^CONFIG_EXTRA_CFLAGS=" /CONFIG_EXTRA_CFLAGS="/' \ @@ -49,22 +57,16 @@ done # perform build for i in $TARGETS do - BITS=32 - if [ $i = "build_64" ] + BITS=64 + if [ $i = "build_32" ] then - BITS=64; + BITS=32 fi ( cd $i - GCCV=`rpm -q --qf '%{name} %{version}-%{release}\n' mingw${BITS}-gcc` - CRTV=`rpm -q --qf '%{name} %{version}-%{release}\n' mingw${BITS}-crt` - GLOB="; noglob" - if grep -q ^CONFIG_GLOBBING=y .config - then - GLOB="; glob" - fi - VER="($GCCV; $CRTV$GLOB)" - make -j $(nproc) EXTRAVERSION="-`git describe --match=FRP`" MINGW_VER="$VER" + GCCV=$(rpm -q --qf '%{name} %{version}-%{release}\n' mingw${BITS}-gcc) + CRTV=$(rpm -q --qf '%{name} %{version}-%{release}\n' mingw${BITS}-crt) + make -j $(nproc) EXTRAVERSION="-`git describe --match=FRP`" MINGW_VER="$GCCV; $CRTV" ) done diff --git a/libbb/appletlib.c b/libbb/appletlib.c index 1c135fde7..a70b3a4c2 100644 --- a/libbb/appletlib.c +++ b/libbb/appletlib.c @@ -886,19 +886,20 @@ int busybox_main(int argc UNUSED_PARAM, char **argv) dup2(1, 2); full_write2_str(bb_banner); /* reuse const string */ -#if ENABLE_PLATFORM_MINGW32 -# if ENABLE_FEATURE_UTF8_MANIFEST - full_write2_str(GetACP() == CP_UTF8 ? " (Unicode on)" - : " (Unicode off)"); -# endif - full_write2_str("\n"); -#else - full_write2_str(" multi-call binary.\n"); /* reuse */ -#endif -#if defined(MINGW_VER) +# if ENABLE_PLATFORM_MINGW32 + full_write2_str("\n("); +# if defined(MINGW_VER) if (sizeof(MINGW_VER) > 5) { - full_write2_str(MINGW_VER "\n\n"); + full_write2_str(MINGW_VER "; "); } +# endif + full_write2_str(ENABLE_GLOBBING ? "glob" : "noglob"); +# if ENABLE_FEATURE_UTF8_MANIFEST + full_write2_str("; Unicode"); +# endif + full_write2_str(")\n\n"); +# else + full_write2_str(" multi-call binary.\n"); /* reuse */ #endif full_write2_str( "BusyBox is copyrighted by many authors between 1998-2023.\n" @@ -1303,6 +1304,14 @@ int main(int argc UNUSED_PARAM, char **argv) } #endif #if ENABLE_PLATFORM_MINGW32 +# if ENABLE_FEATURE_UTF8_MANIFEST + if (GetACP() != CP_UTF8) { + full_write2_str(bb_basename(argv[0])); + full_write2_str(": needs UTF8 code page\n"); + return 1; + } +# endif + /* detect if we're running an interpreted script */ if (argv[0][1] == ':' && argv[0][2] == '/') { switch (argv[0][0]) { -- cgit v1.2.3-55-g6feb