Skip to content

Commit

Permalink
all vcpkg builds should work
Browse files Browse the repository at this point in the history
  • Loading branch information
Archdoog committed Oct 11, 2024
1 parent 249c5f3 commit 6fde46f
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 38 deletions.
38 changes: 25 additions & 13 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
13 changes: 10 additions & 3 deletions .github/workflows/ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
13 changes: 12 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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
Expand Down
10 changes: 4 additions & 6 deletions scripts/build_apple.sh
Original file line number Diff line number Diff line change
@@ -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."
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
30 changes: 15 additions & 15 deletions scripts/create_xcframework.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 6fde46f

Please sign in to comment.