-
Notifications
You must be signed in to change notification settings - Fork 16
/
build.sh
executable file
·107 lines (92 loc) · 4.42 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
99
100
101
102
103
104
105
106
107
#!/bin/zsh
set -euo pipefail
target_property() {
bundle exec xcodeproj show NXBoot.xcodeproj --no-ansi --format=tree_hash \
| yj \
| jq -r \
'.rootObject.targets[]
|select(.name=="NXBoot")
|.buildConfigurationList.buildConfigurations[]
|select(.name=="Release").buildSettings.'$1
}
version=$(target_property MARKETING_VERSION)
buildno=$(target_property CURRENT_PROJECT_VERSION)
bundleid=$(target_property PRODUCT_BUNDLE_IDENTIFIER)
distdir=dist
tmpdir=DerivedData/bin
releasedir=DerivedData/NXBoot/Build/Products/Release-iphoneos
mkdir -p {$distdir,$tmpdir}/{iphoneos,macos}
#
# app build
#
echo "Building iOS application for arm64..."
xcodebuild -scheme NXBoot -configuration Release -destination "generic/platform=iOS" clean build | bundle exec xcpretty
rm -f "$releasedir/NXBoot.app/embedded.mobileprovision"
ldid -I$bundleid -Cadhoc -SNXBoot/NXBootJailbreak.entitlements "$releasedir/NXBoot.app/NXBoot"
echo "Building IPA..."
rm -rf DerivedData/ipa
mkdir -p DerivedData/ipa/Payload
ditto DerivedData/NXBoot/Build/Products/Release-iphoneos/NXBoot.app DerivedData/ipa/Payload/NXBoot.app
tipa=$distdir/iphoneos/NXBoot_$version-$buildno.tipa
rm -f "$tipa"
(cd DerivedData/ipa && COPYFILE_DISABLE=1 zip -r "../../$tipa" "Payload" -x "._*" -x ".DS_Store" -x "__MACOSX")
echo "Exporting debug information..."
ditto "$releasedir/NXBoot.app.dSYM" "$distdir/iphoneos/NXBoot_$version-$buildno.app.dSYM"
echo "Building main binary for armv7..."
CoreDataGenerated=DerivedData/NXBoot/Build/Intermediates.noindex/NXBoot.build/Release-iphoneos/NXBoot.build/DerivedSources/CoreDataGenerated/Model
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang \
-target armv7-apple-ios9.0 \
-std=gnu11 \
-isysroot "$(xcrun --show-sdk-path --sdk iphoneos)" \
-iframework System/Frameworks-iphoneos \
-isystem System/include \
-I. \
-INXBootKit \
-I$CoreDataGenerated \
-D__OPEN_SOURCE__=1 \
-F$releasedir \
-framework AppCenter \
-framework AppCenterAnalytics \
-framework AppCenterCrashes \
-framework WebKit \
-O2 \
-Wall \
-fmodules -fstrict-aliasing -fvisibility=hidden \
-fobjc-arc -fobjc-weak -fobjc-link-runtime \
-dead_strip \
-Xlinker -reproducible \
-Xlinker -export_dynamic \
-Xlinker -no_deduplicate \
-Xlinker -no_adhoc_codesign \
-o "$releasedir/NXBoot.armv7" \
NXBoot/*.m NXBootKit/*.m $CoreDataGenerated/*.m
ldid -I$bundleid -Cadhoc -SNXBoot/NXBootJailbreak.entitlements "$releasedir/NXBoot.armv7"
echo "Making iOS application universal..."
mv "$releasedir/NXBoot.app/NXBoot" "$releasedir/NXBoot.arm64"
lipo -create -output "$releasedir/NXBoot"{.app/NXBoot,.armv7,.arm64}
#
# command line tool build
#
cmd_srcs=(NXBootCmd/*.m NXBootKit/*.m)
cmd_cflags=(-DNXBOOT_VERSION=\"$version\" -DNXBOOT_BUILDNO=$buildno -I. -INXBootKit -std=gnu11 -fobjc-arc -fobjc-weak -fmodules -fvisibility=hidden -Wall -O2)
cmd_cflags_ios=(-D__OPEN_SOURCE__=1 -DDYLD_EXCLAVEKIT_UNAVAILABLE=)
cmd_fwkflags=(-framework CoreFoundation -framework Foundation -framework IOKit)
cmd_fwkflags_ios=("${cmd_fwkflags[@]}" -isystem System/include -iframework System/Frameworks-iphoneos)
cmd_ldflags=(-sectcreate __TEXT __intermezzo Shared/intermezzo.bin)
echo "Building nxboot iOS tool..."
xcrun -sdk iphoneos clang "${cmd_srcs[@]}" "${cmd_cflags[@]}" "${cmd_cflags_ios[@]}" "${cmd_fwkflags_ios[@]}" "${cmd_ldflags[@]}" -arch armv7 -arch arm64 -miphoneos-version-min=9.0 -o "$tmpdir/iphoneos/nxboot"
ldid -Inxboot -Cadhoc -SNXBootCmd/nxboot.entitlements "$tmpdir/iphoneos/nxboot"
install "$tmpdir/iphoneos/nxboot" "$distdir/iphoneos/nxboot"
echo "Fakesigned iOS executable available at $distdir/iphoneos/nxboot"
echo "Building nxboot macOS tool..."
clang "${cmd_srcs[@]}" "${cmd_cflags[@]}" "${cmd_fwkflags[@]}" "${cmd_ldflags[@]}" -arch x86_64 -mmacosx-version-min=10.11 -o "$tmpdir/macos/nxboot.x86_64"
clang "${cmd_srcs[@]}" "${cmd_cflags[@]}" "${cmd_fwkflags[@]}" "${cmd_ldflags[@]}" -arch arm64 -mmacosx-version-min=11.0 -o "$tmpdir/macos/nxboot.arm64"
lipo -create -output "$distdir/macos/nxboot" "$tmpdir/macos/nxboot".*
echo "macOS executable available at $distdir/macos/nxboot"
#
# package build
#
echo "Building DEB package..."
echo "(This may prompt for your user password, which is required for preparing the Debian package where files are owned by root.)"
sudo env uid=$(id -u) gid=$(id -g) version=$version buildno=$buildno releasedir=$releasedir ./build_deb.sh
echo "All done, results are available at $distdir/"