-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·87 lines (75 loc) · 1.73 KB
/
build.sh
File metadata and controls
executable file
·87 lines (75 loc) · 1.73 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
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/zsh
# a simple build script for tinyhook
# arguments:
# -a <arch> add an arch to build
# -t <target> specify target system, macosx(default) or iphoneos
# -v <version> specify minimum system version
# -c build compact version
set -e
set -o pipefail
cd "$(dirname "$0")"
archs2build=()
target=macosx
sysver=
compact=0
noexport=0
while {getopts a:t:v:cn arg} {
case $arg {
(a)
archs2build+=($OPTARG)
;;
(t)
target=$OPTARG
;;
(v)
sysver=$OPTARG
;;
(c)
compact=1
;;
(n)
noexport=1
;;
(?)
echo error
return 1
;;
}
}
if (($#archs2build == 0)) {
if [[ $target == macosx ]] {
archs2build+=(arm64 x86_64)
} elif [[ $target == iphoneos ]] {
archs2build+=(arm64 arm64e)
} else {
echo "unknown target: $target!"
exit 1
}
}
local build_arg=(TARGET=$target)
if [[ $sysver != "" ]] {
build_arg+=(MIN_OSVER=$sysver)
}
if (($compact == 1)) {
build_arg+=(COMPACT=1)
}
if (($noexport == 1)) {
build_arg+=(NO_EXPORT=1)
}
for i ($archs2build) {
(set -x # print command before executing
mkdir -p build/$i
make clean ARCH=$i && make all ARCH=$i $build_arg
cp libtinyhook.a libtinyhook.dylib build/$i
)
}
if (($#archs2build > 1)) {
(set -x
cd build
mkdir -p universal
rm -f universal/libtinyhook.a universal/libtinyhook.dylib
lipo -create -o universal/libtinyhook.a ${archs2build/%//libtinyhook.a}
lipo -create -o universal/libtinyhook.dylib ${archs2build/%//libtinyhook.dylib}
cp universal/libtinyhook.a universal/libtinyhook.dylib ..
)
}