Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
emscripten-core
GitHub Repository: emscripten-core/emscripten
Path: blob/main/system/lib/libcxxabi/src/demangle/cp-to-llvm.sh
6193 views
1
#!/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 $(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
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
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
echo
35
36
copy_files() {
37
local src=$1
38
local dst=$2
39
local hdrs=$3
40
41
cp -f README.txt $dst
42
chmod -w $dst/README.txt
43
44
for I in $hdrs ; do
45
rm -f $dst/$I
46
dash=$(echo "$I---------------------------" | cut -c -27 |\
47
sed 's|[^-]*||')
48
sed -e '1s|^//=*-* .*\..* -*.*=*// *$|//===--- '"$I $dash"'-*- mode:c++;eval:(read-only-mode) -*-===//|' \
49
-e '2s|^// *$|// Do not edit! See README.txt.|' \
50
$src/$I >$dst/$I
51
chmod -w $dst/$I
52
done
53
}
54
55
if [[ $ANSWER =~ ^[Yy]$ ]]; then
56
copy_files . $LLVM_DEMANGLE_DIR $HDRS
57
copy_files ../../test $LLVM_TESTING_DIR $TEST_HDRS
58
fi
59
60