This repository was archived by the owner on Mar 18, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgenerate-csv
More file actions
executable file
·44 lines (37 loc) · 1.45 KB
/
generate-csv
File metadata and controls
executable file
·44 lines (37 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env bash
set -e
if [ -z "$1" ] || [ -z "$ABSOUTDIR" ] || [ -z "$ABSROOTDIR" ] || [ "$1" = "--help" ]; then
echo "Usage: $0 <cmd>"
echo
echo "Arguments:"
echo "- <cmd> the build command for your project, MUST use \$CXX instead of clang/clang++/gcc/g++ directly, CWD set to ABSROOTDIR"
echo
echo "Environment variables:"
echo "- ABSOUTDIR (required) absolute path to directory in which to write CSV output"
echo "- ABSROOTDIR (required) absolute path to directory which contains source code"
echo "- CLEAN (optional) removes existing *.csv from ABSOUTDIR before running"
echo
echo "Example:"
echo
echo " env CLEAN=true ABSROOTDIR=\$PWD/examples/five/root ABSOUTDIR=\$PWD/examples/five/output ./generate-csv \"\\\$CXX -c /host/root/*.cpp ; ls /host/output\""
exit 1
fi
if [ -n "$CLEAN" ]; then
echo "Cleaning $ABSOUTDIR/*.csv"
rm -f "$ABSOUTDIR"/*.csv
fi
cmd="$1"
FLAGS="-Xclang -load -Xclang $(realpath "$(dirname "${BASH_SOURCE[0]}")")/clang/libclang-index-plugin.so -Xclang -add-plugin -Xclang dxr-index -Xclang -plugin-arg-dxr-index -Xclang ."
export CXX="clang++ $FLAGS"
export CC="clang $FLAGS"
echo "Running... $cmd"
(
cd "$ABSROOTDIR"
env \
CXX="$CXX" \
CC="$CC" \
DXR_CXX_CLANG_TEMP_FOLDER="$ABSOUTDIR" \
bash -c "$cmd"
)
echo
echo "Generated $(find "$ABSOUTDIR" -maxdepth 1 -mindepth 1 -name "*.csv" | wc -l | awk '{ print $1 }') .csv files. Output location: $ABSOUTDIR/*.csv"