feat(target): exclude files from a srcs glob
This commit is contained in:
1 file changed
+7
-4
+7
-4
@@ -2,8 +2,8 @@ open Ast
|
|||||||
open Types
|
open Types
|
||||||
|
|
||||||
let target_fields =
|
let target_fields =
|
||||||
[ "srcs"; "include"; "use"; "cflags"; "cxxflags"; "ldflags"; "define"; "pkg"; "install";
|
[ "srcs"; "exclude"; "include"; "use"; "cflags"; "cxxflags"; "ldflags"; "define"; "pkg";
|
||||||
"soname"; "args" ]
|
"install"; "soname"; "args" ]
|
||||||
|
|
||||||
let rule_fields = [ "inputs"; "outputs"; "use"; "command"; "description" ]
|
let rule_fields = [ "inputs"; "outputs"; "use"; "command"; "description" ]
|
||||||
let install_fields = [ "files"; "to" ]
|
let install_fields = [ "files"; "to" ]
|
||||||
@@ -138,9 +138,12 @@ let sources_of ~extra ((b : block), base) (t : target) =
|
|||||||
if pats = [] then
|
if pats = [] then
|
||||||
Diag.error ~span:b.nspan ~hint:"add a line like: srcs src/*.c" "%s %s declares no srcs"
|
Diag.error ~span:b.nspan ~hint:"add a line like: srcs src/*.c" "%s %s declares no srcs"
|
||||||
b.kind b.bname;
|
b.kind b.bname;
|
||||||
|
let expand ps = List.concat_map (fun p -> Glob.expand_with ~extra (Eval.under base p)) ps in
|
||||||
|
(* a glob is the natural way to say srcs, and then there is always the one file
|
||||||
|
that has to come back out of it *)
|
||||||
|
let dropped = expand (texts (get b "exclude")) in
|
||||||
let files =
|
let files =
|
||||||
List.concat_map (fun p -> Glob.expand_with ~extra (Eval.under base p)) pats
|
expand pats |> List.filter (fun f -> not (List.mem f dropped)) |> List.sort_uniq compare
|
||||||
|> List.sort_uniq compare
|
|
||||||
in
|
in
|
||||||
if files = [] then
|
if files = [] then
|
||||||
Diag.error ~span:b.nspan
|
Diag.error ~span:b.nspan
|
||||||
|
|||||||
Reference in new issue
Block a user