[chore](thirdparty) Support cleaning extracted data before building them (#15458)

Currently, we may fail to build the third-party libraries if we keep the outdated extracted data.

Considering the following scenario, Bob added patches to some libraries and Alice updates the codebase and builds 
the third-party libraries. If Alice kept the outdated extracted data, she should fail to build the third-party libraries 
because the patches are not applied due to the outdated `patched_marks`.

This PR introduces a way to clean the outdated data before building the third-party libraries.
This commit is contained in:
Adonis Ling
2022-12-29 16:01:23 +08:00
committed by GitHub
parent c22ba8e160
commit 43c8e7b465

View File

@ -49,6 +49,7 @@ usage() {
Usage: $0 <options>
Optional options:
-j build thirdparty parallel
--clean clean the extracted data
"
exit 1
}
@ -58,6 +59,7 @@ if ! OPTS="$(getopt \
-o '' \
-o 'h' \
-l 'help' \
-l 'clean' \
-o 'j:' \
-- "$@")"; then
usage
@ -88,6 +90,10 @@ if [[ "$#" -ne 1 ]]; then
HELP=1
shift
;;
--clean)
CLEAN=1
shift
;;
--)
shift
break
@ -102,11 +108,11 @@ fi
if [[ "${HELP}" -eq 1 ]]; then
usage
exit
fi
echo "Get params:
PARALLEL -- ${PARALLEL}
CLEAN -- ${CLEAN}
"
if [[ ! -f "${TP_DIR}/download-thirdparty.sh" ]]; then
@ -123,6 +129,12 @@ fi
cd "${TP_DIR}"
if [[ "${CLEAN}" -eq 1 ]] && [[ -d "${TP_SOURCE_DIR}" ]]; then
echo 'Clean the extracted data ...'
find "${TP_SOURCE_DIR}" -mindepth 1 -maxdepth 1 -type d -exec rm -rf {} \;
echo 'Success!'
fi
# Download thirdparties.
"${TP_DIR}/download-thirdparty.sh"