Skip to content

Commit

Permalink
Make build -with-deps a default behaviour (#6350)
Browse files Browse the repository at this point in the history
* Make build -with-deps a default behaviour

* Clean up -with-deps from the codebase

* Fix build tests

* Update changelog

* Update args parse message

* Fix error

* Uncomment ciTest code

* Update module not found error.

* Clean up build_tests package jsons
  • Loading branch information
DZakh authored Aug 19, 2023
1 parent 98717b1 commit cc410f2
Show file tree
Hide file tree
Showing 52 changed files with 224 additions and 183 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
# 11.0.0-rc.2 (Unreleased)

#### :rocket: New Feature

- `rescript build` will always build its dependency by default. The argument `-with-deps` is not needed anymore. https://github.com/rescript-lang/rescript-compiler/pull/6350

#### :bug: Bug Fix

- Fixed outcome printer resolution of uncurried config. https://github.com/rescript-lang/rescript-compiler/pull/6353
Expand Down
3 changes: 1 addition & 2 deletions jscomp/bsb/bsb_exception.ml
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ let print (fmt : Format.formatter) (x : error) =
Format.fprintf fmt
"File \"bsconfig.json\", line 1\n\
@{<error>Error:@} package @{<error>%s@} not found or built %s\n\
- Did you install it?\n\
- If you did, did you run `rescript build -with-deps`?" name in_json
- Did you install it?" name in_json
| Json_config (pos, s) ->
Format.fprintf fmt
"File %S, line %d:\n\
Expand Down
45 changes: 8 additions & 37 deletions jscomp/bsb_exe/rescript_main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ let separator = "--"

let watch_mode = ref false

let make_world = ref false

let do_install = ref false

let force_regenerate = ref false
Expand Down Expand Up @@ -109,24 +107,6 @@ let install_target () =
let eid = Bsb_unix.run_command_execv install_command in
if eid <> 0 then Bsb_unix.command_fatal_error install_command eid

(** check if every dependency installation dierctory is there
This is in hot path, so we want it to be fast.
The heuristics is that if the installation directory is not there,
we definitely need build the world.
If it is there, we do not check if it is up-to-date, since that's
going be slow, user can use `-with-deps` to enforce such check
*)
let check_deps_installation_directory (config_opt : Bsb_config_types.t option) :
bool =
match config_opt with
| Some { bs_dependencies; bs_dev_dependencies } ->
not
(Ext_list.for_all bs_dependencies (fun x ->
Ext_sys.is_directory_no_exn x.package_install_path)
&& Ext_list.for_all bs_dev_dependencies (fun x ->
Ext_sys.is_directory_no_exn x.package_install_path))
| None -> false

let build_subcommand ~start argv argv_len =
let i = Ext_array.rfind_with_index argv Ext_string.equal separator in

Expand All @@ -135,10 +115,10 @@ let build_subcommand ~start argv argv_len =
~argv
[|
("-w", unit_set_spec watch_mode, "Watch mode");
("-with-deps", unit_set_spec make_world, "Build dependencies explicitly");
("-with-deps", unit_set_spec (ref true), "*deprecated* This is the default behavior now. This option will be removed in a future release");
( "-install",
unit_set_spec do_install,
"*internal* Install public interface files for dependencies " );
"*internal* Install public interface files for dependencies" );
(* This should be put in a subcommand
previously it works with the implication `bsb && bsb -install`
*)
Expand All @@ -162,15 +142,8 @@ let build_subcommand ~start argv argv_len =
| _ ->
let config_opt =
Bsb_ninja_regen.regenerate_ninja ~package_kind:Toplevel
~per_proj_dir:Bsb_global_paths.cwd ~forced:!force_regenerate
in
let implict_build = check_deps_installation_directory config_opt in
(match (!make_world, implict_build) with
| true, _ ->
Bsb_world.make_world_deps Bsb_global_paths.cwd config_opt ninja_args
| false, true ->
Bsb_world.make_world_deps Bsb_global_paths.cwd config_opt [||]
| false, false -> ());
~per_proj_dir:Bsb_global_paths.cwd ~forced:!force_regenerate in
Bsb_world.make_world_deps Bsb_global_paths.cwd config_opt ninja_args;
if !do_install then install_target ();
if !watch_mode then exit 0 (* let the watcher do the build*)
else ninja_command_exit ninja_args
Expand All @@ -179,8 +152,8 @@ let clean_subcommand ~start argv =
Bsb_arg.parse_exn ~usage:clean_usage ~start ~argv
[|
( "-with-deps",
unit_set_spec make_world,
"*internal* Clean dependencies too" );
unit_set_spec (ref true),
"*deprecated* This is the default behavior now. This option will be removed in a future release" );
("-verbose", call_spec Bsb_log.verbose, "Set the output to be verbose");
|]
failed_annon;
Expand Down Expand Up @@ -226,10 +199,8 @@ let () =
(* specialize this path which is used in watcher *)
let config_opt =
Bsb_ninja_regen.regenerate_ninja ~package_kind:Toplevel ~forced:false
~per_proj_dir:Bsb_global_paths.cwd
in
if !make_world || check_deps_installation_directory config_opt then
Bsb_world.make_world_deps Bsb_global_paths.cwd config_opt [||];
~per_proj_dir:Bsb_global_paths.cwd in
Bsb_world.make_world_deps Bsb_global_paths.cwd config_opt [||];
ninja_command_exit [||])
else
match argv.(1) with
Expand Down
2 changes: 1 addition & 1 deletion jscomp/build_tests/case/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "case",
"version": "0.1.0",
"scripts": {
"clean": "rescript clean -with-deps",
"clean": "rescript clean",
"build": "rescript build",
"watch": "rescript build -w"
},
Expand Down
2 changes: 1 addition & 1 deletion jscomp/build_tests/case2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "case2",
"version": "0.1.0",
"scripts": {
"clean": "rescript clean -with-deps",
"clean": "rescript clean",
"build": "rescript build",
"watch": "rescript build -w"
},
Expand Down
2 changes: 1 addition & 1 deletion jscomp/build_tests/case3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "case3",
"version": "0.1.0",
"scripts": {
"clean": "rescript clean -with-deps",
"clean": "rescript clean",
"build": "rescript build",
"watch": "rescript build -w"
},
Expand Down
2 changes: 1 addition & 1 deletion jscomp/build_tests/custom_namespace/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var path = require("path");
var assert = require("assert");
var rescript_exe = require("../../../scripts/bin_path").rescript_exe;

child_process.execSync(`${rescript_exe} clean -with-deps && ${rescript_exe} build`, {
child_process.execSync(`${rescript_exe} clean && ${rescript_exe} build`, {
cwd: __dirname,
});

Expand Down
2 changes: 1 addition & 1 deletion jscomp/build_tests/custom_namespace/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "namespace",
"version": "0.1.0",
"scripts": {
"clean": "rescript clean -with-deps",
"clean": "rescript clean",
"build": "rescript build",
"watch": "rescript build -w"
},
Expand Down
2 changes: 1 addition & 1 deletion jscomp/build_tests/cycle/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "cycle",
"version": "0.1.0",
"scripts": {
"clean": "rescript clean -with-deps",
"clean": "rescript clean",
"build": "rescript build",
"watch": "rescript build -w"
},
Expand Down
2 changes: 1 addition & 1 deletion jscomp/build_tests/cycle1/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const fs = require('fs')
const path = require('path')
var rescript_exe = require("../../../scripts/bin_path").rescript_exe

cp.execSync(`${rescript_exe} clean -with-deps`, { cwd: __dirname, });
cp.execSync(`${rescript_exe} clean`, { cwd: __dirname, });

var output = cp.spawnSync(rescript_exe, { encoding: "utf8", shell: true });

Expand Down
33 changes: 0 additions & 33 deletions jscomp/build_tests/devdeps/input.js

This file was deleted.

4 changes: 0 additions & 4 deletions jscomp/build_tests/devdeps/node_modules/weird/bsconfig.json

This file was deleted.

Empty file.
64 changes: 0 additions & 64 deletions jscomp/build_tests/devdeps/package-lock.json

This file was deleted.

2 changes: 1 addition & 1 deletion jscomp/build_tests/devonly/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "devonly",
"version": "0.1.0",
"scripts": {
"clean": "rescript clean -with-deps",
"clean": "rescript clean",
"build": "rescript build",
"watch": "rescript build -w"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"scripts": {
"build": "rescript build",
"start": "rescript build -w",
"clean": "rescript clean -with-deps"
"clean": "rescript clean"
},
"keywords": [
"BuckleScript"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"scripts": {
"build": "rescript build",
"start": "rescript build -w",
"clean": "rescript clean -with-deps"
"clean": "rescript clean"
},
"keywords": [
"BuckleScript"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"scripts": {
"build": "rescript build",
"start": "rescript build -w",
"clean": "rescript clean -with-deps"
"clean": "rescript clean"
},
"keywords": [
"BuckleScript"
Expand Down
2 changes: 1 addition & 1 deletion jscomp/build_tests/duplicated_symlinked_packages/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function postProcessErrorOutput (output) {
output = output.replace(new RegExp(__dirname, 'gi'), '.')
return output
}
child_process.execSync(`${rescript_exe} clean -with-deps`,{cwd:__dirname})
child_process.execSync(`${rescript_exe} clean`,{cwd:__dirname})
child_process.exec(rescript_exe, {cwd: __dirname}, (err, stdout, stderr) => {
const actualErrorOutput = postProcessErrorOutput(stderr.toString())
if (updateTests) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "duplicated-symlinked-packages",
"version": "0.1.0",
"scripts": {
"clean": "rescript clean -with-deps",
"clean": "rescript clean",
"build": "rescript build",
"watch": "rescript build -w"
},
Expand Down
2 changes: 1 addition & 1 deletion jscomp/build_tests/exports/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "exports",
"version": "0.1.0",
"scripts": {
"clean": "rescript clean -with-deps",
"clean": "rescript clean",
"build": "rescript build",
"watch": "rescript build -w"
},
Expand Down
2 changes: 1 addition & 1 deletion jscomp/build_tests/hyphen2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "hyphen2",
"version": "0.1.0",
"scripts": {
"clean": "rescript clean -with-deps",
"clean": "rescript clean",
"build": "rescript build",
"watch": "rescript build -w"
},
Expand Down
2 changes: 1 addition & 1 deletion jscomp/build_tests/install/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "install",
"version": "0.1.0",
"scripts": {
"clean": "rescript clean -with-deps",
"clean": "rescript clean",
"build": "rescript build",
"install": "rescript build -install",
"watch": "rescript build -w"
Expand Down
2 changes: 1 addition & 1 deletion jscomp/build_tests/nested/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "nested",
"version": "0.1.0",
"scripts": {
"clean": "rescript clean -with-deps",
"clean": "rescript clean",
"build": "rescript build",
"watch": "rescript build -w"
},
Expand Down
2 changes: 1 addition & 1 deletion jscomp/build_tests/nnest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "nested",
"version": "0.1.0",
"scripts": {
"clean": "rescript clean -with-deps",
"clean": "rescript clean",
"build": "rescript build",
"watch": "rescript build -w"
},
Expand Down
2 changes: 1 addition & 1 deletion jscomp/build_tests/ns/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "ns",
"version": "0.1.0",
"scripts": {
"clean": "rescript clean -with-deps",
"clean": "rescript clean",
"build": "rescript build",
"watch": "rescript build -w"
},
Expand Down
2 changes: 1 addition & 1 deletion jscomp/build_tests/post-build/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "post-build",
"version": "0.1.0",
"scripts": {
"clean": "rescript clean -with-deps",
"clean": "rescript clean",
"build": "rescript build",
"watch": "rescript build -w"
},
Expand Down
Loading

0 comments on commit cc410f2

Please sign in to comment.