Skip to content

Commit 59b8d2e

Browse files
committed
address #895 using bsconfig.json instead, add label warning
1 parent 9058df4 commit 59b8d2e

16 files changed

+131
-121
lines changed

jscomp/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ BYTE=ocamlc.opt$(EXE)
1010
OCAMLLEX=ocamllex.opt$(EXE)
1111
CAMLP4OF=camlp4of
1212
CAMLDEP=ocamldep.opt$(EXE)
13-
COMPFLAGS= -g -w -40-30 -warn-error +a-40-30
13+
COMPFLAGS= -g -w +6-40-30 -warn-error +a-40-30
1414

1515

1616
.SUFFIXES: .mli .ml .cmi .cmx .mll

jscomp/bin/all_ounit_tests.ml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4601,7 +4601,7 @@ let add (h : _ t) key info =
46014601
h.size <- h.size + 1;
46024602
if h.size > Array.length h.data lsl 1 then Hashtbl_gen.resize key_index h
46034603

4604-
4604+
(* after upgrade to 4.04 we should provide an efficient [replace_or_init] *)
46054605
let modify_or_init (h : _ t) key modf default =
46064606
let rec find_bucket (bucketlist : _ bucketlist) =
46074607
match bucketlist with
@@ -7771,21 +7771,21 @@ let node_relative_path (file1 : t)
77717771

77727772

77737773

7774+
(* Input must be absolute directory *)
7775+
let rec find_root_filename ~cwd filename =
7776+
if Sys.file_exists (cwd // filename) then cwd
7777+
else
7778+
let cwd' = Filename.dirname cwd in
7779+
if String.length cwd' < String.length cwd then
7780+
find_root_filename ~cwd:cwd' filename
7781+
else
7782+
Ext_pervasives.failwithf
7783+
~loc:__LOC__
7784+
"%s not found from %s" filename cwd
77747785

77757786

77767787
let find_package_json_dir cwd =
7777-
let rec aux cwd =
7778-
if Sys.file_exists (cwd // Literals.package_json) then cwd
7779-
else
7780-
let cwd' = Filename.dirname cwd in
7781-
if String.length cwd' < String.length cwd then
7782-
aux cwd'
7783-
else
7784-
Ext_pervasives.failwithf
7785-
~loc:__LOC__
7786-
"package.json not found from %s" cwd
7787-
in
7788-
aux cwd
7788+
find_root_filename ~cwd Literals.bsconfig_json
77897789

77907790
let package_dir = lazy (find_package_json_dir (Lazy.force cwd))
77917791

jscomp/bin/bsb.ml

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1228,21 +1228,21 @@ let node_relative_path (file1 : t)
12281228

12291229

12301230

1231+
(* Input must be absolute directory *)
1232+
let rec find_root_filename ~cwd filename =
1233+
if Sys.file_exists (cwd // filename) then cwd
1234+
else
1235+
let cwd' = Filename.dirname cwd in
1236+
if String.length cwd' < String.length cwd then
1237+
find_root_filename ~cwd:cwd' filename
1238+
else
1239+
Ext_pervasives.failwithf
1240+
~loc:__LOC__
1241+
"%s not found from %s" filename cwd
12311242

12321243

12331244
let find_package_json_dir cwd =
1234-
let rec aux cwd =
1235-
if Sys.file_exists (cwd // Literals.package_json) then cwd
1236-
else
1237-
let cwd' = Filename.dirname cwd in
1238-
if String.length cwd' < String.length cwd then
1239-
aux cwd'
1240-
else
1241-
Ext_pervasives.failwithf
1242-
~loc:__LOC__
1243-
"package.json not found from %s" cwd
1244-
in
1245-
aux cwd
1245+
find_root_filename ~cwd Literals.bsconfig_json
12461246

12471247
let package_dir = lazy (find_package_json_dir (Lazy.force cwd))
12481248

@@ -6007,7 +6007,8 @@ let print_arrays file_array oc offset =
60076007
| _ (* first::(_::_ as rest) *)
60086008
->
60096009
output_string oc "[ \n";
6010-
String_vect.iter_range 0 (len - 2 ) (fun s -> p_str @@ "\"" ^ s ^ "\",") file_array;
6010+
String_vect.iter_range ~from:0 ~to_:(len - 2 )
6011+
(fun s -> p_str @@ "\"" ^ s ^ "\",") file_array;
60116012
p_str @@ "\"" ^ (String_vect.last file_array) ^ "\"";
60126013

60136014
p_str "]"
@@ -7382,7 +7383,7 @@ let output_ninja
73827383
~js_post_build_cmd ~package_specs bs_file_groups ([],[]) in
73837384
let all_deps =
73847385
(* we need copy package.json into [_build] since it does affect build output *)
7385-
(* Literals.package_json ::
7386+
(*
73867387
it is a bad idea to copy package.json which requires to copy js files
73877388
*)
73887389
static_resources

jscomp/bin/bsb_helper.ml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,21 +1194,21 @@ let node_relative_path (file1 : t)
11941194

11951195

11961196

1197+
(* Input must be absolute directory *)
1198+
let rec find_root_filename ~cwd filename =
1199+
if Sys.file_exists (cwd // filename) then cwd
1200+
else
1201+
let cwd' = Filename.dirname cwd in
1202+
if String.length cwd' < String.length cwd then
1203+
find_root_filename ~cwd:cwd' filename
1204+
else
1205+
Ext_pervasives.failwithf
1206+
~loc:__LOC__
1207+
"%s not found from %s" filename cwd
11971208

11981209

11991210
let find_package_json_dir cwd =
1200-
let rec aux cwd =
1201-
if Sys.file_exists (cwd // Literals.package_json) then cwd
1202-
else
1203-
let cwd' = Filename.dirname cwd in
1204-
if String.length cwd' < String.length cwd then
1205-
aux cwd'
1206-
else
1207-
Ext_pervasives.failwithf
1208-
~loc:__LOC__
1209-
"package.json not found from %s" cwd
1210-
in
1211-
aux cwd
1211+
find_root_filename ~cwd Literals.bsconfig_json
12121212

12131213
let package_dir = lazy (find_package_json_dir (Lazy.force cwd))
12141214

jscomp/bin/bsdep.ml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26403,21 +26403,21 @@ let node_relative_path (file1 : t)
2640326403

2640426404

2640526405

26406+
(* Input must be absolute directory *)
26407+
let rec find_root_filename ~cwd filename =
26408+
if Sys.file_exists (cwd // filename) then cwd
26409+
else
26410+
let cwd' = Filename.dirname cwd in
26411+
if String.length cwd' < String.length cwd then
26412+
find_root_filename ~cwd:cwd' filename
26413+
else
26414+
Ext_pervasives.failwithf
26415+
~loc:__LOC__
26416+
"%s not found from %s" filename cwd
2640626417

2640726418

2640826419
let find_package_json_dir cwd =
26409-
let rec aux cwd =
26410-
if Sys.file_exists (cwd // Literals.package_json) then cwd
26411-
else
26412-
let cwd' = Filename.dirname cwd in
26413-
if String.length cwd' < String.length cwd then
26414-
aux cwd'
26415-
else
26416-
Ext_pervasives.failwithf
26417-
~loc:__LOC__
26418-
"package.json not found from %s" cwd
26419-
in
26420-
aux cwd
26420+
find_root_filename ~cwd Literals.bsconfig_json
2642126421

2642226422
let package_dir = lazy (find_package_json_dir (Lazy.force cwd))
2642326423

jscomp/bin/bsppx.ml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8270,21 +8270,21 @@ let node_relative_path (file1 : t)
82708270

82718271

82728272

8273+
(* Input must be absolute directory *)
8274+
let rec find_root_filename ~cwd filename =
8275+
if Sys.file_exists (cwd // filename) then cwd
8276+
else
8277+
let cwd' = Filename.dirname cwd in
8278+
if String.length cwd' < String.length cwd then
8279+
find_root_filename ~cwd:cwd' filename
8280+
else
8281+
Ext_pervasives.failwithf
8282+
~loc:__LOC__
8283+
"%s not found from %s" filename cwd
82738284

82748285

82758286
let find_package_json_dir cwd =
8276-
let rec aux cwd =
8277-
if Sys.file_exists (cwd // Literals.package_json) then cwd
8278-
else
8279-
let cwd' = Filename.dirname cwd in
8280-
if String.length cwd' < String.length cwd then
8281-
aux cwd'
8282-
else
8283-
Ext_pervasives.failwithf
8284-
~loc:__LOC__
8285-
"package.json not found from %s" cwd
8286-
in
8287-
aux cwd
8287+
find_root_filename ~cwd Literals.bsconfig_json
82888288

82898289
let package_dir = lazy (find_package_json_dir (Lazy.force cwd))
82908290

jscomp/bin/whole_compiler.ml

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21624,21 +21624,21 @@ let node_relative_path (file1 : t)
2162421624

2162521625

2162621626

21627+
(* Input must be absolute directory *)
21628+
let rec find_root_filename ~cwd filename =
21629+
if Sys.file_exists (cwd // filename) then cwd
21630+
else
21631+
let cwd' = Filename.dirname cwd in
21632+
if String.length cwd' < String.length cwd then
21633+
find_root_filename ~cwd:cwd' filename
21634+
else
21635+
Ext_pervasives.failwithf
21636+
~loc:__LOC__
21637+
"%s not found from %s" filename cwd
2162721638

2162821639

2162921640
let find_package_json_dir cwd =
21630-
let rec aux cwd =
21631-
if Sys.file_exists (cwd // Literals.package_json) then cwd
21632-
else
21633-
let cwd' = Filename.dirname cwd in
21634-
if String.length cwd' < String.length cwd then
21635-
aux cwd'
21636-
else
21637-
Ext_pervasives.failwithf
21638-
~loc:__LOC__
21639-
"package.json not found from %s" cwd
21640-
in
21641-
aux cwd
21641+
find_root_filename ~cwd Literals.bsconfig_json
2164221642

2164321643
let package_dir = lazy (find_package_json_dir (Lazy.force cwd))
2164421644

@@ -24061,7 +24061,7 @@ let sort project_ml project_mli (ast_table : _ t String_map.t) =
2406124061
(read_parse_and_extract Ml (project_ml impl))
2406224062
(read_parse_and_extract Mli (project_mli intf))
2406324063
) ast_table in
24064-
sort_files_by_dependencies domain h
24064+
sort_files_by_dependencies ~domain h
2406524065

2406624066
(** same as {!Ocaml_parse.check_suffix} but does not care with [-c -o] option*)
2406724067
let check_suffix name =
@@ -57255,7 +57255,7 @@ let add (h : _ t) key info =
5725557255
h.size <- h.size + 1;
5725657256
if h.size > Array.length h.data lsl 1 then Hashtbl_gen.resize key_index h
5725757257

57258-
57258+
(* after upgrade to 4.04 we should provide an efficient [replace_or_init] *)
5725957259
let modify_or_init (h : _ t) key modf default =
5726057260
let rec find_bucket (bucketlist : _ bucketlist) =
5726157261
match bucketlist with
@@ -63256,7 +63256,7 @@ let prim ~primitive:(prim : Prim.t) ~args:(ll : t list) loc : t =
6325663256

6325763257

6325863258
let not_ loc x : t =
63259-
prim Pnot [x] loc
63259+
prim ~primitive:Pnot ~args:[x] loc
6326063260

6326163261
let lam_prim ~primitive:( p : Lambda.primitive) ~args loc : t =
6326263262
match p with
@@ -67434,7 +67434,7 @@ let add (h : _ t) key info =
6743467434
h.size <- h.size + 1;
6743567435
if h.size > Array.length h.data lsl 1 then Hashtbl_gen.resize key_index h
6743667436

67437-
67437+
(* after upgrade to 4.04 we should provide an efficient [replace_or_init] *)
6743867438
let modify_or_init (h : _ t) key modf default =
6743967439
let rec find_bucket (bucketlist : _ bucketlist) =
6744067440
match bucketlist with
@@ -71009,7 +71009,7 @@ let string_of_module_id ~output_prefix
7100971009
let js_file = Printf.sprintf "%s.js" modulename in
7101071010
let rebase package_dir dep =
7101171011
let current_unit_dir =
71012-
`Dir (Js_config.get_output_dir package_dir module_system output_prefix) in
71012+
`Dir (Js_config.get_output_dir ~pkg_dir:package_dir module_system output_prefix) in
7101371013
Ext_filename.node_relative_path current_unit_dir dep
7101471014
in
7101571015
let dependency_pkg_info =
@@ -85607,7 +85607,7 @@ let add (h : _ t) key info =
8560785607
h.size <- h.size + 1;
8560885608
if h.size > Array.length h.data lsl 1 then Hashtbl_gen.resize key_index h
8560985609

85610-
85610+
(* after upgrade to 4.04 we should provide an efficient [replace_or_init] *)
8561185611
let modify_or_init (h : _ t) key modf default =
8561285612
let rec find_bucket (bucketlist : _ bucketlist) =
8561385613
match bucketlist with
@@ -85985,7 +85985,7 @@ let subst_helper (subst : subst_tbl) query lam =
8598585985
(simplif body)
8598685986
| Lprim {primitive; args; loc} ->
8598785987
let args = List.map simplif args in
85988-
Lam.prim primitive args loc
85988+
Lam.prim ~primitive ~args loc
8598985989
| Lswitch(l, sw) ->
8599085990
let new_l = simplif l
8599185991
and new_consts = List.map (fun (n, e) -> (n, simplif e)) sw.sw_consts
@@ -96090,7 +96090,7 @@ let lambda_as_module
9609096090
| NonBrowser (_, []) ->
9609196091
(* script mode *)
9609296092
let output_chan chan =
96093-
Js_dump.dump_deps_program output_prefix `NodeJS lambda_output chan in
96093+
Js_dump.dump_deps_program ~output_prefix `NodeJS lambda_output chan in
9609496094
(if !Js_config.dump_js then output_chan stdout);
9609596095
if not @@ !Clflags.dont_write_files then
9609696096
Ext_pervasives.with_file_as_chan

jscomp/bsb/bsb_build_ui.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ let print_arrays file_array oc offset =
6060
| _ (* first::(_::_ as rest) *)
6161
->
6262
output_string oc "[ \n";
63-
String_vect.iter_range 0 (len - 2 ) (fun s -> p_str @@ "\"" ^ s ^ "\",") file_array;
63+
String_vect.iter_range ~from:0 ~to_:(len - 2 )
64+
(fun s -> p_str @@ "\"" ^ s ^ "\",") file_array;
6465
p_str @@ "\"" ^ (String_vect.last file_array) ^ "\"";
6566

6667
p_str "]"

jscomp/bsb/bsb_gen.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ let output_ninja
100100
~js_post_build_cmd ~package_specs bs_file_groups ([],[]) in
101101
let all_deps =
102102
(* we need copy package.json into [_build] since it does affect build output *)
103-
(* Literals.package_json ::
103+
(*
104104
it is a bad idea to copy package.json which requires to copy js files
105105
*)
106106
static_resources

jscomp/core/js_program_loader.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ let string_of_module_id ~output_prefix
8787
let js_file = Printf.sprintf "%s.js" modulename in
8888
let rebase package_dir dep =
8989
let current_unit_dir =
90-
`Dir (Js_config.get_output_dir package_dir module_system output_prefix) in
90+
`Dir (Js_config.get_output_dir ~pkg_dir:package_dir module_system output_prefix) in
9191
Ext_filename.node_relative_path current_unit_dir dep
9292
in
9393
let dependency_pkg_info =

0 commit comments

Comments
 (0)