diff options
author | Klaus Aehlig <klaus.aehlig@huawei.com> | 2024-07-24 11:46:28 +0200 |
---|---|---|
committer | Klaus Aehlig <klaus.aehlig@huawei.com> | 2024-07-25 15:52:37 +0200 |
commit | f8d12beb459041c15781f18a6b5a0928affb4e7c (patch) | |
tree | 802c51e13c5eddb2d923162c8b00ee535b903be0 /CC/RULES | |
parent | a5a98b35fc9a710e723673946ea5c769274b9ddb (diff) | |
download | rules-cc-f8d12beb459041c15781f18a6b5a0928affb4e7c.tar.gz |
["CC", "library"] Add concept of components
... i.e., dependencies that are to be included into the library
itself. In this way, a large library (convenient for a user to have
single library to care about) can be defined as a collection of
smaller libraries.
Technically, components are like public dependencies on libraries
transitioned to object libraries with the following differences
- the header files (i.e., runfiles) of the components become header
files of the resulting libary, and
- the objects (i.e., artifacts) of the components become objects
of the library rather than link dependencies.
To achive the transfer of the object to the requesting library,
an object library can be instructed to drop the objects from the
link arguments; in order to continue to support tranditional object
libraries in the style of, e.g., cmake, this is done by a different
configuration variable that is transitioned as well. In particular,
the object-library test case (using a configure target) can be
left unchanged.
Diffstat (limited to 'CC/RULES')
-rw-r--r-- | CC/RULES | 46 |
1 files changed, 46 insertions, 0 deletions
@@ -384,6 +384,7 @@ , "private-deps" , "proto" , "private-proto" + , "components" ] , "string_fields": [ "name" @@ -412,6 +413,7 @@ , "ENV" , "BUILD_POSITION_INDEPENDENT" , "BUILD_OBJECT_ONLY" + , "BUILD_OBJECT_ONLY_DROP_OBJECT_LINKING" , "DEBUG" ] , "implicit": {"defaults": ["defaults"]} @@ -424,6 +426,11 @@ [ "Any header files that only need to be present when compiling the" , "source files, but are not needed for any consumer of the library." ] + , "components": + [ "Any other libraries that are considered part of this library;" + , "all object files of those are included unconditionally into this" + , "library." + ] , "stage": [ "The logical location of all header and source files, as well as the" , "resulting library file. Individual directory components are joined" @@ -543,6 +550,12 @@ , "configuration is set, the \"shared\" option is ignored. This" , "variable is cleared for all dependencies." ] + , "BUILD_OBJECT_ONLY_DROP_OBJECT_LINKING": + [ "If true, do not include the objects in the provided \"link-args\"." + , "This allows consuming libraries that pick on the objects themselves" + , "to still forward the \"link-args\" of that library, and thus getting" + , "correct linking instructions for the resulting library." + ] } , "artifacts_doc": ["The actual library (libname.a) staged in the specified directory"] @@ -583,10 +596,12 @@ } , "imports": { "artifacts": ["./", "..", "field_artifacts"] + , "runfiles": ["./", "..", "field_runfiles"] , "static result": "lib result" , "shared result": "shared result" , "object result": "object result" , "fPIC transition": ["transitions", "with fPIC, not object-only"] + , "component transition": ["transitions", "with fPIC, object-only"] } , "config_transitions": { "deps": [{"type": "CALL_EXPRESSION", "name": "fPIC transition"}] @@ -595,6 +610,8 @@ , "private-proto-deps": [{"type": "CALL_EXPRESSION", "name": "fPIC transition"}] , "defaults": [{"type": "CALL_EXPRESSION", "name": "fPIC transition"}] + , "components": + [{"type": "CALL_EXPRESSION", "name": "component transition"}] } , "expression": { "type": "let*" @@ -653,6 +670,27 @@ } } ] + , [ "component transition" + , {"type": "CALL_EXPRESSION", "name": "component transition"} + ] + , [ "component hdrs" + , { "type": "let*" + , "bindings": + [ ["fieldname", "components"] + , ["transition", {"type": "var", "name": "component transition"}] + ] + , "body": {"type": "CALL_EXPRESSION", "name": "runfiles"} + } + ] + , [ "hdrs" + , { "type": "disjoint_map_union" + , "msg": "Staging conflict between component and own header files" + , "$1": + [ {"type": "var", "name": "hdrs"} + , {"type": "var", "name": "component hdrs"} + ] + } + ] , [ "private-hdrs" , { "type": "to_subdir" , "subdir": {"type": "var", "name": "stage"} @@ -687,8 +725,16 @@ , "proto-deps" , "private-proto-deps" , "defaults" + , "components" ] ] + , ["component-fieldnames", ["components"]] + , [ "modified-transitions" + , { "type": "singleton_map" + , "key": "components" + , "value": {"type": "var", "name": "component transition"} + } + ] , [ "shared" , { "type": "and" , "$1": |