File: prepare_symbols.sh

package info (click to toggle)
renderdoc 1.2%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 79,584 kB
  • sloc: cpp: 491,671; ansic: 285,823; python: 12,617; java: 11,345; cs: 7,181; makefile: 6,703; yacc: 5,682; ruby: 4,648; perl: 3,461; php: 2,119; sh: 2,068; lisp: 1,835; tcl: 1,068; ml: 747; xml: 137
file content (101 lines) | stat: -rwxr-xr-x 3,078 bytes parent folder | download | duplicates (4)
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/bin/bash

# We don't have symbol servers on linux
if [ "$PLATFORM" == "Linux" ]; then
	exit;
fi

if [[ "$GITTAG" == "" ]]; then
	echo "Git tag is not valid.";
	exit 0;
fi

if [ ! -d "${REPO_ROOT}"/Win32/Release ] || [ ! -d "${REPO_ROOT}"/x64/Release ]; then
	echo "WARNING: No compiled binaries found in release folders."
	exit 0
fi

if [ ! -f "${BUILD_ROOT}"/support/pdbstr.exe ]; then
	echo "WARNING: Need pdbstr.exe from Windows Debugger folder in build root to set up source server information in symbol files."
	echo "e.g. C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\srcsrv\pdbstr.exe";
	exit 0
fi

##########################################################
# Create a source-mapping file to embed into PDBs

PDBSTR="${REPO_ROOT}"/pdbstr.txt

cat << EOF > "${PDBSTR}"
SRCSRV: ini ------------------------------------------------
VERSION=2
VERCTRL=http
SRCSRV: variables ------------------------------------------
HTTP_ALIAS=https://raw.githubusercontent.com/baldurk/renderdoc/$GITTAG/
HTTP_EXTRACT_TARGET=%HTTP_ALIAS%%var2%
SRCSRVTRG=%HTTP_EXTRACT_TARGET%
SRCSRV: source files ---------------------------------------
EOF

for I in $(find "${REPO_ROOT}" \( -path '*/3rdparty' -o -path '*/build-android*' -o -path '*/generated' \) -prune -o \( -iname '*.cpp' -o -iname '*.c' -o -iname '*.h' -o -iname '*.inl' \) -print); do
	echo $(native_path ${I})*${I};
done |
  sed -e '{s#\*'"${REPO_ROOT}"'/\?#\*#g}' |
  awk -F"*" '{gsub("/","\\",$1); print $1 "*" $2}' >> "${PDBSTR}"

echo "SRCSRV: end ------------------------------------------------" >> "${PDBSTR}"

##########################################################

# Apply the source-indexing mapping into every pdb file
for PDB in "${REPO_ROOT}"/Win32/Release/*.pdb "${REPO_ROOT}"/x64/Release/*.pdb; do
	"${BUILD_ROOT}"/support/pdbstr.exe -w -p:$(native_path $PDB) -s:srcsrv -i:$(native_path "${PDBSTR}")
done

rm "${PDBSTR}"

if [ ! -f "${BUILD_ROOT}"/support/symstore.exe ]; then
	echo "Need symstore.exe from Windows Debugger folder in build root."
	echo "e.g. C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\symstore.exe";
	exit 0
fi

# check if a symbol store is specified
if [[ "$SYMSTORE" == "" ]]; then
	exit 0;
fi

TMPSTORE="${REPO_ROOT}"/symstore

echo "Storing symbols for $GITTAG in symbol store $SYMSTORE temporarily in $TMPSTORE"

mkdir -p "${SYMSTORE}"

# Store the pdbs in a symbol store
# Process Win32 and x64 separately since they'll overwrite each other otherwise.
for ARCH in Win32 x64; do

	rm -rf "${TMPSTORE}"

	# Add to local symbol store (which is rsync'd to public symbol server)
	for PDB in "${REPO_ROOT}"/$ARCH/Release/*.pdb; do
		mkdir -p "${TMPSTORE}"
		cp $PDB "${TMPSTORE}"

		EXE=${PDB%.pdb}.exe
		DLL=${PDB%.pdb}.dll
		if [ -f "$EXE" ]; then
			cp $EXE "${TMPSTORE}"
		fi
		if [ -f "$DLL" ]; then
			cp $DLL "${TMPSTORE}"
		fi
	done

	if [ -d "${TMPSTORE}" ]; then
		MSYS2_ARG_CONV_EXCL="*" "${BUILD_ROOT}"/support/symstore.exe add /s "$(native_path "${SYMSTORE}")" /compress /r /f "$(native_path "${TMPSTORE}")" /t RenderDoc /v $GITTAG
	fi

done

rm -rf "${TMPSTORE}"