Skip to content

Commit

Permalink
Merge pull request #26 from 0xPolygonID/android_on_macos
Browse files Browse the repository at this point in the history
Android on macos
  • Loading branch information
olomix authored Apr 10, 2024
2 parents 25a3dbc + 68f55ec commit aa6c421
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 7 deletions.
18 changes: 15 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
path: |
depends/gmp
depends/gmp-6.2.1.tar.xz
key: ${{ runner.os }}-witnesscalc-gmp-apple-arm64-${{ hashFiles('build_gmp.sh') }}
key: ${{ runner.os }}-witnesscalc-gmp-apple-arm64-${{ hashFiles('build_gmp.sh') }}-2

- name: install dependencies
run: |
Expand All @@ -31,15 +31,25 @@ jobs:
if [[ ! -d "depends/gmp/package" ]]; then ./build_gmp.sh host; fi
if [[ ! -d "depends/gmp/package_ios_arm64" ]]; then ./build_gmp.sh ios; fi
if [[ ! -d "depends/gmp/package_iphone_simulator" ]]; then ./build_gmp.sh ios_simulator; fi
if [[ ! -d "depends/gmp/package_android_arm64" ]]; then ./build_gmp.sh android; fi
if [[ ! -d "depends/gmp/package_android_x86_64" ]]; then ./build_gmp.sh android_x86_64; fi
- name: build
- name: build Android
run: make android

- name: build Android x86_64
run: make android_x86_64

- name: build macOS
run: |
mkdir build_witnesscalc && cd build_witnesscalc
cmake .. -DTARGET_PLATFORM=arm64_host -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../package
make -j8
make install
cd ../
- name: build iOS
run: |
mkdir build_witnesscalc_ios && cd build_witnesscalc_ios
cmake .. -GXcode -DTARGET_PLATFORM=IOS -DCMAKE_INSTALL_PREFIX=../package_ios
xcodebuild -project witnesscalc.xcodeproj -destination 'generic/platform=iOS' -configuration Release -scheme witnesscalc_authV2Static
Expand Down Expand Up @@ -74,6 +84,8 @@ jobs:
cp -r ../package/include ../package_ios/include
cd ../
- name: build iOS simulator
run: |
mkdir build_prover_ios_simulator && cd build_prover_ios_simulator
cmake .. -GXcode -DTARGET_PLATFORM=IOS -DCMAKE_INSTALL_PREFIX=../package_ios_simulator -DUSE_ASM=NO
xcodebuild -project witnesscalc.xcodeproj -destination 'generic/platform=iOS Simulator' -configuration Debug -scheme witnesscalc_authV2Static
Expand Down Expand Up @@ -107,7 +119,7 @@ jobs:
../package_ios_simulator/lib
cp -r ../package/include ../package_ios_simulator/include
cd ../
- name: Cache circuits
uses: actions/cache@v4
with:
Expand Down
12 changes: 10 additions & 2 deletions build_gmp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,11 @@ build_android()
return 1
fi

export TOOLCHAIN=$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64
if [ "$(uname)" == "Darwin" ]; then
export TOOLCHAIN=$ANDROID_NDK/toolchains/llvm/prebuilt/darwin-x86_64
else
export TOOLCHAIN=$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64
fi

export TARGET=aarch64-linux-android
export API=21
Expand Down Expand Up @@ -173,7 +177,11 @@ build_android_x86_64()
return 1
fi

export TOOLCHAIN=$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64
if [ "$(uname)" == "Darwin" ]; then
export TOOLCHAIN=$ANDROID_NDK/toolchains/llvm/prebuilt/darwin-x86_64
else
export TOOLCHAIN=$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64
fi

export TARGET=x86_64-linux-android
export API=21
Expand Down
2 changes: 1 addition & 1 deletion cmake/platform.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ else()

endif()

if (CMAKE_HOST_SYSTEM_NAME MATCHES "Darwin")
if (CMAKE_HOST_SYSTEM_NAME MATCHES "Darwin" AND NOT TARGET_PLATFORM MATCHES "^android(_x86_64)?")
set(GMP_DEFINIONS -D_LONG_LONG_LIMB)
endif()

Expand Down
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ endif()

if(USE_ASM AND ARCH MATCHES "x86_64")

if (CMAKE_HOST_SYSTEM_NAME MATCHES "Darwin")
if (CMAKE_HOST_SYSTEM_NAME MATCHES "Darwin" AND NOT TARGET_PLATFORM MATCHES "^android(_x86_64)?")
set(NASM_FLAGS -fmacho64 --prefix _)
else()
set(NASM_FLAGS -felf64 -DPIC)
Expand Down

0 comments on commit aa6c421

Please sign in to comment.