Skip to content

Revert "Move all dune/ocaml config files into the compiler folder" #7093

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 9, 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 @@ -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
Expand Down Expand Up @@ -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
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 --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
Expand Down
File renamed without changes.
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 = ./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
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 --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
Expand Down
1 change: 1 addition & 0 deletions dune
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(dirs compiler)
File renamed without changes.
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 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");
Expand All @@ -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,
Expand All @@ -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`);

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(
PLAYGROUND_BUNDLING_DIR,
PROJECT_ROOT_DIR,
"node_modules",
"rescript",
"lib",
Expand All @@ -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",
Expand Down
File renamed without changes.
1 change: 0 additions & 1 deletion scripts/dune.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ 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 --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
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 --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"
Expand Down
4 changes: 3 additions & 1 deletion scripts/test_syntax.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading