diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9635fe1125..d7bf0316ed 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -150,7 +150,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('compiler/dune-project') }}" | sed 's/,/-/g' >> $GITHUB_ENV + run: echo "opam_cache_key=opam-env-v3-${{ matrix.os }}-${{ matrix.ocaml_compiler }}-${{ hashFiles('dune-project') }}" | sed 's/,/-/g' >> $GITHUB_ENV - name: Restore OPAM environment id: cache-opam-env @@ -250,11 +250,11 @@ jobs: - name: Build compiler if: runner.os != 'Linux' - run: opam exec -- dune build --root compiler --display quiet --profile release + run: opam exec -- dune build --display quiet --profile release - name: Build compiler (Linux static) if: runner.os == 'Linux' - run: opam exec -- dune build --root compiler --display quiet --profile static + run: opam exec -- dune build --display quiet --profile static - name: Install npm packages run: npm ci --ignore-scripts @@ -324,8 +324,8 @@ jobs: if: matrix.build_playground run: | opam exec -- node packages/playground-bundling/scripts/generate_cmijs.js - opam exec -- dune build --root compiler --profile browser - cp ./compiler/_build/default/jsoo/jsoo_playground_main.bc.js playground/compiler.js + opam exec -- dune build --profile browser + cp ./_build/default/compiler/jsoo/jsoo_playground_main.bc.js playground/compiler.js - name: Test playground compiler if: matrix.build_playground diff --git a/compiler/.ocamlformat b/.ocamlformat similarity index 100% rename from compiler/.ocamlformat rename to .ocamlformat diff --git a/Makefile b/Makefile index 67129e5954..237333c785 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,13 @@ SHELL = /bin/bash -DUNE_BIN_DIR = ./compiler/_build/install/default/bin +DUNE_BIN_DIR = ./_build/install/default/bin build: ninja rewatch - dune build --root compiler + dune build ./scripts/copyExes.js -compiler watch: - dune build --root compiler -w + dune build -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 --root compiler --profile browser - cp ./compiler/_build/default/jsoo/jsoo_playground_main.bc.js playground/compiler.js + dune build --profile browser + cp ./_build/default/compiler/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/dune b/dune new file mode 100644 index 0000000000..a2dde03ccd --- /dev/null +++ b/dune @@ -0,0 +1 @@ +(dirs compiler) diff --git a/compiler/dune-project b/dune-project similarity index 100% rename from compiler/dune-project rename to dune-project diff --git a/packages/playground-bundling/scripts/generate_cmijs.js b/packages/playground-bundling/scripts/generate_cmijs.js index 1358454694..d2f42b4640 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 PROJECT_ROOT_DIR = path.join(__dirname, "..", "..", ".."); -const PLAYGROUND_DIR = path.join(PROJECT_ROOT_DIR, "playground"); +const RESCRIPT_COMPILER_ROOT_DIR = path.join(__dirname, "..", "..", ".."); +const PLAYGROUND_DIR = path.join(RESCRIPT_COMPILER_ROOT_DIR, "playground"); // The playground-bundling root dir -const PLAYGROUND_BUNDLING_DIR = path.join(__dirname, ".."); +const PROJECT_ROOT_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: PLAYGROUND_BUNDLING_DIR, + cwd: PROJECT_ROOT_DIR, encoding: "utf8", stdio: [0, 1, 2], shell: true, @@ -49,7 +49,7 @@ function e(cmd) { } e(`npm install`); -e(`npm link ${PROJECT_ROOT_DIR}`); +e(`npm link ${RESCRIPT_COMPILER_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( - PLAYGROUND_BUNDLING_DIR, + PROJECT_ROOT_DIR, "node_modules", "rescript", "lib", @@ -82,14 +82,14 @@ function buildCompilerCmij() { function buildThirdPartyCmijs() { packages.forEach(function installLib(pkg) { const libOcamlFolder = path.join( - PLAYGROUND_BUNDLING_DIR, + PROJECT_ROOT_DIR, "node_modules", pkg, "lib", "ocaml", ); const libEs6Folder = path.join( - PLAYGROUND_BUNDLING_DIR, + PROJECT_ROOT_DIR, "node_modules", pkg, "lib", diff --git a/compiler/rescript.opam b/rescript.opam similarity index 100% rename from compiler/rescript.opam rename to rescript.opam diff --git a/scripts/dune.js b/scripts/dune.js index 58f8459a69..dd22149381 100644 --- a/scripts/dune.js +++ b/scripts/dune.js @@ -3,7 +3,6 @@ var path = require("path"); var duneBinDir = path.join( __dirname, "..", - "compiler", "_build", "install", "default", diff --git a/scripts/format.sh b/scripts/format.sh index e95ce0b0f4..aa5665c2d8 100755 --- a/scripts/format.sh +++ b/scripts/format.sh @@ -2,7 +2,7 @@ shopt -s extglob -dune build @fmt --root compiler --auto-promote +dune build @fmt --auto-promote files=$(find runtime tests -type f \( -name "*.res" -o -name "*.resi" \) ! -name "syntaxErrors*" ! -path "tests/syntax_tests/*" ! -path "tests/gentype_tests/typescript-react-example/node_modules/*") ./cli/rescript format $files diff --git a/scripts/format_check.sh b/scripts/format_check.sh index de2ce39e3e..602b1f0519 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 --root compiler; then + if opam exec -- dune build @fmt; then printf "${successGreen}✅ OCaml code formatting ok.${reset}\n" else printf "${warningYellow}⚠️ OCaml code formatting issues found.${reset}\n" diff --git a/scripts/test_syntax.sh b/scripts/test_syntax.sh index b60f38cebd..4371fe4052 100755 --- a/scripts/test_syntax.sh +++ b/scripts/test_syntax.sh @@ -8,7 +8,9 @@ scriptDir=`dirname $0` # macOS 12 does not have the realpath utility, # so let's use this workaround instead. -DUNE_BIN_DIR=`cd "$scriptDir/../compiler/_build/install/default/bin"; pwd -P` +DUNE_BIN_DIR=`cd "$scriptDir/../_build/install/default/bin"; pwd -P` + +$DUNE_BIN_DIR/syntax_tests function exp { echo "$(dirname $1)/expected/$(basename $1).txt"