From fbb0205db0ddcbe27020c0f14643d9d66be091e2 Mon Sep 17 00:00:00 2001 From: Stepan Usatiuk Date: Tue, 4 Jun 2024 14:48:52 +0200 Subject: [PATCH] CI: a bit more streamlined scripts --- ficus-toolchain/build-all.sh | 66 ++++++++++++++++----------------- ficus-toolchain/build-newlib.sh | 40 ++++++++++++++++---- ficus-toolchain/buildenv.sh | 19 ++++++++++ 3 files changed, 84 insertions(+), 41 deletions(-) create mode 100755 ficus-toolchain/buildenv.sh diff --git a/ficus-toolchain/build-all.sh b/ficus-toolchain/build-all.sh index 10a3a1276..845b2f644 100755 --- a/ficus-toolchain/build-all.sh +++ b/ficus-toolchain/build-all.sh @@ -1,16 +1,9 @@ #!/bin/bash -set -euxo pipefail - -if [ -z "$FICUS_ROOT" ]; then - echo "$FICUS_ROOT" is blank -fi export SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd) - -export PREFIX="$FICUS_ROOT/toolchain/gcc-x86_64-ficus-prefix/" -export TARGET=x86_64-ficus -export PATH="$PREFIX/bin:$PATH" - cd "$SCRIPT_DIR" +source buildenv.sh + +set -euxo pipefail if [ $# -eq 0 ] then @@ -18,28 +11,35 @@ if [ $# -eq 0 ] exit 1 fi -if [ -z "${BUILD_PARALLEL}" ] -then - export BUILD_PARALLEL=$(nproc) -fi -if [ -z "${BUILD_PARALLEL}" ] -then - export BUILD_PARALLEL=$BUILD_PARALLEL -fi - -if [[ "$1" != "s2only" ]] -then - "$SCRIPT_DIR"/build-s1.sh - cd "$SCRIPT_DIR" -fi - -if [[ "$1" = "s1only" ]] -then exit 0 -fi - mkdir -p "$FICUS_ROOT/sysroot" -"$SCRIPT_DIR"/build-newlib.sh -cd "$SCRIPT_DIR" -"$SCRIPT_DIR"/build-s2.sh -cd "$SCRIPT_DIR" +case "$1" in + "newlib") + "$SCRIPT_DIR"/build-newlib.sh noconf + ;; + "newlib-conf") + "$SCRIPT_DIR"/build-newlib.sh conf + ;; + "s2only") + "$SCRIPT_DIR"/build-newlib.sh conf + cd "$SCRIPT_DIR" + "$SCRIPT_DIR"/build-s2.sh + cd "$SCRIPT_DIR" + ;; + "s1only") + "$SCRIPT_DIR"/build-s1.sh + cd "$SCRIPT_DIR" + ;; + "all") + "$SCRIPT_DIR"/build-s1.sh + cd "$SCRIPT_DIR" + "$SCRIPT_DIR"/build-newlib.sh conf + cd "$SCRIPT_DIR" + "$SCRIPT_DIR"/build-s2.sh + cd "$SCRIPT_DIR" + ;; + *) + echo "Unknown command" + exit 1 + ;; +esac diff --git a/ficus-toolchain/build-newlib.sh b/ficus-toolchain/build-newlib.sh index b3b573b5f..6e37ce76a 100755 --- a/ficus-toolchain/build-newlib.sh +++ b/ficus-toolchain/build-newlib.sh @@ -1,20 +1,44 @@ #!/bin/bash set -euxo pipefail -if [ -z "$FICUS_ROOT" ]; then - echo "$FICUS_ROOT" is blank +if [ -z "$SCRIPT_DIR" ]; then + echo "SCRIPT_DIR" is blank! Run this via build-all fi -SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd) -export PREFIX="$FICUS_ROOT/toolchain/gcc-x86_64-ficus-prefix/" -export TARGET=x86_64-ficus -export PATH="$PREFIX/bin:$PATH" cd "$SCRIPT_DIR" + +if [ $# -eq 0 ] + then + echo "No arguments supplied" + exit 1 +fi + +case "$1" in + "conf") + ;; + "noconf") + ;; + *) + echo "Unknown option" + exit 1 + ;; +esac + cd newlib -# rm -rf build + +if [[ "$1" = "conf" ]] +then + rm -rf build +fi + mkdir -p build cd build -../newlib-4.4.0.20231231/configure --enable-newlib-supplied-syscalls --prefix=/usr --target=$TARGET + +if [[ "$1" = "conf" ]] +then + ../newlib-4.4.0.20231231/configure --enable-newlib-supplied-syscalls --prefix=/usr --target=$TARGET +fi + make -j$BUILD_PARALLEL all make DESTDIR="$FICUS_ROOT/sysroot" install cp -r "$FICUS_ROOT/sysroot/usr"/x86_64-ficus/* "$FICUS_ROOT/sysroot/usr" diff --git a/ficus-toolchain/buildenv.sh b/ficus-toolchain/buildenv.sh new file mode 100755 index 000000000..f88c98e1b --- /dev/null +++ b/ficus-toolchain/buildenv.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +if [ -z "$FICUS_ROOT" ]; then + echo "$FICUS_ROOT" is blank +fi + +export PREFIX="$FICUS_ROOT/toolchain/gcc-x86_64-ficus-prefix/" +export TARGET=x86_64-ficus +export PATH="$PREFIX/bin:$PATH" + +if [ -z "${BUILD_PARALLEL}" ] +then + export BUILD_PARALLEL=$(nproc) +fi + +if [ -z "${BUILD_PARALLEL}" ] +then + export BUILD_PARALLEL=$BUILD_PARALLEL +fi