Skip to content

Commit 2c633f8

Browse files
committed
Makefile improvements: playground
1 parent b7e8c2f commit 2c633f8

File tree

5 files changed

+32
-10
lines changed

5 files changed

+32
-10
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ jobs:
404404

405405
- name: Build playground compiler
406406
if: matrix.build_playground
407-
run: opam exec -- make playground playground-cmijs
407+
run: opam exec -- make playground
408408

409409
- name: Test playground compiler
410410
if: matrix.build_playground

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
*~
22
_build
3+
_build_playground
34
*.obj
45
*.out
56
*.compile

Makefile

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -182,27 +182,47 @@ test-rewatch: lib
182182

183183
test-all: test test-gentype test-analysis test-tools test-rewatch
184184

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
185+
# Playground
186+
187+
PLAYGROUND_BUILD_DIR := ./_build_playground
188+
PLAYGROUND_BUILD_STAMP := $(PLAYGROUND_BUILD_DIR)/log # touched by dune on each build
189+
PLAYGROUND_COMPILER := packages/playground/compiler.js
190+
PLAYGROUND_CMI_BUILD_STAMP := packages/playground/.buildstamp # touched by playground npm build script
191+
192+
playground: playground-compiler playground-cmijs
193+
194+
playground-compiler: $(PLAYGROUND_COMPILER)
195+
196+
$(PLAYGROUND_COMPILER): $(PLAYGROUND_BUILD_STAMP)
197+
198+
$(PLAYGROUND_BUILD_STAMP): $(COMPILER_SOURCES)
199+
dune build --profile browser --build-dir $(PLAYGROUND_BUILD_DIR)
200+
cp -f $(PLAYGROUND_BUILD_DIR)/default/compiler/jsoo/jsoo_playground_main.bc.js $(PLAYGROUND_COMPILER)
189201

190202
# 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
203+
playground-cmijs: $(PLAYGROUND_CMI_BUILD_STAMP)
204+
205+
$(PLAYGROUND_CMI_BUILD_STAMP): $(RUNTIME_BUILD_STAMP) $(NINJA_EXE)
192206
yarn workspace playground build
193207

208+
playground-test: playground
209+
yarn workspace playground test
210+
194211
# Builds the playground, runs some e2e tests and releases the playground to the
195212
# Cloudflare R2 (requires Rclone `rescript:` remote)
196-
playground-release: playground playground-cmijs | $(YARN_INSTALL_STAMP)
197-
yarn workspace playground test
213+
playground-release: playground-test
198214
yarn workspace playground upload-bundle
199215

216+
# Format
217+
200218
format: | $(YARN_INSTALL_STAMP)
201219
./scripts/format.sh
202220

203221
checkformat: | $(YARN_INSTALL_STAMP)
204222
./scripts/format_check.sh
205223

224+
# Clean
225+
206226
clean-gentype:
207227
make -C tests/gentype_tests/typescript-react-example clean
208228
make -C tests/gentype_tests/stdlib-no-shims clean
@@ -216,4 +236,4 @@ dev-container:
216236

217237
.DEFAULT_GOAL := build
218238

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
239+
.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

packages/playground/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,4 @@ yarn.lock
3434
/compiler.js
3535

3636
.tmp/
37+
.buildstamp

packages/playground/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"scripts": {
66
"clean": "rescript clean",
77
"test": "node ./playground_test.cjs",
8-
"build": "rescript clean && rescript-legacy build && node scripts/generate_cmijs.mjs && rollup -c",
8+
"build": "rescript clean && rescript-legacy build && node scripts/generate_cmijs.mjs && rollup -c && touch .buildstamp",
99
"upload-bundle": "node scripts/upload_bundle.mjs",
1010
"serve-bundle": "node serve-bundle.mjs"
1111
},

0 commit comments

Comments
 (0)