@@ -5092,6 +5092,7 @@ module Bsb_config : sig
5092
5092
val ocaml_bin_install_prefix : string -> string
5093
5093
val proj_rel : string -> string
5094
5094
5095
+ val lib_lit : string
5095
5096
val lib_js : string
5096
5097
val lib_bs : string
5097
5098
val lib_es6 : string
@@ -9862,6 +9863,81 @@ let walk_all_deps dir cb =
9862
9863
let visited = Hash_string.create 0 in
9863
9864
walk_all_deps_aux visited [] true dir cb
9864
9865
9866
+ end
9867
+ module Bsb_global_backend : sig
9868
+ #1 "bsb_global_backend.mli"
9869
+ (* Copyright (C) 2019 - Authors of BuckleScript
9870
+ *
9871
+ * This program is free software: you can redistribute it and/or modify
9872
+ * it under the terms of the GNU Lesser General Public License as published by
9873
+ * the Free Software Foundation, either version 3 of the License, or
9874
+ * (at your option) any later version.
9875
+ *
9876
+ * In addition to the permissions granted to you by the LGPL, you may combine
9877
+ * or link a "work that uses the Library" with a publicly distributed version
9878
+ * of this file to produce a combined library or application, then distribute
9879
+ * that combined work under the terms of your choosing, with no requirement
9880
+ * to comply with the obligations normally placed on you by section 4 of the
9881
+ * LGPL version 3 (or the corresponding section of a later version of the LGPL
9882
+ * should you choose to use a later version).
9883
+ *
9884
+ * This program is distributed in the hope that it will be useful,
9885
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
9886
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9887
+ * GNU Lesser General Public License for more details.
9888
+ *
9889
+ * You should have received a copy of the GNU Lesser General Public License
9890
+ * along with this program; if not, write to the Free Software
9891
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
9892
+
9893
+ val cmdline_backend : Bsb_config_types.compilation_kind_t option ref
9894
+
9895
+ val backend : Bsb_config_types.compilation_kind_t Lazy.t
9896
+
9897
+ val lib_artifacts_dir : string Lazy.t
9898
+
9899
+ end = struct
9900
+ #1 "bsb_global_backend.ml"
9901
+ (* Copyright (C) 2019 - Authors of BuckleScript
9902
+ *
9903
+ * This program is free software: you can redistribute it and/or modify
9904
+ * it under the terms of the GNU Lesser General Public License as published by
9905
+ * the Free Software Foundation, either version 3 of the License, or
9906
+ * (at your option) any later version.
9907
+ *
9908
+ * In addition to the permissions granted to you by the LGPL, you may combine
9909
+ * or link a "work that uses the Library" with a publicly distributed version
9910
+ * of this file to produce a combined library or application, then distribute
9911
+ * that combined work under the terms of your choosing, with no requirement
9912
+ * to comply with the obligations normally placed on you by section 4 of the
9913
+ * LGPL version 3 (or the corresponding section of a later version of the LGPL
9914
+ * should you choose to use a later version).
9915
+ *
9916
+ * This program is distributed in the hope that it will be useful,
9917
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
9918
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9919
+ * GNU Lesser General Public License for more details.
9920
+ *
9921
+ * You should have received a copy of the GNU Lesser General Public License
9922
+ * along with this program; if not, write to the Free Software
9923
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
9924
+
9925
+
9926
+ let backend = lazy Bsb_config_types.Js
9927
+
9928
+ (* No cost of using this variable below when compiled in JS mode. *)
9929
+ let cmdline_backend = ref (Some Bsb_config_types.Js)
9930
+
9931
+
9932
+ let (//) = Ext_path.combine
9933
+
9934
+ let lib_artifacts_dir = lazy
9935
+ begin match Lazy.force backend with
9936
+ | Bsb_config_types.Js -> Bsb_config.lib_bs
9937
+ | Bsb_config_types.Native -> Bsb_config.lib_lit // "native"
9938
+ | Bsb_config_types.Bytecode -> Bsb_config.lib_lit // "bytecode"
9939
+ end
9940
+
9865
9941
end
9866
9942
module Bsb_global_paths : sig
9867
9943
#1 "bsb_global_paths.mli"
@@ -10527,6 +10603,7 @@ let prune_staled_bs_js_files
10527
10603
(context : cxt)
10528
10604
(cur_sources : _ Map_string.t )
10529
10605
: unit =
10606
+ (* Doesn't need to use Bsb_global_backend.lib_artifacts_dir because this is only for JS. *)
10530
10607
let lib_parent =
10531
10608
Filename.concat (Filename.concat context.root Bsb_config.lib_bs)
10532
10609
context.cwd in
@@ -11029,7 +11106,8 @@ let (//) = Ext_path.combine
11029
11106
let ninja_clean proj_dir =
11030
11107
try
11031
11108
let cmd = Bsb_global_paths.vendor_ninja in
11032
- let cwd = proj_dir // Bsb_config.lib_bs in
11109
+ let lib_artifacts_dir = Lazy.force Bsb_global_backend.lib_artifacts_dir in
11110
+ let cwd = proj_dir // lib_artifacts_dir in
11033
11111
if Sys.file_exists cwd then
11034
11112
let eid =
11035
11113
Bsb_unix.run_command_execv {cmd ; args = [|cmd; "-t"; "clean"|] ; cwd} in
@@ -11763,8 +11841,9 @@ let output_merlin_namespace buffer ns=
11763
11841
match ns with
11764
11842
| None -> ()
11765
11843
| Some x ->
11844
+ let lib_artifacts_dir = Lazy.force Bsb_global_backend.lib_artifacts_dir in
11766
11845
Buffer.add_string buffer merlin_b ;
11767
- Buffer.add_string buffer Bsb_config.lib_bs ;
11846
+ Buffer.add_string buffer lib_artifacts_dir ;
11768
11847
Buffer.add_string buffer merlin_flg ;
11769
11848
Buffer.add_string buffer "-open ";
11770
11849
Buffer.add_string buffer x
@@ -11858,13 +11937,14 @@ let merlin_file_gen ~per_proj_dir:(per_proj_dir:string)
11858
11937
Buffer.add_string buffer merlin_b;
11859
11938
Buffer.add_string buffer path ;
11860
11939
);
11940
+ let lib_artifacts_dir = Lazy.force Bsb_global_backend.lib_artifacts_dir in
11861
11941
Ext_list.iter res_files.files (fun x ->
11862
11942
if not (Bsb_file_groups.is_empty x) then
11863
11943
begin
11864
11944
Buffer.add_string buffer merlin_s;
11865
11945
Buffer.add_string buffer x.dir ;
11866
11946
Buffer.add_string buffer merlin_b;
11867
- Buffer.add_string buffer (Bsb_config.lib_bs //x.dir) ;
11947
+ Buffer.add_string buffer (lib_artifacts_dir //x.dir) ;
11868
11948
end
11869
11949
) ;
11870
11950
Buffer.add_string buffer "\n";
@@ -13434,8 +13514,8 @@ let output_ninja_and_namespace_map
13434
13514
number_of_dev_groups;
13435
13515
} : Bsb_config_types.t) : unit
13436
13516
=
13437
-
13438
- let cwd_lib_bs = per_proj_dir // Bsb_config.lib_bs in
13517
+ let lib_artifacts_dir = Lazy.force Bsb_global_backend.lib_artifacts_dir in
13518
+ let cwd_lib_bs = per_proj_dir // lib_artifacts_dir in
13439
13519
let ppx_flags = Bsb_build_util.ppx_flags ppx_files in
13440
13520
let oc = open_out_bin (cwd_lib_bs // Literals.build_ninja) in
13441
13521
let g_pkg_flg , g_ns_flg =
@@ -13556,7 +13636,7 @@ let output_ninja_and_namespace_map
13556
13636
13557
13637
Ext_option.iter namespace (fun ns ->
13558
13638
let namespace_dir =
13559
- per_proj_dir // Bsb_config.lib_bs in
13639
+ per_proj_dir // lib_artifacts_dir in
13560
13640
Bsb_namespace_map_gen.output
13561
13641
~dir:namespace_dir ns
13562
13642
bs_file_groups;
@@ -13983,7 +14063,8 @@ let regenerate_ninja
13983
14063
~forced ~per_proj_dir
13984
14064
: Bsb_config_types.t option =
13985
14065
let toplevel = toplevel_package_specs = None in
13986
- let lib_bs_dir = per_proj_dir // Bsb_config.lib_bs in
14066
+ let lib_artifacts_dir = Lazy.force Bsb_global_backend.lib_artifacts_dir in
14067
+ let lib_bs_dir = per_proj_dir // lib_artifacts_dir in
13987
14068
let output_deps = lib_bs_dir // bsdeps in
13988
14069
let check_result =
13989
14070
Bsb_ninja_check.check
@@ -16444,17 +16525,18 @@ let install_targets cwd ({files_to_install; namespace; package_name = _} : Bsb_c
16444
16525
let install ~destdir file =
16445
16526
Bsb_file.install_if_exists ~destdir file |> ignore
16446
16527
in
16528
+ let lib_artifacts_dir = Lazy.force Bsb_global_backend.lib_artifacts_dir in
16447
16529
let install_filename_sans_extension destdir namespace x =
16448
16530
let x =
16449
16531
Ext_namespace.make ?ns:namespace x in
16450
16532
install ~destdir (cwd // x ^ Literals.suffix_ml) ;
16451
16533
install ~destdir (cwd // x ^ Literals.suffix_re) ;
16452
16534
install ~destdir (cwd // x ^ Literals.suffix_mli) ;
16453
16535
install ~destdir (cwd // x ^ Literals.suffix_rei) ;
16454
- install ~destdir (cwd // Bsb_config.lib_bs //x ^ Literals.suffix_cmi) ;
16455
- install ~destdir (cwd // Bsb_config.lib_bs //x ^ Literals.suffix_cmj) ;
16456
- install ~destdir (cwd // Bsb_config.lib_bs //x ^ Literals.suffix_cmt) ;
16457
- install ~destdir (cwd // Bsb_config.lib_bs //x ^ Literals.suffix_cmti) ;
16536
+ install ~destdir (cwd // lib_artifacts_dir //x ^ Literals.suffix_cmi) ;
16537
+ install ~destdir (cwd // lib_artifacts_dir //x ^ Literals.suffix_cmj) ;
16538
+ install ~destdir (cwd // lib_artifacts_dir //x ^ Literals.suffix_cmt) ;
16539
+ install ~destdir (cwd // lib_artifacts_dir //x ^ Literals.suffix_cmti) ;
16458
16540
in
16459
16541
let destdir = cwd // Bsb_config.lib_ocaml in (* lib is already there after building, so just mkdir [lib/ocaml] *)
16460
16542
if not @@ Sys.file_exists destdir then begin Unix.mkdir destdir 0o777 end;
@@ -16478,6 +16560,7 @@ let build_bs_deps cwd (deps : Bsb_package_specs.t) (ninja_args : string array) =
16478
16560
if Ext_array.is_empty ninja_args then [|vendor_ninja|]
16479
16561
else Array.append [|vendor_ninja|] ninja_args
16480
16562
in
16563
+ let lib_artifacts_dir = Lazy.force Bsb_global_backend.lib_artifacts_dir in
16481
16564
Bsb_build_util.walk_all_deps cwd (fun {top; proj_dir} ->
16482
16565
if not top then
16483
16566
begin
@@ -16488,7 +16571,7 @@ let build_bs_deps cwd (deps : Bsb_package_specs.t) (ninja_args : string array) =
16488
16571
~per_proj_dir:proj_dir in (* set true to force regenrate ninja file so we have [config_opt]*)
16489
16572
let command =
16490
16573
{Bsb_unix.cmd = vendor_ninja;
16491
- cwd = proj_dir // Bsb_config.lib_bs ;
16574
+ cwd = proj_dir // lib_artifacts_dir ;
16492
16575
args
16493
16576
} in
16494
16577
let eid =
@@ -16518,6 +16601,7 @@ let make_world_deps cwd (config : Bsb_config_types.t option) (ninja_args : strin
16518
16601
Bsb_config_parse.package_specs_from_bsconfig ()
16519
16602
| Some config -> config.package_specs in
16520
16603
build_bs_deps cwd deps ninja_args
16604
+
16521
16605
end
16522
16606
module Bsb_main : sig
16523
16607
#1 "bsb_main.mli"
@@ -16622,20 +16706,21 @@ let exec_command_then_exit command =
16622
16706
(* Execute the underlying ninja build call, then exit (as opposed to keep watching) *)
16623
16707
let ninja_command_exit ninja_args =
16624
16708
let ninja_args_len = Array.length ninja_args in
16709
+ let lib_artifacts_dir = Lazy.force Bsb_global_backend.lib_artifacts_dir in
16625
16710
if Ext_sys.is_windows_or_cygwin then
16626
16711
let path_ninja = Filename.quote Bsb_global_paths.vendor_ninja in
16627
16712
exec_command_then_exit
16628
16713
(if ninja_args_len = 0 then
16629
16714
Ext_string.inter3
16630
- path_ninja "-C" Bsb_config.lib_bs
16715
+ path_ninja "-C" lib_artifacts_dir
16631
16716
else
16632
16717
let args =
16633
16718
Array.append
16634
- [| path_ninja ; "-C"; Bsb_config.lib_bs |]
16719
+ [| path_ninja ; "-C"; lib_artifacts_dir |]
16635
16720
ninja_args in
16636
16721
Ext_string.concat_array Ext_string.single_space args)
16637
16722
else
16638
- let ninja_common_args = [|"ninja.exe"; "-C"; Bsb_config.lib_bs |] in
16723
+ let ninja_common_args = [|"ninja.exe"; "-C"; lib_artifacts_dir |] in
16639
16724
let args =
16640
16725
if ninja_args_len = 0 then ninja_common_args else
16641
16726
Array.append ninja_common_args ninja_args in
0 commit comments