Skip to content

Commit 7471191

Browse files
jwnrtluismarques
authored andcommitted
Add --clean option to clang script
1 parent 44b4d33 commit 7471191

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

build-clang-with-args.sh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ USAGE: ${0} [options] <args>
2626
OPTIONS:
2727
-h,--help Print this message
2828
--debug Build with assertions and debug info
29+
--clean Build from scratch
2930
3031
ARGS:
3132
--name <name> Name of the toolchain
@@ -34,7 +35,7 @@ ARGS:
3435
--mabi <mabi> Default -mabi
3536
--mcmodel <mcmodel> Default -mcmodel
3637
"
37-
options="$(getopt -a -o '-h' -l 'help,name:,target:,march:,mabi:,mcmodel:,debug' -- "$@")"
38+
options="$(getopt -a -o '-h' -l 'help,name:,target:,march:,mabi:,mcmodel:,debug,clean' -- "$@")"
3839

3940
err() {
4041
echo "ERROR ${1}" >&2
@@ -49,6 +50,7 @@ err() {
4950
[[ "$options" == *"--mcmodel"* ]] || err 'Missing argument `--mcmodel`'
5051

5152
build_type=Release
53+
clean=false
5254

5355
eval set -- "$options"
5456
while true; do
@@ -60,6 +62,7 @@ while true; do
6062
--mabi) mabi="$2"; shift 2;;
6163
--mcmodel) mcmodel="$2"; shift 2;;
6264
--debug) build_type=Debug; shift 1;;
65+
--clean) clean=true; shift 1;;
6366
--) shift; break;;
6467
esac
6568
done
@@ -94,8 +97,9 @@ lld_links_to_create+=";${toolchain_target}-ld.lld;${toolchain_target}-ld64.lld"
9497

9598
llvm_build_dir="${build_dir}/llvm-project/build"
9699

97-
# Delete old build artifacts (if they exist)
98-
rm -rf "${llvm_build_dir}"
100+
if [[ "$clean" == true ]]; then
101+
rm -rf "${llvm_build_dir}"
102+
fi
99103

100104
mkdir -p "${llvm_build_dir}"
101105
cd "${llvm_build_dir}"

0 commit comments

Comments
 (0)