java_sdk_library: Avoid generating system and test .txt files
If the library does not provide system and test APIs then do not generate/require corresponding .txt files. Bug: 145998881 Test: m checkbuild Change-Id: I21cfdb0b63fd575e8c8c63ea2b436e0c4aa8f3fc
This commit is contained in:
@@ -125,6 +125,9 @@ type sdkLibraryProperties struct {
|
|||||||
// don't create dist rules.
|
// don't create dist rules.
|
||||||
No_dist *bool `blueprint:"mutated"`
|
No_dist *bool `blueprint:"mutated"`
|
||||||
|
|
||||||
|
// indicates whether system and test apis should be managed.
|
||||||
|
Has_system_and_test_apis bool `blueprint:"mutated"`
|
||||||
|
|
||||||
// TODO: determines whether to create HTML doc or not
|
// TODO: determines whether to create HTML doc or not
|
||||||
//Html_doc *bool
|
//Html_doc *bool
|
||||||
}
|
}
|
||||||
@@ -160,8 +163,7 @@ func (module *SdkLibrary) DepsMutator(ctx android.BottomUpMutatorContext) {
|
|||||||
}
|
}
|
||||||
ctx.AddVariationDependencies(nil, publicApiFileTag, module.docsName(apiScopePublic))
|
ctx.AddVariationDependencies(nil, publicApiFileTag, module.docsName(apiScopePublic))
|
||||||
|
|
||||||
sdkDep := decodeSdkDep(ctx, sdkContext(&module.Library))
|
if module.sdkLibraryProperties.Has_system_and_test_apis {
|
||||||
if sdkDep.hasStandardLibs() {
|
|
||||||
if useBuiltStubs {
|
if useBuiltStubs {
|
||||||
ctx.AddVariationDependencies(nil, systemApiStubsTag, module.stubsName(apiScopeSystem))
|
ctx.AddVariationDependencies(nil, systemApiStubsTag, module.stubsName(apiScopeSystem))
|
||||||
ctx.AddVariationDependencies(nil, testApiStubsTag, module.stubsName(apiScopeTest))
|
ctx.AddVariationDependencies(nil, testApiStubsTag, module.stubsName(apiScopeTest))
|
||||||
@@ -699,9 +701,22 @@ func (module *SdkLibrary) CreateInternalModules(mctx android.LoadHookContext) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If this builds against standard libraries (i.e. is not part of the core libraries)
|
||||||
|
// then assume it provides both system and test apis. Otherwise, assume it does not and
|
||||||
|
// also assume it does not contribute to the dist build.
|
||||||
|
sdkDep := decodeSdkDep(mctx, sdkContext(&module.Library))
|
||||||
|
hasSystemAndTestApis := sdkDep.hasStandardLibs()
|
||||||
|
module.sdkLibraryProperties.Has_system_and_test_apis = hasSystemAndTestApis
|
||||||
|
module.sdkLibraryProperties.No_dist = proptools.BoolPtr(!hasSystemAndTestApis)
|
||||||
|
|
||||||
|
scopes := []string{""}
|
||||||
|
if hasSystemAndTestApis {
|
||||||
|
scopes = append(scopes, "system-", "test-")
|
||||||
|
}
|
||||||
|
|
||||||
missing_current_api := false
|
missing_current_api := false
|
||||||
|
|
||||||
for _, scope := range []string{"", "system-", "test-"} {
|
for _, scope := range scopes {
|
||||||
for _, api := range []string{"current.txt", "removed.txt"} {
|
for _, api := range []string{"current.txt", "removed.txt"} {
|
||||||
path := path.Join(mctx.ModuleDir(), "api", scope+api)
|
path := path.Join(mctx.ModuleDir(), "api", scope+api)
|
||||||
p := android.ExistentPathForSource(mctx, path)
|
p := android.ExistentPathForSource(mctx, path)
|
||||||
@@ -722,7 +737,8 @@ func (module *SdkLibrary) CreateInternalModules(mctx android.LoadHookContext) {
|
|||||||
|
|
||||||
mctx.ModuleErrorf("One or more current api files are missing. "+
|
mctx.ModuleErrorf("One or more current api files are missing. "+
|
||||||
"You can update them by:\n"+
|
"You can update them by:\n"+
|
||||||
"%s %q && m update-api", script, mctx.ModuleDir())
|
"%s %q %s && m update-api",
|
||||||
|
script, mctx.ModuleDir(), strings.Join(scopes, " "))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -730,8 +746,7 @@ func (module *SdkLibrary) CreateInternalModules(mctx android.LoadHookContext) {
|
|||||||
module.createStubsLibrary(mctx, apiScopePublic)
|
module.createStubsLibrary(mctx, apiScopePublic)
|
||||||
module.createStubsSources(mctx, apiScopePublic)
|
module.createStubsSources(mctx, apiScopePublic)
|
||||||
|
|
||||||
sdkDep := decodeSdkDep(mctx, sdkContext(&module.Library))
|
if hasSystemAndTestApis {
|
||||||
if sdkDep.hasStandardLibs() {
|
|
||||||
// for system API stubs
|
// for system API stubs
|
||||||
module.createStubsLibrary(mctx, apiScopeSystem)
|
module.createStubsLibrary(mctx, apiScopeSystem)
|
||||||
module.createStubsSources(mctx, apiScopeSystem)
|
module.createStubsSources(mctx, apiScopeSystem)
|
||||||
|
@@ -15,15 +15,16 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
if [[ -z "$1" ]]; then
|
if [[ -z "$1" ]]; then
|
||||||
echo "usage: $0 <modulePath>" >&2
|
echo "usage: $0 <modulePath> scopes..." >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
api_dir=$1/api
|
api_dir=$1/api
|
||||||
|
shift
|
||||||
|
|
||||||
mkdir -p "$api_dir"
|
mkdir -p "$api_dir"
|
||||||
|
|
||||||
scopes=("" system- test-)
|
scopes=("" "$@")
|
||||||
apis=(current removed)
|
apis=(current removed)
|
||||||
|
|
||||||
for scope in "${scopes[@]}"; do
|
for scope in "${scopes[@]}"; do
|
||||||
@@ -31,3 +32,4 @@ for scope in "${scopes[@]}"; do
|
|||||||
touch "${api_dir}/${scope}${api}.txt"
|
touch "${api_dir}/${scope}${api}.txt"
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user