@@ -24,6 +24,8 @@ let excludes = "excludes"
24
24
let slow_re = " slow-re"
25
25
let resources = " resources"
26
26
let public = " public"
27
+ let js_post_build = " js-post-build"
28
+ let cmd = " cmd"
27
29
28
30
end
29
31
module Ext_pervasives : sig
@@ -4987,6 +4989,10 @@ val get_refmt : unit -> string
4987
4989
val get_bs_dependencies : unit -> string list
4988
4990
val set_bs_dependencies : Bsb_json .t array -> unit
4989
4991
4992
+
4993
+ val get_js_post_build_cmd : unit -> string option
4994
+ val set_js_post_build_cmd : cwd :string -> string -> unit
4995
+
4990
4996
end = struct
4991
4997
#1 " bsb_default.ml"
4992
4998
(* Copyright (C) 2015-2016 Bloomberg Finance L.P.
@@ -5081,6 +5087,12 @@ let set_ppx_flags ~cwd s =
5081
5087
) in
5082
5088
ppx_flags := s
5083
5089
5090
+
5091
+ let js_post_build_cmd = ref None
5092
+ let get_js_post_build_cmd () = ! js_post_build_cmd
5093
+ let set_js_post_build_cmd ~cwd s =
5094
+ js_post_build_cmd := Some (resolve_bsb_magic_path ~cwd ~desc: " js-post-build:cmd" s )
5095
+
5084
5096
end
5085
5097
module Bsb_dep_infos : sig
5086
5098
#1 " bsb_dep_infos.mli"
@@ -5302,6 +5314,7 @@ val output_kvs : (string * string) list -> out_channel -> unit
5302
5314
5303
5315
type info = string list * string list
5304
5316
val handle_file_groups : out_channel ->
5317
+ js_post_build_cmd :string option ->
5305
5318
Bsb_build_ui .file_group list ->
5306
5319
info -> info
5307
5320
@@ -5433,15 +5446,15 @@ module Rules = struct
5433
5446
let build_cmj_js =
5434
5447
define
5435
5448
~command: " ${bsc} ${bs_package_flags} -bs-no-builtin-ppx-ml -bs-no-implicit-include \
5436
- ${bs_package_includes} ${bsc_includes} ${bsc_flags} -o ${in} -c -impl ${in}"
5449
+ ${bs_package_includes} ${bsc_includes} ${bsc_flags} -o ${in} -c -impl ${in} ${postbuild} "
5437
5450
5438
5451
~depfile: " ${in}.d"
5439
5452
" build_cmj_only"
5440
5453
5441
5454
let build_cmi_cmj_js =
5442
5455
define
5443
5456
~command: " ${bsc} ${bs_package_flags} -bs-assume-no-mli -bs-no-builtin-ppx-ml -bs-no-implicit-include \
5444
- ${bs_package_includes} ${bsc_includes} ${bsc_flags} -o ${in} -c -impl ${in}"
5457
+ ${bs_package_includes} ${bsc_includes} ${bsc_flags} -o ${in} -c -impl ${in} ${postbuild} "
5445
5458
~depfile: " ${in}.d"
5446
5459
" build_cmj_cmi"
5447
5460
let build_cmi =
@@ -5556,7 +5569,7 @@ let (++) (us : info) (vs : info) =
5556
5569
5557
5570
5558
5571
5559
- let handle_file_group oc acc (group : Bsb_build_ui.file_group ) =
5572
+ let handle_file_group oc ~ js_post_build_cmd acc (group : Bsb_build_ui.file_group ) =
5560
5573
let handle_module_info oc module_name
5561
5574
( module_info : Binary_cache.module_info )
5562
5575
bs_dependencies
@@ -5628,7 +5641,13 @@ let handle_file_group oc acc (group: Bsb_build_ui.file_group) =
5628
5641
[ output_cmi] , []
5629
5642
else Rules. build_cmi_cmj_js, [] , [output_cmi]
5630
5643
in
5631
-
5644
+ let shadows =
5645
+ match js_post_build_cmd with
5646
+ | None -> shadows
5647
+ | Some cmd ->
5648
+ (" postbuild" ,
5649
+ `Overwrite (" && " ^ cmd ^ " " ^ output_js)) :: shadows
5650
+ in
5632
5651
output_build oc
5633
5652
~output: output_cmj
5634
5653
~shadows
@@ -5708,8 +5727,8 @@ let handle_file_group oc acc (group: Bsb_build_ui.file_group) =
5708
5727
handle_module_info oc k v group.bs_dependencies acc
5709
5728
) group.sources acc
5710
5729
5711
- let handle_file_groups oc (file_groups : Bsb_build_ui.file_group list ) st =
5712
- List. fold_left (handle_file_group oc) st file_groups
5730
+ let handle_file_groups oc ~ js_post_build_cmd (file_groups : Bsb_build_ui.file_group list ) st =
5731
+ List. fold_left (handle_file_group oc ~js_post_build_cmd ) st file_groups
5713
5732
5714
5733
end
5715
5734
module Bsb_gen : sig
@@ -5742,6 +5761,7 @@ module Bsb_gen : sig
5742
5761
val output_ninja :
5743
5762
builddir :string ->
5744
5763
cwd :string ->
5764
+ js_post_build_cmd :string option ->
5745
5765
string ->
5746
5766
string ->
5747
5767
string option ->
@@ -5785,6 +5805,7 @@ let (//) = Ext_filename.combine
5785
5805
let output_ninja
5786
5806
~builddir
5787
5807
~cwd
5808
+ ~js_post_build_cmd
5788
5809
bsc
5789
5810
bsdep
5790
5811
package_name
@@ -5795,6 +5816,7 @@ let output_ninja
5795
5816
ppx_flags
5796
5817
bs_dependencies
5797
5818
refmt
5819
+
5798
5820
=
5799
5821
let ppx_flags = Bsb_build_util. flag_concat " -ppx" ppx_flags in
5800
5822
let bs_groups, source_dirs,static_resources =
@@ -5847,7 +5869,7 @@ let output_ninja
5847
5869
]
5848
5870
in
5849
5871
let all_deps, all_cmis =
5850
- Bsb_ninja. handle_file_groups oc bs_file_groups ([] ,[] ) in
5872
+ Bsb_ninja. handle_file_groups oc ~js_post_build_cmd bs_file_groups ([] ,[] ) in
5851
5873
let all_deps =
5852
5874
(* we need copy package.json into [_build] since it does affect build output *)
5853
5875
(* Literals.package_json ::
@@ -5931,6 +5953,11 @@ let write_ninja_file cwd =
5931
5953
|?
5932
5954
(Bsb_build_schemas. ocaml_config, `Obj begin fun m ->
5933
5955
m
5956
+ |? (Bsb_build_schemas. js_post_build, `Obj begin fun m ->
5957
+ m |? (Bsb_build_schemas. cmd , `Str (Bsb_default. set_js_post_build_cmd ~cwd )
5958
+ )
5959
+ |> ignore
5960
+ end)
5934
5961
|? (Bsb_build_schemas. ocamllex, `Str Bsb_default. set_ocamllex)
5935
5962
|? (Bsb_build_schemas. bs_dependencies, `Arr Bsb_default. set_bs_dependencies)
5936
5963
(* More design *)
@@ -5962,7 +5989,7 @@ let write_ninja_file cwd =
5962
5989
Unix. unlink Literals. bsconfig_json;
5963
5990
Unix. rename config_file_bak Literals. bsconfig_json
5964
5991
end ;
5965
- Bsb_gen. output_ninja ~builddir ~cwd
5992
+ Bsb_gen. output_ninja ~builddir ~cwd ~js_post_build_cmd: Bsb_default. (get_js_post_build_cmd () )
5966
5993
bsc
5967
5994
bsdep
5968
5995
(Bsb_default. get_package_name () )
@@ -5973,6 +6000,7 @@ let write_ninja_file cwd =
5973
6000
Bsb_default. (get_ppx_flags () )
5974
6001
Bsb_default. (get_bs_dependencies () )
5975
6002
Bsb_default. (get_refmt () )
6003
+
5976
6004
;
5977
6005
! globbed_dirs
5978
6006
0 commit comments