Makefile 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. .POSIX:
  2. # Cargo binary
  3. CARGO = cargo
  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-mint-pay-swap: all
  42. RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) test --target=$(RUST_TARGET) \
  43. --release --package $(PKGNAME) \
  44. --features=no-entrypoint,client \
  45. --test mint_pay_swap
  46. test-genesis-mint: all
  47. RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) test --target=$(RUST_TARGET) \
  48. --release --package $(PKGNAME) \
  49. --features=no-entrypoint,client \
  50. --test genesis_mint
  51. test-token-mint: all
  52. RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) test --target=$(RUST_TARGET) \
  53. --release --package $(PKGNAME) \
  54. --features=no-entrypoint,client \
  55. --test token_mint
  56. test-delayed-tx: all
  57. RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) test --target=$(RUST_TARGET) \
  58. --release --package $(PKGNAME) \
  59. --features=no-entrypoint,client \
  60. --test delayed_tx
  61. test: test-integration test-mint-pay-swap test-genesis-mint test-token-mint test-delayed-tx
  62. clippy: all
  63. RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) clippy --target=$(WASM_TARGET) \
  64. --release --package $(PKGNAME)
  65. RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) clippy --target=$(RUST_TARGET) \
  66. --release --package $(PKGNAME) \
  67. --features=no-entrypoint,client --tests
  68. clean:
  69. RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) clean --target=$(WASM_TARGET) \
  70. --release --package $(PKGNAME)
  71. RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) clean --target=$(RUST_TARGET) \
  72. --release --package $(PKGNAME)
  73. rm -f $(PROOFS_BIN) $(WASM_BIN)
  74. .PHONY: all test-integration test-mint-pay-swap test-genesis-mint test-delayed-tx test clippy clean