Merge "Revert "pass read new storage parameter to java codegen"" into main
diff --git a/android/deapexer.go b/android/deapexer.go
index dcae3e4..4049d2b 100644
--- a/android/deapexer.go
+++ b/android/deapexer.go
@@ -15,7 +15,6 @@
package android
import (
- "fmt"
"strings"
"github.com/google/blueprint"
@@ -109,10 +108,6 @@
return i.exportedModuleNames
}
-// Provider that can be used from within the `GenerateAndroidBuildActions` of a module that depends
-// on a `deapexer` module to retrieve its `DeapexerInfo`.
-var DeapexerProvider = blueprint.NewProvider[DeapexerInfo]()
-
// NewDeapexerInfo creates and initializes a DeapexerInfo that is suitable
// for use with a prebuilt_apex module.
//
@@ -169,45 +164,6 @@
RequiresFilesFromPrebuiltApex()
}
-// FindDeapexerProviderForModule searches through the direct dependencies of the current context
-// module for a DeapexerTag dependency and returns its DeapexerInfo. If a single nonambiguous
-// deapexer module isn't found then it returns it an error
-// clients should check the value of error and call ctx.ModuleErrof if a non nil error is received
-func FindDeapexerProviderForModule(ctx ModuleContext) (*DeapexerInfo, error) {
- var di *DeapexerInfo
- var err error
- ctx.VisitDirectDepsWithTag(DeapexerTag, func(m Module) {
- if err != nil {
- // An err has been found. Do not visit further.
- return
- }
- c, ok := OtherModuleProvider(ctx, m, DeapexerProvider)
- if !ok {
- ctx.ModuleErrorf("Expected all deps with DeapexerTag to have a DeapexerProvider, but module %q did not", m.Name())
- return
- }
- p := &c
- if di != nil {
- // If two DeapexerInfo providers have been found then check if they are
- // equivalent. If they are then use the selected one, otherwise fail.
- if selected := equivalentDeapexerInfoProviders(di, p); selected != nil {
- di = selected
- return
- }
- err = fmt.Errorf("Multiple installable prebuilt APEXes provide ambiguous deapexers: %s and %s", di.ApexModuleName(), p.ApexModuleName())
- }
- di = p
- })
- if err != nil {
- return nil, err
- }
- if di != nil {
- return di, nil
- }
- ai, _ := ModuleProvider(ctx, ApexInfoProvider)
- return nil, fmt.Errorf("No prebuilt APEX provides a deapexer module for APEX variant %s", ai.ApexVariationName)
-}
-
// removeCompressedApexSuffix removes the _compressed suffix from the name if present.
func removeCompressedApexSuffix(name string) string {
return strings.TrimSuffix(name, "_compressed")
diff --git a/apex/apex_test.go b/apex/apex_test.go
index 0d5bad4..1f4e5ea 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -3685,7 +3685,7 @@
}
func ensureExactDeapexedContents(t *testing.T, ctx *android.TestContext, moduleName string, variant string, files []string) {
- deapexer := ctx.ModuleForTests(moduleName+".deapexer", variant).Description("deapex")
+ deapexer := ctx.ModuleForTests(moduleName, variant).Description("deapex")
outputs := make([]string, 0, len(deapexer.ImplicitOutputs)+1)
if deapexer.Output != nil {
outputs = append(outputs, deapexer.Output.String())
@@ -4907,23 +4907,6 @@
}),
)
- checkBootDexJarPath := func(t *testing.T, ctx *android.TestContext, stem string, bootDexJarPath string) {
- t.Helper()
- s := ctx.ModuleForTests("dex_bootjars", "android_common")
- foundLibfooJar := false
- base := stem + ".jar"
- for _, output := range s.AllOutputs() {
- if filepath.Base(output) == base {
- foundLibfooJar = true
- buildRule := s.Output(output)
- android.AssertStringEquals(t, "boot dex jar path", bootDexJarPath, buildRule.Input.String())
- }
- }
- if !foundLibfooJar {
- t.Errorf("Rule for libfoo.jar missing in dex_bootjars singleton outputs %q", android.StringPathsRelativeToTop(ctx.Config().SoongOutDir(), s.AllOutputs()))
- }
- }
-
checkHiddenAPIIndexFromClassesInputs := func(t *testing.T, ctx *android.TestContext, expectedIntermediateInputs string) {
t.Helper()
platformBootclasspath := ctx.ModuleForTests("platform-bootclasspath", "android_common")
@@ -4976,12 +4959,14 @@
},
}
- java_import {
+ java_sdk_library_import {
name: "libfoo",
- jars: ["libfoo.jar"],
+ public: {
+ jars: ["libfoo.jar"],
+ },
apex_available: ["myapex"],
+ shared_library: false,
permitted_packages: ["foo"],
- sdk_version: "core_current",
}
java_sdk_library_import {
@@ -4996,8 +4981,6 @@
`
ctx := testDexpreoptWithApexes(t, bp, "", preparer, fragment)
- checkBootDexJarPath(t, ctx, "libfoo", "out/soong/.intermediates/prebuilt_myapex.deapexer/android_common/deapexer/javalib/libfoo.jar")
- checkBootDexJarPath(t, ctx, "libbar", "out/soong/.intermediates/prebuilt_myapex.deapexer/android_common/deapexer/javalib/libbar.jar")
// Verify the correct module jars contribute to the hiddenapi index file.
checkHiddenAPIIndexFromClassesInputs(t, ctx, `out/soong/.intermediates/platform/foo/android_common/javac/foo.jar`)
@@ -5037,13 +5020,17 @@
apex_available: ["myapex"],
}
- java_import {
+ java_sdk_library_import {
name: "libfoo",
- jars: ["libfoo.jar"],
+ public: {
+ jars: ["libfoo.jar"],
+ },
apex_available: ["myapex"],
- permitted_packages: ["foo"],
+ shared_library: false,
+ permitted_packages: ["libfoo"],
}
+
java_sdk_library_import {
name: "libbar",
public: {
@@ -5066,8 +5053,6 @@
`
ctx := testDexpreoptWithApexes(t, bp, "", preparer, fragment)
- checkBootDexJarPath(t, ctx, "libfoo", "out/soong/.intermediates/prebuilt_myapex.deapexer/android_common/deapexer/javalib/libfoo.jar")
- checkBootDexJarPath(t, ctx, "libbar", "out/soong/.intermediates/prebuilt_myapex.deapexer/android_common/deapexer/javalib/libbar.jar")
// Verify the correct module jars contribute to the hiddenapi index file.
checkHiddenAPIIndexFromClassesInputs(t, ctx, `out/soong/.intermediates/platform/foo/android_common/javac/foo.jar`)
@@ -5221,13 +5206,15 @@
},
}
- java_import {
+ java_sdk_library_import {
name: "libfoo",
prefer: true,
- jars: ["libfoo.jar"],
+ public: {
+ jars: ["libfoo.jar"],
+ },
apex_available: ["myapex"],
- permitted_packages: ["foo"],
- sdk_version: "core_current",
+ shared_library: false,
+ permitted_packages: ["libfoo"],
}
java_library {
@@ -5259,8 +5246,6 @@
`
ctx := testDexpreoptWithApexes(t, bp, "", preparer, fragment)
- checkBootDexJarPath(t, ctx, "libfoo", "out/soong/.intermediates/prebuilt_myapex.deapexer/android_common/deapexer/javalib/libfoo.jar")
- checkBootDexJarPath(t, ctx, "libbar", "out/soong/.intermediates/prebuilt_myapex.deapexer/android_common/deapexer/javalib/libbar.jar")
// Verify the correct module jars contribute to the hiddenapi index file.
checkHiddenAPIIndexFromClassesInputs(t, ctx, `out/soong/.intermediates/platform/foo/android_common/javac/foo.jar`)
@@ -5359,8 +5344,6 @@
`
ctx := testDexpreoptWithApexes(t, bp, "", preparer, fragment)
- checkBootDexJarPath(t, ctx, "libfoo", "out/soong/.intermediates/my-bootclasspath-fragment/android_common_myapex/hiddenapi-modular/encoded/libfoo.jar")
- checkBootDexJarPath(t, ctx, "libbar", "out/soong/.intermediates/my-bootclasspath-fragment/android_common_myapex/hiddenapi-modular/encoded/libbar.jar")
// Verify the correct module jars contribute to the hiddenapi index file.
checkHiddenAPIIndexFromClassesInputs(t, ctx, `out/soong/.intermediates/platform/foo/android_common/javac/foo.jar`)
@@ -5472,8 +5455,6 @@
)
ctx := testDexpreoptWithApexes(t, bp, "", preparer2, fragment)
- checkBootDexJarPath(t, ctx, "libfoo", "out/soong/.intermediates/prebuilt_myapex.deapexer/android_common/deapexer/javalib/libfoo.jar")
- checkBootDexJarPath(t, ctx, "libbar", "out/soong/.intermediates/prebuilt_myapex.deapexer/android_common/deapexer/javalib/libbar.jar")
// Verify the correct module jars contribute to the hiddenapi index file.
checkHiddenAPIIndexFromClassesInputs(t, ctx, `out/soong/.intermediates/platform/foo/android_common/javac/foo.jar`)
@@ -7101,7 +7082,7 @@
java_library {
name: "bar",
srcs: ["a.java"],
- libs: ["foo"],
+ libs: ["foo.impl"],
apex_available: ["myapex"],
sdk_version: "none",
system_modules: "none",
@@ -7154,7 +7135,7 @@
java_library {
name: "bar",
srcs: ["a.java"],
- libs: ["foo"],
+ libs: ["foo.stubs"],
sdk_version: "none",
system_modules: "none",
}
@@ -7208,7 +7189,7 @@
java_library {
name: "bar",
srcs: ["a.java"],
- libs: ["foo"],
+ libs: ["foo.impl"],
apex_available: ["myapex"],
sdk_version: "none",
system_modules: "none",
@@ -7881,9 +7862,9 @@
ctx := testApex(t, bp, prepareForTestWithSantitizeHwaddress)
// Check that the extractor produces the correct output file from the correct input file.
- extractorOutput := "out/soong/.intermediates/prebuilt_myapex.apex.extractor/android_common/extracted/myapex.hwasan.apks"
+ extractorOutput := "out/soong/.intermediates/myapex/android_common_myapex/extracted/myapex.hwasan.apks"
- m := ctx.ModuleForTests("prebuilt_myapex.apex.extractor", "android_common")
+ m := ctx.ModuleForTests("myapex", "android_common_myapex")
extractedApex := m.Output(extractorOutput)
android.AssertArrayString(t, "extractor input", []string{"myapex.hwasan.apks"}, extractedApex.Inputs.Strings())
@@ -7908,10 +7889,10 @@
}
`)
- m := ctx.ModuleForTests("prebuilt_myapex.apex.extractor", "android_common")
+ m := ctx.ModuleForTests("myapex", "android_common_myapex")
// Check that the extractor produces the correct apks file from the input module
- extractorOutput := "out/soong/.intermediates/prebuilt_myapex.apex.extractor/android_common/extracted/myapex.apks"
+ extractorOutput := "out/soong/.intermediates/myapex/android_common_myapex/extracted/myapex.apks"
extractedApex := m.Output(extractorOutput)
android.AssertArrayString(t, "extractor input", []string{"myapex.apks"}, extractedApex.Inputs.Strings())
@@ -7973,189 +7954,6 @@
return result.TestContext
}
-func TestDuplicateDeapexersFromPrebuiltApexes(t *testing.T) {
- preparers := android.GroupFixturePreparers(
- java.PrepareForTestWithJavaDefaultModules,
- prepareForTestWithBootclasspathFragment,
- dexpreopt.FixtureSetTestOnlyArtBootImageJars("com.android.art:libfoo"),
- PrepareForTestWithApexBuildComponents,
- ).
- ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(
- "Multiple installable prebuilt APEXes provide ambiguous deapexers: prebuilt_com.android.art and prebuilt_com.mycompany.android.art"))
-
- bpBase := `
- apex_set {
- name: "com.android.art",
- installable: true,
- exported_bootclasspath_fragments: ["art-bootclasspath-fragment"],
- set: "myapex.apks",
- }
-
- apex_set {
- name: "com.mycompany.android.art",
- apex_name: "com.android.art",
- installable: true,
- exported_bootclasspath_fragments: ["art-bootclasspath-fragment"],
- set: "company-myapex.apks",
- }
-
- prebuilt_bootclasspath_fragment {
- name: "art-bootclasspath-fragment",
- apex_available: ["com.android.art"],
- hidden_api: {
- annotation_flags: "my-bootclasspath-fragment/annotation-flags.csv",
- metadata: "my-bootclasspath-fragment/metadata.csv",
- index: "my-bootclasspath-fragment/index.csv",
- stub_flags: "my-bootclasspath-fragment/stub-flags.csv",
- all_flags: "my-bootclasspath-fragment/all-flags.csv",
- },
- %s
- }
- `
-
- t.Run("java_import", func(t *testing.T) {
- _ = preparers.RunTestWithBp(t, fmt.Sprintf(bpBase, `contents: ["libfoo"]`)+`
- java_import {
- name: "libfoo",
- jars: ["libfoo.jar"],
- apex_available: ["com.android.art"],
- }
- `)
- })
-
- t.Run("java_sdk_library_import", func(t *testing.T) {
- _ = preparers.RunTestWithBp(t, fmt.Sprintf(bpBase, `contents: ["libfoo"]`)+`
- java_sdk_library_import {
- name: "libfoo",
- public: {
- jars: ["libbar.jar"],
- },
- shared_library: false,
- apex_available: ["com.android.art"],
- }
- `)
- })
-
- t.Run("prebuilt_bootclasspath_fragment", func(t *testing.T) {
- _ = preparers.RunTestWithBp(t, fmt.Sprintf(bpBase, `
- image_name: "art",
- contents: ["libfoo"],
- `)+`
- java_sdk_library_import {
- name: "libfoo",
- public: {
- jars: ["libbar.jar"],
- },
- shared_library: false,
- apex_available: ["com.android.art"],
- }
- `)
- })
-}
-
-func TestDuplicateButEquivalentDeapexersFromPrebuiltApexes(t *testing.T) {
- preparers := android.GroupFixturePreparers(
- java.PrepareForTestWithJavaDefaultModules,
- PrepareForTestWithApexBuildComponents,
- )
-
- errCtx := moduleErrorfTestCtx{}
-
- bpBase := `
- apex_set {
- name: "com.android.myapex",
- installable: true,
- exported_bootclasspath_fragments: ["my-bootclasspath-fragment"],
- set: "myapex.apks",
- }
-
- apex_set {
- name: "com.android.myapex_compressed",
- apex_name: "com.android.myapex",
- installable: true,
- exported_bootclasspath_fragments: ["my-bootclasspath-fragment"],
- set: "myapex_compressed.apks",
- }
-
- prebuilt_bootclasspath_fragment {
- name: "my-bootclasspath-fragment",
- apex_available: [
- "com.android.myapex",
- "com.android.myapex_compressed",
- ],
- hidden_api: {
- annotation_flags: "annotation-flags.csv",
- metadata: "metadata.csv",
- index: "index.csv",
- signature_patterns: "signature_patterns.csv",
- },
- %s
- }
- `
-
- t.Run("java_import", func(t *testing.T) {
- result := preparers.RunTestWithBp(t,
- fmt.Sprintf(bpBase, `contents: ["libfoo"]`)+`
- java_import {
- name: "libfoo",
- jars: ["libfoo.jar"],
- apex_available: [
- "com.android.myapex",
- "com.android.myapex_compressed",
- ],
- }
- `)
-
- module := result.Module("libfoo", "android_common_com.android.myapex")
- usesLibraryDep := module.(java.UsesLibraryDependency)
- android.AssertPathRelativeToTopEquals(t, "dex jar path",
- "out/soong/.intermediates/prebuilt_com.android.myapex.deapexer/android_common/deapexer/javalib/libfoo.jar",
- usesLibraryDep.DexJarBuildPath(errCtx).Path())
- })
-
- t.Run("java_sdk_library_import", func(t *testing.T) {
- result := preparers.RunTestWithBp(t,
- fmt.Sprintf(bpBase, `contents: ["libfoo"]`)+`
- java_sdk_library_import {
- name: "libfoo",
- public: {
- jars: ["libbar.jar"],
- },
- apex_available: [
- "com.android.myapex",
- "com.android.myapex_compressed",
- ],
- compile_dex: true,
- }
- `)
-
- module := result.Module("libfoo", "android_common_com.android.myapex")
- usesLibraryDep := module.(java.UsesLibraryDependency)
- android.AssertPathRelativeToTopEquals(t, "dex jar path",
- "out/soong/.intermediates/prebuilt_com.android.myapex.deapexer/android_common/deapexer/javalib/libfoo.jar",
- usesLibraryDep.DexJarBuildPath(errCtx).Path())
- })
-
- t.Run("prebuilt_bootclasspath_fragment", func(t *testing.T) {
- _ = preparers.RunTestWithBp(t, fmt.Sprintf(bpBase, `
- image_name: "art",
- contents: ["libfoo"],
- `)+`
- java_sdk_library_import {
- name: "libfoo",
- public: {
- jars: ["libbar.jar"],
- },
- apex_available: [
- "com.android.myapex",
- "com.android.myapex_compressed",
- ],
- compile_dex: true,
- }
- `)
- })
-}
-
func TestUpdatable_should_set_min_sdk_version(t *testing.T) {
testApexError(t, `"myapex" .*: updatable: updatable APEXes should set min_sdk_version`, `
apex {
@@ -8267,12 +8065,16 @@
},
}
- java_import {
- name: "libfoo",
+ java_sdk_library_import {
+ name: "libfoo",
+ prefer: true,
+ public: {
jars: ["libfoo.jar"],
- apex_available: ["myapex"],
- permitted_packages: ["libfoo"],
- }
+ },
+ apex_available: ["myapex"],
+ shared_library: false,
+ permitted_packages: ["libfoo"],
+ }
`, "", preparer, fragment)
})
}
@@ -8652,7 +8454,7 @@
}),
)
- m := ctx.ModuleForTests("prebuilt_myapex.apex.extractor", "android_common")
+ m := ctx.ModuleForTests("myapex", "android_common_myapex")
// Check extract_apks tool parameters.
extractedApex := m.Output("extracted/myapex.apks")
@@ -8693,7 +8495,7 @@
}),
)
- m := ctx.ModuleForTests("prebuilt_myapex.apex.extractor", "android_common")
+ m := ctx.ModuleForTests("myapex", "android_common_myapex")
// Check extract_apks tool parameters. No native bridge arch expected
extractedApex := m.Output("extracted/myapex.apks")
@@ -10959,12 +10761,12 @@
{
desc: "Prebuilt apex prebuilt_com.android.foo is selected, profile should come from .prof deapexed from the prebuilt",
selectedApexContributions: "foo.prebuilt.contributions",
- expectedBootJar: "out/soong/.intermediates/prebuilt_com.android.foo.deapexer/android_common/deapexer/javalib/framework-foo.jar",
+ expectedBootJar: "out/soong/.intermediates/prebuilt_com.android.foo/android_common_com.android.foo/deapexer/javalib/framework-foo.jar",
},
{
desc: "Prebuilt apex prebuilt_com.android.foo.v2 is selected, profile should come from .prof deapexed from the prebuilt",
selectedApexContributions: "foo.prebuilt.v2.contributions",
- expectedBootJar: "out/soong/.intermediates/prebuilt_com.android.foo.v2.deapexer/android_common/deapexer/javalib/framework-foo.jar",
+ expectedBootJar: "out/soong/.intermediates/com.android.foo.v2/android_common_com.android.foo/deapexer/javalib/framework-foo.jar",
},
}
diff --git a/apex/bootclasspath_fragment_test.go b/apex/bootclasspath_fragment_test.go
index df7857f..e44d3f5 100644
--- a/apex/bootclasspath_fragment_test.go
+++ b/apex/bootclasspath_fragment_test.go
@@ -398,11 +398,20 @@
// Make sure that a preferred prebuilt with consistent contents doesn't affect the apex.
addPrebuilt(true, "foo", "bar"),
+ android.FixtureMergeMockFs(android.MockFS{
+ "apex_contributions/Android.bp": []byte(`
+ apex_contributions {
+ name: "prebuilt_art_contributions",
+ contents: ["prebuilt_com.android.art"],
+ api_domain: "com.android.art",
+ }
+ `)}),
+ android.PrepareForTestWithBuildFlag("RELEASE_APEX_CONTRIBUTIONS_ART", "prebuilt_art_contributions"),
java.FixtureSetBootImageInstallDirOnDevice("art", "apex/com.android.art/javalib"),
).RunTest(t)
- ensureExactDeapexedContents(t, result.TestContext, "prebuilt_com.android.art", "android_common", []string{
+ ensureExactDeapexedContents(t, result.TestContext, "prebuilt_com.android.art", "android_common_com.android.art", []string{
"etc/boot-image.prof",
"javalib/bar.jar",
"javalib/foo.jar",
@@ -495,6 +504,7 @@
java.FixtureConfigureBootJars("com.android.art:foo", "com.android.art:bar"),
dexpreopt.FixtureSetTestOnlyArtBootImageJars("com.android.art:foo", "com.android.art:bar"),
java.FixtureSetBootImageInstallDirOnDevice("art", "apex/com.android.art/javalib"),
+ android.PrepareForTestWithBuildFlag("RELEASE_APEX_CONTRIBUTIONS_ART", "prebuilt_art_contributions"),
)
bp := `
@@ -552,6 +562,12 @@
src: "com.mycompany.android.art.apex",
exported_bootclasspath_fragments: ["art-bootclasspath-fragment"],
}
+
+ apex_contributions {
+ name: "prebuilt_art_contributions",
+ contents: ["prebuilt_com.android.art"],
+ api_domain: "com.android.art",
+ }
`
t.Run("disabled alternative APEX", func(t *testing.T) {
@@ -561,27 +577,18 @@
`all_apex_contributions`,
`dex2oatd`,
`prebuilt_art-bootclasspath-fragment`,
- `prebuilt_com.android.art.apex.selector`,
- `prebuilt_com.android.art.deapexer`,
})
java.CheckModuleDependencies(t, result.TestContext, "art-bootclasspath-fragment", "android_common_com.android.art", []string{
`all_apex_contributions`,
`dex2oatd`,
`prebuilt_bar`,
- `prebuilt_com.android.art.deapexer`,
`prebuilt_foo`,
})
module := result.ModuleForTests("dex_bootjars", "android_common")
checkCopiesToPredefinedLocationForArt(t, result.Config, module, "bar", "foo")
})
-
- t.Run("enabled alternative APEX", func(t *testing.T) {
- preparers.ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(
- "Multiple installable prebuilt APEXes provide ambiguous deapexers: prebuilt_com.android.art and prebuilt_com.mycompany.android.art")).
- RunTestWithBp(t, fmt.Sprintf(bp, ""))
- })
}
// checkCopiesToPredefinedLocationForArt checks that the supplied modules are copied to the
diff --git a/apex/deapexer.go b/apex/deapexer.go
index a673108..3b8233d 100644
--- a/apex/deapexer.go
+++ b/apex/deapexer.go
@@ -15,37 +15,9 @@
package apex
import (
- "strings"
-
"android/soong/android"
)
-// Contains 'deapexer' a private module type used by 'prebuilt_apex' to make dex files contained
-// within a .apex file referenced by `prebuilt_apex` available for use by their associated
-// `java_import` modules.
-//
-// An 'apex' module references `java_library` modules from which .dex files are obtained that are
-// stored in the resulting `.apex` file. The resulting `.apex` file is then made available as a
-// prebuilt by referencing it from a `prebuilt_apex`. For each such `java_library` that is used by
-// modules outside the `.apex` file a `java_import` prebuilt is made available referencing a jar
-// that contains the Java classes.
-//
-// When building a Java module type, e.g. `java_module` or `android_app` against such prebuilts the
-// `java_import` provides the classes jar (jar containing `.class` files) against which the
-// module's `.java` files are compiled. That classes jar usually contains only stub classes. The
-// resulting classes jar is converted into a dex jar (jar containing `.dex` files). Then if
-// necessary the dex jar is further processed by `dexpreopt` to produce an optimized form of the
-// library specific to the current Android version. This process requires access to implementation
-// dex jars for each `java_import`. The `java_import` will obtain the implementation dex jar from
-// the `.apex` file in the associated `prebuilt_apex`.
-//
-// This is intentionally not registered by name as it is not intended to be used from within an
-// `Android.bp` file.
-
-// DeapexerProperties specifies the properties supported by the deapexer module.
-//
-// As these are never intended to be supplied in a .bp file they use a different naming convention
-// to make it clear that they are different.
type DeapexerProperties struct {
// List of common modules that may need access to files exported by this module.
//
@@ -72,46 +44,9 @@
Selected_apex *string `android:"path" blueprint:"mutated"`
}
-type Deapexer struct {
- android.ModuleBase
-
- properties DeapexerProperties
- selectedApexProperties SelectedApexProperties
-
- inputApex android.Path
-}
-
-// Returns the name of the deapexer module corresponding to an APEX module with the given name.
-func deapexerModuleName(apexModuleName string) string {
- return apexModuleName + ".deapexer"
-}
-
-// Returns the name of the APEX module corresponding to an deapexer module with
-// the given name. This reverses deapexerModuleName.
-func apexModuleName(deapexerModuleName string) string {
- return strings.TrimSuffix(deapexerModuleName, ".deapexer")
-}
-
-func privateDeapexerFactory() android.Module {
- module := &Deapexer{}
- module.AddProperties(&module.properties, &module.selectedApexProperties)
- android.InitAndroidMultiTargetsArchModule(module, android.DeviceSupported, android.MultilibCommon)
- return module
-}
-
-func (p *Deapexer) DepsMutator(ctx android.BottomUpMutatorContext) {
- // Add dependencies from the java modules to which this exports files from the `.apex` file onto
- // this module so that they can access the `DeapexerInfo` object that this provides.
- // TODO: b/308174306 - Once all the mainline modules have been flagged, drop this dependency edge
- for _, lib := range p.properties.CommonModules {
- dep := prebuiltApexExportedModuleName(ctx, lib)
- ctx.AddReverseDependency(ctx.Module(), android.DeapexerTag, dep)
- }
-}
-
-func (p *Deapexer) GenerateAndroidBuildActions(ctx android.ModuleContext) {
- p.inputApex = android.OptionalPathForModuleSrc(ctx, p.selectedApexProperties.Selected_apex).Path()
-
+// deapex creates the build rules to deapex a prebuilt .apex file
+// it returns a pointer to a DeapexerInfo object
+func deapex(ctx android.ModuleContext, apexFile android.Path, deapexerProps DeapexerProperties) *android.DeapexerInfo {
// Create and remember the directory into which the .apex file's contents will be unpacked.
deapexerOutput := android.PathForModuleOut(ctx, "deapexer")
@@ -119,7 +54,7 @@
// Create mappings from apex relative path to the extracted file's path.
exportedPaths := make(android.Paths, 0, len(exports))
- for _, path := range p.properties.ExportedFiles {
+ for _, path := range deapexerProps.ExportedFiles {
// Populate the exports that this makes available.
extractedPath := deapexerOutput.Join(ctx, path)
exports[path] = extractedPath
@@ -131,9 +66,8 @@
// apex relative path to extracted file path available for other modules.
if len(exports) > 0 {
// Make the information available for other modules.
- di := android.NewDeapexerInfo(apexModuleName(ctx.ModuleName()), exports, p.properties.CommonModules)
- di.AddDexpreoptProfileGuidedExportedModuleNames(p.properties.DexpreoptProfileGuidedModules...)
- android.SetProvider(ctx, android.DeapexerProvider, di)
+ di := android.NewDeapexerInfo(ctx.ModuleName(), exports, deapexerProps.CommonModules)
+ di.AddDexpreoptProfileGuidedExportedModuleNames(deapexerProps.DexpreoptProfileGuidedModules...)
// Create a sorted list of the files that this exports.
exportedPaths = android.SortedUniquePaths(exportedPaths)
@@ -147,11 +81,13 @@
BuiltTool("deapexer").
BuiltTool("debugfs").
BuiltTool("fsck.erofs").
- Input(p.inputApex).
+ Input(apexFile).
Text(deapexerOutput.String())
for _, p := range exportedPaths {
command.Output(p.(android.WritablePath))
}
- builder.Build("deapexer", "deapex "+apexModuleName(ctx.ModuleName()))
+ builder.Build("deapexer", "deapex "+ctx.ModuleName())
+ return &di
}
+ return nil
}
diff --git a/apex/dexpreopt_bootjars_test.go b/apex/dexpreopt_bootjars_test.go
index d8ee4ba..4feade8 100644
--- a/apex/dexpreopt_bootjars_test.go
+++ b/apex/dexpreopt_bootjars_test.go
@@ -127,16 +127,29 @@
src: "com.android.art-arm.apex",
exported_bootclasspath_fragments: ["art-bootclasspath-fragment"],
}
+
+ apex_contributions {
+ name: "prebuilt_art_contributions",
+ contents: ["prebuilt_com.android.art"],
+ api_domain: "com.android.art",
+ }
`
- result := android.GroupFixturePreparers(
+ fixture := android.GroupFixturePreparers(
java.PrepareForTestWithDexpreopt,
java.PrepareForTestWithJavaSdkLibraryFiles,
java.FixtureWithLastReleaseApis("foo"),
java.FixtureConfigureBootJars("com.android.art:core-oj", "platform:foo", "system_ext:bar", "platform:baz"),
PrepareForTestWithApexBuildComponents,
prepareForTestWithArtApex,
- ).RunTestWithBp(t, fmt.Sprintf(bp, preferPrebuilt))
+ )
+ if preferPrebuilt {
+ fixture = android.GroupFixturePreparers(
+ fixture,
+ android.PrepareForTestWithBuildFlag("RELEASE_APEX_CONTRIBUTIONS_ART", "prebuilt_art_contributions"),
+ )
+ }
+ result := fixture.RunTestWithBp(t, fmt.Sprintf(bp, preferPrebuilt))
dexBootJars := result.ModuleForTests("dex_bootjars", "android_common")
rule := dexBootJars.Output(ruleFile)
@@ -200,7 +213,7 @@
"out/soong/dexpreopt_arm64/dex_bootjars_input/foo.jar",
"out/soong/dexpreopt_arm64/dex_bootjars_input/bar.jar",
"out/soong/dexpreopt_arm64/dex_bootjars_input/baz.jar",
- "out/soong/.intermediates/prebuilt_com.android.art.deapexer/android_common/deapexer/etc/boot-image.prof",
+ "out/soong/.intermediates/prebuilt_com.android.art/android_common_com.android.art/deapexer/etc/boot-image.prof",
"out/soong/.intermediates/default/java/dex_bootjars/android_common/boot/boot.prof",
"out/soong/dexpreopt/uffd_gc_flag.txt",
}
@@ -384,12 +397,12 @@
{
desc: "Prebuilt apex prebuilt_com.android.art is selected, profile should come from .prof deapexed from the prebuilt",
selectedArtApexContributions: "art.prebuilt.contributions",
- expectedProfile: "out/soong/.intermediates/prebuilt_com.android.art.deapexer/android_common/deapexer/etc/boot-image.prof",
+ expectedProfile: "out/soong/.intermediates/prebuilt_com.android.art/android_common_com.android.art/deapexer/etc/boot-image.prof",
},
{
desc: "Prebuilt apex prebuilt_com.android.art.v2 is selected, profile should come from .prof deapexed from the prebuilt",
selectedArtApexContributions: "art.prebuilt.v2.contributions",
- expectedProfile: "out/soong/.intermediates/prebuilt_com.android.art.v2.deapexer/android_common/deapexer/etc/boot-image.prof",
+ expectedProfile: "out/soong/.intermediates/com.android.art.v2/android_common_com.android.art/deapexer/etc/boot-image.prof",
},
}
for _, tc := range testCases {
diff --git a/apex/prebuilt.go b/apex/prebuilt.go
index f6f3efb..d3f14f9 100644
--- a/apex/prebuilt.go
+++ b/apex/prebuilt.go
@@ -194,9 +194,8 @@
}
// If this prebuilt has system server jar, create the rules to dexpreopt it and install it alongside the prebuilt apex
-func (p *prebuiltCommon) dexpreoptSystemServerJars(ctx android.ModuleContext) {
- // If this apex does not export anything, return
- if !p.hasExportedDeps() {
+func (p *prebuiltCommon) dexpreoptSystemServerJars(ctx android.ModuleContext, di *android.DeapexerInfo) {
+ if di == nil {
return
}
// If this prebuilt apex has not been selected, return
@@ -205,10 +204,7 @@
}
// Use apex_name to determine the api domain of this prebuilt apex
apexName := p.ApexVariationName()
- di, err := android.FindDeapexerProviderForModule(ctx)
- if err != nil {
- ctx.ModuleErrorf(err.Error())
- }
+ // TODO: do not compute twice
dc := dexpreopt.GetGlobalConfig(ctx)
systemServerJarList := dc.AllApexSystemServerJars(ctx)
@@ -257,6 +253,8 @@
return entriesList
}
+// DEPRECATED. // TODO (spandandas): Remove this interface.
+
// prebuiltApexModuleCreator defines the methods that need to be implemented by prebuilt_apex and
// apex_set in order to create the modules needed to provide access to the prebuilt .apex file.
type prebuiltApexModuleCreator interface {
@@ -403,34 +401,6 @@
}
}
-// prebuiltApexSelectorModule is a private module type that is only created by the prebuilt_apex
-// module. It selects the apex to use and makes it available for use by prebuilt_apex and the
-// deapexer.
-type prebuiltApexSelectorModule struct {
- android.ModuleBase
-
- apexFileProperties ApexFileProperties
-
- inputApex android.Path
-}
-
-func privateApexSelectorModuleFactory() android.Module {
- module := &prebuiltApexSelectorModule{}
- module.AddProperties(
- &module.apexFileProperties,
- )
- android.InitAndroidMultiTargetsArchModule(module, android.DeviceSupported, android.MultilibCommon)
- return module
-}
-
-func (p *prebuiltApexSelectorModule) Srcs() android.Paths {
- return android.Paths{p.inputApex}
-}
-
-func (p *prebuiltApexSelectorModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
- p.inputApex = android.SingleSourcePathFromSupplier(ctx, p.apexFileProperties.prebuiltApexSelector, "src")
-}
-
type Prebuilt struct {
prebuiltCommon
@@ -473,11 +443,11 @@
// to use methods on it that are specific to the current module.
//
// See the ApexFileProperties.Src property.
-func (p *ApexFileProperties) prebuiltApexSelector(ctx android.BaseModuleContext, prebuilt android.Module) []string {
+func (p *ApexFileProperties) prebuiltApexSelector(ctx android.BaseModuleContext, prebuilt android.Module) string {
multiTargets := prebuilt.MultiTargets()
if len(multiTargets) != 1 {
ctx.OtherModuleErrorf(prebuilt, "compile_multilib shouldn't be \"both\" for prebuilt_apex")
- return nil
+ return ""
}
var src string
switch multiTargets[0].Arch.ArchType {
@@ -510,7 +480,7 @@
// logic from reporting a more general, less useful message.
}
- return []string{src}
+ return src
}
type PrebuiltProperties struct {
@@ -527,35 +497,19 @@
func PrebuiltFactory() android.Module {
module := &Prebuilt{}
module.AddProperties(&module.properties)
- module.initPrebuiltCommon(module, &module.properties.PrebuiltCommonProperties)
+ module.prebuiltCommon.prebuiltCommonProperties = &module.properties.PrebuiltCommonProperties
+
+ // init the module as a prebuilt
+ // even though this module type has srcs, use `InitPrebuiltModuleWithoutSrcs`, since the existing
+ // InitPrebuiltModule* are not friendly with Sources of Configurable type.
+ // The actual src will be evaluated in GenerateAndroidBuildActions.
+ android.InitPrebuiltModuleWithoutSrcs(module)
+ android.InitAndroidMultiTargetsArchModule(module, android.DeviceSupported, android.MultilibCommon)
return module
}
-func createApexSelectorModule(ctx android.BottomUpMutatorContext, name string, apexFileProperties *ApexFileProperties) {
- props := struct {
- Name *string
- }{
- Name: proptools.StringPtr(name),
- }
-
- ctx.CreateModule(privateApexSelectorModuleFactory,
- &props,
- apexFileProperties,
- )
-}
-
-// createDeapexerModuleIfNeeded will create a deapexer module if it is needed.
-//
-// A deapexer module is only needed when the prebuilt apex specifies one or more modules in either
-// the `exported_bootclasspath_fragments` properties as that indicates that
-// the listed modules need access to files from within the prebuilt .apex file.
-func (p *prebuiltCommon) createDeapexerModuleIfNeeded(ctx android.BottomUpMutatorContext, deapexerName string, apexFileSource string) {
- // Only create the deapexer module if it is needed.
- if !p.hasExportedDeps() {
- return
- }
-
+func (p *prebuiltCommon) getDeapexerPropertiesIfNeeded(ctx android.ModuleContext) DeapexerProperties {
// Compute the deapexer properties from the transitive dependencies of this module.
commonModules := []string{}
dexpreoptProfileGuidedModules := []string{}
@@ -589,7 +543,7 @@
})
// Create properties for deapexer module.
- deapexerProperties := &DeapexerProperties{
+ deapexerProperties := DeapexerProperties{
// Remove any duplicates from the common modules lists as a module may be included via a direct
// dependency as well as transitive ones.
CommonModules: android.SortedUniqueStrings(commonModules),
@@ -598,22 +552,7 @@
// Populate the exported files property in a fixed order.
deapexerProperties.ExportedFiles = android.SortedUniqueStrings(exportedFiles)
-
- props := struct {
- Name *string
- Selected_apex *string
- }{
- Name: proptools.StringPtr(deapexerName),
- Selected_apex: proptools.StringPtr(apexFileSource),
- }
- ctx.CreateModule(privateDeapexerFactory,
- &props,
- deapexerProperties,
- )
-}
-
-func apexSelectorModuleName(baseModuleName string) string {
- return baseModuleName + ".apex.selector"
+ return deapexerProperties
}
func prebuiltApexExportedModuleName(ctx android.BottomUpMutatorContext, name string) string {
@@ -659,92 +598,46 @@
exportedSystemserverclasspathFragmentTag = exportedDependencyTag{name: "exported_systemserverclasspath_fragments"}
)
-var _ prebuiltApexModuleCreator = (*Prebuilt)(nil)
-
-// createPrebuiltApexModules creates modules necessary to export files from the prebuilt apex to the
-// build.
-//
-// If this needs to make files from within a `.apex` file available for use by other Soong modules,
-// e.g. make dex implementation jars available for `contents` listed in exported_bootclasspath_fragments,
-// it does so as follows:
-//
-// 1. It creates a `deapexer` module that actually extracts the files from the `.apex` file and
-// makes them available for use by other modules, at both Soong and ninja levels.
-//
-// 2. It adds a dependency onto those modules and creates an apex specific variant similar to what
-// an `apex` module does. That ensures that code which looks for specific apex variant, e.g.
-// dexpreopt, will work the same way from source and prebuilt.
-//
-// 3. The `deapexer` module adds a dependency from the modules that require the exported files onto
-// itself so that they can retrieve the file paths to those files.
-//
-// It also creates a child module `selector` that is responsible for selecting the appropriate
-// input apex for both the prebuilt_apex and the deapexer. That is needed for a couple of reasons:
-//
-// 1. To dedup the selection logic so it only runs in one module.
-//
-// 2. To allow the deapexer to be wired up to a different source for the input apex, e.g. an
-// `apex_set`.
-//
-// prebuilt_apex
-// / | \
-// / | \
-// V V V
-// selector <--- deapexer <--- exported java lib
-func (p *Prebuilt) createPrebuiltApexModules(ctx android.BottomUpMutatorContext) {
- apexSelectorModuleName := apexSelectorModuleName(p.Name())
- createApexSelectorModule(ctx, apexSelectorModuleName, &p.properties.ApexFileProperties)
-
- apexFileSource := ":" + apexSelectorModuleName
- p.createDeapexerModuleIfNeeded(ctx, deapexerModuleName(p.Name()), apexFileSource)
-
- // Add a source reference to retrieve the selected apex from the selector module.
- p.prebuiltCommonProperties.Selected_apex = proptools.StringPtr(apexFileSource)
-}
-
func (p *Prebuilt) ComponentDepsMutator(ctx android.BottomUpMutatorContext) {
p.prebuiltApexContentsDeps(ctx)
}
-func (p *prebuiltCommon) DepsMutator(ctx android.BottomUpMutatorContext) {
- if p.hasExportedDeps() {
- // Create a dependency from the prebuilt apex (prebuilt_apex/apex_set) to the internal deapexer module
- // The deapexer will return a provider which will be used to determine the exported artfifacts from this prebuilt.
- ctx.AddDependency(ctx.Module(), android.DeapexerTag, deapexerModuleName(p.Name()))
- }
-}
-
var _ ApexInfoMutator = (*Prebuilt)(nil)
func (p *Prebuilt) ApexInfoMutator(mctx android.TopDownMutatorContext) {
p.apexInfoMutator(mctx)
}
+// creates the build rules to deapex the prebuilt, and returns a deapexerInfo
+func (p *prebuiltCommon) getDeapexerInfo(ctx android.ModuleContext, apexFile android.Path) *android.DeapexerInfo {
+ if !p.hasExportedDeps() {
+ // nothing to do
+ return nil
+ }
+ deapexerProps := p.getDeapexerPropertiesIfNeeded(ctx)
+ return deapex(ctx, apexFile, deapexerProps)
+}
+
// Set a provider containing information about the jars and .prof provided by the apex
// Apexes built from prebuilts retrieve this information by visiting its internal deapexer module
// Used by dex_bootjars to generate the boot image
-func (p *prebuiltCommon) provideApexExportsInfo(ctx android.ModuleContext) {
- if !p.hasExportedDeps() {
- // nothing to do
+func (p *prebuiltCommon) provideApexExportsInfo(ctx android.ModuleContext, di *android.DeapexerInfo) {
+ if di == nil {
return
}
- if di, err := android.FindDeapexerProviderForModule(ctx); err == nil {
- javaModuleToDexPath := map[string]android.Path{}
- for _, commonModule := range di.GetExportedModuleNames() {
- if dex := di.PrebuiltExportPath(java.ApexRootRelativePathToJavaLib(commonModule)); dex != nil {
- javaModuleToDexPath[commonModule] = dex
- }
+ javaModuleToDexPath := map[string]android.Path{}
+ for _, commonModule := range di.GetExportedModuleNames() {
+ if dex := di.PrebuiltExportPath(java.ApexRootRelativePathToJavaLib(commonModule)); dex != nil {
+ javaModuleToDexPath[commonModule] = dex
}
-
- exports := android.ApexExportsInfo{
- ApexName: p.ApexVariationName(),
- ProfilePathOnHost: di.PrebuiltExportPath(java.ProfileInstallPathInApex),
- LibraryNameToDexJarPathOnHost: javaModuleToDexPath,
- }
- android.SetProvider(ctx, android.ApexExportsInfoProvider, exports)
- } else {
- ctx.ModuleErrorf(err.Error())
}
+
+ exports := android.ApexExportsInfo{
+ ApexName: p.ApexVariationName(),
+ ProfilePathOnHost: di.PrebuiltExportPath(java.ProfileInstallPathInApex),
+ LibraryNameToDexJarPathOnHost: javaModuleToDexPath,
+ }
+ android.SetProvider(ctx, android.ApexExportsInfoProvider, exports)
}
// Set prebuiltInfoProvider. This will be used by `apex_prebuiltinfo_singleton` to print out a metadata file
@@ -780,7 +673,7 @@
p.apexKeysPath = writeApexKeys(ctx, p)
// TODO(jungjw): Check the key validity.
- p.inputApex = android.OptionalPathForModuleSrc(ctx, p.prebuiltCommonProperties.Selected_apex).Path()
+ p.inputApex = android.PathForModuleSrc(ctx, p.properties.prebuiltApexSelector(ctx, ctx.Module()))
p.installDir = android.PathForModuleInstall(ctx, "apex")
p.installFilename = p.InstallFilename()
if !strings.HasSuffix(p.installFilename, imageApexSuffix) {
@@ -798,11 +691,13 @@
return
}
+ deapexerInfo := p.getDeapexerInfo(ctx, p.inputApex)
+
// dexpreopt any system server jars if present
- p.dexpreoptSystemServerJars(ctx)
+ p.dexpreoptSystemServerJars(ctx, deapexerInfo)
// provide info used for generating the boot image
- p.provideApexExportsInfo(ctx)
+ p.provideApexExportsInfo(ctx, deapexerInfo)
p.providePrebuiltInfo(ctx)
@@ -838,26 +733,11 @@
extractedApex android.WritablePath
}
-func privateApexExtractorModuleFactory() android.Module {
- module := &prebuiltApexExtractorModule{}
- module.AddProperties(
- &module.properties,
- )
- android.InitAndroidMultiTargetsArchModule(module, android.DeviceSupported, android.MultilibCommon)
- return module
-}
-
-func (p *prebuiltApexExtractorModule) Srcs() android.Paths {
- return android.Paths{p.extractedApex}
-}
-
-func (p *prebuiltApexExtractorModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
- srcsSupplier := func(ctx android.BaseModuleContext, prebuilt android.Module) []string {
- return p.properties.prebuiltSrcs(ctx)
- }
+// extract registers the build actions to extract an apex from .apks file
+// returns the path of the extracted apex
+func extract(ctx android.ModuleContext, apexSet android.Path, prerelease *bool) android.Path {
defaultAllowPrerelease := ctx.Config().IsEnvTrue("SOONG_ALLOW_PRERELEASE_APEXES")
- apexSet := android.SingleSourcePathFromSupplier(ctx, srcsSupplier, "set")
- p.extractedApex = android.PathForModuleOut(ctx, "extracted", apexSet.Base())
+ extractedApex := android.PathForModuleOut(ctx, "extracted", apexSet.Base())
// Filter out NativeBridge archs (b/260115309)
abis := java.SupportedAbis(ctx, true)
ctx.Build(pctx,
@@ -865,14 +745,16 @@
Rule: extractMatchingApex,
Description: "Extract an apex from an apex set",
Inputs: android.Paths{apexSet},
- Output: p.extractedApex,
+ Output: extractedApex,
Args: map[string]string{
"abis": strings.Join(abis, ","),
- "allow-prereleased": strconv.FormatBool(proptools.BoolDefault(p.properties.Prerelease, defaultAllowPrerelease)),
+ "allow-prereleased": strconv.FormatBool(proptools.BoolDefault(prerelease, defaultAllowPrerelease)),
"sdk-version": ctx.Config().PlatformSdkVersion().String(),
"skip-sdk-check": strconv.FormatBool(ctx.Config().IsEnvTrue("SOONG_SKIP_APPSET_SDK_CHECK")),
},
- })
+ },
+ )
+ return extractedApex
}
type ApexSet struct {
@@ -941,48 +823,18 @@
func apexSetFactory() android.Module {
module := &ApexSet{}
module.AddProperties(&module.properties)
- module.initPrebuiltCommon(module, &module.properties.PrebuiltCommonProperties)
+ module.prebuiltCommon.prebuiltCommonProperties = &module.properties.PrebuiltCommonProperties
+
+ // init the module as a prebuilt
+ // even though this module type has srcs, use `InitPrebuiltModuleWithoutSrcs`, since the existing
+ // InitPrebuiltModule* are not friendly with Sources of Configurable type.
+ // The actual src will be evaluated in GenerateAndroidBuildActions.
+ android.InitPrebuiltModuleWithoutSrcs(module)
+ android.InitAndroidMultiTargetsArchModule(module, android.DeviceSupported, android.MultilibCommon)
return module
}
-func createApexExtractorModule(ctx android.BottomUpMutatorContext, name string, apexExtractorProperties *ApexExtractorProperties) {
- props := struct {
- Name *string
- }{
- Name: proptools.StringPtr(name),
- }
-
- ctx.CreateModule(privateApexExtractorModuleFactory,
- &props,
- apexExtractorProperties,
- )
-}
-
-func apexExtractorModuleName(baseModuleName string) string {
- return baseModuleName + ".apex.extractor"
-}
-
-var _ prebuiltApexModuleCreator = (*ApexSet)(nil)
-
-// createPrebuiltApexModules creates modules necessary to export files from the apex set to other
-// modules.
-//
-// This effectively does for apex_set what Prebuilt.createPrebuiltApexModules does for a
-// prebuilt_apex except that instead of creating a selector module which selects one .apex file
-// from those provided this creates an extractor module which extracts the appropriate .apex file
-// from the zip file containing them.
-func (a *ApexSet) createPrebuiltApexModules(ctx android.BottomUpMutatorContext) {
- apexExtractorModuleName := apexExtractorModuleName(a.Name())
- createApexExtractorModule(ctx, apexExtractorModuleName, &a.properties.ApexExtractorProperties)
-
- apexFileSource := ":" + apexExtractorModuleName
- a.createDeapexerModuleIfNeeded(ctx, deapexerModuleName(a.Name()), apexFileSource)
-
- // After passing the arch specific src properties to the creating the apex selector module
- a.prebuiltCommonProperties.Selected_apex = proptools.StringPtr(apexFileSource)
-}
-
func (a *ApexSet) ComponentDepsMutator(ctx android.BottomUpMutatorContext) {
a.prebuiltApexContentsDeps(ctx)
}
@@ -1005,7 +857,15 @@
ctx.ModuleErrorf("filename should end in %s or %s for apex_set", imageApexSuffix, imageCapexSuffix)
}
- inputApex := android.OptionalPathForModuleSrc(ctx, a.prebuiltCommonProperties.Selected_apex).Path()
+ var apexSet android.Path
+ if srcs := a.properties.prebuiltSrcs(ctx); len(srcs) == 1 {
+ apexSet = android.PathForModuleSrc(ctx, srcs[0])
+ } else {
+ ctx.ModuleErrorf("Expected exactly one source apex_set file, found %v\n", srcs)
+ }
+
+ extractedApex := extract(ctx, apexSet, a.properties.Prerelease)
+
a.outputApex = android.PathForModuleOut(ctx, a.installFilename)
// Build the output APEX. If compression is not enabled, make sure the output is not compressed even if the input is compressed
@@ -1015,7 +875,7 @@
}
ctx.Build(pctx, android.BuildParams{
Rule: buildRule,
- Input: inputApex,
+ Input: extractedApex,
Output: a.outputApex,
})
@@ -1024,11 +884,13 @@
return
}
+ deapexerInfo := a.getDeapexerInfo(ctx, extractedApex)
+
// dexpreopt any system server jars if present
- a.dexpreoptSystemServerJars(ctx)
+ a.dexpreoptSystemServerJars(ctx, deapexerInfo)
// provide info used for generating the boot image
- a.provideApexExportsInfo(ctx)
+ a.provideApexExportsInfo(ctx, deapexerInfo)
a.providePrebuiltInfo(ctx)
diff --git a/apex/systemserver_classpath_fragment_test.go b/apex/systemserver_classpath_fragment_test.go
index fd9020b..acb3649 100644
--- a/apex/systemserver_classpath_fragment_test.go
+++ b/apex/systemserver_classpath_fragment_test.go
@@ -277,8 +277,6 @@
java.CheckModuleDependencies(t, ctx, "myapex", "android_common_myapex", []string{
`all_apex_contributions`,
`dex2oatd`,
- `prebuilt_myapex.apex.selector`,
- `prebuilt_myapex.deapexer`,
`prebuilt_mysystemserverclasspathfragment`,
})
@@ -286,10 +284,9 @@
`all_apex_contributions`,
`prebuilt_bar`,
`prebuilt_foo`,
- `prebuilt_myapex.deapexer`,
})
- ensureExactDeapexedContents(t, ctx, "prebuilt_myapex", "android_common", []string{
+ ensureExactDeapexedContents(t, ctx, "myapex", "android_common_myapex", []string{
"javalib/foo.jar",
"javalib/bar.jar",
"javalib/bar.jar.prof",
@@ -439,10 +436,9 @@
`all_apex_contributions`,
`prebuilt_bar`,
`prebuilt_foo`,
- `prebuilt_myapex.deapexer`,
})
- ensureExactDeapexedContents(t, ctx, "prebuilt_myapex", "android_common", []string{
+ ensureExactDeapexedContents(t, ctx, "myapex", "android_common_myapex", []string{
"javalib/foo.jar",
"javalib/bar.jar",
"javalib/bar.jar.prof",
diff --git a/java/app_test.go b/java/app_test.go
index ec97a55..d7f5f0c 100644
--- a/java/app_test.go
+++ b/java/app_test.go
@@ -3241,7 +3241,7 @@
java_library {
name: "static-runtime-helper",
srcs: ["a.java"],
- libs: ["runtime-library"],
+ libs: ["runtime-library.impl"],
sdk_version: "current",
}
@@ -3305,7 +3305,7 @@
name: "app",
srcs: ["a.java"],
libs: [
- "qux",
+ "qux.impl",
"quuz.stubs"
],
static_libs: [
diff --git a/java/base.go b/java/base.go
index 86ed0e7..b64eb5b 100644
--- a/java/base.go
+++ b/java/base.go
@@ -2414,18 +2414,13 @@
return
}
- if dep, ok := module.(SdkLibraryDependency); ok {
+ if _, ok := module.(SdkLibraryDependency); ok {
switch tag {
- case sdkLibTag, libTag:
- depHeaderJars := dep.SdkHeaderJars(ctx, j.SdkVersion(ctx))
- deps.classpath = append(deps.classpath, depHeaderJars...)
- deps.dexClasspath = append(deps.dexClasspath, depHeaderJars...)
-
- // TODO: SDK libraries should export a provider with TransitiveClasspathHeaderJars
- depHeaderJarsSet := android.NewDepSet(android.PREORDER, depHeaderJars, nil)
- transitiveClasspathHeaderJars = append(transitiveClasspathHeaderJars, depHeaderJarsSet)
- case staticLibTag:
- ctx.ModuleErrorf("dependency on java_sdk_library %q can only be in libs", otherName)
+ case sdkLibTag, libTag, staticLibTag:
+ sdkInfo, _ := android.OtherModuleProvider(ctx, module, SdkLibraryInfoProvider)
+ generatingLibsString := android.PrettyConcat(
+ getGeneratingLibs(ctx, j.SdkVersion(ctx), module.Name(), sdkInfo), true, "or")
+ ctx.ModuleErrorf("cannot depend directly on java_sdk_library %q; try depending on %s instead", module.Name(), generatingLibsString)
}
} else if dep, ok := android.OtherModuleProvider(ctx, module, JavaInfoProvider); ok {
if sdkLinkType != javaPlatform {
diff --git a/java/bootclasspath_fragment.go b/java/bootclasspath_fragment.go
index fe4cc76..4fcd40b 100644
--- a/java/bootclasspath_fragment.go
+++ b/java/bootclasspath_fragment.go
@@ -414,6 +414,12 @@
// Cross-cutting metadata dependencies are metadata.
return false
}
+ // Dependency to the bootclasspath fragment of another apex
+ // e.g. concsrypt-bootclasspath-fragment --> art-bootclasspath-fragment
+ if tag == bootclasspathFragmentDepTag {
+ return false
+
+ }
panic(fmt.Errorf("boot_image module %q should not have a dependency on %q via tag %s", b, dep, android.PrettyPrintTag(tag)))
}
@@ -1099,22 +1105,10 @@
return &output
}
+// DEPRECATED: this information is now generated in the context of the top level prebuilt apex.
// produceBootImageProfile extracts the boot image profile from the APEX if available.
func (module *PrebuiltBootclasspathFragmentModule) produceBootImageProfile(ctx android.ModuleContext) android.WritablePath {
- // This module does not provide a boot image profile.
- if module.getProfileProviderApex(ctx) == "" {
- return nil
- }
-
- di, err := android.FindDeapexerProviderForModule(ctx)
- if err != nil {
- // An error was found, possibly due to multiple apexes in the tree that export this library
- // Defer the error till a client tries to call getProfilePath
- module.profilePathErr = err
- return nil // An error has been reported by FindDeapexerProviderForModule.
- }
-
- return di.PrebuiltExportPath(ProfileInstallPathInApex)
+ return android.PathForModuleInstall(ctx, "intentionally_no_longer_supported")
}
func (b *PrebuiltBootclasspathFragmentModule) getProfilePath() android.Path {
diff --git a/java/droiddoc.go b/java/droiddoc.go
index 2929bb8..a7e92d9 100644
--- a/java/droiddoc.go
+++ b/java/droiddoc.go
@@ -373,8 +373,11 @@
panic(fmt.Errorf("unknown dependency %q for %q", otherName, ctx.ModuleName()))
}
case libTag, sdkLibTag:
- if dep, ok := module.(SdkLibraryDependency); ok {
- deps.classpath = append(deps.classpath, dep.SdkHeaderJars(ctx, j.SdkVersion(ctx))...)
+ if _, ok := module.(SdkLibraryDependency); ok {
+ sdkInfo, _ := android.OtherModuleProvider(ctx, module, SdkLibraryInfoProvider)
+ generatingLibsString := android.PrettyConcat(
+ getGeneratingLibs(ctx, j.SdkVersion(ctx), module.Name(), sdkInfo), true, "or")
+ ctx.ModuleErrorf("cannot depend directly on java_sdk_library %q; try depending on %s instead", module.Name(), generatingLibsString)
} else if dep, ok := android.OtherModuleProvider(ctx, module, JavaInfoProvider); ok {
deps.classpath = append(deps.classpath, dep.HeaderJars...)
deps.aidlIncludeDirs = append(deps.aidlIncludeDirs, dep.AidlIncludeDirs...)
diff --git a/java/java.go b/java/java.go
index d63bbe6..91c4d6d 100644
--- a/java/java.go
+++ b/java/java.go
@@ -2700,13 +2700,13 @@
transitiveBootClasspathHeaderJars = append(transitiveBootClasspathHeaderJars, dep.TransitiveStaticLibsHeaderJars)
}
}
- } else if dep, ok := module.(SdkLibraryDependency); ok {
+ } else if _, ok := module.(SdkLibraryDependency); ok {
switch tag {
case libTag, sdkLibTag:
- depHeaderJars := dep.SdkHeaderJars(ctx, j.SdkVersion(ctx))
- flags.classpath = append(flags.classpath, depHeaderJars...)
- transitiveClasspathHeaderJars = append(transitiveClasspathHeaderJars,
- android.NewDepSet(android.PREORDER, depHeaderJars, nil))
+ sdkInfo, _ := android.OtherModuleProvider(ctx, module, SdkLibraryInfoProvider)
+ generatingLibsString := android.PrettyConcat(
+ getGeneratingLibs(ctx, j.SdkVersion(ctx), module.Name(), sdkInfo), true, "or")
+ ctx.ModuleErrorf("cannot depend directly on java_sdk_library %q; try depending on %s instead", module.Name(), generatingLibsString)
}
}
@@ -2818,41 +2818,14 @@
}
if ctx.Device() {
- // If this is a variant created for a prebuilt_apex then use the dex implementation jar
- // obtained from the associated deapexer module.
+ // Shared libraries deapexed from prebuilt apexes are no longer supported.
+ // Set the dexJarBuildPath to a fake path.
+ // This allows soong analysis pass, but will be an error during ninja execution if there are
+ // any rdeps.
ai, _ := android.ModuleProvider(ctx, android.ApexInfoProvider)
if ai.ForPrebuiltApex {
- // Get the path of the dex implementation jar from the `deapexer` module.
- di, err := android.FindDeapexerProviderForModule(ctx)
- if err != nil {
- // An error was found, possibly due to multiple apexes in the tree that export this library
- // Defer the error till a client tries to call DexJarBuildPath
- j.dexJarFileErr = err
- j.initHiddenAPIError(err)
- return
- }
- dexJarFileApexRootRelative := ApexRootRelativePathToJavaLib(j.BaseModuleName())
- if dexOutputPath := di.PrebuiltExportPath(dexJarFileApexRootRelative); dexOutputPath != nil {
- dexJarFile := makeDexJarPathFromPath(dexOutputPath)
- j.dexJarFile = dexJarFile
- installPath := android.PathForModuleInPartitionInstall(ctx, "apex", ai.ApexVariationName, ApexRootRelativePathToJavaLib(j.BaseModuleName()))
- j.dexJarInstallFile = installPath
-
- j.dexpreopter.installPath = j.dexpreopter.getInstallPath(ctx, android.RemoveOptionalPrebuiltPrefix(ctx.ModuleName()), installPath)
- setUncompressDex(ctx, &j.dexpreopter, &j.dexer)
- j.dexpreopter.uncompressedDex = *j.dexProperties.Uncompress_dex
-
- if profilePath := di.PrebuiltExportPath(dexJarFileApexRootRelative + ".prof"); profilePath != nil {
- j.dexpreopter.inputProfilePathOnHost = profilePath
- }
-
- // Initialize the hiddenapi structure.
- j.initHiddenAPI(ctx, dexJarFile, outputFile, j.dexProperties.Uncompress_dex)
- } else {
- // This should never happen as a variant for a prebuilt_apex is only created if the
- // prebuilt_apex has been configured to export the java library dex file.
- ctx.ModuleErrorf("internal error: no dex implementation jar available from prebuilt APEX %s", di.ApexModuleName())
- }
+ j.dexJarFile = makeDexJarPathFromPath(android.PathForModuleInstall(ctx, "intentionally_no_longer_supported"))
+ j.initHiddenAPI(ctx, j.dexJarFile, outputFile, j.dexProperties.Uncompress_dex)
} else if Bool(j.dexProperties.Compile_dex) {
sdkDep := decodeSdkDep(ctx, android.SdkContext(j))
if sdkDep.invalidVersion {
diff --git a/java/java_test.go b/java/java_test.go
index c13db3e..e0fd0f2 100644
--- a/java/java_test.go
+++ b/java/java_test.go
@@ -670,7 +670,7 @@
java_library {
name: "foo",
srcs: ["a.java", ":stubs-source"],
- libs: ["bar", "sdklib"],
+ libs: ["bar", "sdklib.stubs"],
static_libs: ["baz"],
}
diff --git a/java/prebuilt_apis.go b/java/prebuilt_apis.go
index 00613ee..527e479 100644
--- a/java/prebuilt_apis.go
+++ b/java/prebuilt_apis.go
@@ -124,8 +124,8 @@
return
}
-func prebuiltApiModuleName(mctx android.LoadHookContext, module, scope, version string) string {
- return fmt.Sprintf("%s_%s_%s_%s", mctx.ModuleName(), scope, version, module)
+func prebuiltApiModuleName(moduleName, module, scope, version string) string {
+ return fmt.Sprintf("%s_%s_%s_%s", moduleName, scope, version, module)
}
func createImport(mctx android.LoadHookContext, module, scope, version, path, sdkVersion string, compileDex bool) {
props := struct {
@@ -135,7 +135,7 @@
Installable *bool
Compile_dex *bool
}{
- Name: proptools.StringPtr(prebuiltApiModuleName(mctx, module, scope, version)),
+ Name: proptools.StringPtr(prebuiltApiModuleName(mctx.ModuleName(), module, scope, version)),
Jars: []string{path},
Sdk_version: proptools.StringPtr(sdkVersion),
Installable: proptools.BoolPtr(false),
@@ -257,8 +257,8 @@
Name *string
Libs []string
}{}
- props.Name = proptools.StringPtr(prebuiltApiModuleName(mctx, "system_modules", scope, version))
- props.Libs = append(props.Libs, prebuiltApiModuleName(mctx, "core-for-system-modules", scope, version))
+ props.Name = proptools.StringPtr(prebuiltApiModuleName(mctx.ModuleName(), "system_modules", scope, version))
+ props.Libs = append(props.Libs, prebuiltApiModuleName(mctx.ModuleName(), "core-for-system-modules", scope, version))
mctx.CreateModule(systemModulesImportFactory, &props)
}
diff --git a/java/sdk_library.go b/java/sdk_library.go
index 9f0564a..bb0d7d0 100644
--- a/java/sdk_library.go
+++ b/java/sdk_library.go
@@ -268,10 +268,6 @@
return baseName + ".stubs.source" + scope.moduleSuffix
}
-func (scope *apiScope) apiModuleName(baseName string) string {
- return baseName + ".api" + scope.moduleSuffix
-}
-
func (scope *apiScope) String() string {
return scope.name
}
@@ -1082,21 +1078,6 @@
return nil
}
-func (c *commonToSdkLibraryAndImport) selectHeaderJarsForSdkVersion(ctx android.BaseModuleContext, sdkVersion android.SdkSpec) android.Paths {
-
- // If a specific numeric version has been requested then use prebuilt versions of the sdk.
- if !sdkVersion.ApiLevel.IsPreview() {
- return PrebuiltJars(ctx, c.module.RootLibraryName(), sdkVersion)
- }
-
- paths := c.selectScopePaths(ctx, sdkVersion.Kind)
- if paths == nil {
- return nil
- }
-
- return paths.stubsHeaderPath
-}
-
// selectScopePaths returns the *scopePaths appropriate for the specific kind.
//
// If the module does not support the specific kind then it will return the *scopePaths for the
@@ -1263,12 +1244,6 @@
type SdkLibraryDependency interface {
SdkLibraryComponentDependency
- // Get the header jars appropriate for the supplied sdk_version.
- //
- // These are turbine generated jars so they only change if the externals of the
- // class changes but it does not contain and implementation or JavaDoc.
- SdkHeaderJars(ctx android.BaseModuleContext, sdkVersion android.SdkSpec) android.Paths
-
// SdkApiStubDexJar returns the dex jar for the stubs for the prebuilt
// java_sdk_library_import module. It is needed by the hiddenapi processing tool which
// processes dex files.
@@ -1285,9 +1260,36 @@
// sharedLibrary returns true if this can be used as a shared library.
sharedLibrary() bool
+ // getImplLibraryModule returns the pointer to the implementation library submodule of this
+ // sdk library.
getImplLibraryModule() *Library
}
+type SdkLibraryInfo struct {
+ // GeneratingLibs is the names of the library modules that this sdk library
+ // generates. Note that this only includes the name of the modules that other modules can
+ // depend on, and is not a holistic list of generated modules.
+ GeneratingLibs []string
+}
+
+var SdkLibraryInfoProvider = blueprint.NewProvider[SdkLibraryInfo]()
+
+func getGeneratingLibs(ctx android.ModuleContext, sdkVersion android.SdkSpec, sdkLibraryModuleName string, sdkInfo SdkLibraryInfo) []string {
+ apiLevel := sdkVersion.ApiLevel
+ if apiLevel.IsPreview() {
+ return sdkInfo.GeneratingLibs
+ }
+
+ generatingPrebuilts := []string{}
+ for _, apiScope := range AllApiScopes {
+ scopePrebuiltModuleName := prebuiltApiModuleName("sdk", sdkLibraryModuleName, apiScope.name, apiLevel.String())
+ if ctx.OtherModuleExists(scopePrebuiltModuleName) {
+ generatingPrebuilts = append(generatingPrebuilts, scopePrebuiltModuleName)
+ }
+ }
+ return generatingPrebuilts
+}
+
type SdkLibrary struct {
Library
@@ -1610,9 +1612,22 @@
}
android.SetProvider(ctx, android.AdditionalSdkInfoProvider, android.AdditionalSdkInfo{additionalSdkInfo})
module.setOutputFiles(ctx)
+
+ var generatingLibs []string
+ for _, apiScope := range AllApiScopes {
+ if _, ok := module.scopePaths[apiScope]; ok {
+ generatingLibs = append(generatingLibs, module.stubsLibraryModuleName(apiScope))
+ }
+ }
+
if module.requiresRuntimeImplementationLibrary() && module.implLibraryModule != nil {
+ generatingLibs = append(generatingLibs, module.implLibraryModuleName())
setOutputFiles(ctx, module.implLibraryModule.Module)
}
+
+ android.SetProvider(ctx, SdkLibraryInfoProvider, SdkLibraryInfo{
+ GeneratingLibs: generatingLibs,
+ })
}
func (module *SdkLibrary) BuiltInstalledForApex() []dexpreopterInstall {
@@ -2192,72 +2207,6 @@
mctx.CreateModule(sdkLibraryXmlFactory, &props)
}
-func PrebuiltJars(ctx android.BaseModuleContext, baseName string, s android.SdkSpec) android.Paths {
- var ver android.ApiLevel
- var kind android.SdkKind
- if s.UsePrebuilt(ctx) {
- ver = s.ApiLevel
- kind = s.Kind
- } else {
- // We don't have prebuilt SDK for the specific sdkVersion.
- // Instead of breaking the build, fallback to use "system_current"
- ver = android.FutureApiLevel
- kind = android.SdkSystem
- }
-
- dir := filepath.Join("prebuilts", "sdk", ver.String(), kind.String())
- jar := filepath.Join(dir, baseName+".jar")
- jarPath := android.ExistentPathForSource(ctx, jar)
- if !jarPath.Valid() {
- if ctx.Config().AllowMissingDependencies() {
- return android.Paths{android.PathForSource(ctx, jar)}
- } else {
- ctx.PropertyErrorf("sdk_library", "invalid sdk version %q, %q does not exist", s.Raw, jar)
- }
- return nil
- }
- return android.Paths{jarPath.Path()}
-}
-
-// Check to see if the other module is within the same set of named APEXes as this module.
-//
-// If either this or the other module are on the platform then this will return
-// false.
-func withinSameApexesAs(ctx android.BaseModuleContext, other android.Module) bool {
- apexInfo, _ := android.ModuleProvider(ctx, android.ApexInfoProvider)
- otherApexInfo, _ := android.OtherModuleProvider(ctx, other, android.ApexInfoProvider)
- return len(otherApexInfo.InApexVariants) > 0 && reflect.DeepEqual(apexInfo.InApexVariants, otherApexInfo.InApexVariants)
-}
-
-func (module *SdkLibrary) sdkJars(ctx android.BaseModuleContext, sdkVersion android.SdkSpec) android.Paths {
- // If the client doesn't set sdk_version, but if this library prefers stubs over
- // the impl library, let's provide the widest API surface possible. To do so,
- // force override sdk_version to module_current so that the closest possible API
- // surface could be found in selectHeaderJarsForSdkVersion
- if module.defaultsToStubs() && !sdkVersion.Specified() {
- sdkVersion = android.SdkSpecFrom(ctx, "module_current")
- }
-
- // Only provide access to the implementation library if it is actually built.
- if module.requiresRuntimeImplementationLibrary() {
- // Check any special cases for java_sdk_library.
- //
- // Only allow access to the implementation library in the following condition:
- // * No sdk_version specified on the referencing module.
- // * The referencing module is in the same apex as this.
- if sdkVersion.Kind == android.SdkPrivate || withinSameApexesAs(ctx, module) {
- return module.implLibraryHeaderJars
- }
- }
-
- return module.selectHeaderJarsForSdkVersion(ctx, sdkVersion)
-}
-
-// to satisfy SdkLibraryDependency interface
-func (module *SdkLibrary) SdkHeaderJars(ctx android.BaseModuleContext, sdkVersion android.SdkSpec) android.Paths {
- return module.sdkJars(ctx, sdkVersion)
-}
-
var javaSdkLibrariesKey = android.NewOnceKey("javaSdkLibraries")
func javaSdkLibraries(config android.Config) *[]string {
@@ -2376,10 +2325,6 @@
return !proptools.Bool(module.sdkLibraryProperties.Api_only)
}
-func (module *SdkLibrary) defaultsToStubs() bool {
- return proptools.Bool(module.sdkLibraryProperties.Default_to_stubs)
-}
-
func moduleStubLinkType(j *Module) (stub bool, ret sdkLinkType) {
kind := android.ToSdkKind(proptools.String(j.properties.Stub_contributing_api))
switch kind {
@@ -2823,69 +2768,36 @@
}
if ctx.Device() {
- // If this is a variant created for a prebuilt_apex then use the dex implementation jar
- // obtained from the associated deapexer module.
+ // Shared libraries deapexed from prebuilt apexes are no longer supported.
+ // Set the dexJarBuildPath to a fake path.
+ // This allows soong analysis pass, but will be an error during ninja execution if there are
+ // any rdeps.
ai, _ := android.ModuleProvider(ctx, android.ApexInfoProvider)
if ai.ForPrebuiltApex {
- // Get the path of the dex implementation jar from the `deapexer` module.
- di, err := android.FindDeapexerProviderForModule(ctx)
- if err != nil {
- // An error was found, possibly due to multiple apexes in the tree that export this library
- // Defer the error till a client tries to call DexJarBuildPath
- module.dexJarFileErr = err
- module.initHiddenAPIError(err)
- return
- }
- dexJarFileApexRootRelative := ApexRootRelativePathToJavaLib(module.BaseModuleName())
- if dexOutputPath := di.PrebuiltExportPath(dexJarFileApexRootRelative); dexOutputPath != nil {
- dexJarFile := makeDexJarPathFromPath(dexOutputPath)
- module.dexJarFile = dexJarFile
- installPath := android.PathForModuleInPartitionInstall(
- ctx, "apex", ai.ApexVariationName, dexJarFileApexRootRelative)
- module.installFile = installPath
- module.initHiddenAPI(ctx, dexJarFile, module.findScopePaths(apiScopePublic).stubsImplPath[0], nil)
+ module.dexJarFile = makeDexJarPathFromPath(android.PathForModuleInstall(ctx, "intentionally_no_longer_supported"))
+ module.initHiddenAPI(ctx, module.dexJarFile, module.findScopePaths(apiScopePublic).stubsImplPath[0], nil)
+ }
+ }
- module.dexpreopter.installPath = module.dexpreopter.getInstallPath(ctx, android.RemoveOptionalPrebuiltPrefix(ctx.ModuleName()), installPath)
- module.dexpreopter.isSDKLibrary = true
- module.dexpreopter.uncompressedDex = shouldUncompressDex(ctx, android.RemoveOptionalPrebuiltPrefix(ctx.ModuleName()), &module.dexpreopter)
-
- if profilePath := di.PrebuiltExportPath(dexJarFileApexRootRelative + ".prof"); profilePath != nil {
- module.dexpreopter.inputProfilePathOnHost = profilePath
- }
- } else {
- // This should never happen as a variant for a prebuilt_apex is only created if the
- // prebuilt_apex has been configured to export the java library dex file.
- ctx.ModuleErrorf("internal error: no dex implementation jar available from prebuilt APEX %s", di.ApexModuleName())
+ var generatingLibs []string
+ for _, apiScope := range AllApiScopes {
+ if scopeProperties, ok := module.scopeProperties[apiScope]; ok {
+ if len(scopeProperties.Jars) == 0 {
+ continue
}
+ generatingLibs = append(generatingLibs, module.stubsLibraryModuleName(apiScope))
}
}
module.setOutputFiles(ctx)
if module.implLibraryModule != nil {
+ generatingLibs = append(generatingLibs, module.implLibraryModuleName())
setOutputFiles(ctx, module.implLibraryModule.Module)
}
-}
-func (module *SdkLibraryImport) sdkJars(ctx android.BaseModuleContext, sdkVersion android.SdkSpec, headerJars bool) android.Paths {
-
- // For consistency with SdkLibrary make the implementation jar available to libraries that
- // are within the same APEX.
- implLibraryModule := module.implLibraryModule
- if implLibraryModule != nil && withinSameApexesAs(ctx, module) {
- if headerJars {
- return implLibraryModule.HeaderJars()
- } else {
- return implLibraryModule.ImplementationJars()
- }
- }
-
- return module.selectHeaderJarsForSdkVersion(ctx, sdkVersion)
-}
-
-// to satisfy SdkLibraryDependency interface
-func (module *SdkLibraryImport) SdkHeaderJars(ctx android.BaseModuleContext, sdkVersion android.SdkSpec) android.Paths {
- // This module is just a wrapper for the prebuilt stubs.
- return module.sdkJars(ctx, sdkVersion, true)
+ android.SetProvider(ctx, SdkLibraryInfoProvider, SdkLibraryInfo{
+ GeneratingLibs: generatingLibs,
+ })
}
// to satisfy UsesLibraryDependency interface
diff --git a/java/sdk_library_test.go b/java/sdk_library_test.go
index 31fbc5a..6031d72 100644
--- a/java/sdk_library_test.go
+++ b/java/sdk_library_test.go
@@ -22,8 +22,6 @@
"testing"
"android/soong/android"
-
- "github.com/google/blueprint/proptools"
)
func TestJavaSdkLibrary(t *testing.T) {
@@ -55,7 +53,7 @@
java_library {
name: "baz",
srcs: ["c.java"],
- libs: ["foo", "bar.stubs"],
+ libs: ["foo.stubs.system", "bar.stubs"],
sdk_version: "system_current",
}
java_sdk_library {
@@ -92,25 +90,25 @@
java_library {
name: "qux",
srcs: ["c.java"],
- libs: ["baz", "fred", "quuz.stubs", "wilma", "barney", "betty"],
+ libs: ["baz", "fred.stubs", "quuz.stubs", "wilma.stubs", "barney.stubs.system", "betty.stubs.system"],
sdk_version: "system_current",
}
java_library {
name: "baz-test",
srcs: ["c.java"],
- libs: ["foo"],
+ libs: ["foo.stubs.test"],
sdk_version: "test_current",
}
java_library {
name: "baz-29",
srcs: ["c.java"],
- libs: ["foo"],
+ libs: ["sdk_system_29_foo"],
sdk_version: "system_29",
}
java_library {
name: "baz-module-30",
srcs: ["c.java"],
- libs: ["foo"],
+ libs: ["sdk_module-lib_30_foo"],
sdk_version: "module_30",
}
`)
@@ -162,11 +160,11 @@
baz29Javac := result.ModuleForTests("baz-29", "android_common").Rule("javac")
// tests if baz-29 is actually linked to the system 29 stubs lib
- android.AssertStringDoesContain(t, "baz-29 javac classpath", baz29Javac.Args["classpath"], "prebuilts/sdk/29/system/foo.jar")
+ android.AssertStringDoesContain(t, "baz-29 javac classpath", baz29Javac.Args["classpath"], "prebuilts/sdk/sdk_system_29_foo/android_common/combined/sdk_system_29_foo.jar")
bazModule30Javac := result.ModuleForTests("baz-module-30", "android_common").Rule("javac")
// tests if "baz-module-30" is actually linked to the module 30 stubs lib
- android.AssertStringDoesContain(t, "baz-module-30 javac classpath", bazModule30Javac.Args["classpath"], "prebuilts/sdk/30/module-lib/foo.jar")
+ android.AssertStringDoesContain(t, "baz-module-30 javac classpath", bazModule30Javac.Args["classpath"], "prebuilts/sdk/sdk_module-lib_30_foo/android_common/combined/sdk_module-lib_30_foo.jar")
// test if baz has exported SDK lib names foo and bar to qux
qux := result.ModuleForTests("qux", "android_common")
@@ -445,7 +443,7 @@
java_library {
name: "bar",
srcs: ["b.java"],
- libs: ["foo"],
+ libs: ["foo.stubs"],
}
`)
@@ -763,7 +761,7 @@
java_library {
name: "bar",
srcs: ["a.java"],
- libs: ["foo-public", "foo-system", "foo-module-lib", "foo-system-server"],
+ libs: ["foo-public.stubs", "foo-system.stubs.system", "foo-module-lib.stubs.module_lib", "foo-system-server.stubs.system_server"],
sdk_version: "system_server_current",
}
`)
@@ -789,102 +787,26 @@
}
}
-func TestJavaSdkLibrary_MissingScope(t *testing.T) {
- prepareForJavaTest.
- ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(`requires api scope module-lib from foo but it only has \[\] available`)).
- RunTestWithBp(t, `
- java_sdk_library {
- name: "foo",
- srcs: ["a.java"],
- public: {
- enabled: false,
- },
- }
-
- java_library {
- name: "baz",
- srcs: ["a.java"],
- libs: ["foo"],
- sdk_version: "module_current",
- }
- `)
-}
-
-func TestJavaSdkLibrary_FallbackScope(t *testing.T) {
- android.GroupFixturePreparers(
- prepareForJavaTest,
- PrepareForTestWithJavaSdkLibraryFiles,
- FixtureWithLastReleaseApis("foo"),
- ).RunTestWithBp(t, `
- java_sdk_library {
- name: "foo",
- srcs: ["a.java"],
- system: {
- enabled: true,
- },
- }
-
- java_library {
- name: "baz",
- srcs: ["a.java"],
- libs: ["foo"],
- // foo does not have module-lib scope so it should fallback to system
- sdk_version: "module_current",
- }
- `)
-}
-
-func TestJavaSdkLibrary_DefaultToStubs(t *testing.T) {
- result := android.GroupFixturePreparers(
- prepareForJavaTest,
- PrepareForTestWithJavaSdkLibraryFiles,
- FixtureWithLastReleaseApis("foo"),
- ).RunTestWithBp(t, `
- java_sdk_library {
- name: "foo",
- srcs: ["a.java"],
- system: {
- enabled: true,
- },
- default_to_stubs: true,
- }
-
- java_library {
- name: "baz",
- srcs: ["a.java"],
- libs: ["foo"],
- // does not have sdk_version set, should fallback to module,
- // which will then fallback to system because the module scope
- // is not enabled.
- }
- `)
- // The baz library should depend on the system stubs jar.
- bazLibrary := result.ModuleForTests("baz", "android_common").Rule("javac")
- if expected, actual := `^-classpath .*:out/soong/[^:]*/turbine-combined/foo\.stubs.system\.jar$`, bazLibrary.Args["classpath"]; !regexp.MustCompile(expected).MatchString(actual) {
- t.Errorf("expected %q, found %#q", expected, actual)
- }
-}
-
func TestJavaSdkLibraryImport(t *testing.T) {
result := prepareForJavaTest.RunTestWithBp(t, `
java_library {
name: "foo",
srcs: ["a.java"],
- libs: ["sdklib"],
+ libs: ["sdklib.stubs"],
sdk_version: "current",
}
java_library {
name: "foo.system",
srcs: ["a.java"],
- libs: ["sdklib"],
+ libs: ["sdklib.stubs.system"],
sdk_version: "system_current",
}
java_library {
name: "foo.test",
srcs: ["a.java"],
- libs: ["sdklib"],
+ libs: ["sdklib.stubs.test"],
sdk_version: "test_current",
}
@@ -1017,7 +939,7 @@
java_library {
name: "public",
srcs: ["a.java"],
- libs: ["sdklib"],
+ libs: ["sdklib.stubs"],
sdk_version: "current",
}
`)
@@ -1190,155 +1112,6 @@
}
}
-func TestJavaSdkLibraryEnforce(t *testing.T) {
- partitionToBpOption := func(partition string) string {
- switch partition {
- case "system":
- return ""
- case "vendor":
- return "soc_specific: true,"
- case "product":
- return "product_specific: true,"
- default:
- panic("Invalid partition group name: " + partition)
- }
- }
-
- type testConfigInfo struct {
- libraryType string
- fromPartition string
- toPartition string
- enforceProductInterface bool
- enforceJavaSdkLibraryCheck bool
- allowList []string
- }
-
- createPreparer := func(info testConfigInfo) android.FixturePreparer {
- bpFileTemplate := `
- java_library {
- name: "foo",
- srcs: ["foo.java"],
- libs: ["bar"],
- sdk_version: "current",
- %s
- }
-
- %s {
- name: "bar",
- srcs: ["bar.java"],
- sdk_version: "current",
- %s
- }
- `
-
- bpFile := fmt.Sprintf(bpFileTemplate,
- partitionToBpOption(info.fromPartition),
- info.libraryType,
- partitionToBpOption(info.toPartition))
-
- return android.GroupFixturePreparers(
- PrepareForTestWithJavaSdkLibraryFiles,
- FixtureWithLastReleaseApis("bar"),
- android.FixtureWithRootAndroidBp(bpFile),
- android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
- variables.EnforceProductPartitionInterface = proptools.BoolPtr(info.enforceProductInterface)
- variables.EnforceInterPartitionJavaSdkLibrary = proptools.BoolPtr(info.enforceJavaSdkLibraryCheck)
- variables.InterPartitionJavaLibraryAllowList = info.allowList
- }),
- )
- }
-
- runTest := func(t *testing.T, info testConfigInfo, expectedErrorPattern string) {
- t.Run(fmt.Sprintf("%v", info), func(t *testing.T) {
- errorHandler := android.FixtureExpectsNoErrors
- if expectedErrorPattern != "" {
- errorHandler = android.FixtureExpectsAtLeastOneErrorMatchingPattern(expectedErrorPattern)
- }
- android.GroupFixturePreparers(
- prepareForJavaTest,
- createPreparer(info),
- ).
- ExtendWithErrorHandler(errorHandler).
- RunTest(t)
- })
- }
-
- errorMessage := "is not allowed across the partitions"
-
- runTest(t, testConfigInfo{
- libraryType: "java_library",
- fromPartition: "product",
- toPartition: "system",
- enforceProductInterface: true,
- enforceJavaSdkLibraryCheck: false,
- }, "")
-
- runTest(t, testConfigInfo{
- libraryType: "java_library",
- fromPartition: "product",
- toPartition: "system",
- enforceProductInterface: false,
- enforceJavaSdkLibraryCheck: true,
- }, "")
-
- runTest(t, testConfigInfo{
- libraryType: "java_library",
- fromPartition: "product",
- toPartition: "system",
- enforceProductInterface: true,
- enforceJavaSdkLibraryCheck: true,
- }, errorMessage)
-
- runTest(t, testConfigInfo{
- libraryType: "java_library",
- fromPartition: "vendor",
- toPartition: "system",
- enforceProductInterface: true,
- enforceJavaSdkLibraryCheck: true,
- }, errorMessage)
-
- runTest(t, testConfigInfo{
- libraryType: "java_library",
- fromPartition: "vendor",
- toPartition: "system",
- enforceProductInterface: true,
- enforceJavaSdkLibraryCheck: true,
- allowList: []string{"bar"},
- }, "")
-
- runTest(t, testConfigInfo{
- libraryType: "java_library",
- fromPartition: "vendor",
- toPartition: "product",
- enforceProductInterface: true,
- enforceJavaSdkLibraryCheck: true,
- }, errorMessage)
-
- runTest(t, testConfigInfo{
- libraryType: "java_sdk_library",
- fromPartition: "product",
- toPartition: "system",
- enforceProductInterface: true,
- enforceJavaSdkLibraryCheck: true,
- }, "")
-
- runTest(t, testConfigInfo{
- libraryType: "java_sdk_library",
- fromPartition: "vendor",
- toPartition: "system",
- enforceProductInterface: true,
- enforceJavaSdkLibraryCheck: true,
- }, "")
-
- runTest(t, testConfigInfo{
- libraryType: "java_sdk_library",
- fromPartition: "vendor",
- toPartition: "product",
- enforceProductInterface: true,
- enforceJavaSdkLibraryCheck: true,
- }, "")
-}
-
func TestJavaSdkLibraryDist(t *testing.T) {
result := android.GroupFixturePreparers(
PrepareForTestWithJavaBuildComponents,
@@ -1657,7 +1430,7 @@
name: "bar",
srcs: ["c.java", "b.java"],
libs: [
- "foo",
+ "foo.stubs",
],
uses_libs: [
"foo",
@@ -1752,7 +1525,7 @@
name: "mymodule",
srcs: ["a.java"],
sdk_version: "current",
- libs: ["sdklib",], // this should be dynamically resolved to sdklib.stubs (source) or prebuilt_sdklib.stubs (prebuilt)
+ libs: ["sdklib.stubs",], // this should be dynamically resolved to sdklib.stubs (source) or prebuilt_sdklib.stubs (prebuilt)
}
`
@@ -1893,3 +1666,111 @@
}
`)
}
+
+func TestSdkLibDirectDependency(t *testing.T) {
+ android.GroupFixturePreparers(
+ prepareForJavaTest,
+ PrepareForTestWithJavaSdkLibraryFiles,
+ FixtureWithLastReleaseApis("foo", "bar"),
+ ).ExtendWithErrorHandler(android.FixtureExpectsAllErrorsToMatchAPattern([]string{
+ `module "baz" variant "android_common": cannot depend directly on java_sdk_library ` +
+ `"foo"; try depending on "foo.stubs", or "foo.impl" instead`,
+ `module "baz" variant "android_common": cannot depend directly on java_sdk_library ` +
+ `"prebuilt_bar"; try depending on "bar.stubs", or "bar.impl" instead`,
+ }),
+ ).RunTestWithBp(t, `
+ java_sdk_library {
+ name: "foo",
+ srcs: ["a.java"],
+ sdk_version: "current",
+ public: {
+ enabled: true,
+ },
+ }
+
+ java_sdk_library_import {
+ name: "foo",
+ public: {
+ jars: ["a.jar"],
+ stub_srcs: ["a.java"],
+ current_api: "current.txt",
+ removed_api: "removed.txt",
+ annotations: "annotations.zip",
+ },
+ }
+
+ java_sdk_library {
+ name: "bar",
+ srcs: ["a.java"],
+ sdk_version: "current",
+ public: {
+ enabled: true,
+ },
+ }
+
+ java_sdk_library_import {
+ name: "bar",
+ prefer: true,
+ public: {
+ jars: ["a.jar"],
+ stub_srcs: ["a.java"],
+ current_api: "current.txt",
+ removed_api: "removed.txt",
+ annotations: "annotations.zip",
+ },
+ }
+
+ java_library {
+ name: "baz",
+ srcs: ["b.java"],
+ libs: [
+ "foo",
+ "bar",
+ ],
+ }
+ `)
+}
+
+func TestSdkLibDirectDependencyWithPrebuiltSdk(t *testing.T) {
+ android.GroupFixturePreparers(
+ prepareForJavaTest,
+ PrepareForTestWithJavaSdkLibraryFiles,
+ android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
+ variables.Platform_sdk_version = intPtr(34)
+ variables.Platform_sdk_codename = stringPtr("VanillaIceCream")
+ variables.Platform_version_active_codenames = []string{"VanillaIceCream"}
+ variables.Platform_systemsdk_versions = []string{"33", "34", "VanillaIceCream"}
+ variables.DeviceSystemSdkVersions = []string{"VanillaIceCream"}
+ }),
+ FixtureWithPrebuiltApis(map[string][]string{
+ "33": {"foo"},
+ "34": {"foo"},
+ "35": {"foo"},
+ }),
+ ).ExtendWithErrorHandler(android.FixtureExpectsOneErrorPattern(
+ `module "baz" variant "android_common": cannot depend directly on java_sdk_library "foo"; `+
+ `try depending on "sdk_public_33_foo", "sdk_system_33_foo", "sdk_test_33_foo", `+
+ `"sdk_module-lib_33_foo", or "sdk_system-server_33_foo" instead`),
+ ).RunTestWithBp(t, `
+ java_sdk_library {
+ name: "foo",
+ srcs: ["a.java"],
+ sdk_version: "current",
+ public: {
+ enabled: true,
+ },
+ system: {
+ enabled: true,
+ },
+ }
+
+ java_library {
+ name: "baz",
+ srcs: ["b.java"],
+ libs: [
+ "foo",
+ ],
+ sdk_version: "system_33",
+ }
+ `)
+}
diff --git a/sdk/bootclasspath_fragment_sdk_test.go b/sdk/bootclasspath_fragment_sdk_test.go
index 8b994eb..39c8123 100644
--- a/sdk/bootclasspath_fragment_sdk_test.go
+++ b/sdk/bootclasspath_fragment_sdk_test.go
@@ -204,7 +204,19 @@
.intermediates/mysdk/common_os/empty -> java_boot_libs/snapshot/jars/are/invalid/core1.jar
.intermediates/mysdk/common_os/empty -> java_boot_libs/snapshot/jars/are/invalid/core2.jar
`),
- snapshotTestPreparer(checkSnapshotWithoutSource, preparerForSnapshot),
+ snapshotTestPreparer(checkSnapshotWithoutSource, android.GroupFixturePreparers(
+ preparerForSnapshot,
+ // Flag ART prebuilts
+ android.FixtureMergeMockFs(android.MockFS{
+ "apex_contributions/Android.bp": []byte(`
+ apex_contributions {
+ name: "prebuilt_art_contributions",
+ contents: ["prebuilt_com.android.art"],
+ api_domain: "com.android.art",
+ }
+ `)}),
+ android.PrepareForTestWithBuildFlag("RELEASE_APEX_CONTRIBUTIONS_ART", "prebuilt_art_contributions"),
+ )),
// Check the behavior of the snapshot without the source.
snapshotTestChecker(checkSnapshotWithoutSource, func(t *testing.T, result *android.TestResult) {
@@ -212,8 +224,8 @@
checkBootJarsPackageCheckRule(t, result,
append(
[]string{
- "out/soong/.intermediates/prebuilts/apex/prebuilt_com.android.art.deapexer/android_common/deapexer/javalib/core1.jar",
- "out/soong/.intermediates/prebuilts/apex/prebuilt_com.android.art.deapexer/android_common/deapexer/javalib/core2.jar",
+ "out/soong/.intermediates/prebuilts/apex/com.android.art/android_common_com.android.art/deapexer/javalib/core1.jar",
+ "out/soong/.intermediates/prebuilts/apex/com.android.art/android_common_com.android.art/deapexer/javalib/core2.jar",
"out/soong/.intermediates/default/java/framework/android_common/aligned/framework.jar",
},
java.ApexBootJarDexJarPaths...,
diff --git a/tests/build_action_caching_test.sh b/tests/build_action_caching_test.sh
index 7524d82..8ecd037 100755
--- a/tests/build_action_caching_test.sh
+++ b/tests/build_action_caching_test.sh
@@ -6,6 +6,7 @@
# incremental modules are restored from cache.
OUTPUT_DIR="$(mktemp -d tmp.XXXXXX)"
+
echo ${OUTPUT_DIR}
function cleanup {
@@ -14,7 +15,7 @@
trap cleanup EXIT
function run_soong_build {
- USE_RBE=false TARGET_PRODUCT=aosp_arm TARGET_RELEASE=trunk_staging TARGET_BUILD_VARIANT=userdebug build/soong/soong_ui.bash --make-mode --incremental-build-actions nothing
+ USE_RBE=false TARGET_PRODUCT=aosp_arm TARGET_RELEASE=trunk_staging TARGET_BUILD_VARIANT=userdebug build/soong/soong_ui.bash --make-mode "$@" nothing
}
function run_soong_clean {
@@ -50,34 +51,102 @@
}
function test_build_action_restoring() {
+ local test_dir="${OUTPUT_DIR}/test_build_action_restoring"
+ mkdir -p ${test_dir}
run_soong_clean
- cat > ${OUTPUT_DIR}/Android.bp <<'EOF'
+ cat > ${test_dir}/Android.bp <<'EOF'
python_binary_host {
name: "my_little_binary_host",
srcs: ["my_little_binary_host.py"],
}
EOF
- touch ${OUTPUT_DIR}/my_little_binary_host.py
- run_soong_build
- mkdir -p "${OUTPUT_DIR}/before"
- cp -pr out/soong/build_aosp_arm_ninja_incremental out/soong/*.mk out/soong/build.aosp_arm.*.ninja ${OUTPUT_DIR}/before
+ touch ${test_dir}/my_little_binary_host.py
+ run_soong_build --incremental-build-actions
+ local dir_before="${test_dir}/before"
+ mkdir -p ${dir_before}
+ cp -pr out/soong/build_aosp_arm_ninja_incremental out/soong/*.mk out/soong/build.aosp_arm*.ninja ${test_dir}/before
# add a comment to the bp file, this should force a new analysis but no module
# should be really impacted, so all the incremental modules should be skipped.
- cat >> ${OUTPUT_DIR}/Android.bp <<'EOF'
+ cat >> ${test_dir}/Android.bp <<'EOF'
// new comments
EOF
- run_soong_build
- mkdir -p "${OUTPUT_DIR}/after"
- cp -pr out/soong/build_aosp_arm_ninja_incremental out/soong/*.mk out/soong/build.aosp_arm.*.ninja ${OUTPUT_DIR}/after
+ run_soong_build --incremental-build-actions
+ local dir_after="${test_dir}/after"
+ mkdir -p ${dir_after}
+ cp -pr out/soong/build_aosp_arm_ninja_incremental out/soong/*.mk out/soong/build.aosp_arm*.ninja ${test_dir}/after
- compare_files
- echo "Tests passed"
+ compare_incremental_files $dir_before $dir_after
+ rm -rf "$test_dir"
+ echo "test_build_action_restoring test passed"
}
-function compare_files() {
+function test_incremental_build_parity() {
+ local test_dir="${OUTPUT_DIR}/test_incremental_build_parity"
+ run_soong_clean
+ run_soong_build
+ local dir_before="${test_dir}/before"
+ mkdir -p ${dir_before}
+ cp -pr out/soong/*.mk out/soong/build.aosp_arm*.ninja ${test_dir}/before
+
+ # Now run clean build with incremental enabled
+ run_soong_clean
+ run_soong_build --incremental-build-actions
+ local dir_after="${test_dir}/after"
+ mkdir -p ${dir_after}
+ cp -pr out/soong/build_aosp_arm_ninja_incremental out/soong/*.mk out/soong/build.aosp_arm*.ninja ${test_dir}/after
+
+ compare_files_parity $dir_before $dir_after
+ rm -rf "$test_dir"
+ echo "test_incremental_build_parity test passed"
+}
+
+function compare_files_parity() {
+ local dir_before=$1; shift
+ local dir_after=$1; shift
count=0
- for file_before in ${OUTPUT_DIR}/before/*.ninja; do
- file_after="${OUTPUT_DIR}/after/$(basename "$file_before")"
+ for file_before in ${dir_before}/*.mk; do
+ file_after="${dir_after}/$(basename "$file_before")"
+ assert_files_equal $file_before $file_after
+ ((count++))
+ done
+ echo "Compared $count mk files"
+
+ combined_before_file="${dir_before}/combined_files.ninja"
+ count=0
+ for file in ${dir_before}/build.aosp_arm.*.ninja; do
+ cat $file >> $combined_before_file
+ ((count++))
+ done
+ echo "Combined $count ninja files from normal build"
+
+ combined_after_file="${dir_after}/combined_files.ninja"
+ count=0
+ for file in ${dir_after}/build.aosp_arm.*.ninja; do
+ cat $file >> $combined_after_file
+ ((count++))
+ done
+ echo "Combined $count ninja files from incremental build"
+
+ combined_incremental_ninjas="${dir_after}/combined_incremental_files.ninja"
+ count=0
+ for file in ${dir_after}/build_aosp_arm_ninja_incremental/*.ninja; do
+ cat $file >> $combined_incremental_ninjas
+ ((count++))
+ done
+ echo "Combined $count incremental ninja files"
+
+ cat $combined_incremental_ninjas >> $combined_after_file
+ sort $combined_after_file -o $combined_after_file
+ sort $combined_before_file -o $combined_before_file
+ assert_files_equal $combined_before_file $combined_after_file
+}
+
+function compare_incremental_files() {
+ local dir_before=$1; shift
+ local dir_after=$1; shift
+ count=0
+ for file_before in ${dir_before}/*.ninja; do
+ file_after="${dir_after}/$(basename "$file_before")"
assert_files_equal $file_before $file_after
compare_mtimes $file_before $file_after
if [ $? -ne 0 ]; then
@@ -89,8 +158,8 @@
echo "Compared $count ninja files"
count=0
- for file_before in ${OUTPUT_DIR}/before/*.mk; do
- file_after="${OUTPUT_DIR}/after/$(basename "$file_before")"
+ for file_before in ${dir_before}/*.mk; do
+ file_after="${dir_after}/$(basename "$file_before")"
assert_files_equal $file_before $file_after
compare_mtimes $file_before $file_after
# mk files shouldn't be regenerated
@@ -103,8 +172,8 @@
echo "Compared $count mk files"
count=0
- for file_before in ${OUTPUT_DIR}/before/build_aosp_arm_ninja_incremental/*.ninja; do
- file_after="${OUTPUT_DIR}/after/build_aosp_arm_ninja_incremental/$(basename "$file_before")"
+ for file_before in ${dir_before}/build_aosp_arm_ninja_incremental/*.ninja; do
+ file_after="${dir_after}/build_aosp_arm_ninja_incremental/$(basename "$file_before")"
assert_files_equal $file_before $file_after
compare_mtimes $file_before $file_after
# ninja files of skipped modules shouldn't be regenerated
@@ -117,4 +186,5 @@
echo "Compared $count incremental ninja files"
}
+test_incremental_build_parity
test_build_action_restoring