You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
1.9KB

  1. # 'make' will build:
  2. # - css from scss
  3. # - wasm from rust
  4. # - js from typescript
  5. #
  6. # 'make release' will build the release version of the wasm
  7. #
  8. all: css wasm index
  9. .PHONY: all
  10. # client
  11. #
  12. # todo: also add sketch to all
  13. # Make doesn't come with a recursive wildcard function so we have to use this
  14. # complicated thing which was copy/pasted from StackOverflow.
  15. # Fucking hell, why isn't there a built-in function to recursively traverse
  16. # a directory and select files that match a wildcard?
  17. #
  18. # https://stackoverflow.com/questions/2483182/recursive-wildcards-in-gnu-make/18258352#18258352
  19. #
  20. rwildcard=$(foreach d,$(wildcard $(1:=/*)),$(call rwildcard,$d,$2) $(filter $(subst *,%,$2),$d))
  21. CSS_SRC=$(wildcard stylesheets/scss/*.scss)
  22. CLIENT_RUST_SRC=$(wildcard client/src/*.rs)
  23. CORE_RUST_SRC=$(call rwildcard, core/src, *.rs)
  24. TYPESCRIPT_SRC=$(wildcard typescript/src/*)
  25. release: css wasm-release index
  26. css: www/stylesheet.css
  27. wasm: www/client_bg.wasm
  28. index: www/index.js
  29. sketch: www/sketch.js
  30. www/stylesheet.css: $(CSS_SRC)
  31. cargo run --manifest-path stylesheets/Cargo.toml -- stylesheets/scss/seni.scss www/stylesheet.css
  32. www/client_bg.wasm: $(CLIENT_RUST_SRC) $(CORE_RUST_SRC)
  33. cargo build --manifest-path client/Cargo.toml --target wasm32-unknown-unknown
  34. wasm-bindgen client/target/wasm32-unknown-unknown/debug/client.wasm --out-dir www --no-typescript --no-modules
  35. www/index.js: $(TYPESCRIPT_SRC) typescript/tsconfig-main.json
  36. tsc --project typescript/tsconfig-main.json
  37. www/sketch.js: $(TYPESCRIPT_SRC) typescript/tsconfig-sketch.json
  38. tsc --project typescript/tsconfig-sketch.json
  39. wasm-release:
  40. cargo build --manifest-path client/Cargo.toml --release --target wasm32-unknown-unknown
  41. wasm-bindgen client/target/wasm32-unknown-unknown/release/client.wasm --out-dir www --no-typescript --no-modules
  42. # clean
  43. #
  44. clean:
  45. rm -f www/stylesheet.css
  46. rm -f www/client_bg.wasm
  47. rm -f www/client.js
  48. rm -f www/index.js
  49. rm -f www/sketch.js