Skip to content

Commit d72bae0

Browse files
committed
Clean up Bsb_world.install_targets interface
1 parent 177b55c commit d72bae0

File tree

7 files changed

+50
-58
lines changed

7 files changed

+50
-58
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/main/bsb_main.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ let install_target config_opt =
149149
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
150150
config
151151
| Some config -> config in
152-
Bsb_world.install_targets Bsb_global_paths.cwd (Some config)
152+
Bsb_world.install_targets Bsb_global_paths.cwd config
153153

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

lib/4.02.3/bsb.ml

Lines changed: 16 additions & 18 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

@@ -17022,7 +17020,7 @@ let install_target config_opt =
1702217020
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
1702317021
config
1702417022
| Some config -> config in
17025-
Bsb_world.install_targets Bsb_global_paths.cwd (Some config)
17023+
Bsb_world.install_targets Bsb_global_paths.cwd config
1702617024

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

lib/4.02.3/unstable/bsb_native.ml

Lines changed: 16 additions & 18 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

@@ -17121,7 +17119,7 @@ let install_target config_opt =
1712117119
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
1712217120
config
1712317121
| Some config -> config in
17124-
Bsb_world.install_targets Bsb_global_paths.cwd (Some config)
17122+
Bsb_world.install_targets Bsb_global_paths.cwd config
1712517123

1712617124
(* see discussion #929, if we catch the exception, we don't have stacktrace... *)
1712717125
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)