Makefile 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. .POSIX:
  2. # Cargo binary
  3. CARGO = cargo +nightly
  4. # Compile target for system binaries
  5. RUST_TARGET = $(shell rustc -Vv | grep '^host: ' | cut -d' ' -f2)
  6. # Uncomment when doing musl static builds
  7. #RUSTFLAGS = -C target-feature=+crt-static -C link-self-contained=yes
  8. # wasm build target
  9. WASM_TARGET = wasm32-unknown-unknown
  10. # Cargo package name
  11. PKGNAME = $(shell grep '^name = ' Cargo.toml | cut -d' ' -f3 | tr -d '"')
  12. # wasm contract binary
  13. WASM_BIN = $(PKGNAME:=.wasm)
  14. # zkas compiler binary
  15. ZKAS = ../../../zkas
  16. # zkas circuits
  17. PROOFS_SRC = $(shell find proof -type f -name '*.zk')
  18. PROOFS_BIN = $(PROOFS_SRC:=.bin)
  19. # wasm source files
  20. WASM_SRC = \
  21. Cargo.toml \
  22. ../../../Cargo.toml \
  23. ../../../src/sdk/Cargo.toml \
  24. ../../../src/serial/Cargo.toml \
  25. $(shell find src -type f -name '*.rs') \
  26. $(shell find ../../sdk -type f -name '*.rs') \
  27. $(shell find ../../serial -type f -name '*.rs')
  28. all: $(WASM_BIN)
  29. $(PROOFS_BIN): $(ZKAS) $(PROOFS_SRC)
  30. $(ZKAS) $(basename $@) -o $@
  31. $(WASM_BIN): $(WASM_SRC) $(PROOFS_BIN)
  32. RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) build --target=$(WASM_TARGET) \
  33. --release --package $(PKGNAME)
  34. cp -f ../../../target/$(WASM_TARGET)/release/$@ $@
  35. wasm-strip $@
  36. test-integration: all
  37. RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) test --target=$(RUST_TARGET) \
  38. --release --package $(PKGNAME) \
  39. --features=no-entrypoint,client \
  40. --test integration
  41. test: test-integration
  42. clippy: all
  43. RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) clippy --target=$(WASM_TARGET) \
  44. --release --package $(PKGNAME)
  45. RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) clippy --target=$(RUST_TARGET) \
  46. --release --package $(PKGNAME) \
  47. --features=no-entrypoint,client --tests
  48. clean:
  49. RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) clean --target=$(WASM_TARGET) \
  50. --release --package $(PKGNAME)
  51. RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) clean --target=$(RUST_TARGET) \
  52. --release --package $(PKGNAME)
  53. rm -f $(PROOFS_BIN) $(WASM_BIN)
  54. .PHONY: all test-integration test clippy clean