forked from TelegramMessenger/Telegram-iOS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate-xcode-project.sh
executable file
·77 lines (59 loc) · 2.26 KB
/
generate-xcode-project.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
#!/bin/sh
set -e
APP_TARGET="$1"
if [ "$APP_TARGET" == "" ]; then
echo "Usage: sh generate-xcode-project.sh app_target_folder"
exit 1
fi
BAZEL="$(which bazel)"
if [ "$BAZEL" = "" ]; then
echo "bazel not found in PATH"
exit 1
fi
XCODE_VERSION=$(cat "build-system/xcode_version")
INSTALLED_XCODE_VERSION=$(echo `plutil -p \`xcode-select -p\`/../Info.plist | grep -e CFBundleShortVersionString | sed 's/[^0-9\.]*//g'`)
if [ "$INSTALLED_XCODE_VERSION" != "$XCODE_VERSION" ]; then
echo "Xcode $XCODE_VERSION required, $INSTALLED_XCODE_VERSION installed (at $(xcode-select -p))"
exit 1
fi
GEN_DIRECTORY="build-input/gen/project"
mkdir -p "$GEN_DIRECTORY"
TULSI_DIRECTORY="build-input/gen/project"
TULSI_APP="build-input/gen/project/Tulsi.app"
TULSI="$TULSI_APP/Contents/MacOS/Tulsi"
rm -rf "$GEN_DIRECTORY/${APP_TARGET}.tulsiproj"
rm -rf "$TULSI_APP"
pushd "build-system/tulsi"
"$BAZEL" build //:tulsi --xcode_version="$XCODE_VERSION"
popd
mkdir -p "$TULSI_DIRECTORY"
unzip -oq "build-system/tulsi/bazel-bin/tulsi.zip" -d "$TULSI_DIRECTORY"
CORE_COUNT=$(sysctl -n hw.logicalcpu)
CORE_COUNT_MINUS_ONE=$(expr ${CORE_COUNT} \- 1)
BAZEL_OPTIONS=(\
--features=swift.use_global_module_cache \
--spawn_strategy=standalone \
--strategy=SwiftCompile=standalone \
--features=swift.enable_batch_mode \
--swiftcopt=-j${CORE_COUNT_MINUS_ONE} \
)
if [ "$BAZEL_CACHE_DIR" != "" ]; then
BAZEL_OPTIONS=("${BAZEL_OPTIONS[@]}" --disk_cache="$(echo $BAZEL_CACHE_DIR | sed -e 's/[\/&]/\\&/g')")
fi
"$TULSI" -- \
--verbose \
--create-tulsiproj "$APP_TARGET" \
--workspaceroot ./ \
--bazel "$BAZEL" \
--outputfolder "$GEN_DIRECTORY" \
--target "$APP_TARGET":"$APP_TARGET" \
PATCH_OPTIONS="BazelBuildOptionsDebug BazelBuildOptionsRelease"
for NAME in $PATCH_OPTIONS; do
sed -i "" -e '1h;2,$H;$!d;g' -e 's/\("'"$NAME"'" : {\n[ ]*"p" : "$(inherited)\)/\1'" ${BAZEL_OPTIONS[*]}"'/' "$GEN_DIRECTORY/${APP_TARGET}.tulsiproj/Configs/${APP_TARGET}.tulsigen"
done
sed -i "" -e '1h;2,$H;$!d;g' -e 's/\("sourceFilters" : \[\n[ ]*\)"\.\/\.\.\."/\1"'"${APP_TARGET}"'\/...", "submodules\/..."/' "$GEN_DIRECTORY/${APP_TARGET}.tulsiproj/Configs/${APP_TARGET}.tulsigen"
"$TULSI" -- \
--verbose \
--genconfig "$GEN_DIRECTORY/${APP_TARGET}.tulsiproj:${APP_TARGET}" \
--bazel "$BAZEL" \
--outputfolder "$GEN_DIRECTORY" \