summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKlaus Aehlig <klaus.aehlig@huawei.com>2024-10-25 18:09:00 +0200
committerKlaus Aehlig <klaus.aehlig@huawei.com>2024-10-25 18:09:00 +0200
commit8673c845f507e1916720763433ffee44f64482be (patch)
tree3e4026b47526742ce86fb11d37c7158647261dc6
parentd67fb3eff0159684accbc7afc3438a8aac4feb50 (diff)
parentee06e3ec3b3deb0a9bf43165ba477e54f4ccbcc5 (diff)
downloadrules-cc-8673c845f507e1916720763433ffee44f64482be.tar.gz
Merge branch 'just-rules' into rules
-rw-r--r--CC/EXPRESSIONS58
-rw-r--r--lint/RULES23
-rwxr-xr-xlint/call_lint1
3 files changed, 80 insertions, 2 deletions
diff --git a/CC/EXPRESSIONS b/CC/EXPRESSIONS
index e7fb54d..37d6d62 100644
--- a/CC/EXPRESSIONS
+++ b/CC/EXPRESSIONS
@@ -1094,6 +1094,7 @@
, "cflags-files"
, "lint-deps fieldnames"
, "deps-transition"
+ , "deps-fieldnames"
, "compile-args"
, "defaults-transition"
, "modified-transitions"
@@ -1101,6 +1102,7 @@
, "imports":
{ "objects": "objects"
, "list_provider": ["./", "..", "field_list_provider"]
+ , "runfiles_list": ["./", "..", "field_runfiles_list"]
, "default-TOOLCHAIN": "default-TOOLCHAIN"
, "default-NON_SYSTEM_TOOLS": "default-NON_SYSTEM_TOOLS"
, "compiler": "compiler"
@@ -1145,6 +1147,52 @@
]
}
]
+ , [ "direct-deps hdrs"
+ , { "type": "to_subdir"
+ , "subdir": "include"
+ , "$1":
+ { "type": "let*"
+ , "bindings":
+ [["transition", {"type": "var", "name": "deps-transition"}]]
+ , "body":
+ { "type": "map_union"
+ , "$1":
+ { "type": "++"
+ , "$1":
+ { "type": "foreach"
+ , "var": "fieldname"
+ , "range": {"type": "var", "name": "deps-fieldnames"}
+ , "body":
+ {"type": "CALL_EXPRESSION", "name": "runfiles_list"}
+ }
+ }
+ }
+ }
+ }
+ ]
+ , [ "own headers"
+ , { "type": "to_subdir"
+ , "subdir": "work"
+ , "$1":
+ { "type": "map_union"
+ , "$1":
+ [ {"type": "var", "name": "hdrs"}
+ , {"type": "var", "name": "private-hdrs"}
+ ]
+ }
+ }
+ ]
+ , [ "direct hdrs"
+ , { "type": "map_union"
+ , "$1":
+ [ {"type": "var", "name": "own headers"}
+ , {"type": "var", "name": "direct-deps hdrs"}
+ ]
+ }
+ ]
+ , [ "direct deps artifact names"
+ , {"type": "keys", "$1": {"type": "var", "name": "direct hdrs"}}
+ ]
, [ "hdr lint"
, { "type": "foreach"
, "range":
@@ -1183,7 +1231,10 @@
}
]
]
- , "body": {"type": "env", "vars": ["cmd", "src"]}
+ , "body":
+ { "type": "env"
+ , "vars": ["cmd", "src", "direct deps artifact names"]
+ }
}
}
}
@@ -1255,7 +1306,10 @@
{ "type": "let*"
, "bindings":
[["src", {"type": "var", "name": "work src_name"}]]
- , "body": {"type": "env", "vars": ["cmd", "src"]}
+ , "body":
+ { "type": "env"
+ , "vars": ["cmd", "src", "direct deps artifact names"]
+ }
}
}
}
diff --git a/lint/RULES b/lint/RULES
index fef578a..04ad230 100644
--- a/lint/RULES
+++ b/lint/RULES
@@ -63,6 +63,10 @@
, " by the field \"config\", and"
, "- OUT pointing to a directory to which files with the lint result"
, " can be written."
+ , "- META pointing to a json file contaning"
+ , " - at key \"direct deps artifact names\" a list of all input"
+ , " artifacts that come from the target itself or are runfiles of a"
+ , " direct dependency."
, "It is supposed to indicate by the exit code whether the file to lint"
, "complies with the given linting policy, with 0 meaning"
, "compliant."
@@ -152,6 +156,12 @@
, "dep": {"type": "var", "name": "_"}
}
]
+ , [ "direct deps artifact names"
+ , { "type": "DEP_PROVIDES"
+ , "dep": {"type": "var", "name": "_"}
+ , "provider": "direct deps artifact names"
+ }
+ ]
]
, "body":
{ "type": "TREE"
@@ -170,6 +180,19 @@
, "subdir": "config"
, "$1": {"type": "var", "name": "config"}
}
+ , { "type": "singleton_map"
+ , "key": "meta.json"
+ , "value":
+ { "type": "BLOB"
+ , "data":
+ { "type": "json_encode"
+ , "$1":
+ { "type": "env"
+ , "vars": ["direct deps artifact names"]
+ }
+ }
+ }
+ }
]
}
, "cmd":
diff --git a/lint/call_lint b/lint/call_lint
index ab9c2b8..ca7e4ef 100755
--- a/lint/call_lint
+++ b/lint/call_lint
@@ -23,6 +23,7 @@ echo "${RESULT}" > result
export OUT="$(pwd)/out"
mkdir -p config
export CONFIG="$(pwd)/config"
+export META="$(pwd)/meta.json"
cd work