Merge "Create Stub targets for cc_library_(static|shared)"
This commit is contained in:
@@ -1367,26 +1367,6 @@ func makeCcLibraryTargets(name string, attrs AttrNameToString) []string {
|
||||
return []string{staticTarget, sharedTarget}
|
||||
}
|
||||
|
||||
func makeCcStubSuiteTargets(name string, attrs AttrNameToString) string {
|
||||
if _, hasStubs := attrs["stubs_symbol_file"]; !hasStubs {
|
||||
return ""
|
||||
}
|
||||
STUB_SUITE_ATTRS := map[string]string{
|
||||
"stubs_symbol_file": "symbol_file",
|
||||
"stubs_versions": "versions",
|
||||
"soname": "soname",
|
||||
"source_library": "source_library",
|
||||
}
|
||||
|
||||
stubSuiteAttrs := AttrNameToString{}
|
||||
for key, _ := range attrs {
|
||||
if _, stubSuiteAttr := STUB_SUITE_ATTRS[key]; stubSuiteAttr {
|
||||
stubSuiteAttrs[STUB_SUITE_ATTRS[key]] = attrs[key]
|
||||
}
|
||||
}
|
||||
return MakeBazelTarget("cc_stub_suite", name+"_stub_libs", stubSuiteAttrs)
|
||||
}
|
||||
|
||||
func TestCCLibraryNoLibCrtFalse(t *testing.T) {
|
||||
runCcLibraryTestCase(t, Bp2buildTestCase{
|
||||
ModuleTypeUnderTest: "cc_library",
|
||||
|
@@ -491,6 +491,16 @@ cc_library_shared {
|
||||
ExpectedBazelTargets: []string{MakeBazelTarget("cc_library_shared", "a", AttrNameToString{
|
||||
"has_stubs": `True`,
|
||||
}),
|
||||
makeCcStubSuiteTargets("a", AttrNameToString{
|
||||
"soname": `"a.so"`,
|
||||
"source_library": `":a"`,
|
||||
"stubs_symbol_file": `"a.map.txt"`,
|
||||
"stubs_versions": `[
|
||||
"28",
|
||||
"29",
|
||||
"current",
|
||||
]`,
|
||||
}),
|
||||
},
|
||||
},
|
||||
)
|
||||
|
@@ -463,3 +463,23 @@ type ExpectedRuleTarget struct {
|
||||
func (ebr ExpectedRuleTarget) String() string {
|
||||
return makeBazelTargetHostOrDevice(ebr.Rule, ebr.Name, ebr.Attrs, ebr.Hod)
|
||||
}
|
||||
|
||||
func makeCcStubSuiteTargets(name string, attrs AttrNameToString) string {
|
||||
if _, hasStubs := attrs["stubs_symbol_file"]; !hasStubs {
|
||||
return ""
|
||||
}
|
||||
STUB_SUITE_ATTRS := map[string]string{
|
||||
"stubs_symbol_file": "symbol_file",
|
||||
"stubs_versions": "versions",
|
||||
"soname": "soname",
|
||||
"source_library": "source_library",
|
||||
}
|
||||
|
||||
stubSuiteAttrs := AttrNameToString{}
|
||||
for key, _ := range attrs {
|
||||
if _, stubSuiteAttr := STUB_SUITE_ATTRS[key]; stubSuiteAttr {
|
||||
stubSuiteAttrs[STUB_SUITE_ATTRS[key]] = attrs[key]
|
||||
}
|
||||
}
|
||||
return MakeBazelTarget("cc_stub_suite", name+"_stub_libs", stubSuiteAttrs)
|
||||
}
|
||||
|
@@ -441,6 +441,10 @@ func libraryBp2Build(ctx android.TopDownMutatorContext, m *Module) {
|
||||
android.CommonAttributes{Name: m.Name()},
|
||||
sharedTargetAttrs, sharedAttrs.Enabled)
|
||||
|
||||
createStubsBazelTargetIfNeeded(ctx, m, compilerAttrs, exportedIncludes, baseAttributes)
|
||||
}
|
||||
|
||||
func createStubsBazelTargetIfNeeded(ctx android.TopDownMutatorContext, m *Module, compilerAttrs compilerAttributes, exportedIncludes BazelIncludes, baseAttributes baseAttributes) {
|
||||
if compilerAttrs.stubsSymbolFile != nil && len(compilerAttrs.stubsVersions.Value) > 0 {
|
||||
stubSuitesProps := bazel.BazelTargetModuleProperties{
|
||||
Rule_class: "cc_stub_suite",
|
||||
@@ -2707,6 +2711,8 @@ func sharedOrStaticLibraryBp2Build(ctx android.TopDownMutatorContext, module *Mo
|
||||
}
|
||||
|
||||
ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: module.Name()}, attrs)
|
||||
|
||||
createStubsBazelTargetIfNeeded(ctx, module, compilerAttrs, exportedIncludes, baseAttributes)
|
||||
}
|
||||
|
||||
// TODO(b/199902614): Can this be factored to share with the other Attributes?
|
||||
|
Reference in New Issue
Block a user