Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,8 @@ jobs:
id: ninja-build-cache
uses: actions/cache@v4
with:
path: packages/@rescript/${{ matrix.node-target }}/bin/ninja.exe
key: ninja-build-v1-${{ matrix.os }}-${{ hashFiles('ninja/src/**') }}
path: ninja/ninja${{ runner.os == 'Windows' && '.exe' || '' }}
key: ninja-build-v2-${{ matrix.os }}-${{ hashFiles('ninja/src/**') }}

- name: Setup Python for ninja build
if: steps.ninja-build-cache.outputs.cache-hit != 'true'
Expand All @@ -320,7 +320,6 @@ jobs:
run: node scripts/buildNinjaBinary.js

- name: Copy ninja exe to platform bin dir
if: steps.ninja-build-cache.outputs.cache-hit != 'true'
run: node scripts/copyExes.js --ninja

- name: "Syntax: Run tests"
Expand All @@ -330,7 +329,7 @@ jobs:
shell: bash

- name: Build @rescript/runtime
run: yarn workspace @rescript/runtime rescript build
run: yarn workspace @rescript/runtime build
shell: bash

- name: Check for changes in @rescript/runtime/lib
Expand Down Expand Up @@ -404,7 +403,7 @@ jobs:

- name: Build playground compiler
if: matrix.build_playground
run: opam exec -- make playground playground-cmijs
run: opam exec -- make playground

- name: Test playground compiler
if: matrix.build_playground
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
*~
_build
_build_playground
*.obj
*.out
*.compile
Expand Down
50 changes: 39 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,22 @@ clean-ninja:

REWATCH_SOURCES = $(shell find rewatch/src -name '*.rs') rewatch/Cargo.toml rewatch/Cargo.lock rewatch/rust-toolchain.toml
RESCRIPT_EXE = $(BIN_DIR)/rescript.exe
ifdef CI
REWATCH_PROFILE := release
REWATCH_CARGO_FLAGS := --release
else
REWATCH_PROFILE := debug
REWATCH_CARGO_FLAGS :=
endif
REWATCH_TARGET := rewatch/target/$(REWATCH_PROFILE)/rescript$(PLATFORM_EXE_EXT)

rewatch: $(RESCRIPT_EXE)

$(RESCRIPT_EXE): rewatch/target/debug/rescript$(PLATFORM_EXE_EXT)
$(RESCRIPT_EXE): $(REWATCH_TARGET)
$(call COPY_EXE,$<,$@)

rewatch/target/debug/rescript$(PLATFORM_EXE_EXT): $(REWATCH_SOURCES)
cargo build --manifest-path rewatch/Cargo.toml
$(REWATCH_TARGET): $(REWATCH_SOURCES)
cargo build --manifest-path rewatch/Cargo.toml $(REWATCH_CARGO_FLAGS)

clean-rewatch:
cargo clean --manifest-path rewatch/Cargo.toml && rm -rf rewatch/target && rm -f $(RESCRIPT_EXE)
Expand Down Expand Up @@ -182,27 +190,47 @@ test-rewatch: lib

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

# Builds the core playground bundle (without the relevant cmijs files for the runtime)
playground: | $(YARN_INSTALL_STAMP)
dune build --profile browser
cp -f ./_build/default/compiler/jsoo/jsoo_playground_main.bc.js packages/playground/compiler.js
# Playground

PLAYGROUND_BUILD_DIR := ./_build_playground
PLAYGROUND_BUILD_STAMP := $(PLAYGROUND_BUILD_DIR)/log # touched by dune on each build
PLAYGROUND_COMPILER := packages/playground/compiler.js
PLAYGROUND_CMI_BUILD_STAMP := packages/playground/.buildstamp # touched by playground npm build script

playground: playground-compiler playground-cmijs

playground-compiler: $(PLAYGROUND_COMPILER)

$(PLAYGROUND_COMPILER): $(PLAYGROUND_BUILD_STAMP)

$(PLAYGROUND_BUILD_STAMP): $(COMPILER_SOURCES)
dune build --profile browser --build-dir $(PLAYGROUND_BUILD_DIR)
cp -f $(PLAYGROUND_BUILD_DIR)/default/compiler/jsoo/jsoo_playground_main.bc.js $(PLAYGROUND_COMPILER)

# Creates all the relevant core and third party cmij files to side-load together with the playground bundle
playground-cmijs: | $(YARN_INSTALL_STAMP) # should also depend on artifacts, but that causes an attempt to copy binaries for JSOO
playground-cmijs: $(PLAYGROUND_CMI_BUILD_STAMP)

$(PLAYGROUND_CMI_BUILD_STAMP): $(RUNTIME_BUILD_STAMP) $(NINJA_EXE)
yarn workspace playground build

playground-test: playground
yarn workspace playground test

# Builds the playground, runs some e2e tests and releases the playground to the
# Cloudflare R2 (requires Rclone `rescript:` remote)
playground-release: playground playground-cmijs | $(YARN_INSTALL_STAMP)
yarn workspace playground test
playground-release: playground-test
yarn workspace playground upload-bundle

# Format

format: | $(YARN_INSTALL_STAMP)
./scripts/format.sh

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

# Clean

clean-gentype:
make -C tests/gentype_tests/typescript-react-example clean
make -C tests/gentype_tests/stdlib-no-shims clean
Expand All @@ -216,4 +244,4 @@ dev-container:

.DEFAULT_GOAL := build

.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
.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
1 change: 1 addition & 0 deletions packages/playground/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ yarn.lock
/compiler.js

.tmp/
.buildstamp
2 changes: 1 addition & 1 deletion packages/playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"scripts": {
"clean": "rescript clean",
"test": "node ./playground_test.cjs",
"build": "rescript clean && rescript-legacy build && node scripts/generate_cmijs.mjs && rollup -c",
"build": "rescript clean && rescript-legacy build && node scripts/generate_cmijs.mjs && rollup -c && touch .buildstamp",
"upload-bundle": "node scripts/upload_bundle.mjs",
"serve-bundle": "node serve-bundle.mjs"
},
Expand Down
Loading