[vlc-devel] [PATCH 1/2] package/win32: build.sh: add options to do build with Universal Runtime

Steve Lhomme robux4 at ycbcr.xyz
Thu Apr 9 13:59:52 CEST 2020


---
 extras/package/win32/build.sh | 46 ++++++++++++++++++++++++++++++++---
 1 file changed, 43 insertions(+), 3 deletions(-)

diff --git a/extras/package/win32/build.sh b/extras/package/win32/build.sh
index d3648f0423c..f192cbb341c 100755
--- a/extras/package/win32/build.sh
+++ b/extras/package/win32/build.sh
@@ -29,11 +29,12 @@ OPTIONS:
    -b <url>      Enable breakpad support and send crash reports to this URL
    -d            Create PDB files during the build
    -x            Add extra checks when compiling
+   -u            Use the Universal C Runtime
 EOF
 }
 
 ARCH="x86_64"
-while getopts "hra:pcli:sb:dx" OPTION
+while getopts "hra:pcli:sb:dxu" OPTION
 do
      case $OPTION in
          h)
@@ -71,6 +72,9 @@ do
          x)
              EXTRA_CHECKS="yes"
          ;;
+         u)
+             BUILD_UCRT="yes"
+         ;;
      esac
 done
 shift $(($OPTIND - 1))
@@ -156,9 +160,25 @@ else
 fi
 fi
 
+if [ ! -z "$BUILD_UCRT" ]; then
+    SHORTARCH="$SHORTARCH-ucrt"
+    CPPFLAGS="$CPPFLAGS -D_WIN32_WINNT=0x0A00 -DWINVER=0x0A00 -D_UNICODE -DUNICODE"
+    if [ ! "$COMPILING_WITH_CLANG" -gt 0 ]; then
+        ${CC} -dumpspecs | sed -e "s/-lmingwex/-lmingwex -lruntimeobject -lsynchronization/" -e "s/-lmsvcrt/-lucrt/" -e "s/-lkernel32/-lwindowsapp/" > ../newspecfile
+        NEWSPECFILE="$PWD/../newspecfile"
+        CC="${CC} -specs=$NEWSPECFILE"
+        CXX="${CXX} -specs=$NEWSPECFILE"
+    else
+        # Clang doesn't support spec files, but will skip the builtin -lmsvcrt and -lkernel32 etc if it detects -lmsvcr* or -lucrt*, and
+        # -lwindowsapp on the command line.
+        LDFLAGS="$LDFLAGS -lruntimeobject -lsynchronization -lnormaliz -lucrt -lwindowsapp"
+    fi
+fi
+
 info "Building contribs"
 echo $PATH
 
+CONTRIB_PREFIX=$TRIPLET
 mkdir -p contrib/contrib-$SHORTARCH && cd contrib/contrib-$SHORTARCH
 if [ ! -z "$WITH_PDB" ]; then
     CONTRIBFLAGS="$CONTRIBFLAGS --enable-pdb"
@@ -169,7 +189,22 @@ fi
 if [ "$RELEASE" != "yes" ]; then
      CONTRIBFLAGS="$CONTRIBFLAGS --disable-optim"
 fi
-${SCRIPT_PATH}/../../../contrib/bootstrap --host=$TRIPLET $CONTRIBFLAGS
+if [ ! -z "$BUILD_UCRT" ]; then
+    CONTRIB_PREFIX="$CONTRIB_PREFIX$BUILD_UCRT"
+fi
+
+if [ ! -z "$BUILD_UCRT" ]; then
+    echo "EXTRA_CFLAGS=${CPPFLAGS}" >> config.mak
+    echo "EXTRA_CXXFLAGS=${CPPFLAGS}" >> config.mak
+    echo "LDFLAGS=${LDFLAGS}" >> config.mak
+    echo "WIDL=${BASE_TRIPLET}-widl" >> config.mak
+    if [ ! "$COMPILING_WITH_CLANG" -gt 0 ]; then
+        echo "CC=${CC}" >> config.mak
+        echo "CXX=${CXX}" >> config.mak
+    fi
+fi
+
+${SCRIPT_PATH}/../../../contrib/bootstrap --host=$TRIPLET --prefix=../$CONTRIB_PREFIX $CONTRIBFLAGS
 
 # Rebuild the contribs or use the prebuilt ones
 if [ "$PREBUILT" != "yes" ]; then
@@ -230,12 +265,17 @@ fi
 if [ ! -z "$WITH_PDB" ]; then
     CONFIGFLAGS="$CONFIGFLAGS --enable-pdb"
 fi
+if [ ! -z "$BUILD_UCRT" ]; then
+    CFLAGS="$CFLAGS $CPPFLAGS"
+    CXXFLAGS="$CXXFLAGS $CPPFLAGS"
+fi
 if [ ! -z "$EXTRA_CHECKS" ]; then
     CFLAGS="$CFLAGS -Werror=incompatible-pointer-types -Werror=missing-field-initializers"
     CXXFLAGS="$CXXFLAGS -Werror=missing-field-initializers"
 fi
 
-${SCRIPT_PATH}/configure.sh --host=$TRIPLET --with-contrib=../contrib/$TRIPLET $CONFIGFLAGS
+LDFLAGS="$LDFLAGS" \
+${SCRIPT_PATH}/configure.sh --host=$TRIPLET --with-contrib=../contrib/$CONTRIB_PREFIX $CONFIGFLAGS
 
 info "Compiling"
 make -j$JOBS
-- 
2.17.1



More information about the vlc-devel mailing list