Skip to content

Commit a4b64b5

Browse files
committed
Not passing bsc_dir as an argument
1 parent 5e8ee3f commit a4b64b5

18 files changed

+383
-194
lines changed

jscomp/bsb/bsb_build_util.ml

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -116,21 +116,6 @@ let resolve_bsb_magic_file ~cwd ~desc p : result =
116116

117117
(** converting a file from Linux path format to Windows *)
118118

119-
(**
120-
If [Sys.executable_name] gives an absolute path,
121-
nothing needs to be done.
122-
123-
If [Sys.executable_name] is not an absolute path, for example
124-
(rlwrap ./ocaml)
125-
it is a relative path,
126-
it needs be adapted based on cwd
127-
*)
128-
129-
let get_bsc_dir ~cwd =
130-
Filename.dirname
131-
(Ext_path.normalize_absolute_path
132-
(Ext_path.combine cwd Sys.executable_name))
133-
134119

135120

136121
(**

jscomp/bsb/bsb_build_util.mli

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -67,18 +67,6 @@ val mkp : string -> unit
6767

6868

6969

70-
(**
71-
if [Sys.executable_name] gives an absolute path,
72-
nothing needs to be done
73-
if it is a relative path
74-
75-
there are two cases:
76-
- bsb.exe
77-
- ./bsb.exe
78-
The first should also not be touched
79-
Only the latter need be adapted based on project root
80-
*)
81-
val get_bsc_dir : cwd:string -> string
8270

8371

8472
val get_list_string_acc :

jscomp/bsb/bsb_clean.ml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
let (//) = Ext_path.combine
2727

2828

29-
let ninja_clean bsc_dir proj_dir =
29+
let ninja_clean proj_dir =
3030
try
31-
let cmd = bsc_dir // "ninja.exe" in
31+
let cmd = Bsb_global_paths.vendor_ninja in
3232
let cwd = proj_dir // Bsb_config.lib_bs in
3333
if Sys.file_exists cwd then
3434
let eid =
@@ -38,25 +38,26 @@ let ninja_clean bsc_dir proj_dir =
3838
with e ->
3939
Bsb_log.warn "@{<warning>ninja clean failed@} : %s @." (Printexc.to_string e)
4040

41-
let clean_bs_garbage bsc_dir proj_dir =
41+
let clean_bs_garbage proj_dir =
4242
Bsb_log.info "@{<info>Cleaning:@} in %s@." proj_dir ;
4343
let try_remove x =
4444
let x = proj_dir // x in
4545
if Sys.file_exists x then
4646
Bsb_unix.remove_dir_recursive x in
4747
try
4848
Bsb_parse_sources.clean_re_js proj_dir; (* clean re.js files*)
49-
ninja_clean bsc_dir proj_dir ;
49+
ninja_clean proj_dir ;
5050
Ext_list.iter Bsb_config.all_lib_artifacts try_remove ;
5151
with
5252
e ->
5353
Bsb_log.warn "@{<warning>Failed@} to clean due to %s" (Printexc.to_string e)
5454

5555

56-
let clean_bs_deps bsc_dir proj_dir =
56+
let clean_bs_deps proj_dir =
5757
Bsb_build_util.walk_all_deps proj_dir (fun pkg_cxt ->
5858
(* whether top or not always do the cleaning *)
59-
clean_bs_garbage bsc_dir pkg_cxt.cwd
59+
clean_bs_garbage pkg_cxt.cwd
6060
)
6161

62-
let clean_self bsc_dir proj_dir = clean_bs_garbage bsc_dir proj_dir
62+
let clean_self proj_dir =
63+
clean_bs_garbage proj_dir

jscomp/bsb/bsb_clean.mli

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626
TODO: clean staled in source js artifacts
2727
*)
2828

29-
val clean_bs_deps : string -> string -> unit
29+
val clean_bs_deps :
30+
string ->
31+
unit
3032

31-
val clean_self : string -> string -> unit
33+
val clean_self :
34+
string ->
35+
unit

jscomp/bsb/bsb_config_parse.ml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,6 @@ let extract_js_post_build (map : json_map) cwd : string option =
375375
With a given [cwd] it works anywhere*)
376376
let interpret_json
377377
~toplevel_package_specs
378-
~bsc_dir
379378
~per_proj_dir:(cwd:string)
380379

381380
: Bsb_config_types.t =

jscomp/bsb/bsb_config_parse.mli

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ val package_specs_from_bsconfig :
3030

3131
val interpret_json :
3232
toplevel_package_specs:Bsb_package_specs.t option ->
33-
bsc_dir:string ->
3433
per_proj_dir:string ->
3534
Bsb_config_types.t
3635

jscomp/bsb/bsb_global_paths.ml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
(* Copyright (C) 2019 - Authors of BuckleScript
2+
*
3+
* This program is free software: you can redistribute it and/or modify
4+
* it under the terms of the GNU Lesser General Public License as published by
5+
* the Free Software Foundation, either version 3 of the License, or
6+
* (at your option) any later version.
7+
*
8+
* In addition to the permissions granted to you by the LGPL, you may combine
9+
* or link a "work that uses the Library" with a publicly distributed version
10+
* of this file to produce a combined library or application, then distribute
11+
* that combined work under the terms of your choosing, with no requirement
12+
* to comply with the obligations normally placed on you by section 4 of the
13+
* LGPL version 3 (or the corresponding section of a later version of the LGPL
14+
* should you choose to use a later version).
15+
*
16+
* This program is distributed in the hope that it will be useful,
17+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19+
* GNU Lesser General Public License for more details.
20+
*
21+
* You should have received a copy of the GNU Lesser General Public License
22+
* along with this program; if not, write to the Free Software
23+
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
24+
25+
let cwd = Sys.getcwd ()
26+
27+
28+
(**
29+
If [Sys.executable_name] gives an absolute path,
30+
nothing needs to be done.
31+
32+
If [Sys.executable_name] is not an absolute path, for example
33+
(rlwrap ./ocaml)
34+
it is a relative path,
35+
it needs be adapted based on cwd
36+
37+
if [Sys.executable_name] gives an absolute path,
38+
nothing needs to be done
39+
if it is a relative path
40+
41+
there are two cases:
42+
- bsb.exe
43+
- ./bsb.exe
44+
The first should also not be touched
45+
Only the latter need be adapted based on project root
46+
*)
47+
48+
let bsc_dir =
49+
Filename.dirname
50+
(Ext_path.normalize_absolute_path
51+
(Ext_path.combine cwd Sys.executable_name))
52+
53+
let vendor_ninja =
54+
Filename.concat bsc_dir "ninja.exe"
55+
56+
57+
;; assert (Sys.file_exists bsc_dir)
58+
59+

jscomp/bsb/bsb_global_paths.mli

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
(* Copyright (C) 2019 - Authors of BuckleScript
2+
*
3+
* This program is free software: you can redistribute it and/or modify
4+
* it under the terms of the GNU Lesser General Public License as published by
5+
* the Free Software Foundation, either version 3 of the License, or
6+
* (at your option) any later version.
7+
*
8+
* In addition to the permissions granted to you by the LGPL, you may combine
9+
* or link a "work that uses the Library" with a publicly distributed version
10+
* of this file to produce a combined library or application, then distribute
11+
* that combined work under the terms of your choosing, with no requirement
12+
* to comply with the obligations normally placed on you by section 4 of the
13+
* LGPL version 3 (or the corresponding section of a later version of the LGPL
14+
* should you choose to use a later version).
15+
*
16+
* This program is distributed in the hope that it will be useful,
17+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19+
* GNU Lesser General Public License for more details.
20+
*
21+
* You should have received a copy of the GNU Lesser General Public License
22+
* along with this program; if not, write to the Free Software
23+
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
24+
25+
26+
val cwd : string
27+
28+
val bsc_dir : string
29+
30+
val vendor_ninja : string
31+

jscomp/bsb/bsb_ninja_gen.ml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ let output_static_resources
9797

9898
let output_ninja_and_namespace_map
9999
~cwd
100-
~bsc_dir
101100
~toplevel
102101
({
103102
bs_suffix;
@@ -159,9 +158,9 @@ let output_ninja_and_namespace_map
159158
Bsb_ninja_global_vars.g_pkg_flg, g_pkg_flg ;
160159
Bsb_ninja_global_vars.src_root_dir, cwd (* TODO: need check its integrity -- allow relocate or not? *);
161160
(* The path to [bsc.exe] independent of config *)
162-
Bsb_ninja_global_vars.bsc, (Ext_filename.maybe_quote (bsc_dir // bsc_exe));
161+
Bsb_ninja_global_vars.bsc, (Ext_filename.maybe_quote (Bsb_global_paths.bsc_dir // bsc_exe));
163162
(* The path to [bsb_heler.exe] *)
164-
Bsb_ninja_global_vars.bsdep, (Ext_filename.maybe_quote (bsc_dir // bsb_helper_exe)) ;
163+
Bsb_ninja_global_vars.bsdep, (Ext_filename.maybe_quote (Bsb_global_paths.bsc_dir // bsb_helper_exe)) ;
165164
Bsb_ninja_global_vars.warnings, Bsb_warning.opt_warning_to_string ~toplevel warning ;
166165
Bsb_ninja_global_vars.bsc_flags, (get_bsc_flags ~toplevel bsc_flags) ;
167166
Bsb_ninja_global_vars.ppx_flags, ppx_flags;

jscomp/bsb/bsb_ninja_gen.mli

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,5 @@
2727
*)
2828
val output_ninja_and_namespace_map :
2929
cwd:string ->
30-
bsc_dir:string ->
3130
toplevel:bool ->
3231
Bsb_config_types.t -> unit

0 commit comments

Comments
 (0)