diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9e416ec37a..98a432c13d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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-v7-${{ matrix.os }}-${{ matrix.ocaml_compiler }}-${{ hashFiles('dune-project') }}" | sed 's/,/-/g' >> $GITHUB_ENV + run: echo "opam_cache_key=opam-env-v7-${{ matrix.os }}-${{ matrix.ocaml_compiler }}-${{ hashFiles('*.opam') }}" | sed 's/,/-/g' >> $GITHUB_ENV - name: Restore OPAM environment id: cache-opam-env @@ -249,7 +249,7 @@ jobs: id: compiler-build-state-key shell: bash run: | - echo "value=compiler-build-state-v1-${{ matrix.os }}-${{ matrix.ocaml_compiler }}-${{ hashFiles('dune-project') }}" \ + echo "value=compiler-build-state-v1-${{ matrix.os }}-${{ matrix.ocaml_compiler }}-${{ hashFiles('*.opam') }}" \ | sed 's/,/-/g' >> "$GITHUB_OUTPUT" - name: Restore compiler build state diff --git a/analysis.opam b/analysis.opam index bebaa72055..228193d753 100644 --- a/analysis.opam +++ b/analysis.opam @@ -9,10 +9,11 @@ bug-reports: "https://github.com/rescript-lang/rescript-compiler/issues" depends: [ "ocaml" {>= "4.14"} "cppo" {= "1.8.0"} - "dune" + "dune" {>= "3.17"} + "odoc" {with-doc} ] build: [ - ["dune" "subst"] {pinned} + ["dune" "subst"] {dev} [ "dune" "build" diff --git a/compiler/dune b/compiler/dune index 101b4b8acf..7c5ba77749 100644 --- a/compiler/dune +++ b/compiler/dune @@ -1,5 +1,20 @@ -(dirs bsb bsb_exe bsb_helper bsb_helper_exe bsc cmij common core depends ext - frontend gentype jsoo js_parser ml syntax) +(dirs + bsb + bsb_exe + bsb_helper + bsb_helper_exe + bsc + cmij + common + core + depends + ext + frontend + gentype + jsoo + js_parser + ml + syntax) (env (dev diff --git a/compiler/ext/dune b/compiler/ext/dune index 8c9c936cbc..0896ec2c27 100644 --- a/compiler/ext/dune +++ b/compiler/ext/dune @@ -3,8 +3,12 @@ (wrapped false) (preprocess (action - (run %{bin:cppo} -V OCAML:%{ocaml_version} %{env:CPPO_FLAGS=} - %{input-file}))) + (run + %{bin:cppo} + -V + OCAML:%{ocaml_version} + %{env:CPPO_FLAGS=} + %{input-file}))) (flags (:standard -w +a-4-42-40-9-48-70)) (foreign_stubs diff --git a/compiler/jsoo/dune b/compiler/jsoo/dune index 5c514e5ef6..209f9d9f05 100644 --- a/compiler/jsoo/dune +++ b/compiler/jsoo/dune @@ -2,9 +2,11 @@ (executables (names jsoo_playground_main) - (modes js) + (modes js wasm) (enabled_if (= %{profile} browser)) (flags (:standard -w +a-4-9-40-42-44-45)) - (libraries core syntax ml js_of_ocaml)) + (libraries core syntax ml js_of_ocaml) + (preprocess + (pps js_of_ocaml-ppx))) diff --git a/compiler/jsoo/jsoo_playground_main.ml b/compiler/jsoo/jsoo_playground_main.ml index 370f8177b3..d1de5cad1c 100644 --- a/compiler/jsoo/jsoo_playground_main.ml +++ b/compiler/jsoo/jsoo_playground_main.ml @@ -54,8 +54,6 @@ let api_version = "5" module Js = Js_of_ocaml.Js -let export (field : string) v = Js.Unsafe.set Js.Unsafe.global field v - module Lang = struct type t = Res @@ -676,11 +674,9 @@ module Export = struct end let () = - export "rescript_compiler" - Js.Unsafe.( - obj - [| - ("api_version", inject @@ Js.string api_version); - ("version", inject @@ Js.string Bs_version.version); - ("make", inject @@ Export.make); - |]) + Js.export "rescript_compiler" + (object%js + val api_version = api_version + val version = Bs_version.version + method make = Export.make () + end) diff --git a/compiler/syntax/cli/res_cli.ml b/compiler/syntax/cli/res_cli.ml index d045b16753..572ddd95f3 100644 --- a/compiler/syntax/cli/res_cli.ml +++ b/compiler/syntax/cli/res_cli.ml @@ -26,19 +26,19 @@ *) module Color = struct (* use ANSI color codes, see https://en.wikipedia.org/wiki/ANSI_escape_code *) - type color = - | Black [@live] + type[@warning "-37"] color = + | Black | Red - | Green [@live] + | Green | Yellow - | Blue [@live] + | Blue | Magenta | Cyan - | White [@live] + | White - type style = + type[@warning "-37"] style = | FG of color (* foreground *) - | BG of color [@live] (* background *) + | BG of color (* background *) | Bold | Reset | Dim @@ -132,7 +132,7 @@ module Color = struct let term = try Sys.getenv "TERM" with Not_found -> "" in term <> "dumb" && term <> "" && isatty stderr - type setting = Auto [@live] | Always [@live] | Never [@live] + type[@warning "-37"] setting = Auto | Always | Never let setup = let first = ref true in diff --git a/dune-project b/dune-project index 0b1dd88c9e..61fbc62cd2 100644 --- a/dune-project +++ b/dune-project @@ -1,4 +1,4 @@ -(lang dune 2.3) +(lang dune 3.17) (name rescript) @@ -16,29 +16,7 @@ (package (name rescript) - (synopsis "ReScript compiler") - (depends - (ocaml - (>= 4.14)) - (ocamlformat - (and - :with-test - (= 0.27.0))) - (yojson - (and - :with-test - (= 2.2.2))) - (ocaml-lsp-server - (and - :with-dev-setup - (= 1.22.0))) - (cppo - (= 1.8.0)) - (js_of_ocaml - (= 6.0.1)) - (ounit2 - (= 2.2.7)) - dune)) + (synopsis "ReScript compiler")) (package (name analysis) diff --git a/playground/playground_test.js b/playground/playground_test.js index 98807109cf..be5cc1df71 100644 --- a/playground/playground_test.js +++ b/playground/playground_test.js @@ -1,4 +1,7 @@ -require("./compiler.js") +// Playground bundle is UMD module +// It uses `module.exports` in current context, or fallback to `globalThis` +const { rescript_compiler } = require("./compiler.js") + require("./packages/compiler-builtins/cmij.js") require("./packages/@rescript/react/cmij.js") diff --git a/rescript.opam b/rescript.opam index 9a259d0737..6f5345c73d 100644 --- a/rescript.opam +++ b/rescript.opam @@ -6,18 +6,8 @@ authors: ["Hongbo Zhang "] license: "LGPL-3.0-or-later" homepage: "https://github.com/rescript-lang/rescript-compiler" bug-reports: "https://github.com/rescript-lang/rescript-compiler/issues" -depends: [ - "ocaml" {>= "4.14"} - "ocamlformat" {with-test & = "0.27.0"} - "yojson" {with-test & = "2.2.2"} - "ocaml-lsp-server" {with-dev-setup & = "1.22.0"} - "cppo" {= "1.8.0"} - "js_of_ocaml" {= "6.0.1"} - "ounit2" {= "2.2.7"} - "dune" -] build: [ - ["dune" "subst"] {pinned} + ["dune" "subst"] {dev} [ "dune" "build" @@ -30,3 +20,17 @@ build: [ "@doc" {with-doc} ] ] +depends: [ + "ocaml" {>= "4.14"} + "ocamlformat" {with-test & = "0.27.0"} + "yojson" {with-test & = "2.2.2"} + "ocaml-lsp-server" {with-dev-setup & = "1.22.0"} + "cppo" {= "1.8.0"} + "ounit2" {= "2.2.7"} + "dune" {>= "3.17"} + "odoc" {with-doc} + # Dependencies that could be broken on Windows runners + "js_of_ocaml" {= "6.0.1" & os != "win32"} + "js_of_ocaml-ppx" {= "6.0.1" & os != "win32"} + "wasm_of_ocaml-compiler" {= "6.0.1" & os != "win32"} +] diff --git a/rescript.opam.template b/rescript.opam.template new file mode 100644 index 0000000000..be3ee9d345 --- /dev/null +++ b/rescript.opam.template @@ -0,0 +1,15 @@ +depends: [ + "ocaml" {>= "4.14"} + "cppo" {= "1.8.0"} + "dune" {>= "3.17"} + "ocamlformat" {with-test & = "0.27.0"} + "yojson" {with-test & = "2.2.2"} + "ounit2" {with-test & = "2.2.7"} + "odoc" {with-doc} + "ocaml-lsp-server" {with-dev-setup & = "1.22.0"} + + # Test dependencies that would be broken on Windows runners + "js_of_ocaml" {os != "win32" & with-test & = "6.0.1"} + "js_of_ocaml-ppx" {os != "win32" & with-test & = "6.0.1"} + "wasm_of_ocaml-compiler" {os != "win32" & with-test & = "6.0.1"} +] diff --git a/scripts/copyExes.js b/scripts/copyExes.js index feae5e9b76..b9ebe91cc3 100755 --- a/scripts/copyExes.js +++ b/scripts/copyExes.js @@ -24,10 +24,19 @@ function copyExe(dir, exe) { fs.rmSync(dest); } - fs.copyFileSync(src, dest); - - if (process.platform !== "win32") { - child_process.execSync(`strip ${dest}`); + let mode = 0o755; + if (fs.existsSync(dest)) { + mode = fs.statSync(dest).mode & 0o777; + fs.chmodSync(dest, mode | 0o200); // u+w + } + try { + fs.copyFileSync(src, dest); + if (process.platform !== "win32") { + fs.chmodSync(dest, mode | 0o200); // u+w + child_process.execSync(`strip ${dest}`); + } + } finally { + fs.chmodSync(dest, mode); } } diff --git a/tests/syntax_benchmarks/Benchmark.ml b/tests/syntax_benchmarks/Benchmark.ml index e947612513..dc7093dbe9 100644 --- a/tests/syntax_benchmarks/Benchmark.ml +++ b/tests/syntax_benchmarks/Benchmark.ml @@ -33,16 +33,16 @@ module Time : sig val now : unit -> t - val to_uint64 : t -> int64 [@@live] + val [@warning "-32"] to_uint64 : t -> int64 (* let of_uint64_ns ns = ns *) - val nanosecond : t [@@live] - val microsecond : t [@@live] - val millisecond : t [@@live] - val second : t [@@live] - val minute : t [@@live] - val hour : t [@@live] + val [@warning "-32"] nanosecond : t + val [@warning "-32"] microsecond : t + val [@warning "-32"] millisecond : t + val [@warning "-32"] second : t + val [@warning "-32"] minute : t + val [@warning "-32"] hour : t val zero : t diff --git a/tools.opam b/tools.opam index 7858e8d131..48333848f1 100644 --- a/tools.opam +++ b/tools.opam @@ -10,10 +10,11 @@ depends: [ "ocaml" {>= "4.14"} "cppo" {= "1.8.0"} "analysis" - "dune" + "dune" {>= "3.17"} + "odoc" {with-doc} ] build: [ - ["dune" "subst"] {pinned} + ["dune" "subst"] {dev} [ "dune" "build"