Simplify target resolution code
Split it into 3 functinos * Resolve 1 targets * Do logging * Resolve all targets Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
This commit is contained in:
parent
a3c6f417d0
commit
6197a49c41
32
bin/main.ml
32
bin/main.ml
|
@ -659,13 +659,8 @@ let check_path contexts =
|
|||
name
|
||||
(hint name (String.Set.to_list contexts))
|
||||
|
||||
let resolve_targets ~log common (setup : Main.setup) user_targets =
|
||||
match user_targets with
|
||||
| [] -> []
|
||||
| _ ->
|
||||
let resolve_target common (setup : Main.setup) s =
|
||||
let check_path = check_path setup.contexts in
|
||||
let targets =
|
||||
List.map user_targets ~f:(fun s ->
|
||||
if String.is_prefix s ~prefix:"@" then begin
|
||||
let pos, is_rec =
|
||||
if String.length s >= 2 && s.[1] = '@' then
|
||||
|
@ -707,14 +702,8 @@ let resolve_targets ~log common (setup : Main.setup) user_targets =
|
|||
| [] -> can't_build path
|
||||
| l -> Ok l
|
||||
end
|
||||
)
|
||||
in
|
||||
if common.config.display = Verbose then begin
|
||||
Log.info log "Actual targets:";
|
||||
let targets =
|
||||
List.concat_map targets ~f:(function
|
||||
| Ok targets -> targets
|
||||
| Error _ -> []) in
|
||||
|
||||
let log_targets ~log targets =
|
||||
List.iter targets ~f:(function
|
||||
| File path ->
|
||||
Log.info log @@ "- " ^ (Path.to_string path)
|
||||
|
@ -724,7 +713,20 @@ let resolve_targets ~log common (setup : Main.setup) user_targets =
|
|||
| Alias_rec path ->
|
||||
Log.info log @@ "- recursive alias " ^
|
||||
(Path.to_string_maybe_quoted path));
|
||||
flush stdout;
|
||||
flush stdout
|
||||
|
||||
let resolve_targets ~log common (setup : Main.setup) user_targets =
|
||||
match user_targets with
|
||||
| [] -> []
|
||||
| _ ->
|
||||
let targets =
|
||||
List.map user_targets ~f:(resolve_target common setup) in
|
||||
if common.config.display = Verbose then begin
|
||||
Log.info log "Actual targets:";
|
||||
List.concat_map targets ~f:(function
|
||||
| Ok targets -> targets
|
||||
| Error _ -> [])
|
||||
|> log_targets ~log
|
||||
end;
|
||||
targets
|
||||
|
||||
|
|
Loading…
Reference in New Issue