summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2025-03-20 13:05:28 +0100
committerPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2025-04-23 13:05:10 +0200
commit5b7031c42ad40d462f1652e4565efcca434a5f61 (patch)
tree8f866ac50b2464ff70e16dcead7c15be3b48d1b7
parenta761fdbbc19a52d552fca8bd9a6db73295aec8b8 (diff)
downloadrules-cc-5b7031c42ad40d462f1652e4565efcca434a5f61.tar.gz
rules CC defaults: Add DEBUGFLAGS and ADD_DEBUGFLAGS config vars
If in debug mode - DEBUGFLAGS replaces any resulting CFLAGS and CXXFLAGS, and - ADD_DEBUGFLAGS is appended to the resulting debug compile flags.
-rw-r--r--CC/RULES55
1 files changed, 55 insertions, 0 deletions
diff --git a/CC/RULES b/CC/RULES
index 0f1b0ff..eddf0b7 100644
--- a/CC/RULES
+++ b/CC/RULES
@@ -14,10 +14,12 @@
, "CXXFLAGS"
, "LDFLAGS"
, "ARFLAGS"
+ , "DEBUGFLAGS"
, "ADD_COMPILE_FLAGS"
, "ADD_CFLAGS"
, "ADD_CXXFLAGS"
, "ADD_LDFLAGS"
+ , "ADD_DEBUGFLAGS"
, "AR"
, "PATH"
, "SYSTEM_TOOLS"
@@ -63,6 +65,11 @@
, "object files. If the \"ARFLAGS\" specified in the defaults target are"
, "empty, the rules will use [\"cqs\"]."
]
+ , "DEBUGFLAGS":
+ [ "Flags to be used for the debug-stage for both C and C++, instead of"
+ , "the resulting CFLAGS and CXXFLAGS, respectively."
+ , "Specifying this field overwrites values from \"base\"."
+ ]
, "ADD_COMPILE_FLAGS":
[ "Additional compilation flags for C and C++. Specifying this field"
, "extends values from \"base\" for both, \"CFLAGS\" and \"CXXFLAGS\"."
@@ -79,6 +86,11 @@
[ "Additional linker flags for linking the final CC library. Specifying"
, "this field extends values from \"base\"."
]
+ , "ADD_DEBUGFLAGS":
+ [ "Additional compilation flags for the debug-stage. Specifying this"
+ , "field extends values from \"base\" for both, \"CFLAGS\" and"
+ , "\"CXXFLAGS\"."
+ ]
, "PATH":
[ "Path for looking up the compilers. Individual paths are joined"
, "with \":\". Specifying this field extends values from \"base\"."
@@ -119,6 +131,7 @@
, ["CXXFLAGS", {"type": "FIELD", "name": "CXXFLAGS"}]
, ["LDFLAGS", {"type": "FIELD", "name": "LDFLAGS"}]
, ["ARFLAGS", {"type": "FIELD", "name": "ARFLAGS"}]
+ , ["DEBUGFLAGS", {"type": "FIELD", "name": "DEBUGFLAGS"}]
, ["AR", {"type": "FIELD", "name": "AR"}]
, ["PATH", {"type": "FIELD", "name": "PATH"}]
, ["provider", "CC"]
@@ -169,6 +182,14 @@
, "else": {"type": "CALL_EXPRESSION", "name": "base-provides-++"}
}
]
+ , ["provider", "DEBUGFLAGS"]
+ , [ "DEBUGFLAGS"
+ , { "type": "if"
+ , "cond": {"type": "var", "name": "DEBUGFLAGS"}
+ , "then": {"type": "var", "name": "DEBUGFLAGS"}
+ , "else": {"type": "CALL_EXPRESSION", "name": "base-provides-++"}
+ }
+ ]
, ["provider", "AR"]
, [ "AR"
, { "type": "if"
@@ -308,6 +329,40 @@
]
}
]
+ , [ "CFLAGS"
+ , { "type": "if"
+ , "cond": {"type": "var", "name": "DEBUG"}
+ , "then":
+ { "type": "++"
+ , "$1":
+ [ { "type": "if"
+ , "cond": {"type": "var", "name": "DEBUGFLAGS"}
+ , "then": {"type": "var", "name": "DEBUGFLAGS"}
+ , "else": {"type": "var", "name": "CFLAGS"}
+ }
+ , {"type": "FIELD", "name": "ADD_DEBUGFLAGS"}
+ ]
+ }
+ , "else": {"type": "var", "name": "CFLAGS"}
+ }
+ ]
+ , [ "CXXFLAGS"
+ , { "type": "if"
+ , "cond": {"type": "var", "name": "DEBUG"}
+ , "then":
+ { "type": "++"
+ , "$1":
+ [ { "type": "if"
+ , "cond": {"type": "var", "name": "DEBUGFLAGS"}
+ , "then": {"type": "var", "name": "DEBUGFLAGS"}
+ , "else": {"type": "var", "name": "CXXFLAGS"}
+ }
+ , {"type": "FIELD", "name": "ADD_DEBUGFLAGS"}
+ ]
+ }
+ , "else": {"type": "var", "name": "CXXFLAGS"}
+ }
+ ]
, ["deps-fieldnames", ["base", "deps"]]
, ["compile-deps", {"type": "CALL_EXPRESSION", "name": "compile-deps"}]
, [ "compile-args"