From 2a16b960b6c0243104d400809783d3dfb4bd8e03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Radek=20Barto=C5=88?= Date: Tue, 21 Nov 2023 17:09:28 +0100 Subject: [PATCH] Share same config between build scripts (#49) --- .github/scripts/build-binutils.sh | 14 ++--------- .github/scripts/build-gcc-libs.sh | 6 +---- .github/scripts/build-gcc.sh | 14 ++--------- .github/scripts/build-libgcc.sh | 6 +---- .github/scripts/build-mingw-crt.sh | 33 ++----------------------- .github/scripts/build-mingw-headers.sh | 24 ++---------------- .github/scripts/build-mingw.sh | 33 ++----------------------- .github/scripts/build.sh | 7 +----- .github/scripts/config-mingw.sh | 24 ++++++++++++++++++ .github/scripts/config.sh | 15 +++++++++++ .github/scripts/install-dependencies.sh | 3 +-- .github/scripts/install-libraries.sh | 13 +++------- 12 files changed, 57 insertions(+), 135 deletions(-) create mode 100644 .github/scripts/config-mingw.sh create mode 100644 .github/scripts/config.sh diff --git a/.github/scripts/build-binutils.sh b/.github/scripts/build-binutils.sh index f789dd10d..0a4105302 100755 --- a/.github/scripts/build-binutils.sh +++ b/.github/scripts/build-binutils.sh @@ -1,22 +1,12 @@ #!/bin/bash -BINUTILS_VERSION=${BINUTILS_VERSION:-binutils-master} - -TARGET=${TARGET:-aarch64-w64-mingw32} -BUILD_PATH=${BUILD_PATH:-$PWD/build-$TARGET} -BUILD_MAKE_OPTIONS=-j$(nproc) -INSTALL_PATH=${INSTALL_PATH:-~/cross} - -export PATH=$INSTALL_PATH/bin:$PATH - -set -e # exit on error -set -x # echo on +source `dirname $0`/config.sh mkdir -p $BUILD_PATH/binutils cd $BUILD_PATH/binutils echo "::group::Configure binutils" -../../code/$BINUTILS_VERSION/configure \ +$SOURCE_PATH/$BINUTILS_VERSION/configure \ --prefix=$INSTALL_PATH \ --target=$TARGET echo "::endgroup::" diff --git a/.github/scripts/build-gcc-libs.sh b/.github/scripts/build-gcc-libs.sh index 7e3612b71..0793b6f77 100755 --- a/.github/scripts/build-gcc-libs.sh +++ b/.github/scripts/build-gcc-libs.sh @@ -1,10 +1,6 @@ #!/bin/bash -TARGET=${TARGET:-aarch64-w64-mingw32} -BUILD_PATH=${BUILD_PATH:-$PWD/build-$TARGET} -BUILD_MAKE_OPTIONS=-j$(nproc) - -export PATH=$INSTALL_PATH/bin:$PATH +source `dirname $0`/config.sh cd $BUILD_PATH/gcc diff --git a/.github/scripts/build-gcc.sh b/.github/scripts/build-gcc.sh index 31ae1301c..84d05f8d1 100755 --- a/.github/scripts/build-gcc.sh +++ b/.github/scripts/build-gcc.sh @@ -1,16 +1,6 @@ #!/bin/bash -GCC_VERSION=${GCC_VERSION:-gcc-master} - -TARGET=${TARGET:-aarch64-w64-mingw32} -BUILD_PATH=${BUILD_PATH:-$PWD/build-$TARGET} -BUILD_MAKE_OPTIONS=-j$(nproc) -INSTALL_PATH=${INSTALL_PATH:-~/cross} - -export PATH=$INSTALL_PATH/bin:$PATH - -set -e # exit on error -set -x # echo on +source `dirname $0`/config.sh mkdir -p $BUILD_PATH/gcc @@ -19,7 +9,7 @@ cd $BUILD_PATH/gcc echo "::group::Configure GCC" # REMOVED --libexecdir=/opt/lib # REMOVED --with-{gmp,mpfr,mpc,isl}=/usr -../../code/$GCC_VERSION/configure \ +$SOURCE_PATH/$GCC_VERSION/configure \ --prefix=$INSTALL_PATH \ --target=$TARGET \ --enable-languages=c,lto,c++,fortran \ diff --git a/.github/scripts/build-libgcc.sh b/.github/scripts/build-libgcc.sh index 9345d9ec2..3b4d92f65 100755 --- a/.github/scripts/build-libgcc.sh +++ b/.github/scripts/build-libgcc.sh @@ -1,10 +1,6 @@ #!/bin/bash -TARGET=${TARGET:-aarch64-w64-mingw32} -BUILD_PATH=${BUILD_PATH:-$PWD/build-$TARGET} -BUILD_MAKE_OPTIONS=-j$(nproc) - -export PATH=$INSTALL_PATH/bin:$PATH +source `dirname $0`/config.sh cd $BUILD_PATH/gcc diff --git a/.github/scripts/build-mingw-crt.sh b/.github/scripts/build-mingw-crt.sh index 8d46c0fe6..03aedca57 100755 --- a/.github/scripts/build-mingw-crt.sh +++ b/.github/scripts/build-mingw-crt.sh @@ -1,41 +1,12 @@ #!/bin/bash -MINGW_VERSION=${MINGW_VERSION:-mingw-w64-master} - -TARGET=${TARGET:-aarch64-w64-mingw32} -CRT=${CRT:-msvcrt} -BUILD_PATH=${BUILD_PATH:-$PWD/build-$TARGET} -BUILD_MAKE_OPTIONS=-j$(nproc) -INSTALL_PATH=${INSTALL_PATH:-~/cross} - -case "$TARGET" in - x86_64*) - MINGW_CONF="$MINGW_CONF --disable-lib32 --enable-lib64 --disable-libarm32 --disable-libarm64" - ;; - aarch64*) - MINGW_CONF="$MINGW_CONF --disable-lib32 --disable-lib64 --disable-libarm32 --enable-libarm64" - ;; -esac - -case "$CRT" in - ucrt) - MINGW_CONF="$MINGW_CONF --with-default-msvcrt=ucrt" - ;; - msvcrt) - MINGW_CONF="$MINGW_CONF --with-default-msvcrt=msvcrt" - ;; -esac - -export PATH=$INSTALL_PATH/bin:$PATH - -set -e # exit on error -set -x # echo on +source `dirname $0`/config-mingw.sh mkdir -p $BUILD_PATH/mingw cd $BUILD_PATH/mingw echo "::group::Configure MinGW CRT" -../../code/$MINGW_VERSION/mingw-w64-crt/configure \ +$SOURCE_PATH/$MINGW_VERSION/mingw-w64-crt/configure \ --prefix=$INSTALL_PATH/$TARGET \ --build=x86_64-linux-gnu \ --host=$TARGET \ diff --git a/.github/scripts/build-mingw-headers.sh b/.github/scripts/build-mingw-headers.sh index 13a8c10ff..ef50951bc 100755 --- a/.github/scripts/build-mingw-headers.sh +++ b/.github/scripts/build-mingw-headers.sh @@ -1,32 +1,12 @@ #!/bin/bash -MINGW_VERSION=${MINGW_VERSION:-mingw-w64-master} - -TARGET=${TARGET:-aarch64-w64-mingw32} -CRT=${CRT:-msvcrt} -BUILD_PATH=${BUILD_PATH:-$PWD/build-$TARGET} -BUILD_MAKE_OPTIONS=-j$(nproc) -INSTALL_PATH=${INSTALL_PATH:-~/cross} - -case "$CRT" in - ucrt) - MINGW_CONF="$MINGW_CONF --with-default-msvcrt=ucrt" - ;; - msvcrt) - MINGW_CONF="$MINGW_CONF --with-default-msvcrt=msvcrt" - ;; -esac - -export PATH=$INSTALL_PATH/bin:$PATH - -set -e # exit on error -set -x # echo on +source `dirname $0`/config-mingw.sh mkdir -p $BUILD_PATH/mingw-headers cd $BUILD_PATH/mingw-headers echo "::group::Configure MinGW headers" -../../code/$MINGW_VERSION/mingw-w64-headers/configure \ +$SOURCE_PATH/$MINGW_VERSION/mingw-w64-headers/configure \ --prefix=$INSTALL_PATH/$TARGET \ --host=$TARGET \ $MINGW_CONF diff --git a/.github/scripts/build-mingw.sh b/.github/scripts/build-mingw.sh index 9a8389807..22ab8d960 100755 --- a/.github/scripts/build-mingw.sh +++ b/.github/scripts/build-mingw.sh @@ -1,40 +1,11 @@ #!/bin/bash -MINGW_VERSION=${MINGW_VERSION:-mingw-w64-master} - -TARGET=${TARGET:-aarch64-w64-mingw32} -CRT=${CRT:-msvcrt} -BUILD_PATH=${BUILD_PATH:-$PWD/build-$TARGET} -BUILD_MAKE_OPTIONS=-j$(nproc) -INSTALL_PATH=${INSTALL_PATH:-~/cross} - -case "$TARGET" in - x86_64*) - MINGW_CONF="$MINGW_CONF --disable-lib32 --enable-lib64 --disable-libarm32 --disable-libarm64" - ;; - aarch64*) - MINGW_CONF="$MINGW_CONF --disable-lib32 --disable-lib64 --disable-libarm32 --enable-libarm64" - ;; -esac - -case "$CRT" in - ucrt) - MINGW_CONF="$MINGW_CONF --with-default-msvcrt=ucrt" - ;; - msvcrt) - MINGW_CONF="$MINGW_CONF --with-default-msvcrt=msvcrt" - ;; -esac - -export PATH=$INSTALL_PATH/bin:$PATH - -set -e # exit on error -set -x # echo on +source `dirname $0`/config-mingw.sh cd $BUILD_PATH/mingw echo "::group::Configure MinGW libraries" -../../code/$MINGW_VERSION/configure \ +$SOURCE_PATH/$MINGW_VERSION/configure \ --prefix=$INSTALL_PATH/$TARGET \ --host=$TARGET \ --disable-shared \ diff --git a/.github/scripts/build.sh b/.github/scripts/build.sh index 3c9d77894..0d3a671f3 100755 --- a/.github/scripts/build.sh +++ b/.github/scripts/build.sh @@ -1,11 +1,6 @@ #!/bin/bash -set -e # exit on error -set -x # echo on - -export TARGET=${TARGET:-aarch64-w64-mingw32} -export CRT=${CRT:-msvcrt} -export INSTALL_PATH=${INSTALL_PATH:-~/cross} +source `dirname $0`/config-mingw.sh .github/scripts/build-binutils.sh .github/scripts/build-mingw-headers.sh diff --git a/.github/scripts/config-mingw.sh b/.github/scripts/config-mingw.sh new file mode 100644 index 000000000..c986b928b --- /dev/null +++ b/.github/scripts/config-mingw.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +source `dirname $0`/config.sh + +MINGW_VERSION=${MINGW_VERSION:-mingw-w64-master} +CRT=${CRT:-msvcrt} + +case "$TARGET" in + x86_64*) + MINGW_CONF="$MINGW_CONF --disable-lib32 --enable-lib64 --disable-libarm32 --disable-libarm64" + ;; + aarch64*) + MINGW_CONF="$MINGW_CONF --disable-lib32 --disable-lib64 --disable-libarm32 --enable-libarm64" + ;; +esac + +case "$CRT" in + ucrt) + MINGW_CONF="$MINGW_CONF --with-default-msvcrt=ucrt" + ;; + msvcrt) + MINGW_CONF="$MINGW_CONF --with-default-msvcrt=msvcrt" + ;; +esac diff --git a/.github/scripts/config.sh b/.github/scripts/config.sh new file mode 100644 index 000000000..2edc9d03f --- /dev/null +++ b/.github/scripts/config.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +set -e # exit on error +set -x # echo on + +GCC_VERSION=${GCC_VERSION:-gcc-master} +BINUTILS_VERSION=${BINUTILS_VERSION:-binutils-master} + +TARGET=${TARGET:-aarch64-w64-mingw32} +SOURCE_PATH=${SOURCE_PATH:-$PWD/code} +BUILD_PATH=${BUILD_PATH:-$PWD/build-$TARGET} +BUILD_MAKE_OPTIONS=${BUILD_MAKE_OPTIONS:--j$(nproc)} +INSTALL_PATH=${INSTALL_PATH:-~/cross} + +PATH=$INSTALL_PATH/bin:$PATH diff --git a/.github/scripts/install-dependencies.sh b/.github/scripts/install-dependencies.sh index 9da4a584a..124a61bae 100755 --- a/.github/scripts/install-dependencies.sh +++ b/.github/scripts/install-dependencies.sh @@ -1,7 +1,6 @@ #!/bin/bash -set -e # stop at first error -set -x # echo on +source `dirname $0`/config.sh echo "::group::Install Dependencies" sudo apt update diff --git a/.github/scripts/install-libraries.sh b/.github/scripts/install-libraries.sh index 57077457f..3f1856c68 100755 --- a/.github/scripts/install-libraries.sh +++ b/.github/scripts/install-libraries.sh @@ -1,18 +1,13 @@ #!/bin/bash -BINUTILS_VERSION=${BINUTILS_VERSION:-binutils-master} -GCC_VERSION=${GCC_VERSION:-gcc-master} +source `dirname $0`/config.sh -CODE_PATH=${CODE_PATH:-$PWD/code} MPFR_VERSION=mpfr-4.1.0 GMP_VERSION=gmp-6.2.1 MPC_VERSION=mpc-1.2.1 ISL_VERSION=isl-0.24 WGET_OPTIONS="-nc -P downloads" -set -e # exit on error -set -x # echo on - echo "::group::Install libraries" # Download packages @@ -22,18 +17,18 @@ wget $WGET_OPTIONS https://gcc.gnu.org/pub/gcc/infrastructure/$MPC_VERSION.tar.g wget $WGET_OPTIONS https://gcc.gnu.org/pub/gcc/infrastructure/$ISL_VERSION.tar.bz2 # Extract everything -cd $CODE_PATH +cd $SOURCE_PATH for f in ../downloads/*.tar*; do tar xf $f --skip-old-files; done # Symbolic links for binutils dependencies -cd $CODE_PATH/$BINUTILS_VERSION +cd $SOURCE_PATH/$BINUTILS_VERSION ln -sf `ls -1d ../mpfr-*/` mpfr ln -sf `ls -1d ../gmp-*/` gmp ln -sf `ls -1d ../mpc-*/` mpc ln -sf `ls -1d ../isl-*/` isl # Symbolic links for GCC dependencies -cd $CODE_PATH/$GCC_VERSION +cd $SOURCE_PATH/$GCC_VERSION ln -sf `ls -1d ../mpfr-*/` mpfr ln -sf `ls -1d ../gmp-*/` gmp ln -sf `ls -1d ../mpc-*/` mpc