forked from avito-tech/Emcee
-
Notifications
You must be signed in to change notification settings - Fork 0
/
make.sh
executable file
·87 lines (71 loc) · 2.14 KB
/
make.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
#!/bin/bash
cd "$(dirname "$0")"
set -xueo pipefail
EMCEE_COMMIT_HASH=$(git rev-parse HEAD)
EMCEE_SHORT_VERSION="${EMCEE_COMMIT_HASH:0:7}"
function install_deps() {
brew ls --versions pkg-config > /dev/null || brew install pkg-config
brew ls --versions libssh2 > /dev/null || brew install libssh2
if [[ ! -h $(brew --prefix)/lib/pkgconfig/openssl.pc ]]; then
ln -s $(brew --prefix)/opt/[email protected]/lib/pkgconfig/openssl.pc $(brew --prefix)/lib/pkgconfig/openssl.pc
fi
if [[ ! -h $(brew --prefix)/lib/pkgconfig/libssl.pc ]]; then
ln -s $(brew --prefix)/opt/[email protected]/lib/pkgconfig/libssl.pc $(brew --prefix)/lib/pkgconfig/libssl.pc
fi
if [[ ! -h $(brew --prefix)/lib/pkgconfig/libcrypto.pc ]]; then
ln -s $(brew --prefix)/opt/[email protected]/lib/pkgconfig/libcrypto.pc $(brew --prefix)/lib/pkgconfig/libcrypto.pc
fi
swift package resolve
}
function generate_package_swift() {
install_deps
swift run --package-path ".build/checkouts/CommandLineToolkit/PackageGenerator/" package-gen .
}
function generate_emcee_version() {
sed -i '' -- "s/undefined_version/$EMCEE_SHORT_VERSION/g" "Sources/EmceeVersion/EmceeVersion.swift"
echo "Replaced source code version from 'undefined_version' with '$EMCEE_SHORT_VERSION'"
}
function reset_emcee_version() {
sed -i '' -- "s/$EMCEE_SHORT_VERSION/undefined_version/g" "Sources/EmceeVersion/EmceeVersion.swift"
echo "Reverted source code version '$EMCEE_SHORT_VERSION' to 'undefined_version'"
}
function open_package() {
generate_package_swift
open Package.swift
}
function clean() {
rm -rf .build/
rm -rf .swiftpm/
rm -rf *.xcodeproj
}
function build() {
trap reset_emcee_version EXIT
generate_emcee_version
install_deps
generate_package_swift
swift build
}
function run_tests_parallel() {
trap reset_emcee_version EXIT
generate_emcee_version
install_deps
generate_package_swift
swift test --parallel
}
case "$1" in
open)
open_package
;;
test)
run_tests_parallel
;;
build)
build
;;
clean)
clean
;;
package)
generate_package_swift
;;
esac