Skip to content

Commit

Permalink
Toolchain: Only reextract GCC-related tarballs if patches change
Browse files Browse the repository at this point in the history
This brings the behaviour in line with Clang, which already does this
since a few revisions.
  • Loading branch information
timschumi authored and linusg committed Oct 1, 2022
1 parent 1faca15 commit b52b6e8
Showing 1 changed file with 51 additions and 41 deletions.
92 changes: 51 additions & 41 deletions Toolchain/BuildIt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -239,53 +239,63 @@ pushd "$DIR/Tarballs"
popd
fi

if [ -d ${BINUTILS_NAME} ]; then
rm -rf "${BINUTILS_NAME}"
rm -rf "$DIR/Build/$ARCH/$BINUTILS_NAME"
fi
echo "Extracting binutils..."
tar -xzf ${BINUTILS_PKG}

pushd ${BINUTILS_NAME}
if [ "$git_patch" = "1" ]; then
git init > /dev/null
git add . > /dev/null
git commit -am "BASE" > /dev/null
git am "$DIR"/Patches/binutils/*.patch > /dev/null
else
for patch in "$DIR"/Patches/binutils/*.patch; do
patch -p1 < "$patch" > /dev/null
done
patch_md5="$(${MD5SUM} "${DIR}"/Patches/binutils/*.patch)"

if [ ! -d "${BINUTILS_NAME}" ] || [ "$(cat ${BINUTILS_NAME}/.patch.applied)" != "${patch_md5}" ]; then
if [ -d ${BINUTILS_NAME} ]; then
rm -rf "${BINUTILS_NAME}"
rm -rf "${DIR}/Build/${ARCH}/${BINUTILS_NAME}"
fi
$MD5SUM "$DIR"/Patches/binutils/*.patch > .patch.applied
popd
echo "Extracting binutils..."
tar -xzf ${BINUTILS_PKG}

if [ -d ${GCC_NAME} ]; then
# Drop the previously patched extracted dir
rm -rf "${GCC_NAME}"
# Also drop the build dir
rm -rf "$DIR/Build/$ARCH/$GCC_NAME"
pushd ${BINUTILS_NAME}
if [ "${git_patch}" = "1" ]; then
git init > /dev/null
git add . > /dev/null
git commit -am "BASE" > /dev/null
git am "${DIR}"/Patches/binutils/*.patch > /dev/null
else
for patch in "${DIR}"/Patches/binutils/*.patch; do
patch -p1 < "${patch}" > /dev/null
done
fi
${MD5SUM} "${DIR}"/Patches/binutils/*.patch > .patch.applied
popd
else
echo "Using existing binutils source directory"
fi
echo "Extracting gcc..."
tar -xzf $GCC_PKG
pushd $GCC_NAME
if [ "$git_patch" = "1" ]; then
git init > /dev/null
git add . > /dev/null
git commit -am "BASE" > /dev/null
git am --keep-non-patch "$DIR"/Patches/gcc/*.patch > /dev/null
else
for patch in "$DIR"/Patches/gcc/*.patch; do
patch -p1 < "$patch" > /dev/null
done


patch_md5="$(${MD5SUM} "${DIR}"/Patches/gcc/*.patch)"

if [ ! -d "${GCC_NAME}" ] || [ "$(cat ${GCC_NAME}/.patch.applied)" != "${patch_md5}" ]; then
if [ -d ${GCC_NAME} ]; then
rm -rf "${GCC_NAME}"
rm -rf "${DIR}/Build/${ARCH}/${GCC_NAME}"
fi
$MD5SUM "$DIR"/Patches/gcc/*.patch > .patch.applied
popd
echo "Extracting gcc..."
tar -xzf ${GCC_PKG}

pushd ${GCC_NAME}
if [ "${git_patch}" = "1" ]; then
git init > /dev/null
git add . > /dev/null
git commit -am "BASE" > /dev/null
git am --keep-non-patch "${DIR}"/Patches/gcc/*.patch > /dev/null
else
for patch in "${DIR}"/Patches/gcc/*.patch; do
patch -p1 < "${patch}" > /dev/null
done
fi
${MD5SUM} "${DIR}"/Patches/gcc/*.patch > .patch.applied

if [ "$SYSTEM_NAME" = "Darwin" ]; then
pushd "gcc-${GCC_VERSION}"
./contrib/download_prerequisites
if [ "${SYSTEM_NAME}" = "Darwin" ]; then
./contrib/download_prerequisites
fi
popd
else
echo "Using existing GCC source directory"
fi
popd

Expand Down

0 comments on commit b52b6e8

Please sign in to comment.