1212 cargo test --lib
1313
1414export ANDROID_HOME := env (" ANDROID_HOME" , " ~/Library/Android/sdk" )
15- export HOST_ARCH := arch ()
1615
1716install-ndk :
1817 #!/usr/bin/env bash
@@ -24,16 +23,23 @@ install-ndk:
2423
2524install-ios-targets :
2625 #!/usr/bin/env bash
27- rustup target add aarch64-apple-ios-sim aarch64-apple-ios aarch64-apple-ios-macabi aarch64-apple-darwin
28- if [ ${HOST_ARCH} == " x86_64" ]; then \
29- rustup target add x86_64-apple-ios; \
30- fi
26+ rustup target add aarch64-apple-ios-sim aarch64-apple-ios
3127
3228install-android-targets :
3329 rustup target add x86 _64 -linux-android aarch64 -linux-android armv7-linux-androideabi
3430 cargo install cargo-ndk@4.1.2
3531
36- test-ios :
32+ build-ios : generate-ios-project
33+ #!/usr/bin/env bash
34+ set -o pipefail
35+ DEVICE_ID=$( xcrun simctl list devices available | grep iPhone | head -1 | sed ' s/.*(\([A-F0-9-]*\)).*/\1/' )
36+ echo " Using Simulator: $DEVICE_ID "
37+ xcodebuild -project tests/ios/GemTest/GemTest.xcodeproj \
38+ -scheme GemTest \
39+ -destination " platform=iOS Simulator,id=$DEVICE_ID ,arch=arm64" \
40+ build | xcbeautify
41+
42+ test-ios : generate-ios-project
3743 #!/usr/bin/env bash
3844 set -o pipefail
3945 DEVICE_ID=$( xcrun simctl list devices available | grep iPhone | head -1 | sed ' s/.*(\([A-F0-9-]*\)).*/\1/' )
@@ -44,7 +50,6 @@ test-ios:
4450 test | xcbeautify
4551
4652export LIB_NAME := " gemstone"
47- export FW_NAME := " Gemstone"
4853export STATIC_LIB_NAME := " lib" + LIB_NAME + " .a"
4954export DY_LIB_NAME := if os () == " macos" { " libgemstone.dylib" } else { " libgemstone.so" }
5055
@@ -56,24 +61,10 @@ export TARGET_DIR := "../target"
5661export GEN_SWIFT_FOLDER := " generated/swift"
5762export GEN_KOTLIN_FOLDER := " generated/kotlin"
5863export ANDROID_MODULE_FOLDER := " android/gemstone/src/main/java"
64+ export IOS_PROJECT_FOLDER := " tests/ios/GemTest"
65+ export IOS_PACKAGE_FOLDER := " tests/ios/Packages/Gemstone"
5966
60- export TARGET_XC_FW_FOLDER := " target/spm"
61- export FW_FFI_NAME := FW_NAME + " FFI"
62- export FW_FFI_FILE := FW_FFI_NAME + " .framework"
63- export XC_FW_FFI_NAME := FW_FFI_NAME + " .xcframework"
64- export DEPLOYMENT_TARGET := env (" IPHONEOS_DEPLOYMENT_TARGET" , " 17.0" )
6567export LIB_OUTPUT_PATH := TARGET_DIR + " /" + BUILD_MODE_TARGET + " /" + DY_LIB_NAME
66- build-ios : build-targets bindgen-swift assemble-frameworks xcframework cp-xcframework-source
67-
68- build-targets :
69- #!/usr/bin/env bash
70- echo " Host: ${HOST_ARCH} , iOS deployment target ${DEPLOYMENT_TARGET} , BUILD_MODE_TARGET: ${BUILD_MODE_TARGET} "
71- if [ ${HOST_ARCH} == " x86_64" ]; then \
72- IPHONEOS_DEPLOYMENT_TARGET=${DEPLOYMENT_TARGET} cargo build --target x86_64-apple-ios ${BUILD_FLAG} ; \
73- else \
74- IPHONEOS_DEPLOYMENT_TARGET=${DEPLOYMENT_TARGET} cargo build --target aarch64-apple-ios-sim --target aarch64-apple-ios ${BUILD_FLAG} ; \
75- env -u IPHONEOS_DEPLOYMENT_TARGET cargo build --target aarch64-apple-ios-macabi --target aarch64-apple-darwin ${BUILD_FLAG} ; \
76- fi
7768
7869bindgen-swift :
7970 #!/usr/bin/env bash
@@ -89,56 +80,14 @@ bindgen-swift:
8980 fi ; \
9081 cargo run ${BUILD_FLAG} -p uniffi-bindgen -- generate --library --language swift --crate ${LIB_NAME} -o ${GEN_SWIFT_FOLDER} " ${LIB_OUTPUT_PATH} "
9182
92- assemble-frameworks :
83+ prepare-ios-package : bindgen-swift
9384 #!/usr/bin/env bash
94- MODULE_MAP=$(
95- cat << EOF
96- // This file was autogenerated by some hot garbage in the uniffi crate.
97- framework module ${FW_FFI_NAME} {
98- header "${FW_FFI_NAME} .h"
99- export *
100- }
101- EOF
102- )
103- cd ${TARGET_DIR} && find . -type d -name ${FW_FFI_FILE} | xargs rm -rf
104- targets=(aarch64-apple-ios-sim aarch64-apple-ios aarch64-apple-ios-macabi aarch64-apple-darwin)
105- if [ ${HOST_ARCH} == "x86_64" ]; then
106- targets=(x86_64-apple-ios)
107- fi
108- for target in ${targets[@]} ; do \
109- pushd ${TARGET_DIR} /${target} /${BUILD_MODE_TARGET} > /dev/null && \
110- mkdir -p ${FW_FFI_FILE} && \
111- cd ${FW_FFI_FILE} && \
112- mkdir Headers Modules && \
113- echo "$MODULE_MAP " > ./Modules/module.modulemap && \
114- cp ../../../../${LIB_NAME} /${GEN_SWIFT_FOLDER} /${FW_FFI_NAME} .h ./Headers && \
115- cp ../${STATIC_LIB_NAME} ./${FW_FFI_NAME} && \
116- cp ../../../../${LIB_NAME} /src/Info.plist ./; \
117- popd > /dev/null; \
118- done
119-
120- xcframework:
121- #!/usr/bin/env bash
122- rm -rf ${TARGET_XC_FW_FOLDER} /Sources/${XC_FW_FFI_NAME}
123- mkdir -p ${TARGET_XC_FW_FOLDER} /Sources
124- if [ ${HOST_ARCH} == "x86_64" ]; then \
125- xcodebuild -create-xcframework \
126- -framework ${TARGET_DIR} /x86_64-apple-ios/${BUILD_MODE_TARGET} /${FW_FFI_FILE} \
127- -output ${TARGET_XC_FW_FOLDER} /Sources/${XC_FW_FFI_NAME} ; \
128- else \
129- xcodebuild -create-xcframework \
130- -framework ${TARGET_DIR} /aarch64-apple-ios/${BUILD_MODE_TARGET} /${FW_FFI_FILE} \
131- -framework ${TARGET_DIR} /aarch64-apple-ios-sim/${BUILD_MODE_TARGET} /${FW_FFI_FILE} \
132- -framework ${TARGET_DIR} /aarch64-apple-ios-macabi/${BUILD_MODE_TARGET} /${FW_FFI_FILE} \
133- -framework ${TARGET_DIR} /aarch64-apple-darwin/${BUILD_MODE_TARGET} /${FW_FFI_FILE} \
134- -output ${TARGET_XC_FW_FOLDER} /Sources/${XC_FW_FFI_NAME} ; \
135- fi
85+ mkdir -p ${IOS_PACKAGE_FOLDER} /Sources/Gemstone ${IOS_PACKAGE_FOLDER} /Sources/GemstoneFFI/include
86+ cp ${GEN_SWIFT_FOLDER} /gemstone.swift ${IOS_PACKAGE_FOLDER} /Sources/Gemstone/Gemstone.swift
87+ cp ${GEN_SWIFT_FOLDER} /GemstoneFFI.h ${IOS_PACKAGE_FOLDER} /Sources/GemstoneFFI/include/GemstoneFFI.h
13688
137- cp-xcframework-source:
138- #!/usr/bin/env bash
139- mkdir -p ${TARGET_XC_FW_FOLDER} /Sources/${FW_NAME}
140- cp src/Package.swift ${TARGET_XC_FW_FOLDER}
141- cp ${GEN_SWIFT_FOLDER} /${FW_NAME} .swift ${TARGET_XC_FW_FOLDER} /Sources/${FW_NAME}
89+ generate-ios-project : prepare-ios-package
90+ xcodegen generate --spec ${IOS_PROJECT_FOLDER}/ project.yml --project ${IOS_PROJECT_FOLDER}
14291
14392bindgen-kotlin :
14493 #!/usr/bin/env bash
0 commit comments