-
Notifications
You must be signed in to change notification settings - Fork 496
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·673 lines (586 loc) · 21.2 KB
/
Copy pathbuild.sh
File metadata and controls
executable file
·673 lines (586 loc) · 21.2 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
#!/bin/bash
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
set -e
set -o pipefail
if hash xcpretty 2>/dev/null; then
HAS_XCPRETTY=true
fi
# Check if xattrs are supported on the current filesystem
# Some virtual filesystems (e.g., EdenFS) don't support xattrs
function supports_xattrs() {
local test_file=".xattr_test_$$"
if touch "$test_file" 2>/dev/null && xattr -w com.test.xattr test "$test_file" 2>/dev/null; then
xattr -d com.test.xattr "$test_file" 2>/dev/null
rm -f "$test_file"
return 0
fi
rm -f "$test_file" 2>/dev/null
return 1
}
# Use build directory outside of repo if xattrs not supported (for Xcode compatibility)
if supports_xattrs; then
BUILD_DIRECTORY="$(pwd)/Build"
else
BUILD_DIRECTORY="/tmp/idb-build-$(basename "$(pwd)")"
echo "Note: Using external build directory at $BUILD_DIRECTORY (xattrs not supported)"
# Companion/project.yml hard-codes framework refs as
# `../Build/Products/Release/...`. Symlink the in-tree `Build` dir so
# those references resolve to the actual external build output.
rm -rf Build
ln -s "$BUILD_DIRECTORY" Build
fi
# =============================================================================
# XcodeGen Project Generation
# =============================================================================
GRPC_SWIFT_VERSION="1.23.1"
GRPC_SWIFT_DIR="$BUILD_DIRECTORY/grpc-swift"
function check_xcodegen() {
if ! command -v xcodegen &> /dev/null; then
echo "error: XcodeGen not found. Install with: brew install xcodegen"
exit 1
fi
}
# Check if ditto is available for xattr-free copying
function has_ditto() {
command -v ditto &> /dev/null
}
# Validate that a generated xcodeproj is valid
# Usage: validate_xcodeproj <xcodeproj_path>
function validate_xcodeproj() {
local xcodeproj_path="$1"
local pbxproj="${xcodeproj_path}/project.pbxproj"
if [ ! -d "$xcodeproj_path" ]; then
echo "error: Generated project not found at $xcodeproj_path"
return 1
fi
if [ ! -f "$pbxproj" ]; then
echo "error: project.pbxproj not found in $xcodeproj_path"
return 1
fi
if [ ! -s "$pbxproj" ]; then
echo "error: project.pbxproj is empty in $xcodeproj_path"
return 1
fi
# Basic validation: check for required Xcode project structure
if ! grep -q "PBXProject" "$pbxproj"; then
echo "error: project.pbxproj appears to be invalid (missing PBXProject)"
return 1
fi
return 0
}
# Generate a single xcodeproj, optionally stripping xattrs for filesystem compatibility
# Usage: generate_xcodeproj <project_dir> <project_name>
function generate_xcodeproj() {
local project_dir="$1"
local project_name="$2"
local xcodeproj_name="${project_name}.xcodeproj"
local dest_path="${project_dir}/${xcodeproj_name}"
# Default to stripping xattrs for filesystem compatibility
local strip_xattrs="${XCODEGEN_STRIP_XATTRS:-true}"
if [[ "$strip_xattrs" == "true" ]] && has_ditto; then
# Generate to temp dir outside filesystem, then copy without xattrs
local temp_dir=$(mktemp -d)
local abs_project_dir
abs_project_dir=$(cd "$project_dir" && pwd)
echo " [xattr workaround] Generating to temp: $temp_dir"
rm -rf "$dest_path"
(cd "$project_dir" && xcodegen generate -p "$temp_dir")
# Fix paths in pbxproj - XcodeGen creates relative paths from temp dir
# We need to convert these back to paths relative to the project dir
local pbxproj="${temp_dir}/${xcodeproj_name}/project.pbxproj"
if [ -f "$pbxproj" ]; then
# Calculate the wrong relative prefix that XcodeGen created
# and replace it with correct relative path
local escaped_path
escaped_path=$(echo "$abs_project_dir/" | sed 's/[\/&]/\\&/g')
local abs_parent_dir
abs_parent_dir=$(dirname "$abs_project_dir")
local escaped_parent
escaped_parent=$(echo "$abs_parent_dir/" | sed 's/[\/&]/\\&/g')
local escaped_parent_no_slash
escaped_parent_no_slash=$(echo "$abs_parent_dir" | sed 's/[\/&]/\\&/g')
# Order matters: handle the longer (project-dir) prefix first so it
# doesn't get partially eaten by the parent-dir pattern, then handle
# references that point into the project's parent directory.
# Files inside project_dir become bare paths.
sed -i '' "s|[.][.]/[^;\"]*${escaped_path}||g" "$pbxproj"
# Files in project_dir's parent become "../" relative to project_dir.
sed -i '' "s|[.][.]/[^;\"]*${escaped_parent}|../|g" "$pbxproj"
# The parent dir itself (no trailing path component) becomes "..".
# Match the terminator (`;` or `"`) and preserve it.
sed -i '' "s|[.][.]/[^;\"]*${escaped_parent_no_slash};|..;|g" "$pbxproj"
sed -i '' "s|[.][.]/[^;\"]*${escaped_parent_no_slash}\"|..\"|g" "$pbxproj"
echo " [xattr workaround] Fixed relative paths in project.pbxproj"
fi
# Validate temp project before copying
if ! validate_xcodeproj "${temp_dir}/${xcodeproj_name}"; then
echo "error: Generated project failed validation"
rm -rf "$temp_dir"
exit 1
fi
# Use ditto to copy without xattrs
echo " [xattr workaround] Copying to $dest_path (without xattrs)"
ditto --noextattr "${temp_dir}/${xcodeproj_name}" "$dest_path"
rm -rf "$temp_dir"
# Validate final project
if validate_xcodeproj "$dest_path"; then
echo " [xattr workaround] Project validated successfully"
else
echo "error: Final project failed validation"
exit 1
fi
else
# Direct generation
(cd "$project_dir" && xcodegen generate)
if ! validate_xcodeproj "$dest_path"; then
echo "error: Generated project failed validation"
exit 1
fi
fi
}
function check_protobuf() {
local missing=()
if ! command -v protoc &> /dev/null; then
missing+=("protoc")
fi
if ! command -v protoc-gen-swift &> /dev/null; then
missing+=("protoc-gen-swift")
fi
if [ ${#missing[@]} -ne 0 ]; then
echo "error: Missing protobuf tools: ${missing[*]}"
echo "Install with: brew install protobuf swift-protobuf"
exit 1
fi
}
function build_grpc_swift_plugin() {
# Build protoc-gen-grpc-swift from grpc-swift 1.x source
local plugin_path="$GRPC_SWIFT_DIR/.build/release/protoc-gen-grpc-swift"
if [ -x "$plugin_path" ]; then
echo "protoc-gen-grpc-swift already built at $plugin_path"
return 0
fi
echo "Building protoc-gen-grpc-swift from grpc-swift $GRPC_SWIFT_VERSION..."
if [ ! -d "$GRPC_SWIFT_DIR" ]; then
echo "Cloning grpc-swift $GRPC_SWIFT_VERSION..."
git clone --depth 1 --branch "$GRPC_SWIFT_VERSION" \
https://github.com/grpc/grpc-swift.git "$GRPC_SWIFT_DIR"
fi
echo "Building protoc-gen-grpc-swift (this may take a few minutes)..."
(cd "$GRPC_SWIFT_DIR" && swift build -c release --product protoc-gen-grpc-swift)
if [ ! -x "$plugin_path" ]; then
echo "error: Failed to build protoc-gen-grpc-swift"
exit 1
fi
echo "Successfully built protoc-gen-grpc-swift"
}
function generate_proto() {
check_protobuf
build_grpc_swift_plugin
local proto_dir="proto"
local output_dir="IDBGRPCSwift"
local protoc=$(which protoc)
local swift_plugin=$(which protoc-gen-swift)
local grpc_plugin="$GRPC_SWIFT_DIR/.build/release/protoc-gen-grpc-swift"
echo "Generating gRPC Swift from proto..."
mkdir -p "$output_dir"
$protoc \
--proto_path="$proto_dir" \
--swift_out=Visibility=Public:"$output_dir" \
--grpc-swift_out=Visibility=Public:"$output_dir" \
--plugin=protoc-gen-grpc-swift="$grpc_plugin" \
--plugin=protoc-gen-swift="$swift_plugin" \
"$proto_dir/idb.proto"
echo "Generated gRPC Swift files in $output_dir"
}
function regenerate_projects() {
check_xcodegen
echo "Generating FBSimulatorControl project from project.yml..."
generate_xcodeproj "." "FBSimulatorControl"
echo "Generating Shimulator project..."
generate_xcodeproj "Shims/Shimulator" "Shimulator"
echo "Generating Repl shim project..."
generate_xcodeproj "Shims/Repl" "Repl"
echo "Generating SimulatorFrameworkBridge project..."
generate_xcodeproj "SimulatorFrameworkBridge" "SimulatorFrameworkBridge"
echo "Generating idb_companion project..."
generate_xcodeproj "Companion" "idb_companion"
# xcodegen ignores `embed: false` for a tool target dependency, so strip the
# leftover entry here.
sed -i '' '/IDBGRPCSwift.framework in Embed Frameworks/d' \
Companion/idb_companion.xcodeproj/project.pbxproj
}
# =============================================================================
# Build Utilities
# =============================================================================
function invoke_xcodebuild() {
local symroot="$BUILD_DIRECTORY/Products"
local objroot="$BUILD_DIRECTORY/Intermediates"
# Use arrays so each setting/argument stays a single word regardless of spaces.
# Add -skipMacroValidation to work around sandbox restrictions on Swift macro plugins
# Add ENABLE_USER_SCRIPT_SANDBOXING=NO to disable sandbox for macros
# Add CLANG_ENABLE_EXPLICIT_MODULES=NO to mirror Configuration/Shared.xcconfig
# Add ARCHS=arm64 to build arm64 only (no Intel/x86_64 slices).
local common_settings=(
-skipMacroValidation
ENABLE_USER_SCRIPT_SANDBOXING=NO
CLANG_ENABLE_EXPLICIT_MODULES=NO
ARCHS=arm64
)
if [[ -n $HAS_XCPRETTY ]]; then
NSUnbufferedIO=YES xcodebuild "${common_settings[@]}" SYMROOT="$symroot" OBJROOT="$objroot" "$@" | xcpretty -c
else
xcodebuild "${common_settings[@]}" SYMROOT="$symroot" OBJROOT="$objroot" "$@"
fi
}
function build_idb_deps() {
if [ -n "$CUSTOM_idb_DEPS_SCRIPT" ]; then
"$CUSTOM_idb_DEPS_SCRIPT"
fi
}
function strip_framework() {
local FRAMEWORK_PATH="$BUILD_DIRECTORY/Products/Release/$1"
if [ -d "$FRAMEWORK_PATH" ]; then
echo "Stripping Framework $FRAMEWORK_PATH"
rm -r "$FRAMEWORK_PATH"
fi
}
function strip_embedded_frameworks() {
strip_framework "FBSimulatorControl.framework/Versions/Current/Frameworks/XCTestBootstrap.framework"
strip_framework "FBSimulatorControl.framework/Versions/Current/Frameworks/FBControlCore.framework"
strip_framework "FBDeviceControl.framework/Versions/Current/Frameworks/XCTestBootstrap.framework"
strip_framework "FBDeviceControl.framework/Versions/Current/Frameworks/FBControlCore.framework"
strip_framework "XCTestBootstrap.framework/Versions/Current/Frameworks/FBControlCore.framework"
}
# =============================================================================
# Build Functions
# =============================================================================
function build_target() {
local name=$1
local configuration=${2:-Debug}
invoke_xcodebuild \
ONLY_ACTIVE_ARCH=NO \
-project FBSimulatorControl.xcodeproj \
-scheme "$name" \
-sdk macosx \
-derivedDataPath "$BUILD_DIRECTORY" \
-configuration "$configuration" \
build
}
function build_all_frameworks() {
build_target FBControlCore
build_target XCTestBootstrap
build_target FBSimulatorControl
build_target FBDeviceControl
}
function build_shim() {
local name=$1
local sdk=$2
# The Repl shims live in their own project (Shims/Repl) to avoid an
# XCTestPrivate.h header collision with the Shimulator shims; default to the
# Shimulator project otherwise.
local project=${3:-Shims/Shimulator/Shimulator.xcodeproj}
invoke_xcodebuild \
ONLY_ACTIVE_ARCH=NO \
-project "$project" \
-scheme "$name" \
-sdk "$sdk" \
-derivedDataPath "$BUILD_DIRECTORY" \
-configuration Release \
build
}
function build_shims() {
build_shim Shimulator-iOS iphonesimulator
build_shim Shimulator-macOS macosx
build_shim Repl-iOS iphonesimulator Shims/Repl/Repl.xcodeproj
build_shim Repl-macOS macosx Shims/Repl/Repl.xcodeproj
}
function build_simulator_framework_bridge() {
# An iOS-simulator command-line executable, spawned by idb_companion inside the
# simulator to drive privacy/services state and the REPL socket.
invoke_xcodebuild \
ONLY_ACTIVE_ARCH=NO \
-project SimulatorFrameworkBridge/SimulatorFrameworkBridge.xcodeproj \
-scheme SimulatorFrameworkBridge \
-sdk iphonesimulator \
-derivedDataPath "$BUILD_DIRECTORY" \
-configuration Release \
build
}
function build_idb_companion() {
check_protobuf
build_idb_deps
# Ensure proto files are generated
if [ ! -f "IDBGRPCSwift/idb.grpc.swift" ] || [ ! -f "IDBGRPCSwift/idb.pb.swift" ]; then
echo "Proto files not found, generating..."
generate_proto
fi
# Build frameworks first in Release (idb_companion depends on them and is built in Release)
build_target FBControlCore Release
build_target XCTestBootstrap Release
build_target FBSimulatorControl Release
build_target FBDeviceControl Release
build_target CompanionLib Release
build_target CompanionUtilities Release
# Build idb_companion from its own project
invoke_xcodebuild \
ONLY_ACTIVE_ARCH=NO \
SWIFT_ENABLE_EXPLICIT_MODULES=NO \
-project Companion/idb_companion.xcodeproj \
-scheme idb_companion \
-sdk macosx \
-derivedDataPath "$BUILD_DIRECTORY" \
-configuration Release \
build
strip_embedded_frameworks
}
function build_idb_repl() {
check_protobuf
# idb-repl links IDBGRPCSwift, which needs the generated gRPC Swift files.
if [ ! -f "IDBGRPCSwift/idb.grpc.swift" ] || [ ! -f "IDBGRPCSwift/idb.pb.swift" ]; then
echo "Proto files not found, generating..."
generate_proto
fi
# Build the idb-repl CLI from the idb_companion project (shares IDBGRPCSwift).
invoke_xcodebuild \
ONLY_ACTIVE_ARCH=NO \
SWIFT_ENABLE_EXPLICIT_MODULES=NO \
-project Companion/idb_companion.xcodeproj \
-scheme idb-repl \
-sdk macosx \
-derivedDataPath "$BUILD_DIRECTORY" \
-configuration Release \
build
}
# Assemble the runtime layout idb_companion expects:
#
# <dist>/
# idb_companion the executable
# idb-repl the REPL CLI
# *.bundle SwiftPM resource bundles (Bundle.module -> Bundle.main)
# Resources/
# libShimulator-iOS.dylib
# libShimulator-macOS.dylib
# libRepl-iOS.dylib
# libRepl-macOS.dylib
# SimulatorFrameworkBridge
#
function build_distribution() {
local release="$BUILD_DIRECTORY/Products/Release"
local sim="$BUILD_DIRECTORY/Products/Release-iphonesimulator"
local dist="$BUILD_DIRECTORY/Distribution"
echo "Assembling distribution into $dist"
# Fail early with a clear message if a prerequisite product is missing.
local required=(
"$release/idb_companion"
"$release/idb-repl"
"$sim/libShimulator-iOS.dylib"
"$release/libShimulator-macOS.dylib"
"$sim/libRepl-iOS.dylib"
"$release/libRepl-macOS.dylib"
"$sim/SimulatorFrameworkBridge"
)
local path
for path in "${required[@]}"; do
if [ ! -e "$path" ]; then
echo "error: expected build product not found: $path"
echo "Run './build.sh build' first."
exit 1
fi
done
rm -rf "$dist"
mkdir -p "$dist/Resources"
# Companion executable and the REPL CLI.
cp "$release/idb_companion" "$dist/"
cp "$release/idb-repl" "$dist/"
# SwiftPM resource bundles (Bundle.module resolves relative to Bundle.main).
local bundle
for bundle in "$release"/*.bundle; do
[ -e "$bundle" ] || continue
ditto "$bundle" "$dist/$(basename "$bundle")"
done
# Shims + SimulatorFrameworkBridge live under Resources/ next to idb_companion.
cp "$sim/libShimulator-iOS.dylib" "$dist/Resources/"
cp "$release/libShimulator-macOS.dylib" "$dist/Resources/"
cp "$sim/libRepl-iOS.dylib" "$dist/Resources/"
cp "$release/libRepl-macOS.dylib" "$dist/Resources/"
cp "$sim/SimulatorFrameworkBridge" "$dist/Resources/"
echo "Distribution ready at $dist"
}
function build_all() {
# build_idb_companion already builds frameworks first
build_shims
build_simulator_framework_bridge
build_idb_companion
build_idb_repl
build_distribution
}
function build() {
local target=$1
if [[ -z $target ]]; then
echo "Building all targets..."
build_all
else
case $target in
all)
build_all;;
frameworks)
build_all_frameworks;;
shims)
build_shims;;
Shimulator-iOS)
build_shim Shimulator-iOS iphonesimulator;;
Shimulator-macOS)
build_shim Shimulator-macOS macosx;;
Repl-iOS)
build_shim Repl-iOS iphonesimulator Shims/Repl/Repl.xcodeproj;;
Repl-macOS)
build_shim Repl-macOS macosx Shims/Repl/Repl.xcodeproj;;
SimulatorFrameworkBridge)
build_simulator_framework_bridge;;
idb_companion)
build_idb_companion;;
idb-repl)
build_idb_repl;;
distribution)
build_distribution;;
FBControlCore|XCTestBootstrap|FBSimulatorControl|FBDeviceControl)
build_target "$target";;
*)
echo "Unknown target: $target"
echo "Valid targets: all, frameworks, shims, idb_companion, idb-repl, FBControlCore, XCTestBootstrap, FBSimulatorControl, FBDeviceControl, Shimulator-iOS, Shimulator-macOS, Repl-iOS, Repl-macOS, SimulatorFrameworkBridge, distribution"
exit 1;;
esac
fi
}
# =============================================================================
# Test Functions
# =============================================================================
function test_target() {
local name=$1
invoke_xcodebuild \
-project FBSimulatorControl.xcodeproj \
-scheme "$name" \
-sdk macosx \
-derivedDataPath "$BUILD_DIRECTORY" \
test
}
function test_all() {
test_target FBControlCore
test_target XCTestBootstrap
test_target FBSimulatorControl
test_target FBDeviceControl
}
function run_tests() {
local target=$1
if [[ -z $target ]]; then
echo "Running all tests..."
test_all
else
case $target in
all)
test_all;;
FBControlCore|XCTestBootstrap|FBSimulatorControl|FBDeviceControl)
test_target "$target";;
*)
echo "Unknown test target: $target"
echo "Valid targets: all, FBControlCore, XCTestBootstrap, FBSimulatorControl, FBDeviceControl"
exit 1;;
esac
fi
}
# =============================================================================
# Usage
# =============================================================================
function print_usage() {
cat <<EOF
./build.sh - Build script for idb
Usage:
./build.sh <command> [<target>]
Commands:
help
Print this usage information.
generate
Regenerate Xcode projects from project.yml using XcodeGen.
generate-proto
Regenerate gRPC Swift files from proto/idb.proto.
This builds protoc-gen-grpc-swift from grpc-swift 1.x source if needed.
build [<target>]
Build targets. If no target specified, builds everything.
Targets:
(none) Build all targets
all Build all targets
distribution Assemble the distribution
frameworks Build all frameworks only
idb_companion Build idb_companion only
idb-repl Build idb-repl only
shims Build all shim dylibs (Shimulator + Repl, iOS + macOS)
FBControlCore Build FBControlCore framework
FBDeviceControl Build FBDeviceControl framework
FBSimulatorControl Build FBSimulatorControl framework
Repl-iOS Build Repl-iOS dylib (iOS simulator)
Repl-macOS Build Repl-macOS dylib (macOS)
Shimulator-iOS Build Shimulator-iOS dylib (iOS simulator)
Shimulator-macOS Build Shimulator-macOS dylib (macOS)
SimulatorFrameworkBridge Build SimulatorFrameworkBridge executable (iOS simulator)
XCTestBootstrap Build XCTestBootstrap framework
test [<target>]
Run tests. If no target specified, runs all tests.
Targets:
(none) Run all tests
all Run all tests
FBControlCore Test FBControlCore
XCTestBootstrap Test XCTestBootstrap
FBSimulatorControl Test FBSimulatorControl
FBDeviceControl Test FBDeviceControl
Examples:
./build.sh generate # Regenerate Xcode projects
./build.sh generate-proto # Regenerate gRPC Swift from proto
./build.sh build # Build everything
./build.sh build frameworks # Build all frameworks
./build.sh build shims # Build Shimulator-iOS and Shimulator-macOS
./build.sh build idb_companion # Build idb_companion
./build.sh build FBControlCore # Build specific framework
./build.sh test # Run all tests
./build.sh test FBSimulatorControl # Test specific framework
Prerequisites:
- Xcode 14.0+
- XcodeGen: brew install xcodegen
- For idb_companion: brew install protobuf swift-protobuf
EOF
}
# =============================================================================
# Main
# =============================================================================
COMMAND=${COMMAND:-$1}
TARGET_ARG=${2:-}
if [[ -z $COMMAND ]]; then
echo "No command provided"
print_usage
exit 1
fi
echo "Command: $COMMAND"
if [[ -n $TARGET_ARG ]]; then
echo "Target: $TARGET_ARG"
fi
case $COMMAND in
help|-h|--help)
print_usage;;
generate)
regenerate_projects;;
generate-proto)
generate_proto;;
build)
regenerate_projects
build "$TARGET_ARG";;
test)
regenerate_projects
run_tests "$TARGET_ARG";;
*)
echo "Unknown command: $COMMAND"
print_usage
exit 1;;
esac
# vim: set tabstop=2 shiftwidth=2 filetype=sh: