Depend on stubs via @api_surfaces
BUILD files of rdeps should depend on stubs via @api_surfaces indirection. e.g. instead of depending on //system/logging/liblog:liblog_stub_libs_current, it should depend on @api_surfaces//module-libapi/current:liblog. This ensures that the generated BUILD files are compatible with Multi-tree. Update the unit tests for this change. Test: TH Change-Id: Ibcc36dcfbee7b1973b341485f015e67987564dcc
This commit is contained in:
@@ -3035,7 +3035,7 @@ cc_library {
|
|||||||
}`,
|
}`,
|
||||||
ExpectedBazelTargets: makeCcLibraryTargets("foolib", AttrNameToString{
|
ExpectedBazelTargets: makeCcLibraryTargets("foolib", AttrNameToString{
|
||||||
"implementation_dynamic_deps": `select({
|
"implementation_dynamic_deps": `select({
|
||||||
"//build/bazel/rules/apex:android-in_apex": [":barlib_stub_libs_current"],
|
"//build/bazel/rules/apex:android-in_apex": ["@api_surfaces//module-libapi/current:barlib"],
|
||||||
"//conditions:default": [":barlib"],
|
"//conditions:default": [":barlib"],
|
||||||
})`,
|
})`,
|
||||||
"local_includes": `["."]`,
|
"local_includes": `["."]`,
|
||||||
@@ -3088,8 +3088,8 @@ cc_library {
|
|||||||
"//build/bazel/platforms/os:linux_musl": [":quxlib"],
|
"//build/bazel/platforms/os:linux_musl": [":quxlib"],
|
||||||
"//build/bazel/platforms/os:windows": [":quxlib"],
|
"//build/bazel/platforms/os:windows": [":quxlib"],
|
||||||
"//build/bazel/rules/apex:android-in_apex": [
|
"//build/bazel/rules/apex:android-in_apex": [
|
||||||
":barlib_stub_libs_current",
|
"@api_surfaces//module-libapi/current:barlib",
|
||||||
":quxlib_stub_libs_current",
|
"@api_surfaces//module-libapi/current:quxlib",
|
||||||
],
|
],
|
||||||
"//conditions:default": [
|
"//conditions:default": [
|
||||||
":barlib",
|
":barlib",
|
||||||
@@ -4130,11 +4130,11 @@ cc_library {
|
|||||||
ExpectedBazelTargets: []string{
|
ExpectedBazelTargets: []string{
|
||||||
MakeBazelTarget("cc_library_static", "foo_bp2build_cc_library_static", AttrNameToString{
|
MakeBazelTarget("cc_library_static", "foo_bp2build_cc_library_static", AttrNameToString{
|
||||||
"implementation_dynamic_deps": `select({
|
"implementation_dynamic_deps": `select({
|
||||||
"//build/bazel/rules/apex:android-in_apex": [":barlib_stub_libs_current"],
|
"//build/bazel/rules/apex:android-in_apex": ["@api_surfaces//module-libapi/current:barlib"],
|
||||||
"//conditions:default": [":barlib"],
|
"//conditions:default": [":barlib"],
|
||||||
})`,
|
})`,
|
||||||
"dynamic_deps": `select({
|
"dynamic_deps": `select({
|
||||||
"//build/bazel/rules/apex:android-in_apex": [":bazlib_stub_libs_current"],
|
"//build/bazel/rules/apex:android-in_apex": ["@api_surfaces//module-libapi/current:bazlib"],
|
||||||
"//conditions:default": [":bazlib"],
|
"//conditions:default": [":bazlib"],
|
||||||
})`,
|
})`,
|
||||||
"local_includes": `["."]`,
|
"local_includes": `["."]`,
|
||||||
@@ -4142,11 +4142,11 @@ cc_library {
|
|||||||
}),
|
}),
|
||||||
MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{
|
MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{
|
||||||
"implementation_dynamic_deps": `select({
|
"implementation_dynamic_deps": `select({
|
||||||
"//build/bazel/rules/apex:android-in_apex": [":barlib_stub_libs_current"],
|
"//build/bazel/rules/apex:android-in_apex": ["@api_surfaces//module-libapi/current:barlib"],
|
||||||
"//conditions:default": [":barlib"],
|
"//conditions:default": [":barlib"],
|
||||||
})`,
|
})`,
|
||||||
"dynamic_deps": `select({
|
"dynamic_deps": `select({
|
||||||
"//build/bazel/rules/apex:android-in_apex": [":bazlib_stub_libs_current"],
|
"//build/bazel/rules/apex:android-in_apex": ["@api_surfaces//module-libapi/current:bazlib"],
|
||||||
"//conditions:default": [":bazlib"],
|
"//conditions:default": [":bazlib"],
|
||||||
})`,
|
})`,
|
||||||
"local_includes": `["."]`,
|
"local_includes": `["."]`,
|
||||||
|
@@ -1553,7 +1553,7 @@ cc_library_static {
|
|||||||
}),
|
}),
|
||||||
MakeBazelTarget("cc_library_static", "keep_with_stubs", AttrNameToString{
|
MakeBazelTarget("cc_library_static", "keep_with_stubs", AttrNameToString{
|
||||||
"implementation_dynamic_deps": `select({
|
"implementation_dynamic_deps": `select({
|
||||||
"//build/bazel/rules/apex:android-in_apex": [":libm_stub_libs_current"],
|
"//build/bazel/rules/apex:android-in_apex": ["@api_surfaces//module-libapi/current:libm"],
|
||||||
"//conditions:default": [":libm"],
|
"//conditions:default": [":libm"],
|
||||||
})`,
|
})`,
|
||||||
"system_dynamic_deps": `[]`,
|
"system_dynamic_deps": `[]`,
|
||||||
|
@@ -1152,6 +1152,10 @@ func (la *linkerAttributes) bp2buildForAxisAndConfig(ctx android.BazelConversion
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
apiSurfaceModuleLibCurrentPackage = "@api_surfaces//" + android.ModuleLibApi.String() + "/current:"
|
||||||
|
)
|
||||||
|
|
||||||
func setStubsForDynamicDeps(ctx android.BazelConversionPathContext, axis bazel.ConfigurationAxis,
|
func setStubsForDynamicDeps(ctx android.BazelConversionPathContext, axis bazel.ConfigurationAxis,
|
||||||
config string, dynamicLibs bazel.LabelList, dynamicDeps *bazel.LabelListAttribute, ind int) {
|
config string, dynamicLibs bazel.LabelList, dynamicDeps *bazel.LabelListAttribute, ind int) {
|
||||||
depsWithStubs := []bazel.Label{}
|
depsWithStubs := []bazel.Label{}
|
||||||
@@ -1167,8 +1171,10 @@ func setStubsForDynamicDeps(ctx android.BazelConversionPathContext, axis bazel.C
|
|||||||
|
|
||||||
stubLibLabels := []bazel.Label{}
|
stubLibLabels := []bazel.Label{}
|
||||||
for _, l := range depsWithStubs {
|
for _, l := range depsWithStubs {
|
||||||
l.Label = l.Label + stubsSuffix
|
stubLabelInApiSurfaces := bazel.Label{
|
||||||
stubLibLabels = append(stubLibLabels, l)
|
Label: apiSurfaceModuleLibCurrentPackage + l.OriginalModuleName,
|
||||||
|
}
|
||||||
|
stubLibLabels = append(stubLibLabels, stubLabelInApiSurfaces)
|
||||||
}
|
}
|
||||||
inApexSelectValue := dynamicDeps.SelectValue(bazel.OsAndInApexAxis, bazel.AndroidAndInApex)
|
inApexSelectValue := dynamicDeps.SelectValue(bazel.OsAndInApexAxis, bazel.AndroidAndInApex)
|
||||||
nonApexSelectValue := dynamicDeps.SelectValue(bazel.OsAndInApexAxis, bazel.AndroidAndNonApex)
|
nonApexSelectValue := dynamicDeps.SelectValue(bazel.OsAndInApexAxis, bazel.AndroidAndNonApex)
|
||||||
@@ -1284,8 +1290,10 @@ func (la *linkerAttributes) finalize(ctx android.BazelConversionPathContext) {
|
|||||||
la.implementationDynamicDeps.Exclude(bazel.OsAndInApexAxis, bazel.AndroidAndNonApex, toRemove)
|
la.implementationDynamicDeps.Exclude(bazel.OsAndInApexAxis, bazel.AndroidAndNonApex, toRemove)
|
||||||
stubsToRemove := make([]bazel.Label, 0, len(la.usedSystemDynamicDepAsDynamicDep))
|
stubsToRemove := make([]bazel.Label, 0, len(la.usedSystemDynamicDepAsDynamicDep))
|
||||||
for _, lib := range toRemove.Includes {
|
for _, lib := range toRemove.Includes {
|
||||||
lib.Label += stubsSuffix
|
stubLabelInApiSurfaces := bazel.Label{
|
||||||
stubsToRemove = append(stubsToRemove, lib)
|
Label: apiSurfaceModuleLibCurrentPackage + lib.OriginalModuleName,
|
||||||
|
}
|
||||||
|
stubsToRemove = append(stubsToRemove, stubLabelInApiSurfaces)
|
||||||
}
|
}
|
||||||
la.implementationDynamicDeps.Exclude(bazel.OsAndInApexAxis, bazel.AndroidAndInApex, bazel.MakeLabelList(stubsToRemove))
|
la.implementationDynamicDeps.Exclude(bazel.OsAndInApexAxis, bazel.AndroidAndInApex, bazel.MakeLabelList(stubsToRemove))
|
||||||
}
|
}
|
||||||
|
@@ -468,7 +468,7 @@ func createStubsBazelTargetIfNeeded(ctx android.TopDownMutatorContext, m *Module
|
|||||||
// Add alias for the stub shared_library in @api_surfaces repository
|
// Add alias for the stub shared_library in @api_surfaces repository
|
||||||
currentModuleLibApiDir := ctx.Config().ApiSurfacesDir(android.ModuleLibApi, "current")
|
currentModuleLibApiDir := ctx.Config().ApiSurfacesDir(android.ModuleLibApi, "current")
|
||||||
actualLabelInMainWorkspace := bazel.Label{
|
actualLabelInMainWorkspace := bazel.Label{
|
||||||
Label: fmt.Sprintf("@//%s:%s_stub_libs_current", ctx.ModuleDir(), m.Name()),
|
Label: fmt.Sprintf("@//%s:%s%s", ctx.ModuleDir(), m.Name(), stubsSuffix),
|
||||||
}
|
}
|
||||||
ctx.CreateBazelTargetAliasInDir(currentModuleLibApiDir, m.Name(), actualLabelInMainWorkspace)
|
ctx.CreateBazelTargetAliasInDir(currentModuleLibApiDir, m.Name(), actualLabelInMainWorkspace)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user