diff options
author | Oliver Reiche <oliver.reiche@huawei.com> | 2022-07-21 15:07:44 +0200 |
---|---|---|
committer | Oliver Reiche <oliver.reiche@huawei.com> | 2022-07-25 11:34:45 +0200 |
commit | d6ade68bc52d56467abdd7aee70c108902f4f0b2 (patch) | |
tree | ecd671fd67f1ddc8ffef26f45b7c4226e9d5f0a4 | |
parent | 3da82010cea24fb8ed41ff88c5d8df8e086c5aa4 (diff) | |
download | rules-cc-d6ade68bc52d56467abdd7aee70c108902f4f0b2.tar.gz |
Rules: Enforce non-empty library and binary names
-rw-r--r-- | CC/EXPRESSIONS | 18 | ||||
-rw-r--r-- | CC/RULES | 5 | ||||
-rw-r--r-- | CC/test/RULES | 2 |
3 files changed, 22 insertions, 3 deletions
diff --git a/CC/EXPRESSIONS b/CC/EXPRESSIONS index b551787..462d219 100644 --- a/CC/EXPRESSIONS +++ b/CC/EXPRESSIONS @@ -405,7 +405,23 @@ ] , ["objects", {"type": "CALL_EXPRESSION", "name": "objects"}] , [ "base name" - , {"type": "join", "$1": {"type": "FIELD", "name": "name"}} + , { "type": "let*" + , "bindings": + [ [ "name" + , {"type": "join", "$1": {"type": "FIELD", "name": "name"}} + ] + ] + , "body": + { "type": "if" + , "cond": {"type": "var", "name": "objects"} + , "then": + { "type": "assert_non_empty" + , "msg": "A name has to be provided for non-header-only libraries" + , "$1": {"type": "var", "name": "name"} + } + , "else": {"type": "var", "name": "name"} + } + } ] , [ "libname" , { "type": "join" @@ -476,7 +476,10 @@ , ["link-deps", {"type": "CALL_EXPRESSION", "name": "link-deps"}] , ["objects", {"type": "CALL_EXPRESSION", "name": "objects"}] , [ "base name" - , {"type": "join", "$1": {"type": "FIELD", "name": "name"}} + , { "type": "assert_non_empty" + , "msg": "A non-empty name has to be provided for binaries" + , "$1": {"type": "join", "$1": {"type": "FIELD", "name": "name"}} + } ] , [ "binary name" , { "type": "if" diff --git a/CC/test/RULES b/CC/test/RULES index 93d7706..f3175d4 100644 --- a/CC/test/RULES +++ b/CC/test/RULES @@ -129,7 +129,7 @@ , ["objects", {"type": "CALL_EXPRESSION", "name": "objects"}] , [ "base name" , { "type": "assert_non_empty" - , "msg": "A non-empy name has to be provided" + , "msg": "A non-empty name has to be provided" , "$1": {"type": "join", "$1": {"type": "FIELD", "name": "name"}} } ] |