From a5a98b35fc9a710e723673946ea5c769274b9ddb Mon Sep 17 00:00:00 2001 From: Klaus Aehlig Date: Tue, 23 Jul 2024 14:45:01 +0200 Subject: ["CC", "library"]: Make object-only a configuration property ... instead of a property of the library itself. An object library is not a meaningful concept in itself; it only exists, because a consumer wants to link the library in its entirety. But consumer-specified properties should be propagated through configuration transitions and the definition of the library should not care about how it is consumed; this is also the approach we follow with respect to building a library position independent. As oposed to position-independent building, however, the property of being included unconditionally is not propagated transitively. --- CC/EXPRESSIONS | 4 ++++ CC/RULES | 45 ++++++++++++++++++++++----------------------- transitions/EXPRESSIONS | 21 ++++++++++++++++++++- 3 files changed, 46 insertions(+), 24 deletions(-) diff --git a/CC/EXPRESSIONS b/CC/EXPRESSIONS index 938c342..081fb31 100644 --- a/CC/EXPRESSIONS +++ b/CC/EXPRESSIONS @@ -1184,6 +1184,8 @@ , "extra-provides" , "public-fieldnames" , "private-fieldnames" + , "deps-transition" + , "defaults-transition" ] , "imports": { "compile-deps": "compile-deps" @@ -1863,6 +1865,8 @@ , "extra-provides" , "public-fieldnames" , "private-fieldnames" + , "deps-transition" + , "defaults-transition" ] , "imports": { "compile-deps": "compile-deps" diff --git a/CC/RULES b/CC/RULES index e5d887a..a8bcfb7 100644 --- a/CC/RULES +++ b/CC/RULES @@ -398,7 +398,7 @@ , "soversion" , "pkg-name" ] - , "config_fields": ["shared", "object_only"] + , "config_fields": ["shared"] , "config_vars": [ "CC" , "CXX" @@ -411,6 +411,7 @@ , "AR" , "ENV" , "BUILD_POSITION_INDEPENDENT" + , "BUILD_OBJECT_ONLY" , "DEBUG" ] , "implicit": {"defaults": ["defaults"]} @@ -473,15 +474,7 @@ , "duplicate work will be carried out, even if the same proto library" , "is used at various places)." ] - , "shared": - [ "If non-empty, produce a shared instead of a static library. Setting" - , "this option is mutually exclusive to the \"object_only\" option." - ] - , "object_only": - [ "If non-empty, produce an object library, resulting in object files" - , "added to the linker line of all depending targets. Setting this option" - , "is mutually exclusive to the \"shared\" option." - ] + , "shared": ["If non-empty, produce a shared instead of a static library."] , "soversion": [ "The SOVERSION for shared libraries. Individual version components are" , "joined with \".\"." @@ -544,6 +537,12 @@ , "ENV": ["The environment for any action generated."] , "BUILD_POSITION_INDEPENDENT": ["Build with -fPIC."] , "DEBUG": ["Compute the debug-stage, needed for local debugging."] + , "BUILD_OBJECT_ONLY": + [ "If true, produce an object library, resulting in object files" + , "added to the linker line of all depending targets. If this" + , "configuration is set, the \"shared\" option is ignored. This" + , "variable is cleared for all dependencies." + ] } , "artifacts_doc": ["The actual library (libname.a) staged in the specified directory"] @@ -587,7 +586,7 @@ , "static result": "lib result" , "shared result": "shared result" , "object result": "object result" - , "fPIC transition": ["transitions", "with fPIC"] + , "fPIC transition": ["transitions", "with fPIC, not object-only"] } , "config_transitions": { "deps": [{"type": "CALL_EXPRESSION", "name": "fPIC transition"}] @@ -690,24 +689,24 @@ , "defaults" ] ] + , [ "shared" + , { "type": "and" + , "$1": + [ {"type": "FIELD", "name": "shared"} + , { "type": "not" + , "$1": {"type": "var", "name": "BUILD_OBJECT_ONLY"} + } + ] + } + ] ] , "body": { "type": "cond" , "cond": - [ [ { "type": "and" - , "$1": - [ {"type": "FIELD", "name": "shared"} - , {"type": "FIELD", "name": "object_only"} - ] - } - , { "type": "fail" - , "msg": "Fields \"shared\" and \"object_only\" are mutually exclusive." - } - ] - , [ {"type": "FIELD", "name": "shared"} + [ [ {"type": "var", "name": "shared"} , {"type": "CALL_EXPRESSION", "name": "shared result"} ] - , [ {"type": "FIELD", "name": "object_only"} + , [ {"type": "var", "name": "BUILD_OBJECT_ONLY"} , {"type": "CALL_EXPRESSION", "name": "object result"} ] ] diff --git a/transitions/EXPRESSIONS b/transitions/EXPRESSIONS index fef8542..18c5dbc 100644 --- a/transitions/EXPRESSIONS +++ b/transitions/EXPRESSIONS @@ -24,9 +24,16 @@ [ "Transition that enables BUILD_POSITION_INDEPENDENT if config_field" , "\"shared\" is not empty." ] + , "var": ["BUILD_OBJECT_ONLY"] , "expression": { "type": "if" - , "cond": {"type": "FIELD", "name": "shared"} + , "cond": + { "type": "and" + , "$1": + [ {"type": "FIELD", "name": "shared"} + , {"type": "not", "$1": {"type": "var", "name": "BUILD_OBJECT_ONLY"}} + ] + } , "then": { "type": "singleton_map" , "key": "BUILD_POSITION_INDEPENDENT" @@ -35,6 +42,18 @@ , "else": {"type": "empty_map"} } } +, "with fPIC, not object-only": + { "doc": ["Like \"with fPIC\", but also clearing BUILD_OBJECT_ONLY"] + , "var": ["BUILD_OBJECT_ONLY"] + , "imports": {"with fPIC": "with fPIC"} + , "expression": + { "type": "map_union" + , "$1": + [ {"type": "CALL_EXPRESSION", "name": "with fPIC"} + , {"type": "singleton_map", "key": "BUILD_OBJECT_ONLY", "value": null} + ] + } + } , "target properties": { "vars": ["ARCH", "TARGET_ARCH", "ARCH_DISPATCH"] , "expression": -- cgit v1.2.3 From f8d12beb459041c15781f18a6b5a0928affb4e7c Mon Sep 17 00:00:00 2001 From: Klaus Aehlig Date: Wed, 24 Jul 2024 11:46:28 +0200 Subject: ["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. --- CC/EXPRESSIONS | 430 +++++++++++++++++++++++++++++++++++------------- CC/RULES | 46 ++++++ transitions/EXPRESSIONS | 21 +++ 3 files changed, 379 insertions(+), 118 deletions(-) diff --git a/CC/EXPRESSIONS b/CC/EXPRESSIONS index 081fb31..a4bdbd9 100644 --- a/CC/EXPRESSIONS +++ b/CC/EXPRESSIONS @@ -215,13 +215,20 @@ , "debug-deps": { "doc": ["Collect debug dependencies (sources/headers) from given target_fields"] - , "vars": ["deps-provider", "deps-fieldnames", "deps-transition"] + , "vars": + [ "deps-provider" + , "deps-fieldnames" + , "deps-transition" + , "modified-transitions" + ] , "vars_doc": { "deps-provider": ["Name of provider to use (debug-srcs/debug-hdrs)."] , "deps-fieldnames": ["List of target_field names to collect dependencies from."] , "deps-transition": ["The optional configuration transition for the targets."] + , "modified-transitions": + ["Map telling fields that need to be transitioned differently"] } , "imports": {"provider_list": ["./", "..", "field_provider_list"]} , "expression": @@ -238,7 +245,17 @@ { "type": "let*" , "bindings": [ ["provider", {"type": "var", "name": "deps-provider"}] - , ["transition", {"type": "var", "name": "deps-transition"}] + , [ "transition" + , { "type": "lookup" + , "map": + { "type": "var" + , "name": "modified-transitions" + , "default": {"type": "empty_map"} + } + , "key": {"type": "var", "name": "fieldname"} + , "default": {"type": "var", "name": "deps-transition"} + } + ] , ["default", {"type": "empty_map"}] ] , "body": [{"type": "CALL_EXPRESSION", "name": "provider_list"}] @@ -250,12 +267,14 @@ } , "compile-deps": { "doc": ["Collect compile dependencies (headers) from given target_fields"] - , "vars": ["deps-fieldnames", "deps-transition"] + , "vars": ["deps-fieldnames", "deps-transition", "modified-transitions"] , "vars_doc": { "deps-fieldnames": ["List of target_field names to collect dependencies from."] , "deps-transition": ["The optional configuration transition for the targets."] + , "modified-transitions": + ["Map telling fields that need to be transitioned differently"] } , "imports": { "runfiles_list": ["./", "..", "field_runfiles_list"] @@ -275,7 +294,17 @@ { "type": "let*" , "bindings": [ ["provider", "compile-deps"] - , ["transition", {"type": "var", "name": "deps-transition"}] + , [ "transition" + , { "type": "lookup" + , "map": + { "type": "var" + , "name": "modified-transitions" + , "default": {"type": "empty_map"} + } + , "key": {"type": "var", "name": "fieldname"} + , "default": {"type": "var", "name": "deps-transition"} + } + ] , ["default", {"type": "empty_map"}] ] , "body": @@ -290,12 +319,14 @@ } , "compile-args-deps": { "doc": ["Collect compile arguments from given target_fields"] - , "vars": ["deps-fieldnames", "deps-transition"] + , "vars": ["deps-fieldnames", "deps-transition", "modified-transitions"] , "vars_doc": { "deps-fieldnames": ["List of target_field names to collect arguments from."] , "deps-transition": ["The optional configuration transition for the targets."] + , "modified-transitions": + ["Map telling fields that need to be transitioned differently"] } , "imports": {"list_provider": ["./", "..", "field_list_provider"]} , "expression": @@ -308,7 +339,17 @@ { "type": "let*" , "bindings": [ ["provider", "compile-args"] - , ["transition", {"type": "var", "name": "deps-transition"}] + , [ "transition" + , { "type": "lookup" + , "map": + { "type": "var" + , "name": "modified-transitions" + , "default": {"type": "empty_map"} + } + , "key": {"type": "var", "name": "fieldname"} + , "default": {"type": "var", "name": "deps-transition"} + } + ] ] , "body": {"type": "CALL_EXPRESSION", "name": "list_provider"} } @@ -317,38 +358,75 @@ } , "link-deps": { "doc": ["Collect link dependencies (libraries) from given target_fields"] - , "vars": ["deps-fieldnames", "deps-transition"] + , "vars": + [ "deps-fieldnames" + , "deps-transition" + , "modified-transitions" + , "component-fieldnames" + ] , "vars_doc": { "deps-fieldnames": ["List of target_field names to collect dependencies from."] , "deps-transition": ["The optional configuration transition for the targets."] + , "modified-transitions": + ["Map telling fields that need to be transitioned differently"] } , "imports": { "artifacts_list": ["./", "..", "field_artifacts_list"] , "provider_list": ["./", "..", "field_provider_list"] } , "expression": - { "type": "disjoint_map_union" - , "$1": - { "type": "++" - , "$1": - { "type": "foreach" - , "var": "fieldname" - , "range": {"type": "var", "name": "deps-fieldnames"} - , "body": - { "type": "++" + { "type": "let*" + , "bindings": + [ [ "drop_artifacts" + , { "type": "set" , "$1": - { "type": "let*" - , "bindings": - [ ["provider", "link-deps"] - , ["default", {"type": "empty_map"}] - , ["transition", {"type": "var", "name": "deps-transition"}] - ] - , "body": - [ {"type": "CALL_EXPRESSION", "name": "provider_list"} - , {"type": "CALL_EXPRESSION", "name": "artifacts_list"} - ] + {"type": "var", "name": "component-fieldnames", "default": []} + } + ] + ] + , "body": + { "type": "disjoint_map_union" + , "$1": + { "type": "++" + , "$1": + { "type": "foreach" + , "var": "fieldname" + , "range": {"type": "var", "name": "deps-fieldnames"} + , "body": + { "type": "++" + , "$1": + { "type": "let*" + , "bindings": + [ ["provider", "link-deps"] + , ["default", {"type": "empty_map"}] + , [ "transition" + , { "type": "lookup" + , "map": + { "type": "var" + , "name": "modified-transitions" + , "default": {"type": "empty_map"} + } + , "key": {"type": "var", "name": "fieldname"} + , "default": {"type": "var", "name": "deps-transition"} + } + ] + ] + , "body": + [ {"type": "CALL_EXPRESSION", "name": "provider_list"} + , { "type": "if" + , "cond": + { "type": "lookup" + , "map": {"type": "var", "name": "drop_artifacts"} + , "key": {"type": "var", "name": "fieldname"} + } + , "then": [] + , "else": + {"type": "CALL_EXPRESSION", "name": "artifacts_list"} + } + ] + } } } } @@ -357,12 +435,14 @@ } , "link-args-deps": { "doc": ["Collect linker arguments from given target_fields"] - , "vars": ["deps-fieldnames", "deps-transition"] + , "vars": ["deps-fieldnames", "deps-transition", "modified-transitions"] , "vars_doc": { "deps-fieldnames": ["List of target_field names to collect arguments from."] , "deps-transition": ["The optional configuration transition for the targets."] + , "modified-transitions": + ["Map telling fields that need to be transitioned differently"] } , "imports": {"list_provider": ["./", "..", "field_list_provider"]} , "expression": @@ -375,7 +455,17 @@ { "type": "let*" , "bindings": [ ["provider", "link-args"] - , ["transition", {"type": "var", "name": "deps-transition"}] + , [ "transition" + , { "type": "lookup" + , "map": + { "type": "var" + , "name": "modified-transitions" + , "default": {"type": "empty_map"} + } + , "key": {"type": "var", "name": "fieldname"} + , "default": {"type": "var", "name": "deps-transition"} + } + ] ] , "body": {"type": "CALL_EXPRESSION", "name": "list_provider"} } @@ -384,12 +474,14 @@ } , "run-libs-deps": { "doc": ["Collect runtime libraries from given target_fields"] - , "vars": ["deps-fieldnames", "deps-transition"] + , "vars": ["deps-fieldnames", "deps-transition", "modified-transitions"] , "vars_doc": { "deps-fieldnames": ["List of target_field names to collect dependencies from."] , "deps-transition": ["The optional configuration transition for the targets."] + , "modified-transitions": + ["Map telling fields that need to be transitioned differently"] } , "imports": {"provider_list": ["./", "..", "field_provider_list"]} , "expression": @@ -408,7 +500,17 @@ , "bindings": [ ["provider", "run-libs"] , ["default", {"type": "empty_map"}] - , ["transition", {"type": "var", "name": "deps-transition"}] + , [ "transition" + , { "type": "lookup" + , "map": + { "type": "var" + , "name": "modified-transitions" + , "default": {"type": "empty_map"} + } + , "key": {"type": "var", "name": "fieldname"} + , "default": {"type": "var", "name": "deps-transition"} + } + ] ] , "body": {"type": "CALL_EXPRESSION", "name": "provider_list"} } @@ -420,12 +522,14 @@ , "run-libs-args-deps": { "doc": ["Collect runtime libraries link arguments from given target_fields"] - , "vars": ["deps-fieldnames", "deps-transition"] + , "vars": ["deps-fieldnames", "deps-transition", "modified-transitions"] , "vars_doc": { "deps-fieldnames": ["List of target_field names to collect arguments from."] , "deps-transition": ["The optional configuration transition for the targets."] + , "modified-transitions": + ["Map telling fields that need to be transitioned differently"] } , "imports": {"list_provider": ["./", "..", "field_list_provider"]} , "expression": @@ -438,7 +542,17 @@ { "type": "let*" , "bindings": [ ["provider", "run-libs-args"] - , ["transition", {"type": "var", "name": "deps-transition"}] + , [ "transition" + , { "type": "lookup" + , "map": + { "type": "var" + , "name": "modified-transitions" + , "default": {"type": "empty_map"} + } + , "key": {"type": "var", "name": "fieldname"} + , "default": {"type": "var", "name": "deps-transition"} + } + ] ] , "body": {"type": "CALL_EXPRESSION", "name": "list_provider"} } @@ -447,12 +561,15 @@ } , "pkg-map-provider-deps": { "doc": ["Collect maps from provider \"package\" for given target_fields"] - , "vars": ["pkg-key", "deps-fieldnames", "deps-transition"] + , "vars": + ["pkg-key", "deps-fieldnames", "deps-transition", "modified-transitions"] , "vars_doc": { "pkg-key": ["Key to lookup in provider \"package\"."] , "deps-fieldnames": ["List of target_field names to collect maps from."] , "deps-transition": ["The optional configuration transition for the targets."] + , "modified-transitions": + ["Map telling fields that need to be transitioned differently"] } , "imports": {"provider_list": ["./", "..", "field_provider_list"]} , "expression": @@ -468,7 +585,17 @@ , "bindings": [ ["provider", "package"] , ["default", {"type": "empty_map"}] - , ["transition", {"type": "var", "name": "deps-transition"}] + , [ "transition" + , { "type": "lookup" + , "map": + { "type": "var" + , "name": "modified-transitions" + , "default": {"type": "empty_map"} + } + , "key": {"type": "var", "name": "fieldname"} + , "default": {"type": "var", "name": "deps-transition"} + } + ] ] , "body": { "type": "foreach" @@ -488,11 +615,13 @@ } , "cflags-files-deps": { "doc": ["Collect cflags files from target_fields"] - , "vars": ["deps-fieldnames", "deps-transition"] + , "vars": ["deps-fieldnames", "deps-transition", "modified-transitions"] , "vars_doc": { "deps-fieldnames": ["List of target_field names to collect files from."] , "deps-transition": ["The optional configuration transition for the targets."] + , "modified-transitions": + ["Map telling fields that need to be transitioned differently"] } , "imports": {"pkg-provider": "pkg-map-provider-deps"} , "expression": @@ -503,11 +632,13 @@ } , "ldflags-files-deps": { "doc": ["Collect cflags files from target_fields"] - , "vars": ["deps-fieldnames", "deps-transition"] + , "vars": ["deps-fieldnames", "deps-transition", "modified-transitions"] , "vars_doc": { "deps-fieldnames": ["List of target_field names to collect files from."] , "deps-transition": ["The optional configuration transition for the targets."] + , "modified-transitions": + ["Map telling fields that need to be transitioned differently"] } , "imports": {"pkg-provider": "pkg-map-provider-deps"} , "expression": @@ -729,7 +860,11 @@ , "private-hdrs" , "compile-deps" , "cflags-files" + , "component-fieldnames" + , "deps-transition" + , "modified-transitions" ] + , "imports": {"field_artifacts": ["./", "..", "field_artifacts"]} , "expression": { "type": "let*" , "bindings": @@ -757,93 +892,129 @@ ] } ] - ] - , "body": - { "type": "map_union" - , "$1": - { "type": "foreach_map" - , "var_key": "src_name" - , "var_val": "src_val" - , "range": {"type": "var", "name": "srcs"} - , "body": - { "type": "let*" - , "bindings": - [ [ "work src_name" - , { "type": "join" - , "separator": "/" - , "$1": ["work", {"type": "var", "name": "src_name"}] - } - ] - , [ "inputs" - , { "type": "map_union" - , "$1": - [ {"type": "var", "name": "all hdrs"} - , { "type": "singleton_map" - , "key": {"type": "var", "name": "work src_name"} - , "value": {"type": "var", "name": "src_val"} + , [ "my objects" + , { "type": "map_union" + , "$1": + { "type": "foreach_map" + , "var_key": "src_name" + , "var_val": "src_val" + , "range": {"type": "var", "name": "srcs"} + , "body": + { "type": "let*" + , "bindings": + [ [ "work src_name" + , { "type": "join" + , "separator": "/" + , "$1": ["work", {"type": "var", "name": "src_name"}] } - , { "type": "var" - , "name": "cflags-files" - , "default": {"type": "empty_map"} + ] + , [ "inputs" + , { "type": "map_union" + , "$1": + [ {"type": "var", "name": "all hdrs"} + , { "type": "singleton_map" + , "key": {"type": "var", "name": "work src_name"} + , "value": {"type": "var", "name": "src_val"} + } + , { "type": "var" + , "name": "cflags-files" + , "default": {"type": "empty_map"} + } + , { "type": "var" + , "name": "TOOLCHAIN" + , "default": {"type": "empty_map"} + } + ] } - , { "type": "var" - , "name": "TOOLCHAIN" - , "default": {"type": "empty_map"} + ] + , [ "out" + , { "type": "change_ending" + , "$1": {"type": "var", "name": "src_name"} + , "ending": ".o" } ] - } - ] - , [ "out" - , { "type": "change_ending" - , "$1": {"type": "var", "name": "src_name"} - , "ending": ".o" - } - ] - , [ "work out" - , { "type": "join" - , "separator": "/" - , "$1": ["work", {"type": "var", "name": "out"}] - } - ] - , [ "action output" - , { "type": "ACTION" - , "outs": [{"type": "var", "name": "work out"}] - , "inputs": {"type": "var", "name": "inputs"} - , "env": - { "type": "var" - , "name": "ENV" - , "default": {"type": "empty_map"} - } - , "cmd": - { "type": "++" - , "$1": - [ [{"type": "var", "name": "COMPILER"}] - , {"type": "var", "name": "COMPILE_FLAGS"} - , ["-I", "work", "-isystem", "include"] - , ["-c", {"type": "var", "name": "work src_name"}] - , ["-o", {"type": "var", "name": "work out"}] - ] - } - } - ] - , [ "staged output artifact" - , { "type": "map_union" - , "$1": - { "type": "foreach_map" - , "range": {"type": "var", "name": "action output"} - , "var_val": "object" - , "body": - { "type": "singleton_map" - , "key": {"type": "var", "name": "out"} - , "value": {"type": "var", "name": "object"} + , [ "work out" + , { "type": "join" + , "separator": "/" + , "$1": ["work", {"type": "var", "name": "out"}] } - } - } - ] - ] - , "body": {"type": "var", "name": "staged output artifact"} + ] + , [ "action output" + , { "type": "ACTION" + , "outs": [{"type": "var", "name": "work out"}] + , "inputs": {"type": "var", "name": "inputs"} + , "env": + { "type": "var" + , "name": "ENV" + , "default": {"type": "empty_map"} + } + , "cmd": + { "type": "++" + , "$1": + [ [{"type": "var", "name": "COMPILER"}] + , {"type": "var", "name": "COMPILE_FLAGS"} + , ["-I", "work", "-isystem", "include"] + , ["-c", {"type": "var", "name": "work src_name"}] + , ["-o", {"type": "var", "name": "work out"}] + ] + } + } + ] + , [ "staged output artifact" + , { "type": "map_union" + , "$1": + { "type": "foreach_map" + , "range": {"type": "var", "name": "action output"} + , "var_val": "object" + , "body": + { "type": "singleton_map" + , "key": {"type": "var", "name": "out"} + , "value": {"type": "var", "name": "object"} + } + } + } + ] + ] + , "body": {"type": "var", "name": "staged output artifact"} + } + } } - } + ] + , [ "component artifacts" + , { "type": "disjoint_map_union" + , "$1": + { "type": "foreach" + , "var": "fieldname" + , "range": + {"type": "var", "name": "component-fieldnames", "default": []} + , "body": + { "type": "let*" + , "bindings": + [ [ "transition" + , { "type": "lookup" + , "map": + { "type": "var" + , "name": "modified-transitions" + , "default": {"type": "empty_map"} + } + , "key": {"type": "var", "name": "fieldname"} + , "default": {"type": "var", "name": "deps-transition"} + } + ] + ] + , "body": {"type": "CALL_EXPRESSION", "name": "field_artifacts"} + } + } + } + ] + ] + , "body": + { "type": "disjoint_map_union" + , "msg": "Stating conflict between own objects and objects of components" + , "$1": + [ {"type": "var", "name": "my objects"} + , {"type": "var", "name": "component artifacts"} + ] } } } @@ -999,6 +1170,9 @@ , "compile-args" , "cflags-files" , "defaults-transition" + , "component-fieldnames" + , "deps-transition" + , "modified-transitions" ] , "imports": { "compiler": "compiler" @@ -1184,7 +1358,9 @@ , "extra-provides" , "public-fieldnames" , "private-fieldnames" + , "component-fieldnames" , "deps-transition" + , "modified-transitions" , "defaults-transition" ] , "imports": @@ -1356,6 +1532,9 @@ , "cflags-files" , "ldflags-files" , "defaults-transition" + , "component-fieldnames" + , "deps-transition" + , "modified-transitions" ] , "imports": { "compiler": "compiler" @@ -1561,8 +1740,10 @@ , "extra-provides" , "defaults-transition" , "deps-transition" + , "modified-transitions" , "public-fieldnames" , "private-fieldnames" + , "component-fieldnames" ] , "imports": { "compile-deps": "compile-deps" @@ -1763,6 +1944,7 @@ , "compile-args" , "cflags-files" , "defaults-transition" + , "component-fieldnames" ] , "imports": { "compiler": "compiler" @@ -1850,6 +2032,7 @@ , "AR" , "ENV" , "BUILD_POSITION_INDEPENDENT" + , "BUILD_OBJECT_ONLY_DROP_OBJECT_LINKING" , "DEBUG" , "name" , "pure C" @@ -1865,7 +2048,9 @@ , "extra-provides" , "public-fieldnames" , "private-fieldnames" + , "component-fieldnames" , "deps-transition" + , "modified-transitions" , "defaults-transition" ] , "imports": @@ -1907,7 +2092,15 @@ , "$1": { "type": "++" , "$1": - [ {"type": "keys", "$1": {"type": "var", "name": "objects"}} + [ { "type": "if" + , "cond": + { "type": "var" + , "name": "BUILD_OBJECT_ONLY_DROP_OBJECT_LINKING" + } + , "then": [] + , "else": + {"type": "keys", "$1": {"type": "var", "name": "objects"}} + } , {"type": "var", "name": "ldflags", "default": []} , {"type": "var", "name": "private-ldflags", "default": []} , {"type": "CALL_EXPRESSION", "name": "link-args-deps"} @@ -2213,6 +2406,7 @@ , "private-ldflags" , "stage" , "private-fieldnames" + , "component-fieldnames" ] , "imports": { "compile-deps": "compile-deps" diff --git a/CC/RULES b/CC/RULES index a8bcfb7..0a69375 100644 --- a/CC/RULES +++ b/CC/RULES @@ -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": diff --git a/transitions/EXPRESSIONS b/transitions/EXPRESSIONS index 18c5dbc..d1ecefa 100644 --- a/transitions/EXPRESSIONS +++ b/transitions/EXPRESSIONS @@ -51,6 +51,27 @@ , "$1": [ {"type": "CALL_EXPRESSION", "name": "with fPIC"} , {"type": "singleton_map", "key": "BUILD_OBJECT_ONLY", "value": null} + , { "type": "singleton_map" + , "key": "BUILD_OBJECT_ONLY_DROP_OBJECT_LINKING" + , "value": null + } + ] + } + } +, "with fPIC, object-only": + { "doc": + ["Like \"with fPIC\", but also unconditionally setting BUILD_OBJECT_ONLY"] + , "var": ["BUILD_OBJECT_ONLY"] + , "imports": {"with fPIC": "with fPIC"} + , "expression": + { "type": "map_union" + , "$1": + [ {"type": "CALL_EXPRESSION", "name": "with fPIC"} + , {"type": "singleton_map", "key": "BUILD_OBJECT_ONLY", "value": true} + , { "type": "singleton_map" + , "key": "BUILD_OBJECT_ONLY_DROP_OBJECT_LINKING" + , "value": true + } ] } } -- cgit v1.2.3