-
Notifications
You must be signed in to change notification settings - Fork 12
/
build.sh
executable file
·98 lines (87 loc) · 3.34 KB
/
build.sh
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
set -e
if [[ "$OSTYPE" != "darwin"* && "$OSTYPE" != "linux"* ]]; then
echo "Error: Not supported OS type." >&2
exit 1
fi
if [[ "$DOWNLOAD_VCPKG" != "0" ]]; then
if [[ -d vcpkg ]]; then
echo "Error: vcpkg directory already exists. Remove it or set DOWNLOAD_VCPKG=0 if you are sure directory content is correct." >&2
exit 1
fi
git clone https://github.com/microsoft/vcpkg.git
cd vcpkg
git checkout tags/2024.01.12
git apply --verbose ../tools/vcpkg_hotfixes/*.patch
./bootstrap-vcpkg.sh
cd ..
fi
if [[ -n "$BINARY_CACHE_GITHUB_TOKEN" ]]; then
echo "Configuring GitHub packages binary cache."
NUGET=`./vcpkg/vcpkg fetch nuget | tail -n1`
echo "Using NuGet: $NUGET"
BINARY_CACHE_GITHUB_OWNERS="${BINARY_CACHE_GITHUB_OWNERS:-docwire}"
for OWNER in $BINARY_CACHE_GITHUB_OWNERS; do
SOURCE_URL="https://nuget.pkg.github.com/$OWNER/index.json"
echo "Using cache source: $SOURCE_URL"
SOURCE_NAME="${OWNER}_github"
mono "$NUGET" sources add -source "$SOURCE_URL" -storepasswordincleartext -name "$SOURCE_NAME" -username "$BINARY_CACHE_GITHUB_USER" -password "$BINARY_CACHE_GITHUB_TOKEN"
mono "$NUGET" setapikey "$BINARY_CACHE_GITHUB_TOKEN" -source "$SOURCE_URL"
VCPKG_BINARY_SOURCES+=";nuget,$SOURCE_NAME,readwrite"
done
export VCPKG_BINARY_SOURCES="clear$VCPKG_BINARY_SOURCES"
echo "Using binary sources: $VCPKG_BINARY_SOURCES"
echo "GitHub packages binary cache enabled."
else
echo "GitHub packages binary cache disabled."
fi
if [[ "$OSTYPE" == "darwin"* ]]; then
if [[ $(arch) == 'arm64' ]]; then
VCPKG_TRIPLET=arm64-osx-dynamic
else
VCPKG_TRIPLET=x64-osx-dynamic
fi
else
VCPKG_TRIPLET=x64-linux-dynamic
fi
if [[ "$SANITIZER" == "address" ]]; then
FEATURES="[tests,address-sanitizer]"
elif [[ "$SANITIZER" == "thread" ]]; then
FEATURES="[tests,thread-sanitizer]"
elif [[ "$SANITIZER" == "memcheck" ]]; then
FEATURES="[tests,memcheck]"
elif [[ "$SANITIZER" == "helgrind" ]]; then
FEATURES="[tests,helgrind]"
elif [[ "$SANITIZER" == "callgrind" ]]; then
FEATURES="[tests,callgrind]"
else
FEATURES="[tests]"
fi
if [[ "$DEBUG" == "1" ]]; then
export DOCWIRE_LOG_VERBOSITY="debug"
VCPKG_DEBUG_OPTION="--debug"
fi
date > ./ports/docwire/.disable_binary_cache
SOURCE_PATH="$PWD" VCPKG_KEEP_ENV_VARS=SOURCE_PATH ./vcpkg/vcpkg --overlay-ports=./ports remove docwire:$VCPKG_TRIPLET
SOURCE_PATH="$PWD" VCPKG_KEEP_ENV_VARS="SOURCE_PATH;DOCWIRE_LOG_VERBOSITY;OPENAI_API_KEY;ASAN_OPTIONS;TSAN_OPTIONS" ./vcpkg/vcpkg --overlay-ports=./ports install $VCPKG_DEBUG_OPTION docwire$FEATURES:$VCPKG_TRIPLET
if [[ "$EXPORT_VCPKG" != "0" ]]; then
version=`cat ./vcpkg/installed/$VCPKG_TRIPLET/share/docwire/VERSION`
./vcpkg/vcpkg --overlay-ports=./ports export docwire:$VCPKG_TRIPLET --raw --output=docwire-$version --output-dir=.
cat tools/setup_env.sh | sed "s/vcpkg_triplet=.*/vcpkg_triplet=\"$VCPKG_TRIPLET\"/" > docwire-$version/setup_env.sh
chmod u+x docwire-$version/setup_env.sh
# test run - relative path
(
. docwire-$version/setup_env.sh
docwire tests/1.pdf
)
# test run - absolute path
(
. $PWD/docwire-$version/setup_env.sh
docwire tests/1.doc
)
if [[ "$CREATE_ARCHIVE" == "1" ]]; then
abi_suffix=`cat ./vcpkg/installed/$VCPKG_TRIPLET/share/docwire/abi-id.txt`
full_suffix="$version-$VCPKG_TRIPLET-$abi_suffix"
tar -cjvf docwire-$full_suffix.tar.bz2 docwire-$version
sha1sum docwire-$full_suffix.tar.bz2 > docwire-$full_suffix.tar.bz2.sha1
fi
fi