Skip to content

Commit

Permalink
support building gemstone on x64 arch
Browse files Browse the repository at this point in the history
  • Loading branch information
0xh3rman committed Nov 9, 2024
1 parent 80a68d5 commit e21896d
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions gemstone/justfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ test:
cargo test

export ANDROID_HOME := env_var_or_default("ANDROID_HOME", "~/Library/Android/sdk")
export HOST_ARCH := arch()

install-ndk:
#!/usr/bin/env bash
Expand All @@ -18,7 +19,11 @@ install-ndk:
$SDK_MANAGER --install $NDK

install-ios-targets:
#!/usr/bin/env bash
rustup target add aarch64-apple-ios-sim aarch64-apple-ios aarch64-apple-ios-macabi
if [ ${HOST_ARCH} == "x86_64" ]; then \
rustup target add x86_64-apple-ios; \
fi
install-android-targets:
rustup target add x86_64-linux-android aarch64-linux-android armv7-linux-androideabi
Expand Down Expand Up @@ -54,8 +59,12 @@ build-ios: build-targets bindgen-swift assemble-frameworks xcframework cp-xcfram

build-targets:
#!/usr/bin/env bash
echo "iOS deployment target ${DEPLOYMENT_TARGET}, BUILD_MODE_TARGET: ${BUILD_MODE_TARGET}"
IPHONEOS_DEPLOYMENT_TARGET=${DEPLOYMENT_TARGET} cargo build --timings --target aarch64-apple-ios-sim --target aarch64-apple-ios --target aarch64-apple-ios-macabi --${BUILD_MODE}
echo "Host: ${HOST_ARCH}, iOS deployment target ${DEPLOYMENT_TARGET}, BUILD_MODE_TARGET: ${BUILD_MODE_TARGET}"
if [ ${HOST_ARCH} == "x86_64" ]; then \
IPHONEOS_DEPLOYMENT_TARGET=${DEPLOYMENT_TARGET} cargo build --timings --target x86_64-apple-ios --${BUILD_MODE}
else \
IPHONEOS_DEPLOYMENT_TARGET=${DEPLOYMENT_TARGET} cargo build --timings --target aarch64-apple-ios-sim --target aarch64-apple-ios --target aarch64-apple-ios-macabi --${BUILD_MODE}
fi
bindgen-swift:
#!/usr/bin/env bash
Expand All @@ -76,7 +85,11 @@ assemble-frameworks:
EOF
)
cd ${TARGET_DIR} && find . -type d -name ${FW_FFI_FILE} | xargs rm -rf
for target in aarch64-apple-ios-sim aarch64-apple-ios aarch64-apple-ios-macabi; do \
targets=(aarch64-apple-ios-sim aarch64-apple-ios aarch64-apple-ios-macabi)
if [ ${HOST_ARCH} == "x86_64" ]; then
targets=(x86_64-apple-ios)
fi
for target in ${targets[@]}; do \
pushd ${TARGET_DIR}/${target}/${BUILD_MODE_TARGET} > /dev/null && \
mkdir -p ${FW_FFI_FILE} && cd ${FW_FFI_FILE} && mkdir Headers Modules && echo "$MODULE_MAP" > ./Modules/module.modulemap && cp ../../../../${LIB_NAME}/${GEN_SWIFT_FOLDER}/${FW_FFI_NAME}.h ./Headers && cp ../${STATIC_LIB_NAME} ./${FW_FFI_NAME} && cp ../../../../${LIB_NAME}/src/Info.plist ./; \
popd > /dev/null; \
Expand All @@ -85,7 +98,11 @@ assemble-frameworks:
xcframework:
#!/usr/bin/env bash
rm -rf ${TARGET_XC_FW_FOLDER}/Sources/${XC_FW_FFI_NAME} && mkdir -p ${TARGET_XC_FW_FOLDER}/Sources
xcodebuild -create-xcframework -framework ${TARGET_DIR}/aarch64-apple-ios/${BUILD_MODE_TARGET}/${FW_FFI_FILE} -framework ${TARGET_DIR}/aarch64-apple-ios-sim/${BUILD_MODE_TARGET}/${FW_FFI_FILE} -framework ${TARGET_DIR}/aarch64-apple-ios-macabi/${BUILD_MODE_TARGET}/${FW_FFI_FILE} -output ${TARGET_XC_FW_FOLDER}/Sources/${XC_FW_FFI_NAME}
if [ ${HOST_ARCH} == "x86_64" ]; then \
xcodebuild -create-xcframework -framework ${TARGET_DIR}/x86_64-apple-ios/${BUILD_MODE_TARGET}/${FW_FFI_FILE} -output ${TARGET_XC_FW_FOLDER}/Sources/${XC_FW_FFI_NAME}; \
else \
xcodebuild -create-xcframework -framework ${TARGET_DIR}/aarch64-apple-ios/${BUILD_MODE_TARGET}/${FW_FFI_FILE} -framework ${TARGET_DIR}/aarch64-apple-ios-sim/${BUILD_MODE_TARGET}/${FW_FFI_FILE} -framework ${TARGET_DIR}/aarch64-apple-ios-macabi/${BUILD_MODE_TARGET}/${FW_FFI_FILE} -output ${TARGET_XC_FW_FOLDER}/Sources/${XC_FW_FFI_NAME}; \
fi
cp-xcframework-source:
#!/usr/bin/env bash
Expand Down

0 comments on commit e21896d

Please sign in to comment.