Merge "bp2build: split full_cc_library into shared/static" am: 58a2eec1a7
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1910490 Change-Id: I1b94b2448db51f2688a499be4df1593d70adef42
This commit is contained in:
committed by
Automerger Merge Worker
commit
bc6610ce5b
@@ -385,9 +385,12 @@ func (ll labelListSelectValues) addSelects(label labelSelectValues) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ll labelListSelectValues) appendSelects(other labelListSelectValues) {
|
func (ll labelListSelectValues) appendSelects(other labelListSelectValues, forceSpecifyEmptyList bool) {
|
||||||
for k, v := range other {
|
for k, v := range other {
|
||||||
l := ll[k]
|
l := ll[k]
|
||||||
|
if forceSpecifyEmptyList && l.IsNil() && !v.IsNil() {
|
||||||
|
l.Includes = []Label{}
|
||||||
|
}
|
||||||
(&l).Append(v)
|
(&l).Append(v)
|
||||||
ll[k] = l
|
ll[k] = l
|
||||||
}
|
}
|
||||||
@@ -443,17 +446,22 @@ func (cll configurableLabelLists) setValueForAxis(axis ConfigurationAxis, config
|
|||||||
cll[axis][config] = list
|
cll[axis][config] = list
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cll configurableLabelLists) Append(other configurableLabelLists) {
|
func (cll configurableLabelLists) Append(other configurableLabelLists, forceSpecifyEmptyList bool) {
|
||||||
for axis, otherSelects := range other {
|
for axis, otherSelects := range other {
|
||||||
selects := cll[axis]
|
selects := cll[axis]
|
||||||
if selects == nil {
|
if selects == nil {
|
||||||
selects = make(labelListSelectValues, len(otherSelects))
|
selects = make(labelListSelectValues, len(otherSelects))
|
||||||
}
|
}
|
||||||
selects.appendSelects(otherSelects)
|
selects.appendSelects(otherSelects, forceSpecifyEmptyList)
|
||||||
cll[axis] = selects
|
cll[axis] = selects
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (lla *LabelListAttribute) Clone() *LabelListAttribute {
|
||||||
|
result := &LabelListAttribute{ForceSpecifyEmptyList: lla.ForceSpecifyEmptyList}
|
||||||
|
return result.Append(*lla)
|
||||||
|
}
|
||||||
|
|
||||||
// MakeLabelListAttribute initializes a LabelListAttribute with the non-arch specific value.
|
// MakeLabelListAttribute initializes a LabelListAttribute with the non-arch specific value.
|
||||||
func MakeLabelListAttribute(value LabelList) LabelListAttribute {
|
func MakeLabelListAttribute(value LabelList) LabelListAttribute {
|
||||||
return LabelListAttribute{
|
return LabelListAttribute{
|
||||||
@@ -507,16 +515,18 @@ func (lla *LabelListAttribute) SortedConfigurationAxes() []ConfigurationAxis {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Append all values, including os and arch specific ones, from another
|
// Append all values, including os and arch specific ones, from another
|
||||||
// LabelListAttribute to this LabelListAttribute.
|
// LabelListAttribute to this LabelListAttribute. Returns this LabelListAttribute.
|
||||||
func (lla *LabelListAttribute) Append(other LabelListAttribute) {
|
func (lla *LabelListAttribute) Append(other LabelListAttribute) *LabelListAttribute {
|
||||||
if lla.ForceSpecifyEmptyList && !other.Value.IsNil() {
|
forceSpecifyEmptyList := lla.ForceSpecifyEmptyList || other.ForceSpecifyEmptyList
|
||||||
|
if forceSpecifyEmptyList && lla.Value.IsNil() && !other.Value.IsNil() {
|
||||||
lla.Value.Includes = []Label{}
|
lla.Value.Includes = []Label{}
|
||||||
}
|
}
|
||||||
lla.Value.Append(other.Value)
|
lla.Value.Append(other.Value)
|
||||||
if lla.ConfigurableValues == nil {
|
if lla.ConfigurableValues == nil {
|
||||||
lla.ConfigurableValues = make(configurableLabelLists)
|
lla.ConfigurableValues = make(configurableLabelLists)
|
||||||
}
|
}
|
||||||
lla.ConfigurableValues.Append(other.ConfigurableValues)
|
lla.ConfigurableValues.Append(other.ConfigurableValues, forceSpecifyEmptyList)
|
||||||
|
return lla
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add inserts the labels for each axis of LabelAttribute at the end of corresponding axis's
|
// Add inserts the labels for each axis of LabelAttribute at the end of corresponding axis's
|
||||||
@@ -795,12 +805,18 @@ func (sla StringListAttribute) HasConfigurableValues() bool {
|
|||||||
|
|
||||||
// Append appends all values, including os and arch specific ones, from another
|
// Append appends all values, including os and arch specific ones, from another
|
||||||
// StringListAttribute to this StringListAttribute
|
// StringListAttribute to this StringListAttribute
|
||||||
func (sla *StringListAttribute) Append(other StringListAttribute) {
|
func (sla *StringListAttribute) Append(other StringListAttribute) *StringListAttribute {
|
||||||
sla.Value = append(sla.Value, other.Value...)
|
sla.Value = append(sla.Value, other.Value...)
|
||||||
if sla.ConfigurableValues == nil {
|
if sla.ConfigurableValues == nil {
|
||||||
sla.ConfigurableValues = make(configurableStringLists)
|
sla.ConfigurableValues = make(configurableStringLists)
|
||||||
}
|
}
|
||||||
sla.ConfigurableValues.Append(other.ConfigurableValues)
|
sla.ConfigurableValues.Append(other.ConfigurableValues)
|
||||||
|
return sla
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sla *StringListAttribute) Clone() *StringListAttribute {
|
||||||
|
result := &StringListAttribute{}
|
||||||
|
return result.Append(*sla)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetSelectValue set a value for a bazel select for the given axis, config and value.
|
// SetSelectValue set a value for a bazel select for the given axis, config and value.
|
||||||
|
File diff suppressed because it is too large
Load Diff
10
cc/cc.go
10
cc/cc.go
@@ -1713,7 +1713,15 @@ func (c *Module) setSubnameProperty(actx android.ModuleContext) {
|
|||||||
|
|
||||||
// Returns true if Bazel was successfully used for the analysis of this module.
|
// Returns true if Bazel was successfully used for the analysis of this module.
|
||||||
func (c *Module) maybeGenerateBazelActions(actx android.ModuleContext) bool {
|
func (c *Module) maybeGenerateBazelActions(actx android.ModuleContext) bool {
|
||||||
bazelModuleLabel := c.GetBazelLabel(actx, c)
|
var bazelModuleLabel string
|
||||||
|
if actx.ModuleType() == "cc_library" && c.static() {
|
||||||
|
// cc_library is a special case in bp2build; two targets are generated -- one for each
|
||||||
|
// of the shared and static variants. The shared variant keeps the module name, but the
|
||||||
|
// static variant uses a different suffixed name.
|
||||||
|
bazelModuleLabel = bazelLabelForStaticModule(actx, c)
|
||||||
|
} else {
|
||||||
|
bazelModuleLabel = c.GetBazelLabel(actx, c)
|
||||||
|
}
|
||||||
bazelActionsUsed := false
|
bazelActionsUsed := false
|
||||||
// Mixed builds mode is disabled for modules outside of device OS.
|
// Mixed builds mode is disabled for modules outside of device OS.
|
||||||
// TODO(b/200841190): Support non-device OS in mixed builds.
|
// TODO(b/200841190): Support non-device OS in mixed builds.
|
||||||
|
105
cc/library.go
105
cc/library.go
@@ -313,35 +313,74 @@ func CcLibraryBp2Build(ctx android.TopDownMutatorContext) {
|
|||||||
asFlags = bazel.MakeStringListAttribute(nil)
|
asFlags = bazel.MakeStringListAttribute(nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
attrs := &bazelCcLibraryAttributes{
|
staticCommonAttrs := staticOrSharedAttributes{
|
||||||
Srcs: srcs,
|
Srcs: *srcs.Clone().Append(staticAttrs.Srcs),
|
||||||
Srcs_c: compilerAttrs.cSrcs,
|
Srcs_c: *compilerAttrs.cSrcs.Clone().Append(staticAttrs.Srcs_c),
|
||||||
Srcs_as: compilerAttrs.asSrcs,
|
Srcs_as: *compilerAttrs.asSrcs.Clone().Append(staticAttrs.Srcs_as),
|
||||||
Hdrs: compilerAttrs.hdrs,
|
Copts: *compilerAttrs.copts.Clone().Append(staticAttrs.Copts),
|
||||||
|
Hdrs: *compilerAttrs.hdrs.Clone().Append(staticAttrs.Hdrs),
|
||||||
|
|
||||||
|
Deps: *linkerAttrs.deps.Clone().Append(staticAttrs.Deps),
|
||||||
|
Implementation_deps: *linkerAttrs.implementationDeps.Clone().Append(staticAttrs.Implementation_deps),
|
||||||
|
Dynamic_deps: *linkerAttrs.dynamicDeps.Clone().Append(staticAttrs.Dynamic_deps),
|
||||||
|
Implementation_dynamic_deps: *linkerAttrs.implementationDynamicDeps.Clone().Append(staticAttrs.Implementation_dynamic_deps),
|
||||||
|
Implementation_whole_archive_deps: linkerAttrs.implementationWholeArchiveDeps,
|
||||||
|
Whole_archive_deps: *linkerAttrs.wholeArchiveDeps.Clone().Append(staticAttrs.Whole_archive_deps),
|
||||||
|
System_dynamic_deps: *linkerAttrs.systemDynamicDeps.Clone().Append(staticAttrs.System_dynamic_deps),
|
||||||
|
}
|
||||||
|
|
||||||
|
sharedCommonAttrs := staticOrSharedAttributes{
|
||||||
|
Srcs: *srcs.Clone().Append(sharedAttrs.Srcs),
|
||||||
|
Srcs_c: *compilerAttrs.cSrcs.Clone().Append(sharedAttrs.Srcs_c),
|
||||||
|
Srcs_as: *compilerAttrs.asSrcs.Clone().Append(sharedAttrs.Srcs_as),
|
||||||
|
Copts: *compilerAttrs.copts.Clone().Append(sharedAttrs.Copts),
|
||||||
|
Hdrs: *compilerAttrs.hdrs.Clone().Append(sharedAttrs.Hdrs),
|
||||||
|
|
||||||
|
Deps: *linkerAttrs.deps.Clone().Append(sharedAttrs.Deps),
|
||||||
|
Implementation_deps: *linkerAttrs.implementationDeps.Clone().Append(sharedAttrs.Implementation_deps),
|
||||||
|
Dynamic_deps: *linkerAttrs.dynamicDeps.Clone().Append(sharedAttrs.Dynamic_deps),
|
||||||
|
Implementation_dynamic_deps: *linkerAttrs.implementationDynamicDeps.Clone().Append(sharedAttrs.Implementation_dynamic_deps),
|
||||||
|
Whole_archive_deps: *linkerAttrs.wholeArchiveDeps.Clone().Append(sharedAttrs.Whole_archive_deps),
|
||||||
|
System_dynamic_deps: *linkerAttrs.systemDynamicDeps.Clone().Append(sharedAttrs.System_dynamic_deps),
|
||||||
|
}
|
||||||
|
|
||||||
|
staticTargetAttrs := &bazelCcLibraryStaticAttributes{
|
||||||
|
staticOrSharedAttributes: staticCommonAttrs,
|
||||||
|
|
||||||
Copts: compilerAttrs.copts,
|
|
||||||
Cppflags: compilerAttrs.cppFlags,
|
Cppflags: compilerAttrs.cppFlags,
|
||||||
Conlyflags: compilerAttrs.conlyFlags,
|
Conlyflags: compilerAttrs.conlyFlags,
|
||||||
Asflags: asFlags,
|
Asflags: asFlags,
|
||||||
|
|
||||||
Implementation_deps: linkerAttrs.implementationDeps,
|
Export_includes: exportedIncludes.Includes,
|
||||||
Deps: linkerAttrs.deps,
|
Export_system_includes: exportedIncludes.SystemIncludes,
|
||||||
Implementation_dynamic_deps: linkerAttrs.implementationDynamicDeps,
|
Local_includes: compilerAttrs.localIncludes,
|
||||||
Dynamic_deps: linkerAttrs.dynamicDeps,
|
Absolute_includes: compilerAttrs.absoluteIncludes,
|
||||||
Whole_archive_deps: linkerAttrs.wholeArchiveDeps,
|
Use_libcrt: linkerAttrs.useLibcrt,
|
||||||
Implementation_whole_archive_deps: linkerAttrs.implementationWholeArchiveDeps,
|
Rtti: compilerAttrs.rtti,
|
||||||
System_dynamic_deps: linkerAttrs.systemDynamicDeps,
|
Stl: compilerAttrs.stl,
|
||||||
Export_includes: exportedIncludes.Includes,
|
Cpp_std: compilerAttrs.cppStd,
|
||||||
Export_system_includes: exportedIncludes.SystemIncludes,
|
C_std: compilerAttrs.cStd,
|
||||||
Local_includes: compilerAttrs.localIncludes,
|
|
||||||
Absolute_includes: compilerAttrs.absoluteIncludes,
|
Features: linkerAttrs.features,
|
||||||
Linkopts: linkerAttrs.linkopts,
|
}
|
||||||
Link_crt: linkerAttrs.linkCrt,
|
|
||||||
Use_libcrt: linkerAttrs.useLibcrt,
|
sharedTargetAttrs := &bazelCcLibrarySharedAttributes{
|
||||||
Rtti: compilerAttrs.rtti,
|
staticOrSharedAttributes: sharedCommonAttrs,
|
||||||
Stl: compilerAttrs.stl,
|
Cppflags: compilerAttrs.cppFlags,
|
||||||
Cpp_std: compilerAttrs.cppStd,
|
Conlyflags: compilerAttrs.conlyFlags,
|
||||||
C_std: compilerAttrs.cStd,
|
Asflags: asFlags,
|
||||||
|
|
||||||
|
Export_includes: exportedIncludes.Includes,
|
||||||
|
Export_system_includes: exportedIncludes.SystemIncludes,
|
||||||
|
Local_includes: compilerAttrs.localIncludes,
|
||||||
|
Absolute_includes: compilerAttrs.absoluteIncludes,
|
||||||
|
Linkopts: linkerAttrs.linkopts,
|
||||||
|
Link_crt: linkerAttrs.linkCrt,
|
||||||
|
Use_libcrt: linkerAttrs.useLibcrt,
|
||||||
|
Rtti: compilerAttrs.rtti,
|
||||||
|
Stl: compilerAttrs.stl,
|
||||||
|
Cpp_std: compilerAttrs.cppStd,
|
||||||
|
C_std: compilerAttrs.cStd,
|
||||||
|
|
||||||
Additional_linker_inputs: linkerAttrs.additionalLinkerInputs,
|
Additional_linker_inputs: linkerAttrs.additionalLinkerInputs,
|
||||||
|
|
||||||
@@ -352,20 +391,20 @@ func CcLibraryBp2Build(ctx android.TopDownMutatorContext) {
|
|||||||
All: linkerAttrs.stripAll,
|
All: linkerAttrs.stripAll,
|
||||||
None: linkerAttrs.stripNone,
|
None: linkerAttrs.stripNone,
|
||||||
},
|
},
|
||||||
|
|
||||||
Shared: sharedAttrs,
|
|
||||||
|
|
||||||
Static: staticAttrs,
|
|
||||||
|
|
||||||
Features: linkerAttrs.features,
|
Features: linkerAttrs.features,
|
||||||
}
|
}
|
||||||
|
|
||||||
props := bazel.BazelTargetModuleProperties{
|
staticProps := bazel.BazelTargetModuleProperties{
|
||||||
Rule_class: "cc_library",
|
Rule_class: "cc_library_static",
|
||||||
Bzl_load_location: "//build/bazel/rules:full_cc_library.bzl",
|
Bzl_load_location: "//build/bazel/rules:cc_library_static.bzl",
|
||||||
|
}
|
||||||
|
sharedProps := bazel.BazelTargetModuleProperties{
|
||||||
|
Rule_class: "cc_library_shared",
|
||||||
|
Bzl_load_location: "//build/bazel/rules:cc_library_shared.bzl",
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: m.Name()}, attrs)
|
ctx.CreateBazelTargetModule(staticProps, android.CommonAttributes{Name: m.Name() + "_bp2build_cc_library_static"}, staticTargetAttrs)
|
||||||
|
ctx.CreateBazelTargetModule(sharedProps, android.CommonAttributes{Name: m.Name()}, sharedTargetAttrs)
|
||||||
}
|
}
|
||||||
|
|
||||||
// cc_library creates both static and/or shared libraries for a device and/or
|
// cc_library creates both static and/or shared libraries for a device and/or
|
||||||
|
@@ -257,9 +257,14 @@ cc_library {
|
|||||||
CcObjectFiles: []string{"foo.o"},
|
CcObjectFiles: []string{"foo.o"},
|
||||||
Includes: []string{"include"},
|
Includes: []string{"include"},
|
||||||
SystemIncludes: []string{"system_include"},
|
SystemIncludes: []string{"system_include"},
|
||||||
RootStaticArchives: []string{"foo.a"},
|
|
||||||
RootDynamicLibraries: []string{"foo.so"},
|
RootDynamicLibraries: []string{"foo.so"},
|
||||||
},
|
},
|
||||||
|
"//foo/bar:bar_bp2build_cc_library_static": cquery.CcInfo{
|
||||||
|
CcObjectFiles: []string{"foo.o"},
|
||||||
|
Includes: []string{"include"},
|
||||||
|
SystemIncludes: []string{"system_include"},
|
||||||
|
RootStaticArchives: []string{"foo.a"},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
ctx := testCcWithConfig(t, config)
|
ctx := testCcWithConfig(t, config)
|
||||||
|
Reference in New Issue
Block a user