Merge changes I33846cdb,I1eb1f4bf into main am: 69ea5b8267
am: a823f9da87
am: 3d0e7d57b4
am: 5a4b14effe
am: e9ec119291
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2705698 Change-Id: I8481e93853f5522fc0124e9da7796033a49c1b58 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
24
java/java.go
24
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) {
|
func (al *ApiLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||||
|
|
||||||
rule := android.NewRuleBuilder(pctx, ctx)
|
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())
|
ctx.ModuleErrorf("Error: %s has an empty api file.", ctx.ModuleName())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
srcFiles = al.sortApiFilesByApiScope(ctx, srcFiles)
|
||||||
|
|
||||||
cmd := metalavaStubCmd(ctx, rule, srcFiles, homeDir)
|
cmd := metalavaStubCmd(ctx, rule, srcFiles, homeDir)
|
||||||
|
|
||||||
al.stubsFlags(ctx, cmd, stubsDir)
|
al.stubsFlags(ctx, cmd, stubsDir)
|
||||||
|
@@ -1864,12 +1864,12 @@ func TestJavaApiLibraryAndProviderLink(t *testing.T) {
|
|||||||
provider_bp_a := `
|
provider_bp_a := `
|
||||||
java_api_contribution {
|
java_api_contribution {
|
||||||
name: "foo1",
|
name: "foo1",
|
||||||
api_file: "foo1.txt",
|
api_file: "current.txt",
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
provider_bp_b := `java_api_contribution {
|
provider_bp_b := `java_api_contribution {
|
||||||
name: "foo2",
|
name: "foo2",
|
||||||
api_file: "foo2.txt",
|
api_file: "current.txt",
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
ctx, _ := testJavaWithFS(t, `
|
ctx, _ := testJavaWithFS(t, `
|
||||||
@@ -1897,11 +1897,11 @@ func TestJavaApiLibraryAndProviderLink(t *testing.T) {
|
|||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
moduleName: "bar1",
|
moduleName: "bar1",
|
||||||
sourceTextFileDirs: []string{"a/foo1.txt"},
|
sourceTextFileDirs: []string{"a/current.txt"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
moduleName: "bar2",
|
moduleName: "bar2",
|
||||||
sourceTextFileDirs: []string{"a/foo1.txt", "b/foo2.txt", "api1/current.txt", "api2/current.txt"},
|
sourceTextFileDirs: []string{"a/current.txt", "b/current.txt", "api1/current.txt", "api2/current.txt"},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, c := range testcases {
|
for _, c := range testcases {
|
||||||
@@ -1918,25 +1918,25 @@ func TestJavaApiLibraryAndDefaultsLink(t *testing.T) {
|
|||||||
provider_bp_a := `
|
provider_bp_a := `
|
||||||
java_api_contribution {
|
java_api_contribution {
|
||||||
name: "foo1",
|
name: "foo1",
|
||||||
api_file: "foo1.txt",
|
api_file: "current.txt",
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
provider_bp_b := `
|
provider_bp_b := `
|
||||||
java_api_contribution {
|
java_api_contribution {
|
||||||
name: "foo2",
|
name: "foo2",
|
||||||
api_file: "foo2.txt",
|
api_file: "current.txt",
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
provider_bp_c := `
|
provider_bp_c := `
|
||||||
java_api_contribution {
|
java_api_contribution {
|
||||||
name: "foo3",
|
name: "foo3",
|
||||||
api_file: "foo3.txt",
|
api_file: "current.txt",
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
provider_bp_d := `
|
provider_bp_d := `
|
||||||
java_api_contribution {
|
java_api_contribution {
|
||||||
name: "foo4",
|
name: "foo4",
|
||||||
api_file: "foo4.txt",
|
api_file: "current.txt",
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
ctx, _ := testJavaWithFS(t, `
|
ctx, _ := testJavaWithFS(t, `
|
||||||
@@ -1985,15 +1985,15 @@ func TestJavaApiLibraryAndDefaultsLink(t *testing.T) {
|
|||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
moduleName: "bar1",
|
moduleName: "bar1",
|
||||||
sourceTextFileDirs: []string{"a/foo1.txt"},
|
sourceTextFileDirs: []string{"a/current.txt"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
moduleName: "bar2",
|
moduleName: "bar2",
|
||||||
sourceTextFileDirs: []string{"a/foo1.txt", "b/foo2.txt"},
|
sourceTextFileDirs: []string{"a/current.txt", "b/current.txt"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
moduleName: "bar3",
|
moduleName: "bar3",
|
||||||
sourceTextFileDirs: []string{"c/foo3.txt", "a/foo1.txt", "b/foo2.txt", "d/foo4.txt", "api1/current.txt", "api2/current.txt"},
|
sourceTextFileDirs: []string{"c/current.txt", "a/current.txt", "b/current.txt", "d/current.txt", "api1/current.txt", "api2/current.txt"},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, c := range testcases {
|
for _, c := range testcases {
|
||||||
@@ -2010,13 +2010,13 @@ func TestJavaApiLibraryJarGeneration(t *testing.T) {
|
|||||||
provider_bp_a := `
|
provider_bp_a := `
|
||||||
java_api_contribution {
|
java_api_contribution {
|
||||||
name: "foo1",
|
name: "foo1",
|
||||||
api_file: "foo1.txt",
|
api_file: "current.txt",
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
provider_bp_b := `
|
provider_bp_b := `
|
||||||
java_api_contribution {
|
java_api_contribution {
|
||||||
name: "foo2",
|
name: "foo2",
|
||||||
api_file: "foo2.txt",
|
api_file: "current.txt",
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
ctx, _ := testJavaWithFS(t, `
|
ctx, _ := testJavaWithFS(t, `
|
||||||
@@ -2063,13 +2063,13 @@ func TestJavaApiLibraryLibsLink(t *testing.T) {
|
|||||||
provider_bp_a := `
|
provider_bp_a := `
|
||||||
java_api_contribution {
|
java_api_contribution {
|
||||||
name: "foo1",
|
name: "foo1",
|
||||||
api_file: "foo1.txt",
|
api_file: "current.txt",
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
provider_bp_b := `
|
provider_bp_b := `
|
||||||
java_api_contribution {
|
java_api_contribution {
|
||||||
name: "foo2",
|
name: "foo2",
|
||||||
api_file: "foo2.txt",
|
api_file: "current.txt",
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
lib_bp_a := `
|
lib_bp_a := `
|
||||||
@@ -2138,13 +2138,13 @@ func TestJavaApiLibraryStaticLibsLink(t *testing.T) {
|
|||||||
provider_bp_a := `
|
provider_bp_a := `
|
||||||
java_api_contribution {
|
java_api_contribution {
|
||||||
name: "foo1",
|
name: "foo1",
|
||||||
api_file: "foo1.txt",
|
api_file: "current.txt",
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
provider_bp_b := `
|
provider_bp_b := `
|
||||||
java_api_contribution {
|
java_api_contribution {
|
||||||
name: "foo2",
|
name: "foo2",
|
||||||
api_file: "foo2.txt",
|
api_file: "current.txt",
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
lib_bp_a := `
|
lib_bp_a := `
|
||||||
@@ -2212,13 +2212,13 @@ func TestJavaApiLibraryFullApiSurfaceStub(t *testing.T) {
|
|||||||
provider_bp_a := `
|
provider_bp_a := `
|
||||||
java_api_contribution {
|
java_api_contribution {
|
||||||
name: "foo1",
|
name: "foo1",
|
||||||
api_file: "foo1.txt",
|
api_file: "current.txt",
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
provider_bp_b := `
|
provider_bp_b := `
|
||||||
java_api_contribution {
|
java_api_contribution {
|
||||||
name: "foo2",
|
name: "foo2",
|
||||||
api_file: "foo2.txt",
|
api_file: "current.txt",
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
lib_bp_a := `
|
lib_bp_a := `
|
||||||
|
Reference in New Issue
Block a user