From 6fde46f94aa078cd9602abb2498b3ed301a1cc61 Mon Sep 17 00:00:00 2001 From: Jacob Fielding Date: Fri, 11 Oct 2024 15:52:35 -0700 Subject: [PATCH] all vcpkg builds should work --- .github/workflows/android.yml | 38 +++++++++++++++++++++++------------ .github/workflows/ios.yml | 13 +++++++++--- build.sh | 13 +++++++++++- scripts/build_apple.sh | 10 ++++----- scripts/create_xcframework.sh | 30 +++++++++++++-------------- 5 files changed, 66 insertions(+), 38 deletions(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 438388d..20ead3e 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -65,16 +65,22 @@ jobs: with: path: jniLibs - - name: Combine artifacts + - name: Organize and zip artifacts run: | - mkdir -p combined/jniLibs - cp -R jniLibs/libvalhalla-*/* combined/jniLibs/ - - - name: Upload combined JNI Libs + mkdir -p android/valhalla/src/main/jniLibs + for arch in arm64-v8a armeabi-v7a x86 x86_64; do + mkdir -p android/valhalla/src/main/jniLibs/$arch + if [ -f jniLibs/libvalhalla-$arch/libvalhalla-wrapper.so ]; then + cp jniLibs/libvalhalla-$arch/libvalhalla-wrapper.so android/valhalla/src/main/jniLibs/$arch/ + fi + done + zip -r valhalla-jniLibs.zip android + + - name: Upload zipped JNI Libs uses: actions/upload-artifact@v4 with: - name: combined-jni-libs - path: combined/jniLibs + name: valhalla-jniLibs + path: valhalla-jniLibs.zip retention-days: 1 check-ktfmt: @@ -120,11 +126,14 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Download combined JNI Libs + - name: Download JNI Libs uses: actions/download-artifact@v4 with: - name: combined-jni-libs - path: android/valhalla/src/main/jniLibs + name: valhalla-jniLibs + path: . + + - name: Unzip JNI Libs + run: unzip valhalla-jniLibs.zip - name: set up JDK 17 uses: actions/setup-java@v4 @@ -166,11 +175,14 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Download combined JNI Libs + - name: Download JNI Libs uses: actions/download-artifact@v4 with: - name: combined-jni-libs - path: android/valhalla/src/main/jniLibs + name: valhalla-jniLibs + path: . + + - name: Unzip JNI Libs + run: unzip valhalla-jniLibs.zip - name: set up JDK 17 uses: actions/setup-java@v4 diff --git a/.github/workflows/ios.yml b/.github/workflows/ios.yml index 45c77fa..2f04350 100644 --- a/.github/workflows/ios.yml +++ b/.github/workflows/ios.yml @@ -11,7 +11,7 @@ jobs: runs-on: macos-14 strategy: matrix: - arch: ["iphoneos", "iphonesimulator", "iphonesimulator-legacy"] + arch: ["arm64-ios", "arm64-ios-simulator", "x64-ios-simulator"] concurrency: group: ${{ github.workflow }}-${{ github.ref }}-ios-build-${{ matrix.arch }} cancel-in-progress: true @@ -34,9 +34,9 @@ jobs: - name: Upload build artifacts uses: actions/upload-artifact@v4 with: - name: valhalla-ios-${{ matrix.arch }} + name: ${{ matrix.arch }} path: | - build/apple/**/${{ matrix.arch }}/install + build/apple/${{ matrix.arch }}/install create-xcframework: needs: build @@ -50,6 +50,13 @@ jobs: with: path: build/apple + - name: Move artifacts to correct locations + run: | + for arch in arm64-ios arm64-ios-simulator x64-ios-simulator; do + mkdir -p build/apple/$arch + mv build/apple/$arch/* build/apple/$arch/install/ || true + done + - name: Create XCFramework run: | ./scripts/create_xcframework.sh diff --git a/build.sh b/build.sh index e2c6140..890fe5a 100755 --- a/build.sh +++ b/build.sh @@ -3,7 +3,7 @@ # Fail on any error set -e -ios_archs=("iphoneos" "iphonesimulator" "iphonesimulator-legacy") +ios_archs=("arm64-ios" "arm64-ios-simulator" "x64-ios-simulator") android_archs=("arm64-v8a" "armeabi-v7a" "x86_64" "x86") build_ios() { @@ -47,6 +47,17 @@ move_android_so() { fi } +if [ -d "$(pwd)/vcpkg" ]; then + export VCPKG_ROOT="$(pwd)/vcpkg" +else + # If VCPKG_ROOT is not set and vcpkg directory doesn't exist locally + if [ -z "${VCPKG_ROOT+x}" ]; then + echo "VCPKG_ROOT is not set and vcpkg directory not found in the current working directory." + echo "Review setup in README.md or export a custom $VCPKG_ROOT." + exit 1 + fi +fi + platform="" arch="" clean=false diff --git a/scripts/build_apple.sh b/scripts/build_apple.sh index 4cbc621..99c4446 100755 --- a/scripts/build_apple.sh +++ b/scripts/build_apple.sh @@ -1,7 +1,5 @@ #!/bin/sh -export VCPKG_ROOT=`pwd`/vcpkg - # Check for Xcode command line tools if ! command -v xcodebuild &> /dev/null; then echo "Xcode command line tools not found. Please install Xcode." @@ -18,19 +16,19 @@ vcpkg_toolchain_file=$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake vcpkg_triplet_overlay=`pwd`/triplets # Check if the first argument is a valid Apple architecture -if [ "$1" == "iphoneos" ]; then +if [ "$1" == "arm64-ios" ]; then sdk=iphoneos system_name=iOS min_deployment_target=13.0 arch=arm64 vcpkg_target_triplet=arm64-ios -elif [ "$1" == "iphonesimulator" ]; then +elif [ "$1" == "arm64-ios-simulator" ]; then sdk=iphonesimulator system_name=iOS min_deployment_target=13.0 arch=arm64 vcpkg_target_triplet=arm64-ios-simulator -elif [ "$1" == "iphonesimulator-legacy" ]; then +elif [ "$1" == "x64-ios-simulator" ]; then sdk=iphonesimulator system_name=iOS min_deployment_target=13.0 @@ -66,7 +64,7 @@ else exit 1 fi -build_dir=`pwd`/build/apple/$arch/$sdk +build_dir=`pwd`/build/apple/$vcpkg_target_triplet wrapper_dir=`pwd`/src # Move to the build directory diff --git a/scripts/create_xcframework.sh b/scripts/create_xcframework.sh index 5781968..0f184f3 100755 --- a/scripts/create_xcframework.sh +++ b/scripts/create_xcframework.sh @@ -2,31 +2,31 @@ # build/apple/arm64/iphoneos/wrapper/install/lib/libprotobuf-lite.a \ # build/apple/arm64/iphoneos/install/lib/libtz.a \ -libtool -static -o build/apple/arm64/iphoneos/libvalhalla_all.a \ - build/apple/arm64/iphoneos/install/lib/libvalhalla.a \ - build/apple/arm64/iphoneos/install/lib/libvalhalla-wrapper.a +libtool -static -o build/apple/arm64-ios/libvalhalla_all.a \ + build/apple/arm64-ios/install/lib/libvalhalla.a \ + build/apple/arm64-ios/install/lib/libvalhalla-wrapper.a # build/apple/arm64/iphonesimulator/wrapper/install/lib/libprotobuf-lite.a \ # build/apple/arm64/iphonesimulator/install/lib/libtz.a \ -libtool -static -o build/apple/arm64/iphonesimulator/libvalhalla_all.a \ - build/apple/arm64/iphonesimulator/install/lib/libvalhalla.a \ - build/apple/arm64/iphonesimulator/install/lib/libvalhalla-wrapper.a +libtool -static -o build/apple/arm64-ios-simulator/libvalhalla_all.a \ + build/apple/arm64-ios-simulator/install/lib/libvalhalla.a \ + build/apple/arm64-ios-simulator/install/lib/libvalhalla-wrapper.a # build/apple/x86_64/iphonesimulator/wrapper/install/lib/libprotobuf-lite.a \ # build/apple/x86_64/iphonesimulator/install/lib/libtz.a \ -libtool -static -o build/apple/x86_64/iphonesimulator/libvalhalla_all.a \ - build/apple/x86_64/iphonesimulator/install/lib/libvalhalla.a \ - build/apple/x86_64/iphonesimulator/install/lib/libvalhalla-wrapper.a +libtool -static -o build/apple/x64-ios-simulator/libvalhalla_all.a \ + build/apple/x64-ios-simulator/install/lib/libvalhalla.a \ + build/apple/x64-ios-simulator/install/lib/libvalhalla-wrapper.a -if [ ! -d "build/apple/arm64-x86_64/iphonesimulator" ]; then - mkdir -p build/apple/arm64-x86_64/iphonesimulator +if [ ! -d "build/apple/arm64-x64-ios-simulator" ]; then + mkdir -p build/apple/arm64-x64-ios-simulator fi # Merge the two simulator libraries into one fat library -lipo -create build/apple/arm64/iphonesimulator/libvalhalla_all.a build/apple/x86_64/iphonesimulator/libvalhalla_all.a \ - -output build/apple/arm64-x86_64/iphonesimulator/libvalhalla_all.a +lipo -create build/apple/arm64-ios-simulator/libvalhalla_all.a build/apple/x64-ios-simulator/libvalhalla_all.a \ + -output build/apple/arm64-x64-ios-simulator/libvalhalla_all.a xcodebuild -create-xcframework \ - -library build/apple/arm64/iphoneos/libvalhalla_all.a -headers build/apple/arm64/iphoneos/install/include \ - -library build/apple/arm64-x86_64/iphonesimulator/libvalhalla_all.a -headers build/apple/arm64/iphoneos/install/include \ + -library build/apple/arm64-ios/libvalhalla_all.a -headers build/apple/arm64-ios/install/include \ + -library build/apple/arm64-x64-ios-simulator/libvalhalla_all.a -headers build/apple/arm64-ios/install/include \ -output build/apple/valhalla-wrapper.xcframework