Makefile 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. RUST_TOOLCHAIN_NIGHTLY = nightly-2025-02-16
  2. SOLANA_CLI_VERSION = 3.0.0
  3. nightly = +${RUST_TOOLCHAIN_NIGHTLY}
  4. # This is a bit tricky -- findstring returns the found string, so we're looking
  5. # for "directory-", returning that, and replacing "-" with "/" to change the
  6. # first "-" to a "/". But if it isn't found, we replace "" with "", which works
  7. # in the case where there is no subdirectory.
  8. pattern-dir = $(firstword $(subst -, ,$1))
  9. find-pattern-dir = $(findstring $(call pattern-dir,$1)-,$1)
  10. make-path = $(subst $(call find-pattern-dir,$1),$(subst -,/,$(call find-pattern-dir,$1)),$1)
  11. rust-toolchain-nightly:
  12. @echo ${RUST_TOOLCHAIN_NIGHTLY}
  13. solana-cli-version:
  14. @echo ${SOLANA_CLI_VERSION}
  15. cargo-nightly:
  16. cargo $(nightly) $(ARGS)
  17. audit:
  18. cargo audit \
  19. --ignore RUSTSEC-2022-0093 \
  20. --ignore RUSTSEC-2024-0421 \
  21. --ignore RUSTSEC-2024-0344 \
  22. --ignore RUSTSEC-2024-0376 $(ARGS)
  23. spellcheck:
  24. cargo spellcheck --code 1 $(ARGS)
  25. clippy-%:
  26. cargo $(nightly) clippy --manifest-path $(call make-path,$*)/Cargo.toml \
  27. --all-targets \
  28. --all-features \
  29. -- \
  30. --deny=warnings \
  31. --deny=clippy::default_trait_access \
  32. --deny=clippy::arithmetic_side_effects \
  33. --deny=clippy::manual_let_else \
  34. --deny=clippy::used_underscore_binding $(ARGS)
  35. format-check-%:
  36. cargo $(nightly) fmt --check --manifest-path $(call make-path,$*)/Cargo.toml $(ARGS)
  37. powerset-%:
  38. cargo $(nightly) hack check --feature-powerset --all-targets --manifest-path $(call make-path,$*)/Cargo.toml $(ARGS)
  39. semver-check-%:
  40. cargo semver-checks --manifest-path $(call make-path,$*)/Cargo.toml $(ARGS)
  41. shellcheck:
  42. git ls-files -- '*.sh' | xargs shellcheck --color=always --external-sources --shell=bash $(ARGS)
  43. sort-check:
  44. cargo $(nightly) sort --workspace --check $(ARGS)
  45. bench-%:
  46. cargo $(nightly) bench --manifest-path $(call make-path,$*)/Cargo.toml $(ARGS)
  47. format-rust:
  48. cargo $(nightly) fmt --all $(ARGS)
  49. build-sbf-%:
  50. cargo build-sbf --manifest-path $(call make-path,$*)/Cargo.toml $(ARGS)
  51. build-wasm-%:
  52. cargo build --target wasm32-unknown-unknown --manifest-path $(call make-path,$*)/Cargo.toml --all-features $(ARGS)
  53. build-doc-%:
  54. RUSTDOCFLAGS="--cfg docsrs -D warnings" cargo $(nightly) doc --all-features --no-deps --manifest-path $(call make-path,$*)/Cargo.toml $(ARGS)
  55. test-doc-%:
  56. cargo $(nightly) test --doc --all-features --manifest-path $(call make-path,$*)/Cargo.toml $(ARGS)
  57. test-%:
  58. SBF_OUT_DIR=$(PWD)/target/deploy cargo $(nightly) test --manifest-path $(call make-path,$*)/Cargo.toml $(ARGS)
  59. format-check-js-%:
  60. cd $(call make-path,$*) && pnpm install && pnpm format $(ARGS)
  61. lint-js-%:
  62. cd $(call make-path,$*) && pnpm install && pnpm lint $(ARGS)
  63. test-js-%:
  64. make restart-test-validator
  65. cd $(call make-path,$*) && pnpm install && pnpm build && pnpm test $(ARGS)
  66. make stop-test-validator
  67. restart-test-validator:
  68. ./scripts/restart-test-validator.sh
  69. stop-test-validator:
  70. pkill -f solana-test-validator
  71. generate-clients:
  72. pnpm generate:clients $(ARGS)
  73. # Helpers for publishing
  74. tag-name = $(lastword $(subst /, ,$(call make-path,$1)))
  75. preid-arg = $(subst pre,--preid $2,$(findstring pre,$1))
  76. package-version = $(subst ",,$(shell jq -r '.version' $(call make-path,$1)/package.json))
  77. crate-version = $(subst ",,$(shell toml get $(call make-path,$1)/Cargo.toml package.version))
  78. git-tag-js-%:
  79. @echo "$(call tag-name,$*)@v$(call package-version,$*)"
  80. publish-js-%:
  81. cd "$(call make-path,$*)" && pnpm install && pnpm version $(LEVEL) --no-git-tag-version $(call preid-arg,$(LEVEL),$(TAG)) && pnpm publish --no-git-checks --tag $(TAG)
  82. git-tag-rust-%:
  83. @echo "$(call tag-name,$*)@v$(call crate-version,$*)"
  84. publish-rust-%:
  85. cd "$(call make-path,$*)" && cargo release $(LEVEL) --tag-name "$(call tag-name,$*)@v{{version}}" --execute --no-confirm --dependent-version fix
  86. publish-rust-dry-run-%:
  87. cd "$(call make-path,$*)" && cargo release $(LEVEL) --tag-name "$(call tag-name,$*)@v{{version}}"