#!/usr/bin/env bash # Shorthand script for adding/removing llvm subprojects. It has a simpler # interface than llvm.py, but it calls it to do the actual work. prog=$(basename $0) progdir=$(dirname $0) syntax() { echo "Syntax: $prog [clang|lldb|lld|rt|libs|all|none] {+/-}[c|r|k|d|l|a|u|t]" echo " no args: List linked projects" echo " clang: Clang" echo " lldb: Clang + lldb" echo " lld: Clang + lld" echo " rt: Clang + compiler-rt" echo " libs: Clang + libcxx + libcxxabi + libunwind" echo " all: Link all projects" echo " none: Unlink all projects" echo " {+/-}: enable / disable projects" echo " c Clang" echo " r Compiler-rt" echo " k lld" echo " d lldb" echo " l libcxx" echo " a libcxxabi" echo " u libunwind" echo " t test-suite" echo " Long options unlink everything before proceeding. Use the short options for fine-tuning" } need_all() { need=$1 clang=$need rt=$need libcxx=$need libcxxabi=$need libunwind=$need lld=$need lldb=$need tests=$need } llvmtool=$progdir/../scripts/llvm.py # Grab the environment name from $LLVM_SRC . llvm-common verify_env repos=$LLVM_ROOT/repos env=$(dirname $LLVM_SRC) # No args, list if [ "$1" = "" ]; then echo "Use $prog -h for options" echo safe_run python3 $llvmtool --repos $repos --env $env projects exit fi need_all UNDEF # See if the first option is one of the long options opt=$1 case $opt in clang) need_all OFF clang=ON shift ;; lldb) need_all OFF clang=ON lldb=ON shift ;; lld) need_all OFF clang=ON lld=ON shift ;; rt) need_all OFF clang=ON rt=ON shift ;; libs) need_all OFF clang=ON libcxx=ON libcxxabi=ON libunwind=ON shift ;; all) need_all ON shift ;; none) need_all OFF shift ;; list) safe_run python3 $llvmtool --repos $repos --env $env projects exit ;; -h) syntax exit ;; esac # Parse short options, if any while ! test -z $1; do opt=$1 sign=${opt:0:1} flag=ON if [ "$sign" = "-" ]; then flag=OFF opt=${opt:1} elif [ "$sign" = "+" ]; then opt=${opt:1} else # Doesn't look like one of our short options syntax exit fi case $opt in c) clang=$flag ;; r) rt=$flag ;; k) lld=$flag ;; d) lldb=$flag ;; l) libcxx=$flag ;; a) libcxxabi=$flag ;; u) libunwind=$flag ;; t) tests=$flag ;; *) syntax exit esac shift done add="" remove="" update() { project="$1" flag="$2" case $flag in ON) add="$add $project" ;; OFF) remove="$remove $project" ;; UNDEF) # Don't care ;; esac } # Update links update "test-suite" $tests update "lldb" $lldb update "lld" $lld update "libunwind" $libunwind update "libcxxabi" $libcxxabi update "libcxx" $libcxx update "compiler-rt" $rt update "clang" $clang if [ "$add" != "" ]; then add="-a $add" fi if [ "$remove" != "" ]; then remove="-r $remove" fi safe_run python3 $llvmtool --repos $repos --env $env projects $add $remove