Skip to content

Move all dune/ocaml config files into the compiler folder #7091

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
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*")
./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