diff options
| author | Treehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com> | 2023-08-12 04:42:48 +0000 |
|---|---|---|
| committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2023-08-12 04:42:48 +0000 |
| commit | 69ea5b82679799abf7b05a14d17f109bcbf87469 (patch) | |
| tree | 9bff046380b7a7261ed3d3d9481f7000e756a556 /java/java.go | |
| parent | a405301f0319e571ef48eac5101e2a50944624ea (diff) | |
| parent | 478ca5b79e3e438a04bd838c9e1f17769d728e92 (diff) | |
Merge changes I33846cdb,I1eb1f4bf into main
* changes:
Move scopeOrderedSourceFileNames as outside var
Sort api files by api scope in java_api_library
Diffstat (limited to 'java/java.go')
| -rw-r--r-- | java/java.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/java/java.go b/java/java.go index 0d39a6a78..6667a52f1 100644 --- a/java/java.go +++ b/java/java.go @@ -1812,6 +1812,28 @@ func (al *ApiLibrary) DepsMutator(ctx android.BottomUpMutatorContext) { } } +// API signature file names sorted from +// the narrowest api scope to the widest api scope +var scopeOrderedSourceFileNames = allApiScopes.Strings( + func(s *apiScope) string { return s.apiFilePrefix + "current.txt" }) + +func (al *ApiLibrary) sortApiFilesByApiScope(ctx android.ModuleContext, srcFiles android.Paths) android.Paths { + sortedSrcFiles := android.Paths{} + + for _, scopeSourceFileName := range scopeOrderedSourceFileNames { + for _, sourceFileName := range srcFiles { + if sourceFileName.Base() == scopeSourceFileName { + sortedSrcFiles = append(sortedSrcFiles, sourceFileName) + } + } + } + if len(srcFiles) != len(sortedSrcFiles) { + ctx.ModuleErrorf("Unrecognizable source file found within %s", srcFiles) + } + + return sortedSrcFiles +} + func (al *ApiLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) { rule := android.NewRuleBuilder(pctx, ctx) @@ -1862,6 +1884,8 @@ func (al *ApiLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) { ctx.ModuleErrorf("Error: %s has an empty api file.", ctx.ModuleName()) } + srcFiles = al.sortApiFilesByApiScope(ctx, srcFiles) + cmd := metalavaStubCmd(ctx, rule, srcFiles, homeDir) al.stubsFlags(ctx, cmd, stubsDir) |
