diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 177ee19207..197dbf49fc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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' @@ -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" @@ -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 @@ -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 diff --git a/.gitignore b/.gitignore index 76f2f75b90..386c70d047 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ *~ _build +_build_playground *.obj *.out *.compile diff --git a/Makefile b/Makefile index 1ad85cf89d..0b9f90faef 100644 --- a/Makefile +++ b/Makefile @@ -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) @@ -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 @@ -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 diff --git a/packages/playground/.gitignore b/packages/playground/.gitignore index e979f5b774..18ad2e0722 100644 --- a/packages/playground/.gitignore +++ b/packages/playground/.gitignore @@ -34,3 +34,4 @@ yarn.lock /compiler.js .tmp/ +.buildstamp diff --git a/packages/playground/package.json b/packages/playground/package.json index cfc2435812..1a8525173b 100644 --- a/packages/playground/package.json +++ b/packages/playground/package.json @@ -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" },