Merge "Modify dist artifact dependency to respect the RELEASE_HIDDEN_API_EXPORTABLE_STUBS build flag" into main
This commit is contained in:
@@ -1993,20 +1993,25 @@ func (module *SdkLibrary) createStubsSourcesAndApi(mctx android.DefaultableHookC
|
|||||||
if !Bool(module.sdkLibraryProperties.No_dist) {
|
if !Bool(module.sdkLibraryProperties.No_dist) {
|
||||||
// Dist the api txt and removed api txt artifacts for sdk builds.
|
// Dist the api txt and removed api txt artifacts for sdk builds.
|
||||||
distDir := proptools.StringPtr(path.Join(module.apiDistPath(apiScope), "api"))
|
distDir := proptools.StringPtr(path.Join(module.apiDistPath(apiScope), "api"))
|
||||||
|
stubsTypeTagPrefix := ""
|
||||||
|
if mctx.Config().ReleaseHiddenApiExportableStubs() {
|
||||||
|
stubsTypeTagPrefix = ".exportable"
|
||||||
|
}
|
||||||
for _, p := range []struct {
|
for _, p := range []struct {
|
||||||
tag string
|
tag string
|
||||||
pattern string
|
pattern string
|
||||||
}{
|
}{
|
||||||
// "exportable" api files are copied to the dist directory instead of the
|
// "exportable" api files are copied to the dist directory instead of the
|
||||||
// "everything" api files.
|
// "everything" api files when "RELEASE_HIDDEN_API_EXPORTABLE_STUBS" build flag
|
||||||
{tag: ".exportable.api.txt", pattern: "%s.txt"},
|
// is set. Otherwise, the "everything" api files are copied to the dist directory.
|
||||||
{tag: ".exportable.removed-api.txt", pattern: "%s-removed.txt"},
|
{tag: "%s.api.txt", pattern: "%s.txt"},
|
||||||
|
{tag: "%s.removed-api.txt", pattern: "%s-removed.txt"},
|
||||||
} {
|
} {
|
||||||
props.Dists = append(props.Dists, android.Dist{
|
props.Dists = append(props.Dists, android.Dist{
|
||||||
Targets: []string{"sdk", "win_sdk"},
|
Targets: []string{"sdk", "win_sdk"},
|
||||||
Dir: distDir,
|
Dir: distDir,
|
||||||
Dest: proptools.StringPtr(fmt.Sprintf(p.pattern, module.distStem())),
|
Dest: proptools.StringPtr(fmt.Sprintf(p.pattern, module.distStem())),
|
||||||
Tag: proptools.StringPtr(p.tag),
|
Tag: proptools.StringPtr(fmt.Sprintf(p.tag, stubsTypeTagPrefix)),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2079,7 +2084,7 @@ func (module *SdkLibrary) createApiLibrary(mctx android.DefaultableHookContext,
|
|||||||
mctx.CreateModule(ApiLibraryFactory, &props, module.sdkComponentPropertiesForChildLibrary())
|
mctx.CreateModule(ApiLibraryFactory, &props, module.sdkComponentPropertiesForChildLibrary())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (module *SdkLibrary) topLevelStubsLibraryProps(mctx android.DefaultableHookContext, apiScope *apiScope) libraryProperties {
|
func (module *SdkLibrary) topLevelStubsLibraryProps(mctx android.DefaultableHookContext, apiScope *apiScope, doDist bool) libraryProperties {
|
||||||
props := libraryProperties{}
|
props := libraryProperties{}
|
||||||
|
|
||||||
props.Visibility = childModuleVisibility(module.sdkLibraryProperties.Stubs_library_visibility)
|
props.Visibility = childModuleVisibility(module.sdkLibraryProperties.Stubs_library_visibility)
|
||||||
@@ -2095,13 +2100,22 @@ func (module *SdkLibrary) topLevelStubsLibraryProps(mctx android.DefaultableHook
|
|||||||
}
|
}
|
||||||
props.Compile_dex = compileDex
|
props.Compile_dex = compileDex
|
||||||
|
|
||||||
|
if !Bool(module.sdkLibraryProperties.No_dist) && doDist {
|
||||||
|
props.Dist.Targets = []string{"sdk", "win_sdk"}
|
||||||
|
props.Dist.Dest = proptools.StringPtr(fmt.Sprintf("%v.jar", module.distStem()))
|
||||||
|
props.Dist.Dir = proptools.StringPtr(module.apiDistPath(apiScope))
|
||||||
|
props.Dist.Tag = proptools.StringPtr(".jar")
|
||||||
|
}
|
||||||
|
|
||||||
return props
|
return props
|
||||||
}
|
}
|
||||||
|
|
||||||
func (module *SdkLibrary) createTopLevelStubsLibrary(
|
func (module *SdkLibrary) createTopLevelStubsLibrary(
|
||||||
mctx android.DefaultableHookContext, apiScope *apiScope, contributesToApiSurface bool) {
|
mctx android.DefaultableHookContext, apiScope *apiScope, contributesToApiSurface bool) {
|
||||||
|
|
||||||
props := module.topLevelStubsLibraryProps(mctx, apiScope)
|
// Dist the "everything" stubs when the RELEASE_HIDDEN_API_EXPORTABLE_STUBS build flag is false
|
||||||
|
doDist := !mctx.Config().ReleaseHiddenApiExportableStubs()
|
||||||
|
props := module.topLevelStubsLibraryProps(mctx, apiScope, doDist)
|
||||||
props.Name = proptools.StringPtr(module.stubsLibraryModuleName(apiScope))
|
props.Name = proptools.StringPtr(module.stubsLibraryModuleName(apiScope))
|
||||||
|
|
||||||
// Add the stub compiling java_library/java_api_library as static lib based on build config
|
// Add the stub compiling java_library/java_api_library as static lib based on build config
|
||||||
@@ -2117,18 +2131,11 @@ func (module *SdkLibrary) createTopLevelStubsLibrary(
|
|||||||
func (module *SdkLibrary) createTopLevelExportableStubsLibrary(
|
func (module *SdkLibrary) createTopLevelExportableStubsLibrary(
|
||||||
mctx android.DefaultableHookContext, apiScope *apiScope) {
|
mctx android.DefaultableHookContext, apiScope *apiScope) {
|
||||||
|
|
||||||
props := module.topLevelStubsLibraryProps(mctx, apiScope)
|
// Dist the "exportable" stubs when the RELEASE_HIDDEN_API_EXPORTABLE_STUBS build flag is true
|
||||||
|
doDist := mctx.Config().ReleaseHiddenApiExportableStubs()
|
||||||
|
props := module.topLevelStubsLibraryProps(mctx, apiScope, doDist)
|
||||||
props.Name = proptools.StringPtr(module.exportableStubsLibraryModuleName(apiScope))
|
props.Name = proptools.StringPtr(module.exportableStubsLibraryModuleName(apiScope))
|
||||||
|
|
||||||
// Dist the class jar artifact for sdk builds.
|
|
||||||
// "exportable" stubs are copied to dist for sdk builds instead of the "everything" stubs.
|
|
||||||
if !Bool(module.sdkLibraryProperties.No_dist) {
|
|
||||||
props.Dist.Targets = []string{"sdk", "win_sdk"}
|
|
||||||
props.Dist.Dest = proptools.StringPtr(fmt.Sprintf("%v.jar", module.distStem()))
|
|
||||||
props.Dist.Dir = proptools.StringPtr(module.apiDistPath(apiScope))
|
|
||||||
props.Dist.Tag = proptools.StringPtr(".jar")
|
|
||||||
}
|
|
||||||
|
|
||||||
staticLib := module.exportableSourceStubsLibraryModuleName(apiScope)
|
staticLib := module.exportableSourceStubsLibraryModuleName(apiScope)
|
||||||
props.Static_libs = append(props.Static_libs, staticLib)
|
props.Static_libs = append(props.Static_libs, staticLib)
|
||||||
|
|
||||||
|
@@ -1393,6 +1393,11 @@ func TestJavaSdkLibraryDist(t *testing.T) {
|
|||||||
"sdklib_group_foo",
|
"sdklib_group_foo",
|
||||||
"sdklib_owner_foo",
|
"sdklib_owner_foo",
|
||||||
"foo"),
|
"foo"),
|
||||||
|
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
|
||||||
|
variables.BuildFlags = map[string]string{
|
||||||
|
"RELEASE_HIDDEN_API_EXPORTABLE_STUBS": "true",
|
||||||
|
}
|
||||||
|
}),
|
||||||
).RunTestWithBp(t, `
|
).RunTestWithBp(t, `
|
||||||
java_sdk_library {
|
java_sdk_library {
|
||||||
name: "sdklib_no_group",
|
name: "sdklib_no_group",
|
||||||
|
Reference in New Issue
Block a user