Simplify target resolution

This commit is contained in:
Jérémie Dimino 2017-02-25 14:01:08 +00:00
parent 5095a05002
commit 7cae1cd3f7
1 changed files with 24 additions and 12 deletions

View File

@ -146,21 +146,33 @@ let resolve_targets (setup : Main.setup) user_targets =
[Alias (path, Alias.make ~dir name)] [Alias (path, Alias.make ~dir name)]
else else
let path = Path.relative Path.root s in let path = Path.relative Path.root s in
if Path.is_in_build_dir path || let can't_build path =
not (Path.is_local path) || die "Don't know how to build %s" (Path.to_string path)
Path.exists path || in
Build_system.is_target setup.build_system path then if not (Path.is_local path) then
[File path] [File path]
else else if Path.is_in_build_dir path then begin
if Build_system.is_target setup.build_system path then
[File path]
else
can't_build path
end else
match match
List.filter_map setup.contexts ~f:(fun ctx -> let l =
let path = Path.append ctx.Context.build_dir path in List.filter_map setup.contexts ~f:(fun ctx ->
if Build_system.is_target setup.build_system path then let path = Path.append ctx.Context.build_dir path in
Some (File path) if Build_system.is_target setup.build_system path then
else Some (File path)
None) else
None)
in
if Build_system.is_target setup.build_system path ||
Path.exists path then
File path :: l
else
l
with with
| [] -> die "Don't know how to build %s" (Path.to_string path) | [] -> can't_build path
| l -> l | l -> l
) )
in in