Bug 1407359 Set up a framework for patching the MinGW toolchain draft
authorTom Ritter <tom@mozilla.com>
Mon, 16 Oct 2017 20:52:47 -0500
changeset 681146 27ad8a8fc285d2b9fe92eccae367edca60f1c3d0
parent 677727 0330ad5ff129ea559f1d726e1b33a872792ac8a7
child 682909 a91f85ee03443a9bfe0bc449656cd827b5f808c7
push id84771
push userbmo:tom@mozilla.com
push dateTue, 17 Oct 2017 01:53:15 +0000
bugs1407359
milestone58.0a1
Bug 1407359 Set up a framework for patching the MinGW toolchain MozReview-Commit-ID: 8HtjLXAIXTP
build/unix/build-gcc/build-gcc.sh
taskcluster/scripts/misc/build-gcc-mingw32.sh
--- a/build/unix/build-gcc/build-gcc.sh
+++ b/build/unix/build-gcc/build-gcc.sh
@@ -61,18 +61,36 @@ prepare() {
 
   # Check all the downloads we did are in the checksums list, and that the
   # checksums match.
   diff -u <(sort -k 2 $root_dir/downloads) $root_dir/checksums
 
   popd
 }
 
+prepare_mingw() {
+  export install_dir=$root_dir/tools/gcc/
+  mkdir -p $install_dir
+  export PATH=$PATH:$install_dir/bin/
+
+  cd $root_dir
+
+  git clone -n git://git.code.sf.net/p/mingw-w64/mingw-w64
+  pushd mingw-w64
+  git checkout $mingw_version # Asserts the integrity of the checkout (Right?)
+  popd
+}
+
 apply_patch() {
-  pushd $root_dir/gcc-$gcc_version
+  if [ $# -ge 2 ]; then
+    pushd $root_dir/$1
+    shift
+  else
+    pushd $root_dir/gcc-$gcc_version
+  fi
   patch -p1 < $1
   popd
 }
 
 build_binutils() {
   # if binutils_configure_flags is not set at all, give it the default value
   if [ -z "${binutils_configure_flags+xxx}" ];
   then
@@ -97,27 +115,16 @@ build_gcc() {
   make $make_flags install DESTDIR=$root_dir
 
   cd $root_dir/tools
   tar caf $root_dir/gcc.tar.xz gcc/
   popd
 }
 
 build_gcc_and_mingw() {
-  export install_dir=$root_dir/tools/gcc/
-  mkdir -p $install_dir
-  export PATH=$PATH:$install_dir/bin/
-
-  cd $root_dir
-
-  git clone -n git://git.code.sf.net/p/mingw-w64/mingw-w64
-  pushd mingw-w64
-  git checkout $mingw_version # Asserts the integrity of the checkout (Right?)
-  popd
-
   mkdir gcc-objdir
   pushd gcc-objdir
   ../gcc-$gcc_version/configure --prefix=$install_dir --target=i686-w64-mingw32 --with-gnu-ld --with-gnu-as --disable-multilib --enable-threads=posix
   make $make_flags all-gcc
   make $make_flags install-gcc
   popd
 
   mkdir mingw-w64-headers32
--- a/taskcluster/scripts/misc/build-gcc-mingw32.sh
+++ b/taskcluster/scripts/misc/build-gcc-mingw32.sh
@@ -37,14 +37,15 @@ 369737ce51587f92466041a97ab7d2358c6d9e1b
 850bf21eafdfe5cd5f6827148184c08c4a0852a37ccf36ce69855334d2c914d4  gcc-6.4.0.tar.xz
 752079520b4690531171d0f4532e40f08600215feefede70b24fabdc6f1ab160  gmp-5.1.3.tar.bz2
 8ceebbf4d9a81afa2b4449113cee4b7cb14a687d7a549a963deb5e2a41458b6b  isl-0.15.tar.bz2
 ae79f8d41d8a86456b68607e9ca398d00f8b7342d1d83bcf4428178ac45380c7  mpc-0.8.2.tar.gz
 ca498c1c7a74dd37a576f353312d1e68d490978de4395fa28f1cbd46a364e658  mpfr-3.1.5.tar.bz2
 EOF
 
 prepare
+prepare_mingw
 build_binutils
 build_gcc_and_mingw
 
 # Put a tarball in the artifacts dir
 mkdir -p $UPLOAD_DIR
 cp $root_dir/mingw32.tar.* $UPLOAD_DIR