summaryrefslogtreecommitdiff
path: root/CC/RULES
diff options
context:
space:
mode:
authorOliver Reiche <oliver.reiche@huawei.com>2022-08-24 18:23:37 +0200
committerOliver Reiche <oliver.reiche@huawei.com>2022-09-13 10:51:13 +0200
commit3e4e38f6987d7435232b175fd0070608b76b4d50 (patch)
treeb65a1966b6fb27b0de42c8b90219e97b952fe7f6 /CC/RULES
parentde4f1edc350636e4e2cde14ef1adda8716d394f6 (diff)
downloadrules-cc-3e4e38f6987d7435232b175fd0070608b76b4d50.tar.gz
Rules: Implement hierarchical defaults
Diffstat (limited to 'CC/RULES')
-rw-r--r--CC/RULES134
1 files changed, 110 insertions, 24 deletions
diff --git a/CC/RULES b/CC/RULES
index 099a629..d4a85b7 100644
--- a/CC/RULES
+++ b/CC/RULES
@@ -6,45 +6,131 @@
, "use of this rule. As targets form a different root, the defaults"
, "can be provided without changing this directory."
]
- , "string_fields": ["CC", "CXX", "CFLAGS", "CXXFLAGS", "PATH", "AR"]
+ , "target_fields": ["base"]
+ , "string_fields":
+ [ "CC"
+ , "CXX"
+ , "CFLAGS"
+ , "CXXFLAGS"
+ , "ADD_CFLAGS"
+ , "ADD_CXXFLAGS"
+ , "PATH"
+ , "AR"
+ ]
+ , "imports": {"base-provides": "defaults-base-provides"}
, "expression":
- { "type": "RESULT"
- , "provides":
- { "type": "map_union"
- , "$1":
- [ { "type": "singleton_map"
- , "key": "CC"
- , "value": {"type": "FIELD", "name": "CC"}
+ { "type": "let*"
+ , "bindings":
+ [ ["CC", {"type": "FIELD", "name": "CC"}]
+ , ["CXX", {"type": "FIELD", "name": "CXX"}]
+ , ["CFLAGS", {"type": "FIELD", "name": "CFLAGS"}]
+ , ["CXXFLAGS", {"type": "FIELD", "name": "CXXFLAGS"}]
+ , ["AR", {"type": "FIELD", "name": "AR"}]
+ , ["PATH", {"type": "FIELD", "name": "PATH"}]
+ , ["provider", "CC"]
+ , [ "CC"
+ , { "type": "if"
+ , "cond": {"type": "var", "name": "CC"}
+ , "then": {"type": "var", "name": "CC"}
+ , "else": {"type": "CALL_EXPRESSION", "name": "base-provides"}
}
- , { "type": "singleton_map"
- , "key": "CXX"
- , "value": {"type": "FIELD", "name": "CXX"}
+ ]
+ , ["provider", "CXX"]
+ , [ "CXX"
+ , { "type": "if"
+ , "cond": {"type": "var", "name": "CXX"}
+ , "then": {"type": "var", "name": "CXX"}
+ , "else": {"type": "CALL_EXPRESSION", "name": "base-provides"}
}
- , { "type": "singleton_map"
- , "key": "CFLAGS"
- , "value": {"type": "FIELD", "name": "CFLAGS"}
+ ]
+ , ["provider", "CFLAGS"]
+ , [ "CFLAGS"
+ , { "type": "if"
+ , "cond": {"type": "var", "name": "CFLAGS"}
+ , "then": {"type": "var", "name": "CFLAGS"}
+ , "else": {"type": "CALL_EXPRESSION", "name": "base-provides"}
}
- , { "type": "singleton_map"
- , "key": "CXXFLAGS"
- , "value": {"type": "FIELD", "name": "CXXFLAGS"}
+ ]
+ , ["provider", "CXXFLAGS"]
+ , [ "CXXFLAGS"
+ , { "type": "if"
+ , "cond": {"type": "var", "name": "CXXFLAGS"}
+ , "then": {"type": "var", "name": "CXXFLAGS"}
+ , "else": {"type": "CALL_EXPRESSION", "name": "base-provides"}
}
- , { "type": "singleton_map"
- , "key": "AR"
- , "value": {"type": "FIELD", "name": "AR"}
+ ]
+ , ["provider", "AR"]
+ , [ "AR"
+ , { "type": "if"
+ , "cond": {"type": "var", "name": "AR"}
+ , "then": {"type": "var", "name": "AR"}
+ , "else": {"type": "CALL_EXPRESSION", "name": "base-provides"}
}
- , { "type": "singleton_map"
- , "key": "ENV"
- , "value":
+ ]
+ , ["provider", "ENV"]
+ , [ "ENV"
+ , { "type": "if"
+ , "cond": {"type": "var", "name": "PATH"}
+ , "then":
{ "type": "singleton_map"
, "key": "PATH"
, "value":
{ "type": "join"
, "separator": ":"
- , "$1": {"type": "FIELD", "name": "PATH"}
+ , "$1": {"type": "var", "name": "PATH"}
}
}
+ , "else": {"type": "CALL_EXPRESSION", "name": "base-provides"}
}
]
+ , [ "CFLAGS"
+ , { "type": "++"
+ , "$1":
+ [ {"type": "var", "name": "CFLAGS"}
+ , {"type": "FIELD", "name": "ADD_CFLAGS"}
+ ]
+ }
+ ]
+ , [ "CXXFLAGS"
+ , { "type": "++"
+ , "$1":
+ [ {"type": "var", "name": "CXXFLAGS"}
+ , {"type": "FIELD", "name": "ADD_CXXFLAGS"}
+ ]
+ }
+ ]
+ ]
+ , "body":
+ { "type": "RESULT"
+ , "provides":
+ { "type": "map_union"
+ , "$1":
+ [ { "type": "singleton_map"
+ , "key": "CC"
+ , "value": {"type": "var", "name": "CC"}
+ }
+ , { "type": "singleton_map"
+ , "key": "CXX"
+ , "value": {"type": "var", "name": "CXX"}
+ }
+ , { "type": "singleton_map"
+ , "key": "CFLAGS"
+ , "value": {"type": "var", "name": "CFLAGS"}
+ }
+ , { "type": "singleton_map"
+ , "key": "CXXFLAGS"
+ , "value": {"type": "var", "name": "CXXFLAGS"}
+ }
+ , { "type": "singleton_map"
+ , "key": "AR"
+ , "value": {"type": "var", "name": "AR"}
+ }
+ , { "type": "singleton_map"
+ , "key": "ENV"
+ , "value": {"type": "var", "name": "ENV"}
+ }
+ ]
+ }
}
}
}