diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9ab1e3f5bb..fae32ea77a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -152,7 +152,7 @@ jobs: # matrix.ocaml_compiler may contain commas - name: Get OPAM cache key shell: bash - run: echo "opam_cache_key=opam-env-v3-${{ matrix.os }}-${{ matrix.ocaml_compiler }}-${{ hashFiles('dune-project') }}" | sed 's/,/-/g' >> $GITHUB_ENV + run: echo "opam_cache_key=opam-env-v3-${{ matrix.os }}-${{ matrix.ocaml_compiler }}-${{ hashFiles('compiler/dune-project') }}" | sed 's/,/-/g' >> $GITHUB_ENV - name: Restore OPAM environment id: cache-opam-env @@ -252,11 +252,11 @@ jobs: - name: Build compiler if: runner.os != 'Linux' - run: opam exec -- dune build --display quiet --profile release + run: opam exec -- dune build --root compiler --display quiet --profile release - name: Build compiler (Linux static) if: runner.os == 'Linux' - run: opam exec -- dune build --display quiet --profile static + run: opam exec -- dune build --root compiler --display quiet --profile static - name: Install npm packages run: npm ci --ignore-scripts @@ -336,8 +336,8 @@ jobs: if: matrix.build_playground run: | opam exec -- node packages/playground-bundling/scripts/generate_cmijs.js - opam exec -- dune build --profile browser - cp ./_build/default/compiler/jsoo/jsoo_playground_main.bc.js playground/compiler.js + opam exec -- dune build --root compiler --profile browser + cp ./compiler/_build/default/jsoo/jsoo_playground_main.bc.js playground/compiler.js - name: Test playground compiler if: matrix.build_playground diff --git a/Makefile b/Makefile index 237333c785..67129e5954 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,13 @@ SHELL = /bin/bash -DUNE_BIN_DIR = ./_build/install/default/bin +DUNE_BIN_DIR = ./compiler/_build/install/default/bin build: ninja rewatch - dune build + dune build --root compiler ./scripts/copyExes.js -compiler watch: - dune build -w + dune build --root compiler -w bench: $(DUNE_BIN_DIR)/syntax_benchmarks @@ -59,8 +59,8 @@ artifacts: lib # Builds the core playground bundle (without the relevant cmijs files for the runtime) playground: - dune build --profile browser - cp ./_build/default/compiler/jsoo/jsoo_playground_main.bc.js playground/compiler.js + dune build --root compiler --profile browser + cp ./compiler/_build/default/jsoo/jsoo_playground_main.bc.js playground/compiler.js # Creates all the relevant core and third party cmij files to side-load together with the playground bundle playground-cmijs: artifacts diff --git a/.ocamlformat b/compiler/.ocamlformat similarity index 100% rename from .ocamlformat rename to compiler/.ocamlformat diff --git a/dune-project b/compiler/dune-project similarity index 100% rename from dune-project rename to compiler/dune-project diff --git a/rescript.opam b/compiler/rescript.opam similarity index 100% rename from rescript.opam rename to compiler/rescript.opam diff --git a/dune b/dune deleted file mode 100644 index a2dde03ccd..0000000000 --- a/dune +++ /dev/null @@ -1 +0,0 @@ -(dirs compiler) diff --git a/packages/playground-bundling/scripts/generate_cmijs.js b/packages/playground-bundling/scripts/generate_cmijs.js index d2f42b4640..1358454694 100644 --- a/packages/playground-bundling/scripts/generate_cmijs.js +++ b/packages/playground-bundling/scripts/generate_cmijs.js @@ -21,11 +21,11 @@ const path = require("path"); const resConfig = require("../rescript.json"); -const RESCRIPT_COMPILER_ROOT_DIR = path.join(__dirname, "..", "..", ".."); -const PLAYGROUND_DIR = path.join(RESCRIPT_COMPILER_ROOT_DIR, "playground"); +const PROJECT_ROOT_DIR = path.join(__dirname, "..", "..", ".."); +const PLAYGROUND_DIR = path.join(PROJECT_ROOT_DIR, "playground"); // The playground-bundling root dir -const PROJECT_ROOT_DIR = path.join(__dirname, ".."); +const PLAYGROUND_BUNDLING_DIR = path.join(__dirname, ".."); // Final target output directory where all the cmijs will be stored const PACKAGES_DIR = path.join(PLAYGROUND_DIR, "packages"); @@ -36,7 +36,7 @@ if (!fs.existsSync(PACKAGES_DIR)) { } const config = { - cwd: PROJECT_ROOT_DIR, + cwd: PLAYGROUND_BUNDLING_DIR, encoding: "utf8", stdio: [0, 1, 2], shell: true, @@ -49,7 +49,7 @@ function e(cmd) { } e(`npm install`); -e(`npm link ${RESCRIPT_COMPILER_ROOT_DIR}`); +e(`npm link ${PROJECT_ROOT_DIR}`); e(`npx rescript clean`); e(`npx rescript`); @@ -59,7 +59,7 @@ const packages = resConfig["bs-dependencies"]; // Otherwise we can't use them for compilation within the playground. function buildCompilerCmij() { const rescriptLibOcamlFolder = path.join( - PROJECT_ROOT_DIR, + PLAYGROUND_BUNDLING_DIR, "node_modules", "rescript", "lib", @@ -82,14 +82,14 @@ function buildCompilerCmij() { function buildThirdPartyCmijs() { packages.forEach(function installLib(pkg) { const libOcamlFolder = path.join( - PROJECT_ROOT_DIR, + PLAYGROUND_BUNDLING_DIR, "node_modules", pkg, "lib", "ocaml", ); const libEs6Folder = path.join( - PROJECT_ROOT_DIR, + PLAYGROUND_BUNDLING_DIR, "node_modules", pkg, "lib", diff --git a/scripts/dune.js b/scripts/dune.js index dd22149381..58f8459a69 100644 --- a/scripts/dune.js +++ b/scripts/dune.js @@ -3,6 +3,7 @@ var path = require("path"); var duneBinDir = path.join( __dirname, "..", + "compiler", "_build", "install", "default", diff --git a/scripts/format.sh b/scripts/format.sh index e39cf99e16..741c50e581 100755 --- a/scripts/format.sh +++ b/scripts/format.sh @@ -2,7 +2,7 @@ shopt -s extglob -dune build @fmt --auto-promote +dune build @fmt --root compiler --auto-promote files=$(find runtime tests -type f \( -name "*.res" -o -name "*.resi" \) ! -name "syntaxErrors*") ./cli/rescript format $files diff --git a/scripts/format_check.sh b/scripts/format_check.sh index 9dbbcf0aa8..a16003ce0d 100755 --- a/scripts/format_check.sh +++ b/scripts/format_check.sh @@ -9,7 +9,7 @@ reset='\033[0m' case "$(uname -s)" in Darwin|Linux) echo "Checking OCaml code formatting..." - if opam exec -- dune build @fmt; then + if opam exec -- dune build @fmt --root compiler; then printf "${successGreen}✅ OCaml code formatting ok.${reset}\n" else printf "${warningYellow}⚠️ OCaml code formatting issues found.${reset}\n"