summaryrefslogtreecommitdiff
path: root/rules/CC/RULES
diff options
context:
space:
mode:
authorOliver Reiche <oliver.reiche@huawei.com>2023-05-30 15:38:40 +0200
committerOliver Reiche <oliver.reiche@huawei.com>2023-05-30 15:38:40 +0200
commit14300d3768522b1a201c30c94b6e54e096520b20 (patch)
treeeaa057fd88ddba1a94c48585fcfcbb71628fcbe7 /rules/CC/RULES
parent2d7051782625966857286aace6ff18760114ecc7 (diff)
parent9f535dadf06c6c6554bac632069777cf1b63ebf5 (diff)
downloadrules-cc-14300d3768522b1a201c30c94b6e54e096520b20.tar.gz
Merge commit '9f535dadf06c6c6554bac632069777cf1b63ebf5' into rules/rules-cc
Diffstat (limited to 'rules/CC/RULES')
-rw-r--r--rules/CC/RULES184
1 files changed, 178 insertions, 6 deletions
diff --git a/rules/CC/RULES b/rules/CC/RULES
index 37460d3..d2aeece 100644
--- a/rules/CC/RULES
+++ b/rules/CC/RULES
@@ -6,7 +6,7 @@
, "use of this rule. As targets form a different root, the defaults"
, "can be provided without changing this directory."
]
- , "target_fields": ["base"]
+ , "target_fields": ["base", "toolchain", "deps"]
, "string_fields":
[ "CC"
, "CXX"
@@ -18,12 +18,28 @@
, "ADD_LDFLAGS"
, "AR"
, "PATH"
+ , "SYSTEM_TOOLS"
]
, "field_doc":
{ "base": ["Other targets (using the same rule) to inherit values from."]
+ , "toolchain":
+ [ "Optional toolchain directory. A collection of artifacts that provide"
+ , "the tools CC, CXX, and AR (if needed). Note that only artifacts of"
+ , "the specified targets are considered (no runfiles etc.). Specifying"
+ , "this field overlays artifacts from \"base\"."
+ ]
+ , "deps":
+ [ "Optional CC libraries any CC library and CC binary implicitly depend"
+ , "on. Those are typically \"libstdc++\" or \"libc++\" for C++ targets."
+ , "Specifying this field extends dependencies from \"base\"."
+ ]
, "CC": ["The C compiler to use"]
, "CXX": ["The C++ compiler to use"]
, "AR": ["The archiver tool to use"]
+ , "SYSTEM_TOOLS":
+ [ "List of tools (\"CC\", \"CXX\", or \"AR\") that should be taken from"
+ , "the system instead of from \"toolchain\" (if specified)."
+ ]
, "CFLAGS":
[ "Flags for C compilation. Specifying this field overwrites"
, "values from \"base\"."
@@ -53,7 +69,22 @@
, "with \":\"."
]
}
- , "imports": {"base-provides": "defaults-base-provides"}
+ , "config_vars": ["ARCH", "HOST_ARCH"]
+ , "imports":
+ { "base-provides": "defaults-base-provides"
+ , "artifacts": ["./", "..", "field_artifacts"]
+ , "compile-deps": "compile-deps"
+ , "compile-args-deps": "compile-args-deps"
+ , "link-deps": "link-deps"
+ , "link-args-deps": "link-args-deps"
+ , "run-libs-deps": "run-libs-deps"
+ , "run-libs-args-deps": "run-libs-args-deps"
+ , "cflags-files-deps": "cflags-files-deps"
+ , "ldflags-files-deps": "ldflags-files-deps"
+ , "for host": ["transitions", "for host"]
+ }
+ , "config_transitions":
+ {"toolchain": [{"type": "CALL_EXPRESSION", "name": "for host"}]}
, "expression":
{ "type": "let*"
, "bindings":
@@ -96,6 +127,14 @@
, "else": {"type": "CALL_EXPRESSION", "name": "base-provides"}
}
]
+ , ["provider", "LDFLAGS"]
+ , [ "LDFLAGS"
+ , { "type": "if"
+ , "cond": {"type": "var", "name": "LDFLAGS"}
+ , "then": {"type": "var", "name": "LDFLAGS"}
+ , "else": {"type": "CALL_EXPRESSION", "name": "base-provides"}
+ }
+ ]
, ["provider", "AR"]
, [ "AR"
, { "type": "if"
@@ -105,6 +144,7 @@
}
]
, ["provider", "ENV"]
+ , ["default", {"type": "empty_map"}]
, [ "ENV"
, { "type": "if"
, "cond": {"type": "var", "name": "PATH"}
@@ -120,6 +160,92 @@
, "else": {"type": "CALL_EXPRESSION", "name": "base-provides"}
}
]
+ , ["provider", "NON_SYSTEM_TOOLS"]
+ , ["default", {"type": "empty_map"}]
+ , [ "NON_SYSTEM_TOOLS"
+ , { "type": "map_union"
+ , "$1":
+ { "type": "++"
+ , "$1":
+ [ [{"type": "CALL_EXPRESSION", "name": "base-provides"}]
+ , { "type": "if"
+ , "cond": {"type": "FIELD", "name": "CC"}
+ , "then":
+ [ { "type": "singleton_map"
+ , "key": "CC"
+ , "value":
+ { "type": "if"
+ , "cond": {"type": "FIELD", "name": "toolchain"}
+ , "then": true
+ , "else": false
+ }
+ }
+ ]
+ }
+ , { "type": "if"
+ , "cond": {"type": "FIELD", "name": "CXX"}
+ , "then":
+ [ { "type": "singleton_map"
+ , "key": "CXX"
+ , "value":
+ { "type": "if"
+ , "cond": {"type": "FIELD", "name": "toolchain"}
+ , "then": true
+ , "else": false
+ }
+ }
+ ]
+ }
+ , { "type": "if"
+ , "cond": {"type": "FIELD", "name": "AR"}
+ , "then":
+ [ { "type": "singleton_map"
+ , "key": "AR"
+ , "value":
+ { "type": "if"
+ , "cond": {"type": "FIELD", "name": "toolchain"}
+ , "then": true
+ , "else": false
+ }
+ }
+ ]
+ }
+ , { "type": "foreach"
+ , "range": {"type": "FIELD", "name": "SYSTEM_TOOLS"}
+ , "var": "tool"
+ , "body":
+ { "type": "singleton_map"
+ , "key": {"type": "var", "name": "tool"}
+ , "value": false
+ }
+ }
+ ]
+ }
+ }
+ ]
+ , ["provider", "TOOLCHAIN"]
+ , ["default", {"type": "empty_map"}]
+ , [ "TOOLCHAIN"
+ , { "type": "map_union"
+ , "$1":
+ [ {"type": "CALL_EXPRESSION", "name": "base-provides"}
+ , { "type": "if"
+ , "cond": {"type": "FIELD", "name": "toolchain"}
+ , "then":
+ { "type": "let*"
+ , "bindings":
+ [ ["fieldname", "toolchain"]
+ , [ "transition"
+ , {"type": "CALL_EXPRESSION", "name": "for host"}
+ ]
+ ]
+ , "body": {"type": "CALL_EXPRESSION", "name": "artifacts"}
+ }
+ , "else": {"type": "empty_map"}
+ }
+ ]
+ }
+ ]
, [ "CFLAGS"
, { "type": "++"
, "$1":
@@ -144,12 +270,47 @@
]
}
]
+ , ["deps-fieldnames", ["base", "deps"]]
+ , ["compile-deps", {"type": "CALL_EXPRESSION", "name": "compile-deps"}]
+ , [ "compile-args"
+ , {"type": "CALL_EXPRESSION", "name": "compile-args-deps"}
+ ]
+ , ["link-deps", {"type": "CALL_EXPRESSION", "name": "link-deps"}]
+ , ["link-args", {"type": "CALL_EXPRESSION", "name": "link-args-deps"}]
+ , ["run-libs", {"type": "CALL_EXPRESSION", "name": "run-libs-deps"}]
+ , [ "run-libs-args"
+ , {"type": "CALL_EXPRESSION", "name": "run-libs-args-deps"}
+ ]
+ , [ "cflags-files"
+ , {"type": "CALL_EXPRESSION", "name": "cflags-files-deps"}
+ ]
+ , [ "ldflags-files"
+ , {"type": "CALL_EXPRESSION", "name": "ldflags-files-deps"}
+ ]
+ , ["package", {"type": "env", "vars": ["cflags-files", "ldflags-files"]}]
]
, "body":
{ "type": "RESULT"
, "provides":
{ "type": "env"
- , "vars": ["CC", "CXX", "CFLAGS", "CXXFLAGS", "LDFLAGS", "AR", "ENV"]
+ , "vars":
+ [ "CC"
+ , "CXX"
+ , "CFLAGS"
+ , "CXXFLAGS"
+ , "LDFLAGS"
+ , "AR"
+ , "ENV"
+ , "TOOLCHAIN"
+ , "NON_SYSTEM_TOOLS"
+ , "compile-deps"
+ , "compile-args"
+ , "link-deps"
+ , "link-args"
+ , "run-libs"
+ , "run-libs-args"
+ , "package"
+ ]
}
}
}
@@ -361,6 +522,7 @@
, "proto-deps": [{"type": "CALL_EXPRESSION", "name": "fPIC transition"}]
, "private-proto-deps":
[{"type": "CALL_EXPRESSION", "name": "fPIC transition"}]
+ , "defaults": [{"type": "CALL_EXPRESSION", "name": "fPIC transition"}]
}
, "expression":
{ "type": "let*"
@@ -440,12 +602,20 @@
, "else": {"type": "var", "name": "name"}
}
]
+ , [ "defaults-transition"
+ , {"type": "CALL_EXPRESSION", "name": "fPIC transition"}
+ ]
, [ "deps-transition"
, {"type": "CALL_EXPRESSION", "name": "fPIC transition"}
]
- , ["public-fieldnames", ["deps", "proto-deps"]]
+ , ["public-fieldnames", ["deps", "proto-deps", "defaults"]]
, [ "private-fieldnames"
- , ["deps", "private-deps", "proto-deps", "private-proto-deps"]
+ , [ "deps"
+ , "private-deps"
+ , "proto-deps"
+ , "private-proto-deps"
+ , "defaults"
+ ]
]
]
, "body":
@@ -608,7 +778,9 @@
}
]
, ["private-ldflags", {"type": "FIELD", "name": "private-ldflags"}]
- , ["private-fieldnames", ["private-deps", "private-proto-deps"]]
+ , [ "private-fieldnames"
+ , ["private-deps", "private-proto-deps", "defaults"]
+ ]
]
, "body": {"type": "CALL_EXPRESSION", "name": "bin result"}
}