Simplify witness generator makefile.

This commit is contained in:
Alejandro Cabeza Romero 2025-08-29 18:16:59 +02:00
parent 7f75894323
commit 7806db9814
No known key found for this signature in database
GPG Key ID: DA3D14AE478030FD
2 changed files with 49 additions and 6 deletions

View File

@ -0,0 +1,43 @@
.PHONY: linux macos windows build clean
# ---- Common ----
CXX := g++
CXXFLAGS_COMMON := -std=c++11 -O3 -I. -Wno-address-of-packed-member
SRCS := main.cpp calcwit.cpp fr.cpp pol.cpp
OBJS := $(SRCS:.cpp=.o)
DEPS_HPP := circom.hpp calcwit.hpp fr.hpp
BIN_WINDOWS := pol.exe
BIN_UNIX := pol
BINS := $(BIN_UNIX) $(BIN_WINDOWS)
# ---- Linux ----
linux: BIN=$(BIN_UNIX)
linux: CXXFLAGS=$(CXXFLAGS_COMMON)
linux: LDFLAGS=-static
linux: LDLIBS=-lgmp
linux: $(BIN_UNIX)
# ---- macOS ----
macos: BIN=$(BIN_UNIX)
macos: CXXFLAGS=$(CXXFLAGS_COMMON) -I/opt/homebrew/include -include gmp_patch.hpp
macos: LDFLAGS=-Wl,-search_paths_first -Wl,-dead_strip
macos: LDLIBS=/opt/homebrew/lib/libgmp.a
macos: $(BIN_UNIX)
# ---- Windows (MinGW) ----
windows: BIN=$(BIN_WINDOWS)
windows: CXXFLAGS=$(CXXFLAGS_COMMON) -I/include -Duint="unsigned int"
windows: LDFLAGS=-static
windows: LDLIBS=-L/lib -lgmp -lmman
windows: $(BIN_WINDOWS)
# ---- Rules ----
$(BINS): $(OBJS)
$(CXX) $(LDFLAGS) $^ $(LDLIBS) -o $@
%.o: %.cpp $(DEPS_HPP)
$(CXX) $(CXXFLAGS) -c $< -o $@
clean:
rm -f $(OBJS) $(BIN_WINDOWS) $(BIN_UNIX)

View File

@ -104,11 +104,11 @@ jobs:
- name: Replace Witness Generator Makefile # TODO: Make a fork generate the appropriate Linux Makefile
working-directory: repo
run: cp .github/resources/witness-generator/${{ env.OS }}.Makefile circom_circuits/Mantle/pol_cpp/Makefile
run: cp .github/resources/witness-generator/Makefile circom_circuits/Mantle/pol_cpp/Makefile
- name: Compile Witness Generator
working-directory: repo/circom_circuits/Mantle/pol_cpp
run: make pol
run: make linux
- name: Bundle Rapidsnark Prover
working-directory: repo
@ -270,12 +270,12 @@ jobs:
- name: Replace Witness Generator Makefile # TODO: Make a fork generate the appropriate Windows Makefile
shell: msys2 {0}
working-directory: repo
run: cp .github/resources/witness-generator/${{ env.OS }}.Makefile circom_circuits/Mantle/pol_cpp/Makefile
run: cp .github/resources/witness-generator/Makefile circom_circuits/Mantle/pol_cpp/Makefile
- name: Compile Witness Generator
shell: msys2 {0}
working-directory: repo/circom_circuits/Mantle/pol_cpp
run: make pol.exe
run: make windows
- name: Bundle Rapidsnark Prover
shell: msys2 {0}
@ -394,7 +394,7 @@ jobs:
- name: Replace Witness Generator's Makefile # TODO: Make a fork generate the appropriate MacOS Makefile
working-directory: repo
run: cp .github/resources/witness-generator/${{ env.OS }}.Makefile circom_circuits/Mantle/pol_cpp/Makefile
run: cp .github/resources/witness-generator/Makefile circom_circuits/Mantle/pol_cpp/Makefile
- name: Patch MacOS GMP
working-directory: repo
@ -402,7 +402,7 @@ jobs:
- name: Compile Witness Generator
working-directory: repo/circom_circuits/Mantle/pol_cpp
run: make pol
run: make macos
- name: Bundle Rapidsnark Prover
working-directory: repo