Skip to content

Commit

Permalink
Move all dune/ocaml config files into the compiler folder (#7091)
Browse files Browse the repository at this point in the history
* Move all dune/ocaml config files into the compiler folder

* Fix "make bench"
  • Loading branch information
cknitt authored Oct 8, 2024
1 parent 7217302 commit 5781b4e
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 21 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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('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
Expand Down Expand Up @@ -250,11 +250,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
Expand Down Expand Up @@ -324,8 +324,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
Expand Down
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 0 additions & 1 deletion dune

This file was deleted.

16 changes: 8 additions & 8 deletions packages/playground-bundling/scripts/generate_cmijs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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,
Expand All @@ -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`);

Expand All @@ -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",
Expand All @@ -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",
Expand Down
1 change: 1 addition & 0 deletions scripts/dune.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ var path = require("path");
var duneBinDir = path.join(
__dirname,
"..",
"compiler",
"_build",
"install",
"default",
Expand Down
2 changes: 1 addition & 1 deletion scripts/format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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*" ! -path "tests/syntax_tests/*" ! -path "tests/gentype_tests/typescript-react-example/node_modules/*")
./cli/rescript format $files
2 changes: 1 addition & 1 deletion scripts/format_check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 5781b4e

Please sign in to comment.