Skip to content

Commit 5781b4e

Browse files
authored
Move all dune/ocaml config files into the compiler folder (#7091)
* Move all dune/ocaml config files into the compiler folder * Fix "make bench"
1 parent 7217302 commit 5781b4e

File tree

10 files changed

+21
-21
lines changed

10 files changed

+21
-21
lines changed

.github/workflows/ci.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ jobs:
150150
# matrix.ocaml_compiler may contain commas
151151
- name: Get OPAM cache key
152152
shell: bash
153-
run: echo "opam_cache_key=opam-env-v3-${{ matrix.os }}-${{ matrix.ocaml_compiler }}-${{ hashFiles('dune-project') }}" | sed 's/,/-/g' >> $GITHUB_ENV
153+
run: echo "opam_cache_key=opam-env-v3-${{ matrix.os }}-${{ matrix.ocaml_compiler }}-${{ hashFiles('compiler/dune-project') }}" | sed 's/,/-/g' >> $GITHUB_ENV
154154

155155
- name: Restore OPAM environment
156156
id: cache-opam-env
@@ -250,11 +250,11 @@ jobs:
250250

251251
- name: Build compiler
252252
if: runner.os != 'Linux'
253-
run: opam exec -- dune build --display quiet --profile release
253+
run: opam exec -- dune build --root compiler --display quiet --profile release
254254

255255
- name: Build compiler (Linux static)
256256
if: runner.os == 'Linux'
257-
run: opam exec -- dune build --display quiet --profile static
257+
run: opam exec -- dune build --root compiler --display quiet --profile static
258258

259259
- name: Install npm packages
260260
run: npm ci --ignore-scripts
@@ -324,8 +324,8 @@ jobs:
324324
if: matrix.build_playground
325325
run: |
326326
opam exec -- node packages/playground-bundling/scripts/generate_cmijs.js
327-
opam exec -- dune build --profile browser
328-
cp ./_build/default/compiler/jsoo/jsoo_playground_main.bc.js playground/compiler.js
327+
opam exec -- dune build --root compiler --profile browser
328+
cp ./compiler/_build/default/jsoo/jsoo_playground_main.bc.js playground/compiler.js
329329
330330
- name: Test playground compiler
331331
if: matrix.build_playground

Makefile

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
SHELL = /bin/bash
22

3-
DUNE_BIN_DIR = ./_build/install/default/bin
3+
DUNE_BIN_DIR = ./compiler/_build/install/default/bin
44

55
build: ninja rewatch
6-
dune build
6+
dune build --root compiler
77
./scripts/copyExes.js -compiler
88

99
watch:
10-
dune build -w
10+
dune build --root compiler -w
1111

1212
bench:
1313
$(DUNE_BIN_DIR)/syntax_benchmarks
@@ -59,8 +59,8 @@ artifacts: lib
5959

6060
# Builds the core playground bundle (without the relevant cmijs files for the runtime)
6161
playground:
62-
dune build --profile browser
63-
cp ./_build/default/compiler/jsoo/jsoo_playground_main.bc.js playground/compiler.js
62+
dune build --root compiler --profile browser
63+
cp ./compiler/_build/default/jsoo/jsoo_playground_main.bc.js playground/compiler.js
6464

6565
# Creates all the relevant core and third party cmij files to side-load together with the playground bundle
6666
playground-cmijs: artifacts

.ocamlformat compiler/.ocamlformat

File renamed without changes.

dune-project compiler/dune-project

File renamed without changes.
File renamed without changes.

dune

-1
This file was deleted.

packages/playground-bundling/scripts/generate_cmijs.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ const path = require("path");
2121

2222
const resConfig = require("../rescript.json");
2323

24-
const RESCRIPT_COMPILER_ROOT_DIR = path.join(__dirname, "..", "..", "..");
25-
const PLAYGROUND_DIR = path.join(RESCRIPT_COMPILER_ROOT_DIR, "playground");
24+
const PROJECT_ROOT_DIR = path.join(__dirname, "..", "..", "..");
25+
const PLAYGROUND_DIR = path.join(PROJECT_ROOT_DIR, "playground");
2626

2727
// The playground-bundling root dir
28-
const PROJECT_ROOT_DIR = path.join(__dirname, "..");
28+
const PLAYGROUND_BUNDLING_DIR = path.join(__dirname, "..");
2929

3030
// Final target output directory where all the cmijs will be stored
3131
const PACKAGES_DIR = path.join(PLAYGROUND_DIR, "packages");
@@ -36,7 +36,7 @@ if (!fs.existsSync(PACKAGES_DIR)) {
3636
}
3737

3838
const config = {
39-
cwd: PROJECT_ROOT_DIR,
39+
cwd: PLAYGROUND_BUNDLING_DIR,
4040
encoding: "utf8",
4141
stdio: [0, 1, 2],
4242
shell: true,
@@ -49,7 +49,7 @@ function e(cmd) {
4949
}
5050

5151
e(`npm install`);
52-
e(`npm link ${RESCRIPT_COMPILER_ROOT_DIR}`);
52+
e(`npm link ${PROJECT_ROOT_DIR}`);
5353
e(`npx rescript clean`);
5454
e(`npx rescript`);
5555

@@ -59,7 +59,7 @@ const packages = resConfig["bs-dependencies"];
5959
// Otherwise we can't use them for compilation within the playground.
6060
function buildCompilerCmij() {
6161
const rescriptLibOcamlFolder = path.join(
62-
PROJECT_ROOT_DIR,
62+
PLAYGROUND_BUNDLING_DIR,
6363
"node_modules",
6464
"rescript",
6565
"lib",
@@ -82,14 +82,14 @@ function buildCompilerCmij() {
8282
function buildThirdPartyCmijs() {
8383
packages.forEach(function installLib(pkg) {
8484
const libOcamlFolder = path.join(
85-
PROJECT_ROOT_DIR,
85+
PLAYGROUND_BUNDLING_DIR,
8686
"node_modules",
8787
pkg,
8888
"lib",
8989
"ocaml",
9090
);
9191
const libEs6Folder = path.join(
92-
PROJECT_ROOT_DIR,
92+
PLAYGROUND_BUNDLING_DIR,
9393
"node_modules",
9494
pkg,
9595
"lib",

scripts/dune.js

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ var path = require("path");
33
var duneBinDir = path.join(
44
__dirname,
55
"..",
6+
"compiler",
67
"_build",
78
"install",
89
"default",

scripts/format.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
shopt -s extglob
44

5-
dune build @fmt --auto-promote
5+
dune build @fmt --root compiler --auto-promote
66

77
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/*")
88
./cli/rescript format $files

scripts/format_check.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ reset='\033[0m'
99
case "$(uname -s)" in
1010
Darwin|Linux)
1111
echo "Checking OCaml code formatting..."
12-
if opam exec -- dune build @fmt; then
12+
if opam exec -- dune build @fmt --root compiler; then
1313
printf "${successGreen}✅ OCaml code formatting ok.${reset}\n"
1414
else
1515
printf "${warningYellow}⚠️ OCaml code formatting issues found.${reset}\n"

0 commit comments

Comments
 (0)