diff --git a/.github/resources/Makefile.windows b/.github/resources/Makefile.windows new file mode 100644 index 0000000..efd1937 --- /dev/null +++ b/.github/resources/Makefile.windows @@ -0,0 +1,17 @@ +CC = g++ +CFLAGS = -std=c++11 -O3 -I. -I/include -Duint="unsigned int" +LDFLAGS = -L/lib -lgmp -lmman + +DEPS_HPP = circom.hpp calcwit.hpp fr.hpp pol.cpp +DEPS_O = main.o calcwit.o fr.o pol.o + +all: pol.exe + +%.o: %.cpp $(DEPS_HPP) + $(CC) -Wno-address-of-packed-member -c $< $(CFLAGS) -o $@ + +pol.exe: $(DEPS_O) + $(CC) -o pol.exe $(DEPS_O) $(LDFLAGS) + +clean: + rm -f *.o pol.exe diff --git a/.github/workflows/compile-circuit.yml b/.github/workflows/compile-circuit.yml new file mode 100644 index 0000000..2bf740c --- /dev/null +++ b/.github/workflows/compile-circuit.yml @@ -0,0 +1,138 @@ +name: Build + +on: + push: + branches: [main] + pull_request: # For testing purposes + +jobs: + build-linux: + name: Build Linux Binary + runs-on: ubuntu-latest + steps: + - name: Install Rust Toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + toolchain: stable + cache: false + + - name: Install Circom + run: | + git clone https://github.com/iden3/circom.git + cd circom + RUSTFLAGS="-A dead_code" cargo build --release + RUSTFLAGS="-A dead_code" cargo install --path circom + circom --version + + - name: Checkout + uses: actions/checkout@v4 + with: + path: repo + + - name: Initialise Submodules + working-directory: repo + run: | + git submodule update --init --recursive + + - name: Generate C++ Circuit + working-directory: repo/circom_circuits/Mantle + run: | + circom --c --r1cs --no_asm pol.circom + + - name: Install Circuit Dependencies + run: | + sudo apt update + sudo apt install nlohmann-json3-dev + + - name: Compile Circuit + working-directory: repo/circom_circuits/Mantle/pol_cpp + run: | + make pol + + - name: Upload Binary + uses: actions/upload-artifact@v4 + working-directory: repo/circom_circuits/Mantle/pol_cpp + with: + name: pol + path: pol + + build-windows-native: + name: Build Windows Binary (Native) + runs-on: windows-latest + steps: + - name: Install Rust Toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + toolchain: stable + cache: false + + - name: Install Circom + run: | + git clone https://github.com/iden3/circom.git + cd circom + $env:RUSTFLAGS="-A dead_code"; cargo build --release + $env:RUSTFLAGS="-A dead_code"; cargo install --path circom + circom --version + + - name: Checkout + uses: actions/checkout@v4 + with: + path: repo + + - name: Initialise Submodules + working-directory: repo + run: | + git submodule update --init --recursive + + - name: Generate C++ Circuit + working-directory: repo/circom_circuits/Mantle + run: | + circom --c --r1cs --no_asm pol.circom + + - name: Setup MSYS2 + uses: msys2/setup-msys2@v2 + with: + update: true + install: >- + base-devel + mingw-w64-x86_64-toolchain + make + git + + - name: Dependencies - Setup + shell: msys2 {0} + run: mkdir /include + + - name: Dependencies - Install [mman-win32] + shell: msys2 {0} + run: | + git clone https://github.com/alitrack/mman-win32.git + cd mman-win32 + pwd + ./configure --prefix= # Path: / + make + make install + + - name: Dependencies - Install [nlohmann/json] + shell: msys2 {0} + run: | + mkdir -p /include/nlohmann/ + wget -O /include/nlohmann/json.hpp https://github.com/nlohmann/json/releases/download/v3.12.0/json.hpp + + - name: Replace pol Makefile # TODO: Make a fork generate the appropriate Windows Makefile + working-directory: repo + shell: msys2 {0} + run: cp .github/resources/Makefile.windows circom_circuits/Mantle/pol_cpp/Makefile + + - name: Compile Circuit + shell: msys2 {0} + working-directory: repo/circom_circuits/Mantle/pol_cpp + run: | + make pol.exe + + - name: Upload Binary + uses: actions/upload-artifact@v4 + working-directory: repo/circom_circuits/Mantle/pol_cpp + with: + name: pol.exe + path: pol.exe