diff --git a/config/psptoolchain-allegrex-config .sh b/config/psptoolchain-allegrex-config .sh new file mode 100644 index 0000000..e71842a --- /dev/null +++ b/config/psptoolchain-allegrex-config .sh @@ -0,0 +1,14 @@ +#!/bin/bash + +PSPTOOLCHAIN_ALLEGREX_BINUTILS_REPO_URL="https://github.com/pspdev/binutils-gdb.git" +PSPTOOLCHAIN_ALLEGREX_BINUTILS_DEFAULT_REPO_REF="allegrex-v2.37.0" +PSPTOOLCHAIN_ALLEGREX_GCC_REPO_URL="https://github.com/pspdev/gcc.git" +PSPTOOLCHAIN_ALLEGREX_GCC_DEFAULT_REPO_REF="allegrex-v13.2.0" +PSPTOOLCHAIN_ALLEGREX_NEWLIB_REPO_URL="https://github.com/pspdev/newlib.git" +PSPTOOLCHAIN_ALLEGREX_NEWLIB_DEFAULT_REPO_REF="allegrex-v4.4.0" +PSPTOOLCHAIN_ALLEGREX_PTHREAD_EMBEDDED_REPO_URL="https://github.com/pspdev/pthread-embedded.git" +PSPTOOLCHAIN_ALLEGREX_PTHREAD_EMBEDDED_DEFAULT_REPO_REF="platform_agnostic" + +if test -f "$PSPDEV_CONFIG_OVERRIDE"; then + source "$PSPDEV_CONFIG_OVERRIDE" +fi \ No newline at end of file diff --git a/scripts/001-binutils.sh b/scripts/001-binutils.sh index 52222fb..9da532f 100755 --- a/scripts/001-binutils.sh +++ b/scripts/001-binutils.sh @@ -1,14 +1,33 @@ #!/bin/bash -# binutils.sh by Francisco Javier Trujillo Mata (fjtrujy@gmail.com) +# 001-binutils.sh by pspdev developers + +## Exit with code 1 when any command executed returns a non-zero exit code. +onerr() +{ + exit 1; +} +trap onerr ERR + +## Read information from the configuration file. +source "$(dirname "$0")/../config/psptoolchain-allegrex-config.sh" ## Download the source code. -REPO_URL="https://github.com/pspdev/binutils-gdb.git" -REPO_FOLDER="binutils-gdb" -BRANCH_NAME="allegrex-v2.37.0" +REPO_URL="$PSPTOOLCHAIN_ALLEGREX_BINUTILS_REPO_URL" +REPO_REF="$PSPTOOLCHAIN_ALLEGREX_BINUTILS_DEFAULT_REPO_REF" +REPO_FOLDER="$(s="$REPO_URL"; s=${s##*/}; printf "%s" "${s%.*}")" + +# Checking if a specific Git reference has been passed in parameter $1 +if test -n "$1"; then + REPO_REF="$1" + printf 'Using specified repo reference %s\n' "$REPO_REF" +fi + if test ! -d "$REPO_FOLDER"; then - git clone --depth 1 -b $BRANCH_NAME $REPO_URL $REPO_FOLDER && cd $REPO_FOLDER || { exit 1; } + git clone --depth 1 -b "$REPO_REF" "$REPO_URL" "$REPO_FOLDER" else - cd $REPO_FOLDER && git fetch origin && git reset --hard origin/${BRANCH_NAME} || { exit 1; } + git -C "$REPO_FOLDER" fetch origin + git -C "$REPO_FOLDER" reset --hard "origin/$REPO_REF" + git -C "$REPO_FOLDER" checkout "$REPO_REF" fi TARGET="psp" diff --git a/scripts/002-gcc-stage1.sh b/scripts/002-gcc-stage1.sh index 457512b..0ece950 100755 --- a/scripts/002-gcc-stage1.sh +++ b/scripts/002-gcc-stage1.sh @@ -1,14 +1,33 @@ #!/bin/bash -# gcc-stage1.sh by Francisco Javier Trujillo Mata (fjtrujy@gmail.com) +# 002-gcc-stage1.sh by pspdev developers + +## Exit with code 1 when any command executed returns a non-zero exit code. +onerr() +{ + exit 1; +} +trap onerr ERR + +## Read information from the configuration file. +source "$(dirname "$0")/../config/psptoolchain-allegrex-config.sh" ## Download the source code. -REPO_URL="https://github.com/pspdev/gcc.git" -REPO_FOLDER="gcc" -BRANCH_NAME="allegrex-v11.2.0" +REPO_URL="$PSPTOOLCHAIN_ALLEGREX_GCC_REPO_URL" +REPO_REF="$PSPTOOLCHAIN_ALLEGREX_GCC_DEFAULT_REPO_REF" +REPO_FOLDER="$(s="$REPO_URL"; s=${s##*/}; printf "%s" "${s%.*}")" + +# Checking if a specific Git reference has been passed in parameter $1 +if test -n "$1"; then + REPO_REF="$1" + printf 'Using specified repo reference %s\n' "$REPO_REF" +fi + if test ! -d "$REPO_FOLDER"; then - git clone --depth 1 -b $BRANCH_NAME $REPO_URL $REPO_FOLDER && cd $REPO_FOLDER || { exit 1; } + git clone --depth 1 -b "$REPO_REF" "$REPO_URL" "$REPO_FOLDER" else - cd $REPO_FOLDER && git fetch origin && git reset --hard origin/${BRANCH_NAME} || { exit 1; } + git -C "$REPO_FOLDER" fetch origin + git -C "$REPO_FOLDER" reset --hard "origin/$REPO_REF" + git -C "$REPO_FOLDER" checkout "$REPO_REF" fi TARGET="psp" diff --git a/scripts/003-newlib.sh b/scripts/003-newlib.sh index 229979a..b26eebd 100755 --- a/scripts/003-newlib.sh +++ b/scripts/003-newlib.sh @@ -1,14 +1,33 @@ #!/bin/bash -# newlib.sh by Francisco Javier Trujillo Mata (fjtrujy@gmail.com) +# 003-newlib.sh by pspdev developers + +## Exit with code 1 when any command executed returns a non-zero exit code. +onerr() +{ + exit 1; +} +trap onerr ERR + +## Read information from the configuration file. +source "$(dirname "$0")/../config/psptoolchain-allegrex-config.sh" ## Download the source code. -REPO_URL="https://github.com/pspdev/newlib.git" -REPO_FOLDER="newlib" -BRANCH_NAME="allegrex-v4.3.0" +REPO_URL="$PSPTOOLCHAIN_ALLEGREX_NEWLIB_REPO_URL" +REPO_REF="$PSPTOOLCHAIN_ALLEGREX_NEWLIB_DEFAULT_REPO_REF" +REPO_FOLDER="$(s="$REPO_URL"; s=${s##*/}; printf "%s" "${s%.*}")" + +# Checking if a specific Git reference has been passed in parameter $1 +if test -n "$1"; then + REPO_REF="$1" + printf 'Using specified repo reference %s\n' "$REPO_REF" +fi + if test ! -d "$REPO_FOLDER"; then - git clone --depth 1 -b $BRANCH_NAME $REPO_URL && cd $REPO_FOLDER || { exit 1; } + git clone --depth 1 -b "$REPO_REF" "$REPO_URL" "$REPO_FOLDER" else - cd $REPO_FOLDER && git fetch origin && git reset --hard origin/${BRANCH_NAME} && git checkout ${BRANCH_NAME} || { exit 1; } + git -C "$REPO_FOLDER" fetch origin + git -C "$REPO_FOLDER" reset --hard "origin/$REPO_REF" + git -C "$REPO_FOLDER" checkout "$REPO_REF" fi TARGET="psp" diff --git a/scripts/004-pthread-embedded.sh b/scripts/004-pthread-embedded.sh index adb8efe..da178a7 100755 --- a/scripts/004-pthread-embedded.sh +++ b/scripts/004-pthread-embedded.sh @@ -1,14 +1,33 @@ #!/bin/bash -# pthread-embedded.sh by Francisco Javier Trujillo Mata (fjtrujy@gmail.com) +# 004-pthread-embeedded.sh by pspdev developers + +## Exit with code 1 when any command executed returns a non-zero exit code. +onerr() +{ + exit 1; +} +trap onerr ERR + +## Read information from the configuration file. +source "$(dirname "$0")/../config/psptoolchain-allegrex-config.sh" ## Download the source code. -REPO_URL="https://github.com/pspdev/pthread-embedded.git" -REPO_FOLDER="pthread-embedded" -BRANCH_NAME="psp" +REPO_URL="$PSPTOOLCHAIN_ALLEGREX_PTHREAD_EMBEDDED_REPO_URL" +REPO_REF="$PSPTOOLCHAIN_ALLEGREX_PTHREAD_EMBEDDED_DEFAULT_REPO_REF" +REPO_FOLDER="$(s="$REPO_URL"; s=${s##*/}; printf "%s" "${s%.*}")" + +# Checking if a specific Git reference has been passed in parameter $1 +if test -n "$1"; then + REPO_REF="$1" + printf 'Using specified repo reference %s\n' "$REPO_REF" +fi + if test ! -d "$REPO_FOLDER"; then - git clone --depth 1 -b $BRANCH_NAME $REPO_URL && cd $REPO_FOLDER || { exit 1; } + git clone --depth 1 -b "$REPO_REF" "$REPO_URL" "$REPO_FOLDER" else - cd $REPO_FOLDER && git fetch origin && git reset --hard origin/${BRANCH_NAME} && git checkout ${BRANCH_NAME} || { exit 1; } + git -C "$REPO_FOLDER" fetch origin + git -C "$REPO_FOLDER" reset --hard "origin/$REPO_REF" + git -C "$REPO_FOLDER" checkout "$REPO_REF" fi TARGET="psp" diff --git a/scripts/005-gcc-stage2.sh b/scripts/005-gcc-stage2.sh index 8c1fc82..48391e0 100755 --- a/scripts/005-gcc-stage2.sh +++ b/scripts/005-gcc-stage2.sh @@ -1,14 +1,33 @@ #!/bin/bash -# gcc-stage2.sh by Francisco Javier Trujillo Mata (fjtrujy@gmail.com) +# 005-gcc-stage2.sh by pspdev developers + +## Exit with code 1 when any command executed returns a non-zero exit code. +onerr() +{ + exit 1; +} +trap onerr ERR + +## Read information from the configuration file. +source "$(dirname "$0")/../config/psptoolchain-allegrex-config.sh" ## Download the source code. -REPO_URL="https://github.com/pspdev/gcc.git" -REPO_FOLDER="gcc" -BRANCH_NAME="allegrex-v11.2.0" +REPO_URL="$PSPTOOLCHAIN_ALLEGREX_GCC_REPO_URL" +REPO_REF="$PSPTOOLCHAIN_ALLEGREX_GCC_DEFAULT_REPO_REF" +REPO_FOLDER="$(s="$REPO_URL"; s=${s##*/}; printf "%s" "${s%.*}")" + +# Checking if a specific Git reference has been passed in parameter $1 +if test -n "$1"; then + REPO_REF="$1" + printf 'Using specified repo reference %s\n' "$REPO_REF" +fi + if test ! -d "$REPO_FOLDER"; then - git clone --depth 1 -b $BRANCH_NAME $REPO_URL && cd $REPO_FOLDER || { exit 1; } + git clone --depth 1 -b "$REPO_REF" "$REPO_URL" "$REPO_FOLDER" else - cd $REPO_FOLDER && git fetch origin && git reset --hard origin/${BRANCH_NAME} || { exit 1; } + git -C "$REPO_FOLDER" fetch origin + git -C "$REPO_FOLDER" reset --hard "origin/$REPO_REF" + git -C "$REPO_FOLDER" checkout "$REPO_REF" fi TARGET="psp"