feat(rule): let a rule use a target as its tool
This commit is contained in:
3 files changed
+17
-2
No files matched your search
+4
-1
@@ -112,8 +112,11 @@ let of_project p =
|
|||||||
List.iter
|
List.iter
|
||||||
(fun r ->
|
(fun r ->
|
||||||
let cmd = Array.of_list r.rcmd in
|
let cmd = Array.of_list r.rcmd in
|
||||||
|
(* a tool the rule runs is an input like any other, so building it first is
|
||||||
|
ordering and rebuilding it is invalidation *)
|
||||||
|
let tools = List.filter_map (fun u -> Option.map (out_of p) (find p u)) r.ruses in
|
||||||
add
|
add
|
||||||
(Graph.make ~id:!n ~tag:"gen" ~label:r.rdesc ~cmd ~outs:r.routs ~ins:r.rin ()))
|
(Graph.make ~id:!n ~tag:"gen" ~label:r.rdesc ~cmd ~outs:r.routs ~ins:(r.rin @ tools) ()))
|
||||||
p.rules;
|
p.rules;
|
||||||
let outputs = Hashtbl.create 16 in
|
let outputs = Hashtbl.create 16 in
|
||||||
List.iter
|
List.iter
|
||||||
|
|||||||
+12
-1
@@ -5,7 +5,7 @@ let target_fields =
|
|||||||
[ "srcs"; "include"; "use"; "cflags"; "cxxflags"; "ldflags"; "define"; "pkg"; "install";
|
[ "srcs"; "include"; "use"; "cflags"; "cxxflags"; "ldflags"; "define"; "pkg"; "install";
|
||||||
"soname"; "args" ]
|
"soname"; "args" ]
|
||||||
|
|
||||||
let rule_fields = [ "inputs"; "outputs"; "command"; "description" ]
|
let rule_fields = [ "inputs"; "outputs"; "use"; "command"; "description" ]
|
||||||
let install_fields = [ "files"; "to" ]
|
let install_fields = [ "files"; "to" ]
|
||||||
let script_fields = [ "use"; "command" ]
|
let script_fields = [ "use"; "command" ]
|
||||||
|
|
||||||
@@ -75,6 +75,7 @@ let rules_of blocks =
|
|||||||
{
|
{
|
||||||
rname = b.bname;
|
rname = b.bname;
|
||||||
rin = [ f ];
|
rin = [ f ];
|
||||||
|
ruses = texts (get b "use");
|
||||||
routs;
|
routs;
|
||||||
rcmd = List.map (subst table) command;
|
rcmd = List.map (subst table) command;
|
||||||
rdesc = subst table descr;
|
rdesc = subst table descr;
|
||||||
@@ -230,6 +231,16 @@ let project (env : Eval.env) =
|
|||||||
| Some _ -> ())
|
| Some _ -> ())
|
||||||
t.uses)
|
t.uses)
|
||||||
targets;
|
targets;
|
||||||
|
List.iter
|
||||||
|
(fun (r : rule) ->
|
||||||
|
List.iter
|
||||||
|
(fun u ->
|
||||||
|
if find p u = None then
|
||||||
|
Diag.error ~span:r.rspan
|
||||||
|
~hint:(Suggest.hint u (List.map (fun (x : target) -> x.name) targets))
|
||||||
|
"rule %s uses %S, which is not a target" r.rname u)
|
||||||
|
r.ruses)
|
||||||
|
p.rules;
|
||||||
let seen_runs = Hashtbl.create 4 in
|
let seen_runs = Hashtbl.create 4 in
|
||||||
List.iter
|
List.iter
|
||||||
(fun (s : script) ->
|
(fun (s : script) ->
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ type target = {
|
|||||||
type rule = {
|
type rule = {
|
||||||
rname : string;
|
rname : string;
|
||||||
rin : string list;
|
rin : string list;
|
||||||
|
ruses : string list;
|
||||||
routs : string list;
|
routs : string list;
|
||||||
rcmd : string list;
|
rcmd : string list;
|
||||||
rdesc : string;
|
rdesc : string;
|
||||||
|
|||||||
Reference in new issue
Block a user