Skip to content

Commit

Permalink
Clerk: list targets on clerk build without target (#765)
Browse files Browse the repository at this point in the history
  • Loading branch information
denismerigoux authored Jan 8, 2025
2 parents c4e036a + c113c96 commit ebb901d
Showing 1 changed file with 25 additions and 11 deletions.
36 changes: 25 additions & 11 deletions build_system/clerk_driver.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1023,17 +1023,31 @@ let build_cmd =
let run ninja_init (targets : string list) (ninja_flags : string list) =
ninja_init ~extra:Seq.empty ~test_flags:[]
@@ fun _build_dir fix_path nin_file ->
let targets =
List.map
(fun f ->
if String.exists (function '/' | '.' -> true | _ -> false) f then
fix_path f
else f)
targets
in
let ninja_cmd = ninja_cmdline ninja_flags nin_file targets in
Message.debug "executing '%s'..." (String.concat " " ninja_cmd);
raise (Catala_utils.Cli.Exit_with (run_ninja ~clean_up_env:false ninja_cmd))
if targets <> [] then
let targets =
List.map
(fun f ->
if String.exists (function '/' | '.' -> true | _ -> false) f then
fix_path f
else f)
targets
in
let ninja_cmd = ninja_cmdline ninja_flags nin_file targets in
Message.debug "executing '%s'..." (String.concat " " ninja_cmd);
raise (Catala_utils.Cli.Exit_with (run_ninja ~clean_up_env:false ninja_cmd))
else (* List targets command *)
let ninja_cmd = ninja_cmdline ninja_flags nin_file ["-t"; "targets"] in
let result = File.process_out (List.hd ninja_cmd) (List.tl ninja_cmd) in
let targets =
String.split_on_char '\n' result |>
List.filter_map (fun line ->
match String.split_on_char ':' line with
| [] | "always" :: _ -> None
| target :: _ -> Some target)
in
Format.eprintf "Available targets:%!";
List.iter print_endline targets;
0
in
let doc =
"Low-level build command: can be used to forward build targets or options \
Expand Down

0 comments on commit ebb901d

Please sign in to comment.