60 lines · bash
1#!/bin/bash2 3# Copies the 'demangle' library, excluding 'DemangleConfig.h', to llvm. If no4# llvm directory is specified, then assume a monorepo layout.5 6set -e7 8cd $(dirname $0)9HDRS="ItaniumDemangle.h ItaniumNodes.def StringViewExtras.h Utility.h"10TEST_HDRS="DemangleTestCases.inc"11LLVM_DEMANGLE_DIR=$112LLVM_TESTING_DIR=13 14if [[ -z "$LLVM_DEMANGLE_DIR" ]]; then15 LLVM_DEMANGLE_DIR="../../../llvm/include/llvm/Demangle"16 LLVM_TESTING_DIR=$LLVM_DEMANGLE_DIR/../Testing/Demangle17fi18 19if [[ ! -d "$LLVM_DEMANGLE_DIR" ]]; then20 echo "No such directory: $LLVM_DEMANGLE_DIR" >&221 exit 122fi23 24if [[ ! -d "$LLVM_TESTING_DIR" ]]; then25 LLVM_TESTING_DIR="../../../llvm/include/llvm/Testing/Demangle"26fi27 28if [[ ! -d "$LLVM_TESTING_DIR" ]]; then29 echo "No such directory: $LLVM_TESTING_DIR" >&230 exit 131fi32 33read -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 ANSWER34echo35 36copy_files() {37 local src=$138 local dst=$239 local hdrs=$340 41 cp -f README.txt $dst42 chmod -w $dst/README.txt43 44 for I in $hdrs ; do45 echo "Copying ${src}/$I to ${dst}/$I"46 rm -f $dst/$I47 dash=$(echo "$I---------------------------" | cut -c -27 |\48 sed 's|[^-]*||')49 sed -e '1s|^//=*-* .*\..* -*.*=*// *$|//===--- '"$I $dash"'-*- mode:c++;eval:(read-only-mode) -*-===//|' \50 -e '2s|^// *$|// Do not edit! See README.txt.|' \51 $src/$I >$dst/$I52 chmod -w $dst/$I53 done54}55 56if [[ $ANSWER =~ ^[Yy]$ ]]; then57 copy_files . $LLVM_DEMANGLE_DIR "${HDRS}"58 copy_files ../../test $LLVM_TESTING_DIR "${TEST_HDRS}"59fi60