Skip to content

Commit 516cfcc

Browse files
authored
Merge pull request #3808 from BuckleScript/clean_up
tweak, duplicated test
2 parents 05a6ac5 + 9a8a0e7 commit 516cfcc

File tree

8 files changed

+102
-90
lines changed

8 files changed

+102
-90
lines changed

jscomp/bsb/bsb_world.ml

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ let (//) = Ext_path.combine
2828
(** TODO: create the animation effect
2929
logging installed files
3030
*)
31-
let install_targets cwd (config : Bsb_config_types.t option) =
31+
let install_targets cwd ({files_to_install; namespace; package_name} : Bsb_config_types.t ) =
3232
let install ~destdir file =
3333
Bsb_file.install_if_exists ~destdir file |> ignore
3434
in
@@ -43,21 +43,19 @@ let install_targets cwd (config : Bsb_config_types.t option) =
4343
install ~destdir (cwd // Bsb_config.lib_bs//x ^ Literals.suffix_cmj) ;
4444
install ~destdir (cwd // Bsb_config.lib_bs//x ^ Literals.suffix_cmt) ;
4545
install ~destdir (cwd // Bsb_config.lib_bs//x ^ Literals.suffix_cmti) ;
46-
4746
in
48-
Ext_option.iter config (fun {files_to_install; namespace; package_name} ->
49-
let destdir = cwd // Bsb_config.lib_ocaml in (* lib is already there after building, so just mkdir [lib/ocaml] *)
50-
if not @@ Sys.file_exists destdir then begin Unix.mkdir destdir 0o777 end;
51-
begin
52-
Bsb_log.info "@{<info>Installing started@}@.";
53-
begin match namespace with
54-
| None -> ()
55-
| Some x ->
56-
install_filename_sans_extension destdir None x
57-
end;
58-
String_hash_set.iter files_to_install (install_filename_sans_extension destdir namespace) ;
59-
Bsb_log.info "@{<info>Installing finished@} @.";
60-
end)
47+
let destdir = cwd // Bsb_config.lib_ocaml in (* lib is already there after building, so just mkdir [lib/ocaml] *)
48+
if not @@ Sys.file_exists destdir then begin Unix.mkdir destdir 0o777 end;
49+
begin
50+
Bsb_log.info "@{<info>Installing started@}@.";
51+
begin match namespace with
52+
| None -> ()
53+
| Some x ->
54+
install_filename_sans_extension destdir None x
55+
end;
56+
String_hash_set.iter files_to_install (install_filename_sans_extension destdir namespace) ;
57+
Bsb_log.info "@{<info>Installing finished@} @.";
58+
end
6159

6260

6361

@@ -91,7 +89,7 @@ let build_bs_deps cwd (deps : Bsb_package_specs.t) (ninja_args : string array) =
9189
Note that we can check if ninja print "no work to do",
9290
then don't need reinstall more
9391
*)
94-
install_targets proj_dir config_opt;
92+
Ext_option.iter config_opt (install_targets proj_dir);
9593
end
9694
)
9795

jscomp/bsb/bsb_world.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
val install_targets:
2727
string ->
28-
Bsb_config_types.t option ->
28+
Bsb_config_types.t ->
2929
unit
3030

3131
val make_world_deps:

jscomp/core/lam_compile_main.ml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,6 @@ let lambda_as_module
295295
(lambda_output : J.deps_program)
296296
(output_prefix : string)
297297
: unit =
298-
if not !Js_config.cmj_only then begin
299298
let basename =
300299
Ext_namespace.change_ext_ns_suffix
301300
(Filename.basename
@@ -326,7 +325,7 @@ let lambda_as_module
326325
) output_chan )
327326

328327
#end
329-
end
328+
330329
(* We can use {!Env.current_unit = "Pervasives"} to tell if it is some specific module,
331330
We need handle some definitions in standard libraries in a special way, most are io specific,
332331
includes {!Pervasives.stdin, Pervasives.stdout, Pervasives.stderr}

jscomp/main/bsb_main.ml

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -138,18 +138,25 @@ let install_target config_opt =
138138
let config =
139139
match config_opt with
140140
| None ->
141-
let config = Bsb_config_parse.interpret_json ~toplevel_package_specs:None ~per_proj_dir:Bsb_global_paths.cwd in
142-
let _ = Ext_list.iter config.file_groups.files (fun group ->
143-
let check_file = match group.public with
144-
| Export_all -> fun _ -> true
145-
| Export_none -> fun _ -> false
146-
| Export_set set ->
147-
fun module_name ->
148-
String_set.mem set module_name in
149-
String_map.iter group.sources (fun module_name module_info -> if check_file module_name then begin String_hash_set.add config.files_to_install module_info.name_sans_extension end)) in
150-
config
141+
let config =
142+
Bsb_config_parse.interpret_json
143+
~toplevel_package_specs:None
144+
~per_proj_dir:Bsb_global_paths.cwd in
145+
let _ = Ext_list.iter config.file_groups.files (fun group ->
146+
let check_file = match group.public with
147+
| Export_all -> fun _ -> true
148+
| Export_none -> fun _ -> false
149+
| Export_set set ->
150+
fun module_name ->
151+
String_set.mem set module_name in
152+
String_map.iter group.sources
153+
(fun module_name module_info ->
154+
if check_file module_name then
155+
begin String_hash_set.add config.files_to_install module_info.name_sans_extension end
156+
)) in
157+
config
151158
| Some config -> config in
152-
Bsb_world.install_targets Bsb_global_paths.cwd (Some config)
159+
Bsb_world.install_targets Bsb_global_paths.cwd config
153160

154161
(* see discussion #929, if we catch the exception, we don't have stacktrace... *)
155162
let () =

lib/4.02.3/bsb.ml

Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -16744,7 +16744,7 @@ module Bsb_world : sig
1674416744

1674516745
val install_targets:
1674616746
string ->
16747-
Bsb_config_types.t option ->
16747+
Bsb_config_types.t ->
1674816748
unit
1674916749

1675016750
val make_world_deps:
@@ -16784,7 +16784,7 @@ let (//) = Ext_path.combine
1678416784
(** TODO: create the animation effect
1678516785
logging installed files
1678616786
*)
16787-
let install_targets cwd (config : Bsb_config_types.t option) =
16787+
let install_targets cwd ({files_to_install; namespace; package_name} : Bsb_config_types.t ) =
1678816788
let install ~destdir file =
1678916789
Bsb_file.install_if_exists ~destdir file |> ignore
1679016790
in
@@ -16799,21 +16799,19 @@ let install_targets cwd (config : Bsb_config_types.t option) =
1679916799
install ~destdir (cwd // Bsb_config.lib_bs//x ^ Literals.suffix_cmj) ;
1680016800
install ~destdir (cwd // Bsb_config.lib_bs//x ^ Literals.suffix_cmt) ;
1680116801
install ~destdir (cwd // Bsb_config.lib_bs//x ^ Literals.suffix_cmti) ;
16802-
1680316802
in
16804-
Ext_option.iter config (fun {files_to_install; namespace; package_name} ->
16805-
let destdir = cwd // Bsb_config.lib_ocaml in (* lib is already there after building, so just mkdir [lib/ocaml] *)
16806-
if not @@ Sys.file_exists destdir then begin Unix.mkdir destdir 0o777 end;
16807-
begin
16808-
Bsb_log.info "@{<info>Installing started@}@.";
16809-
begin match namespace with
16810-
| None -> ()
16811-
| Some x ->
16812-
install_filename_sans_extension destdir None x
16813-
end;
16814-
String_hash_set.iter files_to_install (install_filename_sans_extension destdir namespace) ;
16815-
Bsb_log.info "@{<info>Installing finished@} @.";
16816-
end)
16803+
let destdir = cwd // Bsb_config.lib_ocaml in (* lib is already there after building, so just mkdir [lib/ocaml] *)
16804+
if not @@ Sys.file_exists destdir then begin Unix.mkdir destdir 0o777 end;
16805+
begin
16806+
Bsb_log.info "@{<info>Installing started@}@.";
16807+
begin match namespace with
16808+
| None -> ()
16809+
| Some x ->
16810+
install_filename_sans_extension destdir None x
16811+
end;
16812+
String_hash_set.iter files_to_install (install_filename_sans_extension destdir namespace) ;
16813+
Bsb_log.info "@{<info>Installing finished@} @.";
16814+
end
1681716815

1681816816

1681916817

@@ -16847,7 +16845,7 @@ let build_bs_deps cwd (deps : Bsb_package_specs.t) (ninja_args : string array) =
1684716845
Note that we can check if ninja print "no work to do",
1684816846
then don't need reinstall more
1684916847
*)
16850-
install_targets proj_dir config_opt;
16848+
Ext_option.iter config_opt (install_targets proj_dir);
1685116849
end
1685216850
)
1685316851

@@ -17011,18 +17009,25 @@ let install_target config_opt =
1701117009
let config =
1701217010
match config_opt with
1701317011
| None ->
17014-
let config = Bsb_config_parse.interpret_json ~toplevel_package_specs:None ~per_proj_dir:Bsb_global_paths.cwd in
17015-
let _ = Ext_list.iter config.file_groups.files (fun group ->
17016-
let check_file = match group.public with
17017-
| Export_all -> fun _ -> true
17018-
| Export_none -> fun _ -> false
17019-
| Export_set set ->
17020-
fun module_name ->
17021-
String_set.mem set module_name in
17022-
String_map.iter group.sources (fun module_name module_info -> if check_file module_name then begin String_hash_set.add config.files_to_install module_info.name_sans_extension end)) in
17023-
config
17012+
let config =
17013+
Bsb_config_parse.interpret_json
17014+
~toplevel_package_specs:None
17015+
~per_proj_dir:Bsb_global_paths.cwd in
17016+
let _ = Ext_list.iter config.file_groups.files (fun group ->
17017+
let check_file = match group.public with
17018+
| Export_all -> fun _ -> true
17019+
| Export_none -> fun _ -> false
17020+
| Export_set set ->
17021+
fun module_name ->
17022+
String_set.mem set module_name in
17023+
String_map.iter group.sources
17024+
(fun module_name module_info ->
17025+
if check_file module_name then
17026+
begin String_hash_set.add config.files_to_install module_info.name_sans_extension end
17027+
)) in
17028+
config
1702417029
| Some config -> config in
17025-
Bsb_world.install_targets Bsb_global_paths.cwd (Some config)
17030+
Bsb_world.install_targets Bsb_global_paths.cwd config
1702617031

1702717032
(* see discussion #929, if we catch the exception, we don't have stacktrace... *)
1702817033
let () =

lib/4.02.3/unstable/bsb_native.ml

Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -16843,7 +16843,7 @@ module Bsb_world : sig
1684316843

1684416844
val install_targets:
1684516845
string ->
16846-
Bsb_config_types.t option ->
16846+
Bsb_config_types.t ->
1684716847
unit
1684816848

1684916849
val make_world_deps:
@@ -16883,7 +16883,7 @@ let (//) = Ext_path.combine
1688316883
(** TODO: create the animation effect
1688416884
logging installed files
1688516885
*)
16886-
let install_targets cwd (config : Bsb_config_types.t option) =
16886+
let install_targets cwd ({files_to_install; namespace; package_name} : Bsb_config_types.t ) =
1688716887
let install ~destdir file =
1688816888
Bsb_file.install_if_exists ~destdir file |> ignore
1688916889
in
@@ -16898,21 +16898,19 @@ let install_targets cwd (config : Bsb_config_types.t option) =
1689816898
install ~destdir (cwd // Bsb_config.lib_bs//x ^ Literals.suffix_cmj) ;
1689916899
install ~destdir (cwd // Bsb_config.lib_bs//x ^ Literals.suffix_cmt) ;
1690016900
install ~destdir (cwd // Bsb_config.lib_bs//x ^ Literals.suffix_cmti) ;
16901-
1690216901
in
16903-
Ext_option.iter config (fun {files_to_install; namespace; package_name} ->
16904-
let destdir = cwd // Bsb_config.lib_ocaml in (* lib is already there after building, so just mkdir [lib/ocaml] *)
16905-
if not @@ Sys.file_exists destdir then begin Unix.mkdir destdir 0o777 end;
16906-
begin
16907-
Bsb_log.info "@{<info>Installing started@}@.";
16908-
begin match namespace with
16909-
| None -> ()
16910-
| Some x ->
16911-
install_filename_sans_extension destdir None x
16912-
end;
16913-
String_hash_set.iter files_to_install (install_filename_sans_extension destdir namespace) ;
16914-
Bsb_log.info "@{<info>Installing finished@} @.";
16915-
end)
16902+
let destdir = cwd // Bsb_config.lib_ocaml in (* lib is already there after building, so just mkdir [lib/ocaml] *)
16903+
if not @@ Sys.file_exists destdir then begin Unix.mkdir destdir 0o777 end;
16904+
begin
16905+
Bsb_log.info "@{<info>Installing started@}@.";
16906+
begin match namespace with
16907+
| None -> ()
16908+
| Some x ->
16909+
install_filename_sans_extension destdir None x
16910+
end;
16911+
String_hash_set.iter files_to_install (install_filename_sans_extension destdir namespace) ;
16912+
Bsb_log.info "@{<info>Installing finished@} @.";
16913+
end
1691616914

1691716915

1691816916

@@ -16946,7 +16944,7 @@ let build_bs_deps cwd (deps : Bsb_package_specs.t) (ninja_args : string array) =
1694616944
Note that we can check if ninja print "no work to do",
1694716945
then don't need reinstall more
1694816946
*)
16949-
install_targets proj_dir config_opt;
16947+
Ext_option.iter config_opt (install_targets proj_dir);
1695016948
end
1695116949
)
1695216950

@@ -17110,18 +17108,25 @@ let install_target config_opt =
1711017108
let config =
1711117109
match config_opt with
1711217110
| None ->
17113-
let config = Bsb_config_parse.interpret_json ~toplevel_package_specs:None ~per_proj_dir:Bsb_global_paths.cwd in
17114-
let _ = Ext_list.iter config.file_groups.files (fun group ->
17115-
let check_file = match group.public with
17116-
| Export_all -> fun _ -> true
17117-
| Export_none -> fun _ -> false
17118-
| Export_set set ->
17119-
fun module_name ->
17120-
String_set.mem set module_name in
17121-
String_map.iter group.sources (fun module_name module_info -> if check_file module_name then begin String_hash_set.add config.files_to_install module_info.name_sans_extension end)) in
17122-
config
17111+
let config =
17112+
Bsb_config_parse.interpret_json
17113+
~toplevel_package_specs:None
17114+
~per_proj_dir:Bsb_global_paths.cwd in
17115+
let _ = Ext_list.iter config.file_groups.files (fun group ->
17116+
let check_file = match group.public with
17117+
| Export_all -> fun _ -> true
17118+
| Export_none -> fun _ -> false
17119+
| Export_set set ->
17120+
fun module_name ->
17121+
String_set.mem set module_name in
17122+
String_map.iter group.sources
17123+
(fun module_name module_info ->
17124+
if check_file module_name then
17125+
begin String_hash_set.add config.files_to_install module_info.name_sans_extension end
17126+
)) in
17127+
config
1712317128
| Some config -> config in
17124-
Bsb_world.install_targets Bsb_global_paths.cwd (Some config)
17129+
Bsb_world.install_targets Bsb_global_paths.cwd config
1712517130

1712617131
(* see discussion #929, if we catch the exception, we don't have stacktrace... *)
1712717132
let () =

lib/4.02.3/unstable/js_compiler.ml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116451,7 +116451,6 @@ let lambda_as_module
116451116451
(lambda_output : J.deps_program)
116452116452
(output_prefix : string)
116453116453
: unit =
116454-
if not !Js_config.cmj_only then begin
116455116454
let basename =
116456116455
Ext_namespace.change_ext_ns_suffix
116457116456
(Filename.basename
@@ -116478,7 +116477,7 @@ let lambda_as_module
116478116477
) output_chan )
116479116478

116480116479

116481-
end
116480+
116482116481
(* We can use {!Env.current_unit = "Pervasives"} to tell if it is some specific module,
116483116482
We need handle some definitions in standard libraries in a special way, most are io specific,
116484116483
includes {!Pervasives.stdin, Pervasives.stdout, Pervasives.stderr}

lib/4.02.3/whole_compiler.ml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114160,7 +114160,6 @@ let lambda_as_module
114160114160
(lambda_output : J.deps_program)
114161114161
(output_prefix : string)
114162114162
: unit =
114163-
if not !Js_config.cmj_only then begin
114164114163
let basename =
114165114164
Ext_namespace.change_ext_ns_suffix
114166114165
(Filename.basename
@@ -114187,7 +114186,7 @@ let lambda_as_module
114187114186
) output_chan )
114188114187

114189114188

114190-
end
114189+
114191114190
(* We can use {!Env.current_unit = "Pervasives"} to tell if it is some specific module,
114192114191
We need handle some definitions in standard libraries in a special way, most are io specific,
114193114192
includes {!Pervasives.stdin, Pervasives.stdout, Pervasives.stderr}

0 commit comments

Comments
 (0)