@@ -8156,7 +8156,7 @@ let revise_merlin new_content =
8156
8156
output_string ochan merlin_trailer ;
8157
8157
output_string ochan " \n " ;
8158
8158
close_out ochan
8159
- else if header > = 0 && tail > = 0 then
8159
+ else if header > = 0 && tail > = 0 then
8160
8160
(* there is one, hit it everytime,
8161
8161
should be fixed point
8162
8162
*)
@@ -8207,12 +8207,12 @@ let write_ninja_file bsc_dir cwd =
8207
8207
FLG -ppx %s\n \
8208
8208
" lib_ocaml_dir lib_ocaml_dir bsppx
8209
8209
) in
8210
- let () =
8211
- match Bsb_default. get_bsc_flags () with
8210
+ let () =
8211
+ match Bsb_default. get_bsc_flags () with
8212
8212
| [] -> ()
8213
- | xs ->
8214
- Buffer. add_string buffer
8215
- (Printf. sprintf " \n FLG %s" (String. concat " " xs) ) in
8213
+ | xs ->
8214
+ Buffer. add_string buffer
8215
+ (Printf. sprintf " \n FLG %s" (String. concat " " xs) ) in
8216
8216
let () =
8217
8217
Bsb_default. get_bs_dependencies ()
8218
8218
|> List. iter (fun package ->
@@ -8270,7 +8270,7 @@ let write_ninja_file bsc_dir cwd =
8270
8270
|? (Bsb_build_schemas. refmt, `Str (Bsb_default. set_refmt ~cwd ))
8271
8271
8272
8272
|? (Bsb_build_schemas. sources, `Obj (fun x ->
8273
- let res : Bsb_build_ui.t =
8273
+ let res : Bsb_build_ui.t =
8274
8274
Bsb_build_ui. parsing_source
8275
8275
Bsb_build_ui. lib_dir_index
8276
8276
Filename. current_dir_name x in
@@ -8279,7 +8279,7 @@ let write_ninja_file bsc_dir cwd =
8279
8279
|? (Bsb_build_schemas. sources, `Arr (fun xs ->
8280
8280
8281
8281
let res : Bsb_build_ui.t =
8282
- Bsb_build_ui. parsing_sources
8282
+ Bsb_build_ui. parsing_sources
8283
8283
Bsb_build_ui. lib_dir_index
8284
8284
Filename. current_dir_name xs
8285
8285
in
@@ -8353,50 +8353,50 @@ let separator = "--"
8353
8353
8354
8354
8355
8355
let internal_package_specs = " -internal-package-specs"
8356
- let internal_install = " -internal-install"
8357
- let build_bs_deps package_specs =
8358
- let bsc_dir = Bsb_build_util. get_bsc_dir cwd in
8359
- let bsb_exe = bsc_dir // " bsb.exe" in
8360
- Bsb_default. walk_all_deps true cwd
8361
- (fun top cwd ->
8362
- if not top then
8356
+ let internal_install = " -internal-install"
8357
+ let build_bs_deps package_specs =
8358
+ let bsc_dir = Bsb_build_util. get_bsc_dir cwd in
8359
+ let bsb_exe = bsc_dir // " bsb.exe" in
8360
+ Bsb_default. walk_all_deps true cwd
8361
+ (fun top cwd ->
8362
+ if not top then
8363
8363
Bsb_unix. run_command_execv true
8364
- {cmd = bsb_exe;
8365
- cwd = cwd;
8366
- args =
8364
+ {cmd = bsb_exe;
8365
+ cwd = cwd;
8366
+ args =
8367
8367
[| bsb_exe ; internal_install ; no_dev; internal_package_specs; package_specs; regen; separator |]})
8368
8368
8369
8369
let annoymous filename =
8370
8370
String_vec. push filename targets
8371
8371
8372
- let watch_mode = ref false
8373
- let make_world = ref false
8372
+ let watch_mode = ref false
8373
+ let make_world = ref false
8374
8374
8375
8375
let lib_bs = " lib" // " bs"
8376
8376
let lib_amdjs = " lib" // " amdjs"
8377
8377
let lib_goog = " lib" // " goog"
8378
8378
let lib_js = " lib" // " js"
8379
8379
let lib_ocaml = " lib" // " ocaml" (* installed binary artifacts *)
8380
- let clean_bs_garbage cwd =
8380
+ let clean_bs_garbage cwd =
8381
8381
print_string " Doing cleaning in " ;
8382
- print_endline cwd;
8383
- let aux x =
8384
- let x = (cwd // x) in
8385
- if Sys. file_exists x then
8386
- Bsb_unix. remove_dir_recursive x in
8387
- try
8388
- aux lib_bs ;
8389
- aux lib_amdjs ;
8382
+ print_endline cwd;
8383
+ let aux x =
8384
+ let x = (cwd // x) in
8385
+ if Sys. file_exists x then
8386
+ Bsb_unix. remove_dir_recursive x in
8387
+ try
8388
+ aux lib_bs ;
8389
+ aux lib_amdjs ;
8390
8390
aux lib_goog;
8391
8391
aux lib_js ;
8392
- aux lib_ocaml
8393
- with
8394
- e ->
8392
+ aux lib_ocaml
8393
+ with
8394
+ e ->
8395
8395
prerr_endline (" Failed to clean due to " ^ Printexc. to_string e)
8396
8396
8397
- let clean_bs_deps () =
8398
- Bsb_default. walk_all_deps true cwd (fun top cwd ->
8399
- clean_bs_garbage cwd
8397
+ let clean_bs_deps () =
8398
+ Bsb_default. walk_all_deps true cwd (fun top cwd ->
8399
+ clean_bs_garbage cwd
8400
8400
)
8401
8401
8402
8402
@@ -8407,22 +8407,22 @@ let bsb_main_flags =
8407
8407
" -w" , Arg. Set watch_mode,
8408
8408
" Watch mode" ;
8409
8409
internal_install, Arg. Set Bsb_config. install,
8410
- " (internal)Install public interface or not, when make-world it will install(in combination with -regen to make sure it has effect)" ;
8411
- no_dev, Arg. Set Bsb_config. no_dev,
8410
+ " (internal)Install public interface or not, when make-world it will install(in combination with -regen to make sure it has effect)" ;
8411
+ no_dev, Arg. Set Bsb_config. no_dev,
8412
8412
" (internal)Build dev dependencies in make-world and dev group(in combination with -regen)" ;
8413
8413
regen, Arg. Set force_regenerate,
8414
8414
" Always regenerate build.ninja no matter bsconfig.json is changed or not (for debugging purpose)"
8415
8415
;
8416
- internal_package_specs, Arg. String Bsb_default. internal_override_package_specs,
8417
- " (internal)Overide package specs (in combination with -regen)" ;
8416
+ internal_package_specs, Arg. String Bsb_default. internal_override_package_specs,
8417
+ " (internal)Overide package specs (in combination with -regen)" ;
8418
8418
" -clean-world" , Arg. Unit clean_bs_deps,
8419
8419
" Clean all bs dependencies" ;
8420
8420
" -make-world" , Arg. Set make_world,
8421
8421
" Build all dependencies and itself "
8422
8422
]
8423
8423
8424
- (* * Regenerate ninja file and return None if we dont need regenerate
8425
- otherwise return some info
8424
+ (* * Regenerate ninja file and return None if we dont need regenerate
8425
+ otherwise return some info
8426
8426
*)
8427
8427
let regenerate_ninja cwd bsc_dir forced : Bsb_default.package_specs option =
8428
8428
let output_deps = Bsb_config. lib_bs // bsdeps in
@@ -8446,43 +8446,43 @@ let regenerate_ninja cwd bsc_dir forced : Bsb_default.package_specs option =
8446
8446
Some (Bsb_default. get_package_specs () )
8447
8447
(* This makes sense since we did parse the json file *)
8448
8448
end
8449
- else None
8449
+ else None
8450
8450
8451
8451
let ninja_error_message = " ninja (required for bsb build system) is not installed, \n \
8452
8452
please visit https://github.com/ninja-build/ninja to have it installed\n "
8453
- let () =
8454
- Printexc. register_printer (function
8455
- | Unix. Unix_error (Unix. ENOENT, "execvp" , "ninja" ) ->
8453
+ let () =
8454
+ Printexc. register_printer (function
8455
+ | Unix. Unix_error (Unix. ENOENT, "execvp" , "ninja" ) ->
8456
8456
Some ninja_error_message
8457
8457
| _ -> None
8458
8458
)
8459
8459
8460
- let print_string_args (args : string array ) =
8461
- for i = 0 to Array. length args - 1 do
8462
- print_string (Array. unsafe_get args i) ;
8460
+ let print_string_args (args : string array ) =
8461
+ for i = 0 to Array. length args - 1 do
8462
+ print_string (Array. unsafe_get args i) ;
8463
8463
print_string " " ;
8464
- done ;
8465
- print_newline ()
8464
+ done ;
8465
+ print_newline ()
8466
8466
8467
8467
(* Note that [keepdepfile] only makes sense when combined with [deps] for optimizatoin *)
8468
- let ninja_command ninja ninja_args =
8468
+ let ninja_command ninja ninja_args =
8469
8469
let ninja_args_len = Array. length ninja_args in
8470
- if ninja_args_len = 0 then
8471
- begin
8472
- let args = [|" ninja" ; " -C" ; Bsb_config. lib_bs |] in
8473
- print_string_args args ;
8474
- Unix. execvp ninja args
8475
- end
8476
- else
8477
- let fixed_args_length = 3 in
8470
+ if ninja_args_len = 0 then
8471
+ begin
8472
+ let args = [|" ninja" ; " -C" ; Bsb_config. lib_bs |] in
8473
+ print_string_args args ;
8474
+ Unix. execvp ninja args
8475
+ end
8476
+ else
8477
+ let fixed_args_length = 3 in
8478
8478
let args = (Array. init (fixed_args_length + ninja_args_len)
8479
- (fun i -> match i with
8479
+ (fun i -> match i with
8480
8480
| 0 -> " ninja"
8481
8481
| 1 -> " -C"
8482
8482
| 2 -> Bsb_config. lib_bs
8483
- | _ -> Array. unsafe_get ninja_args (i - fixed_args_length) )) in
8483
+ | _ -> Array. unsafe_get ninja_args (i - fixed_args_length) )) in
8484
8484
print_string_args args ;
8485
- Unix. execvp ninja args
8485
+ Unix. execvp ninja args
8486
8486
8487
8487
8488
8488
@@ -8502,37 +8502,37 @@ let usage = "Usage : bsb.exe <bsb-options> <files> -- <ninja_options>\n\
8502
8502
8503
8503
8504
8504
(*
8505
- let bsb_exe = bsc_dir // "bsb.exe" in
8506
- Bsb_default.walk_all_deps true cwd
8505
+ let bsb_exe = bsc_dir // "bsb.exe" in
8506
+ Bsb_default.walk_all_deps true cwd
8507
8507
(fun top cwd -> Bsb_unix.run_command_execv (not top)
8508
8508
{cmd = bsb_exe; cwd = cwd; args = [| bsb_exe ; separator; "-t" ; "clean"|]})
8509
8509
*)
8510
- let make_world_deps deps =
8510
+ let make_world_deps deps =
8511
8511
print_endline " \n Making the dependency world!" ;
8512
- let deps =
8513
- match deps with
8514
- | None ->
8515
- let json = Ext_json. parse_json_from_file Literals. bsconfig_json in
8516
- begin match json with
8517
- | `Obj map ->
8518
- map
8519
- |? (Bsb_build_schemas. package_specs,
8512
+ let deps =
8513
+ match deps with
8514
+ | None ->
8515
+ let json = Ext_json. parse_json_from_file Literals. bsconfig_json in
8516
+ begin match json with
8517
+ | `Obj map ->
8518
+ map
8519
+ |? (Bsb_build_schemas. package_specs,
8520
8520
`Arr Bsb_default. set_package_specs_from_array)
8521
8521
|> ignore ;
8522
8522
Bsb_default. get_package_specs ()
8523
8523
| _ -> assert false
8524
- end
8525
- | Some spec -> spec in
8526
- build_bs_deps ( String_set. fold
8527
- (fun k acc -> k ^ " ," ^ acc ) deps Ext_string. empty )
8524
+ end
8525
+ | Some spec -> spec in
8526
+ build_bs_deps ( String_set. fold
8527
+ (fun k acc -> k ^ " ," ^ acc ) deps Ext_string. empty )
8528
8528
let () =
8529
8529
let bsc_dir = Bsb_build_util. get_bsc_dir cwd in
8530
- let ninja =
8531
- if Sys. win32 then
8530
+ let ninja =
8531
+ if Sys. win32 then
8532
8532
bsc_dir // " ninja.exe"
8533
- else
8534
- " ninja"
8535
- in
8533
+ else
8534
+ " ninja"
8535
+ in
8536
8536
(* try *)
8537
8537
(* see discussion #929 *)
8538
8538
if Array. length Sys. argv < = 1 then
@@ -8546,30 +8546,33 @@ let () =
8546
8546
| `No_split
8547
8547
->
8548
8548
begin
8549
- Arg. parse bsb_main_flags annoymous usage;
8549
+ Arg. parse bsb_main_flags annoymous usage;
8550
8550
(* [-make-world] should never be combined with [-package-specs] *)
8551
- if ! make_world then
8551
+ if ! make_world then begin
8552
8552
(* don't regenerate files when we only run [bsb -clean-world] *)
8553
- let deps = regenerate_ninja cwd bsc_dir ! force_regenerate in
8554
- make_world_deps deps ;
8555
- if ! watch_mode then
8556
- watch ()
8557
- (* ninja is not triggered in this case *)
8553
+ let deps = regenerate_ninja cwd bsc_dir ! force_regenerate in
8554
+ make_world_deps deps
8555
+ end ;
8556
+ if ! watch_mode then begin
8557
+ watch ()
8558
+ (* ninja is not triggered in this case *)
8559
+ end
8558
8560
end
8559
8561
| `Split (bsb_args,ninja_args)
8560
8562
->
8561
8563
begin
8562
8564
Arg. parse_argv bsb_args bsb_main_flags annoymous usage ;
8563
- let deps = (regenerate_ninja cwd bsc_dir ! force_regenerate) in
8565
+ let deps = (regenerate_ninja cwd bsc_dir ! force_regenerate) in
8564
8566
(* [-make-world] should never be combined with [-package-specs] *)
8565
- if ! make_world then
8566
- make_world_deps deps ;
8567
- if ! watch_mode then watch ()
8567
+ if ! make_world then
8568
+ make_world_deps deps ;
8569
+ if ! watch_mode then watch ()
8568
8570
else ninja_command ninja ninja_args
8569
8571
end
8570
8572
end
8571
8573
(* with x ->
8572
8574
prerr_endline @@ Printexc.to_string x ;
8573
8575
exit 2*)
8574
- (* with [try, with], there is no stacktrace anymore .. *)
8576
+ (* with [try, with], there is no stacktrace anymore .. *)
8577
+
8575
8578
end
0 commit comments