Skip to content

Commit

Permalink
feat: improved isolated build setup for ios vs visionos
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanWalker committed Jan 31, 2024
1 parent a02f3d4 commit 8242a85
Show file tree
Hide file tree
Showing 5 changed files with 116 additions and 21 deletions.
4 changes: 2 additions & 2 deletions build_all_vision.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -e
rm -rf ./dist
./update_version.sh
./build_metadata_generator.sh
./build_nativescript.sh
./build_tklivesync.sh
BUILD_CATALYST=false BUILD_IPHONE=false BUILD_SIMULATOR=false ./build_nativescript.sh
BUILD_CATALYST=false BUILD_IPHONE=false BUILD_SIMULATOR=false ./build_tklivesync.sh
./prepare_dSYMs.sh
./build_npm_vision.sh
21 changes: 19 additions & 2 deletions build_nativescript.sh
Original file line number Diff line number Diff line change
Expand Up @@ -111,17 +111,32 @@ xcodebuild archive -project v8ios.xcodeproj \
fi

if $BUILD_VISION; then
checkpoint "Building NativeScript for visionOS"
checkpoint "Building NativeScript for visionOS Device"
xcodebuild archive -project v8ios.xcodeproj \
-scheme "NativeScript" \
-configuration Release \
-destination "generic/platform=xrsimulator" \
-destination "generic/platform=visionOS" \
-sdk xros \
$QUIET \
EXCLUDED_ARCHS="i386 x86_64" \
DEVELOPMENT_TEAM=$DEV_TEAM \
SKIP_INSTALL=NO \
IPHONEOS_DEPLOYMENT_TARGET=13.0 \
-archivePath $DIST/intermediates/NativeScript.xros.xcarchive

checkpoint "Building NativeScript for visionOS Simulators"
xcodebuild archive -project v8ios.xcodeproj \
-scheme "NativeScript" \
-configuration Release \
-destination "generic/platform=visionOS Simulator" \
-sdk xrsimulator \
$QUIET \
EXCLUDED_ARCHS="i386 x86_64" \
DEVELOPMENT_TEAM=$DEV_TEAM \
SKIP_INSTALL=NO \
IPHONEOS_DEPLOYMENT_TARGET=13.0 \
-archivePath $DIST/intermediates/NativeScript.xrsimulator.xcarchive

fi

if $BUILD_IPHONE; then
Expand Down Expand Up @@ -170,6 +185,8 @@ if $BUILD_IPHONE; then
fi

if $BUILD_VISION; then
XCFRAMEWORKS+=( -framework "$DIST/intermediates/NativeScript.xros.xcarchive/Products/Library/Frameworks/NativeScript.framework" \
-debug-symbols "$DIST/intermediates/NativeScript.xros.xcarchive/dSYMs/NativeScript.framework.dSYM" )
XCFRAMEWORKS+=( -framework "$DIST/intermediates/NativeScript.xrsimulator.xcarchive/Products/Library/Frameworks/NativeScript.framework" \
-debug-symbols "$DIST/intermediates/NativeScript.xrsimulator.xcarchive/dSYMs/NativeScript.framework.dSYM" )
fi
Expand Down
102 changes: 89 additions & 13 deletions build_tklivesync.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,48 @@
set -e
source "$(dirname "$0")/build_utils.sh"

function to_bool() {
local arg="$1"
case "$(echo "$arg" | tr '[:upper:]' '[:lower:]')" in
[0-9]+)
if [ $arg -eq 0 ]; then
echo false
else
echo true
fi
;;
n|no|f|false) echo false ;;
y|yes|t|true) echo true ;;
* )
if [ -n "$arg" ]; then
echo "warning: invalid boolean argument ('$arg'). Expected true or false" >&2
fi
echo false
;;
esac;
}

BUILD_CATALYST=$(to_bool ${BUILD_CATALYST:=true})
BUILD_IPHONE=$(to_bool ${BUILD_IPHONE:=true})
BUILD_SIMULATOR=$(to_bool ${BUILD_SIMULATOR:=true})
BUILD_VISION=$(to_bool ${BUILD_VISION:=true})
VERBOSE=$(to_bool ${VERBOSE:=false})

for arg in $@; do
case $arg in
--catalyst|--maccatalyst) BUILD_CATALYST=true ;;
--no-catalyst|--no-maccatalyst) BUILD_CATALYST=false ;;
--sim|--simulator) BUILD_SIMULATOR=true ;;
--no-sim|--no-simulator) BUILD_SIMULATOR=false ;;
--iphone|--device) BUILD_IPHONE=true ;;
--no-iphone|--no-device) BUILD_IPHONE=false ;;
--xr|--vision) BUILD_VISION=true ;;
--no-xr|--no-vision) BUILD_VISION=false ;;
--verbose|-v) VERBOSE=true ;;
*) ;;
esac
done

DIST=$(PWD)/dist
mkdir -p $DIST

Expand All @@ -14,6 +56,7 @@ xcodebuild -project v8ios.xcodeproj \
-configuration Release clean \
-quiet

if $BUILD_CATALYST; then
#generates library for Mac Catalyst target
checkpoint "Building TKLiveSync for Mac Catalyst"
xcodebuild archive -project v8ios.xcodeproj \
Expand All @@ -23,6 +66,7 @@ xcodebuild archive -project v8ios.xcodeproj \
-quiet \
SKIP_INSTALL=NO \
-archivePath $DIST/intermediates/TKLiveSync.maccatalyst.xcarchive
fi

# #generates library for x86_64 simulator target
# xcodebuild archive -project v8ios.xcodeproj \
Expand All @@ -43,6 +87,7 @@ xcodebuild archive -project v8ios.xcodeproj \
# SKIP_INSTALL=NO \
# -archivePath $DIST/TKLiveSync.arm64-iphonesimulator.xcarchive

if $BUILD_SIMULATOR; then
# generates library for simulator targets (usually includes arm64, x86_64)
checkpoint "Building TKLiveSync for iphone simulators (multi-arch)"
xcodebuild archive -project v8ios.xcodeproj \
Expand All @@ -53,17 +98,31 @@ xcodebuild archive -project v8ios.xcodeproj \
-quiet \
SKIP_INSTALL=NO \
-archivePath $DIST/intermediates/TKLiveSync.iphonesimulator.xcarchive
fi

checkpoint "Building TKLiveSync for visionOS"
if $BUILD_VISION; then
checkpoint "Building TKLiveSync for visionOS Device"
xcodebuild archive -project v8ios.xcodeproj \
-scheme TKLiveSync \
-scheme "TKLiveSync" \
-configuration Release \
-destination "generic/platform=visionOS" \
-sdk xros \
-quiet \
SKIP_INSTALL=NO \
-archivePath $DIST/intermediates/TKLiveSync.xros.xcarchive

checkpoint "Building TKLiveSync for visionOS Simulators"
xcodebuild archive -project v8ios.xcodeproj \
-scheme "TKLiveSync" \
-configuration Release \
-destination "generic/platform=xrsimulator" \
-destination "generic/platform=visionOS Simulator" \
-sdk xrsimulator \
-quiet \
SKIP_INSTALL=NO \
-archivePath $DIST/intermediates/TKLiveSync.xrsimulator.xcarchive
fi

if $BUILD_IPHONE; then
#generates library for device target
checkpoint "Building TKLiveSync for ARM64 device"
xcodebuild archive -project v8ios.xcodeproj \
Expand All @@ -74,6 +133,7 @@ xcodebuild archive -project v8ios.xcodeproj \
-quiet \
SKIP_INSTALL=NO \
-archivePath $DIST/intermediates/TKLiveSync.iphoneos.xcarchive
fi

#Creates directory for fat-library
OUTPUT_DIR="$DIST/TKLiveSync.xcframework"
Expand All @@ -95,17 +155,33 @@ rm -rf "${OUTPUT_PATH}"
# "$DIST/TKLiveSync.iphonesimulator.xcarchive/Products/Library/Frameworks/TKLiveSync.framework/TKLiveSync"

#Creates xcframework
XCFRAMEWORKS=()
if $BUILD_CATALYST; then
XCFRAMEWORKS+=( -framework "$DIST/intermediates/TKLiveSync.maccatalyst.xcarchive/Products/Library/Frameworks/TKLiveSync.framework" \
-debug-symbols "$DIST/intermediates/TKLiveSync.maccatalyst.xcarchive/dSYMs/TKLiveSync.framework.dSYM" )
fi

if $BUILD_SIMULATOR; then
XCFRAMEWORKS+=( -framework "$DIST/intermediates/TKLiveSync.iphonesimulator.xcarchive/Products/Library/Frameworks/TKLiveSync.framework" \
-debug-symbols "$DIST/intermediates/TKLiveSync.iphonesimulator.xcarchive/dSYMs/TKLiveSync.framework.dSYM" )
fi

if $BUILD_IPHONE; then
XCFRAMEWORKS+=( -framework "$DIST/intermediates/TKLiveSync.iphoneos.xcarchive/Products/Library/Frameworks/TKLiveSync.framework" \
-debug-symbols "$DIST/intermediates/TKLiveSync.iphoneos.xcarchive/dSYMs/TKLiveSync.framework.dSYM" )
fi

if $BUILD_VISION; then
XCFRAMEWORKS+=( -framework "$DIST/intermediates/TKLiveSync.xros.xcarchive/Products/Library/Frameworks/TKLiveSync.framework" \
-debug-symbols "$DIST/intermediates/TKLiveSync.xros.xcarchive/dSYMs/TKLiveSync.framework.dSYM" )
XCFRAMEWORKS+=( -framework "$DIST/intermediates/TKLiveSync.xrsimulator.xcarchive/Products/Library/Frameworks/TKLiveSync.framework" \
-debug-symbols "$DIST/intermediates/TKLiveSync.xrsimulator.xcarchive/dSYMs/TKLiveSync.framework.dSYM" )
fi

checkpoint "Creating TKLiveSync.xcframework"
xcodebuild -create-xcframework \
-framework "$DIST/intermediates/TKLiveSync.maccatalyst.xcarchive/Products/Library/Frameworks/TKLiveSync.framework" \
-debug-symbols "$DIST/intermediates/TKLiveSync.maccatalyst.xcarchive/dSYMs/TKLiveSync.framework.dSYM" \
-framework "$DIST/intermediates/TKLiveSync.iphonesimulator.xcarchive/Products/Library/Frameworks/TKLiveSync.framework" \
-debug-symbols "$DIST/intermediates/TKLiveSync.iphonesimulator.xcarchive/dSYMs/TKLiveSync.framework.dSYM" \
-framework "$DIST/intermediates/TKLiveSync.iphoneos.xcarchive/Products/Library/Frameworks/TKLiveSync.framework" \
-debug-symbols "$DIST/intermediates/TKLiveSync.iphoneos.xcarchive/dSYMs/TKLiveSync.framework.dSYM" \
-framework "$DIST/intermediates/TKLiveSync.xrsimulator.xcarchive/Products/Library/Frameworks/TKLiveSync.framework" \
-debug-symbols "$DIST/intermediates/TKLiveSync.xrsimulator.xcarchive/dSYMs/TKLiveSync.framework.dSYM" \
-output "$OUTPUT_DIR"
OUTPUT_DIR="$DIST/TKLiveSync.xcframework"
rm -rf $OUTPUT_DIR
xcodebuild -create-xcframework ${XCFRAMEWORKS[@]} -output "$OUTPUT_DIR"

rm -rf "$DIST/intermediates"

Expand Down
2 changes: 1 addition & 1 deletion metadata-generator/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ if (NOT LIBXML2_FOUND)
endif ()

get_filename_component(LLVM_ROOT "../../llvm/13.0.1" REALPATH BASE_DIR "${CMAKE_BINARY_DIR}")
set(CMAKE_OSX_DEPLOYMENT_TARGET 11.0)
set(CMAKE_OSX_DEPLOYMENT_TARGET 13.0)

set(LLVM_SYSTEM_LIBS "-lz -lcurses -lm -lxml2")
set(LLVM_PREPROCESSOR_FLAGS "-I${LLVM_ROOT}/include -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS")
Expand Down
8 changes: 5 additions & 3 deletions project-template-vision/internal/nsld.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,19 @@ function GEN_MODULEMAP() {
}

function GEN_METADATA() {
TARGET_ARCH=$1
set -e
cpu_arch=$(uname -m)
pushd "$SRCROOT/internal/metadata-generator-${cpu_arch}/bin"
./build-step-metadata-generator.py
./build-step-metadata-generator.py $TARGET_ARCH
popd
}

# Workaround for ARCH being set to `undefined_arch` here. Extract it from command line arguments.
GEN_MODULEMAP $(getArch "$@")
TARGET_ARCH=$(getArch "$@")
GEN_MODULEMAP $TARGET_ARCH
printf "Generating metadata..."
GEN_METADATA
GEN_METADATA $TARGET_ARCH
DELETE_SWIFT_MODULES_DIR
NS_LD="${NS_LD:-"$TOOLCHAIN_DIR/usr/bin/clang"}"
$NS_LD "$@"

0 comments on commit 8242a85

Please sign in to comment.