Skip to content

Commit

Permalink
chore: add newlines, seperate build and prepare script, update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
vivianjeng authored and oskarth committed Oct 20, 2023
1 parent 6e4f553 commit 018bb1e
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 41 deletions.
36 changes: 18 additions & 18 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -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
- 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
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion mopro-core/examples/circom/compile.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash

circom ./examples/circom/multiplier2.circom --r1cs --wasm --sym --output ./examples/circom/target
circom ./examples/circom/multiplier2.circom --r1cs --wasm --sym --output ./examples/circom/target
4 changes: 2 additions & 2 deletions mopro-core/examples/circom/keccak256/compile.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash

mkdir target
circom ./keccak256_256_test.circom --r1cs --wasm --sym --output ./target
mkdir -p target
circom ./keccak256_256_test.circom --r1cs --wasm --sym --output ./target
31 changes: 23 additions & 8 deletions mopro-ios/README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
# mopro-ios

## Prepare

<!--TODO: If the monorepo is seperated, update this-->

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
```
21 changes: 9 additions & 12 deletions scripts/build_ios.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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

Expand All @@ -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
Expand All @@ -67,4 +64,4 @@ do
echo "${config}" >> "${FILE_NAME}"
fi
done
done
done
13 changes: 13 additions & 0 deletions scripts/prepare.sh
Original file line number Diff line number Diff line change
@@ -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 .

0 comments on commit 018bb1e

Please sign in to comment.