@@ -95,14 +95,22 @@ clean-ninja:
9595
9696REWATCH_SOURCES = $(shell find rewatch/src -name '* .rs') rewatch/Cargo.toml rewatch/Cargo.lock rewatch/rust-toolchain.toml
9797RESCRIPT_EXE = $(BIN_DIR ) /rescript.exe
98+ ifdef CI
99+ REWATCH_PROFILE := release
100+ REWATCH_CARGO_FLAGS := --release
101+ else
102+ REWATCH_PROFILE := debug
103+ REWATCH_CARGO_FLAGS :=
104+ endif
105+ REWATCH_TARGET := rewatch/target/$(REWATCH_PROFILE ) /rescript$(PLATFORM_EXE_EXT )
98106
99107rewatch : $(RESCRIPT_EXE )
100108
101- $(RESCRIPT_EXE ) : rewatch/target/debug/rescript $( PLATFORM_EXE_EXT )
109+ $(RESCRIPT_EXE ) : $( REWATCH_TARGET )
102110 $(call COPY_EXE,$< ,$@ )
103111
104- rewatch/target/debug/rescript $( PLATFORM_EXE_EXT ) : $(REWATCH_SOURCES )
105- cargo build --manifest-path rewatch/Cargo.toml
112+ $( REWATCH_TARGET ) : $(REWATCH_SOURCES )
113+ cargo build --manifest-path rewatch/Cargo.toml $( REWATCH_CARGO_FLAGS )
106114
107115clean-rewatch :
108116 cargo clean --manifest-path rewatch/Cargo.toml && rm -rf rewatch/target && rm -f $(RESCRIPT_EXE )
@@ -182,27 +190,47 @@ test-rewatch: lib
182190
183191test-all : test test-gentype test-analysis test-tools test-rewatch
184192
185- # Builds the core playground bundle (without the relevant cmijs files for the runtime)
186- playground : | $(YARN_INSTALL_STAMP )
187- dune build --profile browser
188- cp -f ./_build/default/compiler/jsoo/jsoo_playground_main.bc.js packages/playground/compiler.js
193+ # Playground
194+
195+ PLAYGROUND_BUILD_DIR := ./_build_playground
196+ PLAYGROUND_BUILD_STAMP := $(PLAYGROUND_BUILD_DIR ) /log # touched by dune on each build
197+ PLAYGROUND_COMPILER := packages/playground/compiler.js
198+ PLAYGROUND_CMI_BUILD_STAMP := packages/playground/.buildstamp # touched by playground npm build script
199+
200+ playground : playground-compiler playground-cmijs
201+
202+ playground-compiler : $(PLAYGROUND_COMPILER )
203+
204+ $(PLAYGROUND_COMPILER ) : $(PLAYGROUND_BUILD_STAMP )
205+
206+ $(PLAYGROUND_BUILD_STAMP ) : $(COMPILER_SOURCES )
207+ dune build --profile browser --build-dir $(PLAYGROUND_BUILD_DIR )
208+ cp -f $(PLAYGROUND_BUILD_DIR ) /default/compiler/jsoo/jsoo_playground_main.bc.js $(PLAYGROUND_COMPILER )
189209
190210# Creates all the relevant core and third party cmij files to side-load together with the playground bundle
191- playground-cmijs : | $(YARN_INSTALL_STAMP ) # should also depend on artifacts, but that causes an attempt to copy binaries for JSOO
211+ playground-cmijs : $(PLAYGROUND_CMI_BUILD_STAMP )
212+
213+ $(PLAYGROUND_CMI_BUILD_STAMP ) : $(RUNTIME_BUILD_STAMP ) $(NINJA_EXE )
192214 yarn workspace playground build
193215
216+ playground-test : playground
217+ yarn workspace playground test
218+
194219# Builds the playground, runs some e2e tests and releases the playground to the
195220# Cloudflare R2 (requires Rclone `rescript:` remote)
196- playground-release : playground playground-cmijs | $(YARN_INSTALL_STAMP )
197- yarn workspace playground test
221+ playground-release : playground-test
198222 yarn workspace playground upload-bundle
199223
224+ # Format
225+
200226format : | $(YARN_INSTALL_STAMP )
201227 ./scripts/format.sh
202228
203229checkformat : | $(YARN_INSTALL_STAMP )
204230 ./scripts/format_check.sh
205231
232+ # Clean
233+
206234clean-gentype :
207235 make -C tests/gentype_tests/typescript-react-example clean
208236 make -C tests/gentype_tests/stdlib-no-shims clean
@@ -216,4 +244,4 @@ dev-container:
216244
217245.DEFAULT_GOAL := build
218246
219- .PHONY : yarn-install build ninja rewatch compiler lib artifacts bench test test-analysis test-tools test-syntax test-syntax-roundtrip test-gentype test-rewatch test-all playground playground-cmijs playground-release format checkformat clean-ninja clean-rewatch clean-compiler clean-lib clean-gentype clean-tests clean dev-container
247+ .PHONY : yarn-install build ninja rewatch compiler lib artifacts bench test test-analysis test-tools test-syntax test-syntax-roundtrip test-gentype test-rewatch test-all playground playground-compiler playground-test playground- cmijs playground-release format checkformat clean-ninja clean-rewatch clean-compiler clean-lib clean-gentype clean-tests clean dev-container
0 commit comments