| 1 | #!/bin/bashscip-shell filesystem . . `/bin/bash`. |
| 2 | |
| 3 | # Copies the 'demangle' library, excluding 'DemangleConfig.h', to llvm. If no |
| 4 | # llvm directory is specified, then assume a monorepo layout. |
| 5 | |
| 6 | set -e |
| 7 | |
| 8 | cd $(dirnamescip-shell system . . dirname. $0) |
| 9 | HDRS="ItaniumDemangle.h ItaniumNodes.def StringViewExtras.h Utility.h" |
| 10 | TEST_HDRS="DemangleTestCases.inc" |
| 11 | LLVM_DEMANGLE_DIR=$1 |
| 12 | LLVM_TESTING_DIR= |
| 13 | |
| 14 | if [[ -z "$LLVM_DEMANGLE_DIR" ]]; then |
| 15 | LLVM_DEMANGLE_DIR="../../../llvm/include/llvm/Demangle" |
| 16 | LLVM_TESTING_DIR=$LLVM_DEMANGLE_DIR/../Testing/Demangle |
| 17 | fi |
| 18 | |
| 19 | if [[ ! -d "$LLVM_DEMANGLE_DIR" ]]; then |
| 20 | echoscip-shell system . . echo. "No such directory: $LLVM_DEMANGLE_DIR" >&2 |
| 21 | exit 1 |
| 22 | fi |
| 23 | |
| 24 | if [[ ! -d "$LLVM_TESTING_DIR" ]]; then |
| 25 | LLVM_TESTING_DIR="../../../llvm/include/llvm/Testing/Demangle" |
| 26 | fi |
| 27 | |
| 28 | if [[ ! -d "$LLVM_TESTING_DIR" ]]; then |
| 29 | echoscip-shell system . . echo. "No such directory: $LLVM_TESTING_DIR" >&2 |
| 30 | exit 1 |
| 31 | fi |
| 32 | |
| 33 | read -p "This will overwrite the copies of $HDRS in $LLVM_DEMANGLE_DIR and $TEST_HDRS in $LLVM_TESTING_DIR; are you sure? [y/N]" -n 1 -r ANSWER |
| 34 | echoscip-shell system . . echo. |
| 35 | |
| 36 | copy_filesscip-shell shell llvm-toolchain-22 1:22.1.7-1 copy_files().() { |
| 37 | local src=$1 |
| 38 | local dst=$2 |
| 39 | local hdrs=$3 |
| 40 | |
| 41 | cpscip-shell system . . cp. -f README.txt $dst |
| 42 | chmodscip-shell system . . chmod. -w $dst/README.txt |
| 43 | |
| 44 | for I in $hdrs ; do |
| 45 | echoscip-shell system . . echo. "Copying ${src}/$I to ${dst}/$I" |
| 46 | rmscip-shell system . . rm. -f $dst/$I |
| 47 | dash=$(echoscip-shell system . . echo. "$I---------------------------" | cutscip-shell system . . cut. -c -27 |\ |
| 48 | sed 's|[^-]*||') |
| 49 | sedscip-shell system . . sed. -e '1s|^//=*-* .*\..* -*.*=*// *$|//===--- '"$I $dash"'-*- mode:c++;eval:(read-only-mode) -*-===//|' \ |
| 50 | -e '2s|^// *$|// Do not edit! See README.txt.|' \ |
| 51 | $src/$I >$dst/$I |
| 52 | chmodscip-shell system . . chmod. -w $dst/$I |
| 53 | done |
| 54 | } |
| 55 | |
| 56 | if [[ $ANSWER =~ ^[Yy]$ ]]; then |
| 57 | copy_filesscip-shell shell llvm-toolchain-22 1:22.1.7-1 copy_files(). . $LLVM_DEMANGLE_DIR "${HDRS}" |
| 58 | copy_filesscip-shell shell llvm-toolchain-22 1:22.1.7-1 copy_files(). ../../test $LLVM_TESTING_DIR "${TEST_HDRS}" |
| 59 | fi |