summaryrefslogtreecommitdiff
path: root/rules
diff options
context:
space:
mode:
authorOliver Reiche <oliver.reiche@huawei.com>2022-08-25 12:17:26 +0200
committerOliver Reiche <oliver.reiche@huawei.com>2022-09-13 10:51:13 +0200
commit4bd4a86034feb3c12c2980a8973eb2b93faa7445 (patch)
treec7fea91e7051e8f27d008023cded46c261a5c8d8 /rules
parentdd88616b852f2837917ee31777b5a6479941ae05 (diff)
downloadjustbuild-4bd4a86034feb3c12c2980a8973eb2b93faa7445.tar.gz
Rules: Implement setting ADD_{C,CXX}FLAGS via variables
Diffstat (limited to 'rules')
-rw-r--r--rules/CC/EXPRESSIONS28
-rw-r--r--rules/CC/RULES35
-rw-r--r--rules/CC/proto/RULES26
-rw-r--r--rules/CC/test/RULES24
4 files changed, 101 insertions, 12 deletions
diff --git a/rules/CC/EXPRESSIONS b/rules/CC/EXPRESSIONS
index 7ebc8ad4..a1033d90 100644
--- a/rules/CC/EXPRESSIONS
+++ b/rules/CC/EXPRESSIONS
@@ -358,7 +358,7 @@
}
}
, "flags":
- { "vars": ["CFLAGS", "CXXFLAGS"]
+ { "vars": ["CFLAGS", "CXXFLAGS", "ADD_CFLAGS", "ADD_CXXFLAGS"]
, "imports":
{ "default-CFLAGS": "default-CFLAGS"
, "default-CXXFLAGS": "default-CXXFLAGS"
@@ -367,14 +367,24 @@
{ "type": "if"
, "cond": {"type": "FIELD", "name": "pure C"}
, "then":
- { "type": "var"
- , "name": "CFLAGS"
- , "default": {"type": "CALL_EXPRESSION", "name": "default-CFLAGS"}
+ { "type": "++"
+ , "$1":
+ [ { "type": "var"
+ , "name": "CFLAGS"
+ , "default": {"type": "CALL_EXPRESSION", "name": "default-CFLAGS"}
+ }
+ , {"type": "var", "name": "ADD_CFLAGS", "default": []}
+ ]
}
, "else":
- { "type": "var"
- , "name": "CXXFLAGS"
- , "default": {"type": "CALL_EXPRESSION", "name": "default-CXXFLAGS"}
+ { "type": "++"
+ , "$1":
+ [ { "type": "var"
+ , "name": "CXXFLAGS"
+ , "default": {"type": "CALL_EXPRESSION", "name": "default-CXXFLAGS"}
+ }
+ , {"type": "var", "name": "ADD_CXXFLAGS", "default": []}
+ ]
}
}
}
@@ -382,8 +392,10 @@
{ "vars":
[ "CXX"
, "CXXFLAGS"
+ , "ADD_CXXFLAGS"
, "CC"
, "CFLAGS"
+ , "ADD_CFLAGS"
, "ENV"
, "AR"
, "srcs"
@@ -501,8 +513,10 @@
{ "vars":
[ "CXX"
, "CXXFLAGS"
+ , "ADD_CXXFLAGS"
, "CC"
, "CFLAGS"
+ , "ADD_CFLAGS"
, "ENV"
, "AR"
, "srcs"
diff --git a/rules/CC/RULES b/rules/CC/RULES
index d4a85b70..44bdabc3 100644
--- a/rules/CC/RULES
+++ b/rules/CC/RULES
@@ -249,7 +249,16 @@
, "local cflags"
, "link external"
]
- , "config_vars": ["CXX", "CC", "CXXFLAGS", "CFLAGS", "ENV", "AR"]
+ , "config_vars":
+ [ "CXX"
+ , "CC"
+ , "CXXFLAGS"
+ , "CFLAGS"
+ , "ADD_CXXFLAGS"
+ , "ADD_CFLAGS"
+ , "ENV"
+ , "AR"
+ ]
, "implicit": {"defaults": ["defaults"]}
, "field_doc":
{ "name":
@@ -315,6 +324,18 @@
, "adapting the default target [\"CC\", \"defaults\"] is the better"
, "choice"
]
+ , "ADD_CXXFLAGS":
+ [ "The flags to add to the default ones for CXX."
+ , "For libraries that should be built in a non-standard way; usually"
+ , "adapting the default target [\"CC\", \"defaults\"] is the better"
+ , "choice."
+ ]
+ , "ADD_CFLAGS":
+ [ "The flags to add to the default ones for CC."
+ , "For libraries that should be built in a non-standard way; usually"
+ , "adapting the default target [\"CC\", \"defaults\"] is the better"
+ , "choice."
+ ]
}
, "artifacts_doc":
["The actual library (libname.a) staged in the specified directory"]
@@ -431,7 +452,8 @@
, "target_fields": ["srcs", "private-hdrs", "deps", "proto"]
, "string_fields":
["name", "stage", "pure C", "local defines", "link external"]
- , "config_vars": ["CXX", "CC", "CXXFLAGS", "CFLAGS", "ENV"]
+ , "config_vars":
+ ["CXX", "CC", "CXXFLAGS", "CFLAGS", "ADD_CXXFLAGS", "ADD_CFLAGS", "ENV"]
, "implicit": {"defaults": ["defaults"]}
, "field_doc":
{ "name": ["The name of the binary"]
@@ -477,6 +499,14 @@
[ "The flags for CXX to be used instead of the default ones"
, "taken from the [\"CC\", \"defaults\"] target"
]
+ , "ADD_CXXFLAGS":
+ [ "The flags to add to the default ones for CXX"
+ , "taken from the [\"CC\", \"defaults\"] target"
+ ]
+ , "ADD_CFLAGS":
+ [ "The flags to add to the default ones for CC"
+ , "taken from the [\"CC\", \"defaults\"] target"
+ ]
}
, "artifacts_doc": ["The final binary, staged to the given directory"]
, "runfiles_doc": ["None"]
@@ -615,6 +645,7 @@
, "-o"
, {"type": "var", "name": "binary name"}
]
+ , {"type": "var", "name": "CXXFLAGS"}
, {"type": "var", "name": "link-args"}
]
}
diff --git a/rules/CC/proto/RULES b/rules/CC/proto/RULES
index 04082c1b..a4579e7e 100644
--- a/rules/CC/proto/RULES
+++ b/rules/CC/proto/RULES
@@ -8,7 +8,18 @@
, "string_fields": ["name", "stage"]
, "target_fields": ["srcs", "deps"]
, "config_vars":
- ["OS", "ARCH", "HOST_ARCH", "CXX", "CC", "CXXFLAGS", "CFLAGS", "ENV", "AR"]
+ [ "OS"
+ , "ARCH"
+ , "HOST_ARCH"
+ , "CXX"
+ , "CC"
+ , "CXXFLAGS"
+ , "CFLAGS"
+ , "ADD_CXXFLAGS"
+ , "ADD_CFLAGS"
+ , "ENV"
+ , "AR"
+ ]
, "implicit":
{ "protoc": [["@", "protoc", "", "protoc"]]
, "defaults": [["./", "..", "defaults"]]
@@ -39,7 +50,18 @@
, "string_fields": ["name", "stage"]
, "target_fields": ["srcs", "deps"]
, "config_vars":
- ["OS", "ARCH", "HOST_ARCH", "CXX", "CC", "CXXFLAGS", "CFLAGS", "ENV", "AR"]
+ [ "OS"
+ , "ARCH"
+ , "HOST_ARCH"
+ , "CXX"
+ , "CC"
+ , "CXXFLAGS"
+ , "CFLAGS"
+ , "ADD_CXXFLAGS"
+ , "ADD_CFLAGS"
+ , "ENV"
+ , "AR"
+ ]
, "implicit":
{ "protoc": [["@", "protoc", "", "protoc"]]
, "grpc_cpp_plugin": [["@", "grpc", "src/compiler", "grpc_cpp_plugin"]]
diff --git a/rules/CC/test/RULES b/rules/CC/test/RULES
index f3175d4b..8082047e 100644
--- a/rules/CC/test/RULES
+++ b/rules/CC/test/RULES
@@ -7,7 +7,16 @@
, "target_fields": ["srcs", "private-hdrs", "deps", "data"]
, "string_fields": ["name", "stage"]
, "config_vars":
- ["CXX", "CC", "CXXFLAGS", "CFLAGS", "ENV", "TEST_ENV", "CC_TEST_LAUNCHER"]
+ [ "CXX"
+ , "CC"
+ , "CXXFLAGS"
+ , "CFLAGS"
+ , "ADD_CXXFLAGS"
+ , "ADD_CFLAGS"
+ , "ENV"
+ , "TEST_ENV"
+ , "CC_TEST_LAUNCHER"
+ ]
, "implicit":
{ "defaults": [["./", "..", "defaults"]]
, "proto-deps": []
@@ -32,11 +41,24 @@
}
, "config_doc":
{ "CXX": ["The name of the C++ compiler to be used."]
+ , "CC": ["The name of the C compiler to be used."]
, "ENV": ["The environment for any action generated."]
, "CXXFLAGS":
[ "The flags for CXX to be used instead of the default ones"
, "taken from the [\"CC\", \"defaults\"] target"
]
+ , "CFLAGS":
+ [ "The flags for CC to be used instead of the default ones"
+ , "taken from the [\"CC\", \"defaults\"] target"
+ ]
+ , "ADD_CXXFLAGS":
+ [ "The flags to add to the default ones for CXX"
+ , "taken from the [\"CC\", \"defaults\"] target"
+ ]
+ , "ADD_CFLAGS":
+ [ "The flags to add to the default ones for CC"
+ , "taken from the [\"CC\", \"defaults\"] target"
+ ]
, "TEST_ENV": ["The environment for executing the test runner."]
, "CC_TEST_LAUNCHER":
[ "List of strings representing the launcher that is prepend to the"