diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 12e88858..acb70368 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -1,29 +1,29 @@ name: Rust -on: - [push, pull_request] +on: [push, pull_request] env: CARGO_TERM_COLOR: always jobs: build: - runs-on: macos-latest steps: - - uses: actions/checkout@v3 - - name: Install circom - run: | - git clone https://github.com/iden3/circom.git - cd circom - cargo build --release - cargo install --path circom - - name: Build - run: ./scripts/build_ios.sh simulator debug - - name: Run core tests - run: cd mopro-core/ && cargo test --verbose - - name: Run ffi tests - run: cd mopro-ffi/ && cargo test --verbose - - name: Run bindings tests - run: cd mopro-ffi/ && cargo test --test test_generated_bindings \ No newline at end of file + - uses: actions/checkout@v3 + - name: Install circom + run: | + git clone https://github.com/iden3/circom.git + cd circom + cargo build --release + cargo install --path circom + - name: Prepare + run: ./scripts/prepare.sh + - name: Build + run: ./scripts/build_ios.sh simulator debug + - name: Run core tests + run: cd mopro-core/ && cargo test --verbose + - name: Run ffi tests + run: cd mopro-ffi/ && cargo test --verbose + - name: Run bindings tests + run: cd mopro-ffi/ && cargo test --test test_generated_bindings diff --git a/README.md b/README.md index 1d772625..ba2ee02e 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,12 @@ Zooming in a bit: ![mopro architecture](images/mopro_architecture2.png) +## Prepare + +- Install [circom](https://docs.circom.io/) +- Install [cocoapods](https://cocoapods.org/) +- Run `./scripts/prepare.sh` to check all prerequisites are set. + ## Build Bindings To build bindings for iOS simulator debug mode, run diff --git a/mopro-core/examples/circom/compile.sh b/mopro-core/examples/circom/compile.sh index 9ed1f2ce..68fe351b 100755 --- a/mopro-core/examples/circom/compile.sh +++ b/mopro-core/examples/circom/compile.sh @@ -1,3 +1,3 @@ #!/bin/bash -circom ./examples/circom/multiplier2.circom --r1cs --wasm --sym --output ./examples/circom/target \ No newline at end of file +circom ./examples/circom/multiplier2.circom --r1cs --wasm --sym --output ./examples/circom/target diff --git a/mopro-core/examples/circom/keccak256/compile.sh b/mopro-core/examples/circom/keccak256/compile.sh index f7f18690..fd9f0cc5 100755 --- a/mopro-core/examples/circom/keccak256/compile.sh +++ b/mopro-core/examples/circom/keccak256/compile.sh @@ -1,4 +1,4 @@ #!/bin/bash -mkdir target -circom ./keccak256_256_test.circom --r1cs --wasm --sym --output ./target \ No newline at end of file +mkdir -p target +circom ./keccak256_256_test.circom --r1cs --wasm --sym --output ./target diff --git a/mopro-ios/README.md b/mopro-ios/README.md index ad96f3aa..b50fed0b 100644 --- a/mopro-ios/README.md +++ b/mopro-ios/README.md @@ -1,12 +1,27 @@ # mopro-ios +## Prepare + + + +Check the [Prepare](../README.md#prepare) and [Build Bindings](../README.md#build-bindings) steps in the root directory. + +## Execute + +Open the `MoproKit/Example/MoproKit.xcworkspace` in Xcode. +Use `command`+`R` to execute a simulator. + ## Linker problems? -- Open Xcworkspace -- Pod > MoproKit target -- Build Settings - - Library Search Paths - - Other Linker Flags - - Header search paths -- (Build Phases > Link Binary With Libraries `lmopro_ffi` (no lib no .a)) -- Gitignore +Add the following settings after + +1. `MoproKit/Example/Pods/Target Support Files/MoproKit/MoproKit.debug.xcconfig` +2. `MoproKit/Example/Pods/Target Support Files/MoproKit/MoproKit.release.xcconfig` + +files + +``` +LIBRARY_SEARCH_PATHS=${SRCROOT}/../../Libs +OTHER_LDFLAGS=-lmopro_ffi +USER_HEADER_SEARCH_PATHS=${SRCROOT}/../../include +``` diff --git a/scripts/build_ios.sh b/scripts/build_ios.sh index 59e7fc75..48b4f63e 100755 --- a/scripts/build_ios.sh +++ b/scripts/build_ios.sh @@ -2,6 +2,10 @@ PROJECT_DIR=$(pwd) +# Color definitions +DEFAULT='\033[0m' +RED='\033[0;31m' + # Check for the device type argument if [[ "$1" == "simulator" ]]; then DEVICE_TYPE="simulator" @@ -27,17 +31,11 @@ else fi # build circom circuits in mopro-core - -cd ${PROJECT_DIR}/mopro-core/examples/circom/keccak256 -npm install -./compile.sh cd ${PROJECT_DIR}/mopro-core cargo build --release # build ffi in mopro-ffi cd ${PROJECT_DIR}/mopro-ffi -rustup target add x86_64-apple-ios aarch64-apple-ios aarch64-apple-ios-sim -cargo install --bin uniffi-bindgen --path . make cargo build --release @@ -47,16 +45,15 @@ pod install # update bindings cd ${PROJECT_DIR} -./scripts/update_bindings.sh $1 $2 +./scripts/update_bindings.sh ${DEVICE_TYPE} ${BUILD_MODE} # update xcconfig - MODES="debug release" XCCONFIG_PATH=mopro-ios/MoproKit/Example/Pods/Target\ Support\ Files/MoproKit CONFIGS=" - LIBRARY_SEARCH_PATHS=\${SRCROOT}/../../Libs - OTHER_LDFLAGS=-lmopro_ffi - USER_HEADER_SEARCH_PATHS=\${SRCROOT}/../../include +LIBRARY_SEARCH_PATHS=\${SRCROOT}/../../Libs +OTHER_LDFLAGS=-lmopro_ffi +USER_HEADER_SEARCH_PATHS=\${SRCROOT}/../../include " for mode in ${MODES} do @@ -67,4 +64,4 @@ do echo "${config}" >> "${FILE_NAME}" fi done -done \ No newline at end of file +done diff --git a/scripts/prepare.sh b/scripts/prepare.sh new file mode 100755 index 00000000..fc7c4c2c --- /dev/null +++ b/scripts/prepare.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +PROJECT_DIR=$(pwd) + +# build circom circuits in mopro-core +cd ${PROJECT_DIR}/mopro-core/examples/circom/keccak256 +npm install +./compile.sh + +# build ffi in mopro-ffi +cd ${PROJECT_DIR}/mopro-ffi +rustup target add x86_64-apple-ios aarch64-apple-ios aarch64-apple-ios-sim +cargo install --bin uniffi-bindgen --path .