Merge "rust: Re-enable host address sanitizer." into main
diff --git a/android/api_levels.go b/android/api_levels.go
index c019f99..6fa4a0e 100644
--- a/android/api_levels.go
+++ b/android/api_levels.go
@@ -288,6 +288,8 @@
// a core-for-system-modules.jar for the module-lib API scope.
var LastWithoutModuleLibCoreSystemModules = uncheckedFinalApiLevel(31)
+var ApiLevelR = uncheckedFinalApiLevel(30)
+
// ReplaceFinalizedCodenames returns the API level number associated with that API level
// if the `raw` input is the codename of an API level has been finalized.
// If the input is *not* a finalized codename, the input is returned unmodified.
diff --git a/android/config.go b/android/config.go
index f9cb842..e57bc2c 100644
--- a/android/config.go
+++ b/android/config.go
@@ -1499,18 +1499,18 @@
}
// AfdoProfile returns fully qualified path associated to the given module name
-func (c *deviceConfig) AfdoProfile(name string) (*string, error) {
+func (c *deviceConfig) AfdoProfile(name string) (string, error) {
for _, afdoProfile := range c.config.productVariables.AfdoProfiles {
split := strings.Split(afdoProfile, ":")
if len(split) != 3 {
- return nil, fmt.Errorf("AFDO_PROFILES has invalid value: %s. "+
+ return "", fmt.Errorf("AFDO_PROFILES has invalid value: %s. "+
"The expected format is <module>:<fully-qualified-path-to-fdo_profile>", afdoProfile)
}
if split[0] == name {
- return proptools.StringPtr(strings.Join([]string{split[1], split[2]}, ":")), nil
+ return strings.Join([]string{split[1], split[2]}, ":"), nil
}
}
- return nil, nil
+ return "", nil
}
func (c *deviceConfig) VendorSepolicyDirs() []string {
@@ -1739,10 +1739,6 @@
return String(c.config.productVariables.PlatformSepolicyVersion)
}
-func (c *deviceConfig) TotSepolicyVersion() string {
- return String(c.config.productVariables.TotSepolicyVersion)
-}
-
func (c *deviceConfig) PlatformSepolicyCompatVersions() []string {
return c.config.productVariables.PlatformSepolicyCompatVersions
}
diff --git a/android/variable.go b/android/variable.go
index a4917c5..758967e 100644
--- a/android/variable.go
+++ b/android/variable.go
@@ -383,7 +383,6 @@
BoardSepolicyVers *string `json:",omitempty"`
PlatformSepolicyVersion *string `json:",omitempty"`
- TotSepolicyVersion *string `json:",omitempty"`
SystemExtSepolicyPrebuiltApiDir *string `json:",omitempty"`
ProductSepolicyPrebuiltApiDir *string `json:",omitempty"`
diff --git a/apex/apex_test.go b/apex/apex_test.go
index d3959ec..5cc50dd 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -790,6 +790,79 @@
}
}
+func TestApexWithDessertSha(t *testing.T) {
+ ctx := testApex(t, `
+ apex_defaults {
+ name: "my_defaults",
+ key: "myapex.key",
+ product_specific: true,
+ file_contexts: ":my-file-contexts",
+ updatable: false,
+ }
+ apex {
+ name: "myapex_30",
+ min_sdk_version: "30",
+ defaults: ["my_defaults"],
+ }
+
+ apex {
+ name: "myapex_current",
+ min_sdk_version: "current",
+ defaults: ["my_defaults"],
+ }
+
+ apex {
+ name: "myapex_none",
+ defaults: ["my_defaults"],
+ }
+
+ apex_key {
+ name: "myapex.key",
+ public_key: "testkey.avbpubkey",
+ private_key: "testkey.pem",
+ }
+
+ filegroup {
+ name: "my-file-contexts",
+ srcs: ["product_specific_file_contexts"],
+ }
+ `, withFiles(map[string][]byte{
+ "product_specific_file_contexts": nil,
+ }), android.FixtureModifyProductVariables(
+ func(variables android.FixtureProductVariables) {
+ variables.Unbundled_build = proptools.BoolPtr(true)
+ variables.Always_use_prebuilt_sdks = proptools.BoolPtr(false)
+ }), android.FixtureMergeEnv(map[string]string{
+ "UNBUNDLED_BUILD_TARGET_SDK_WITH_DESSERT_SHA": "UpsideDownCake.abcdefghijklmnopqrstuvwxyz123456",
+ }))
+
+ testCases := []struct {
+ module string
+ minSdkVersion string
+ }{
+ {
+ module: "myapex_30",
+ minSdkVersion: "30",
+ },
+ {
+ module: "myapex_current",
+ minSdkVersion: "UpsideDownCake.abcdefghijklmnopqrstuvwxyz123456",
+ },
+ {
+ module: "myapex_none",
+ minSdkVersion: "UpsideDownCake.abcdefghijklmnopqrstuvwxyz123456",
+ },
+ }
+ for _, tc := range testCases {
+ module := ctx.ModuleForTests(tc.module, "android_common_"+tc.module)
+ args := module.Rule("apexRule").Args
+ optFlags := args["opt_flags"]
+ if !strings.Contains(optFlags, "--min_sdk_version "+tc.minSdkVersion) {
+ t.Errorf("%s: Expected min_sdk_version=%s, got: %s", tc.module, tc.minSdkVersion, optFlags)
+ }
+ }
+}
+
func TestFileContexts(t *testing.T) {
for _, vendor := range []bool{true, false} {
prop := ""
diff --git a/apex/builder.go b/apex/builder.go
index 40ccd2c..3d61219 100644
--- a/apex/builder.go
+++ b/apex/builder.go
@@ -695,18 +695,20 @@
if moduleMinSdkVersion.IsCurrent() || moduleMinSdkVersion.IsNone() {
minSdkVersion = ctx.Config().DefaultAppTargetSdk(ctx).String()
- if java.UseApiFingerprint(ctx) {
- minSdkVersion = ctx.Config().PlatformSdkCodename() + fmt.Sprintf(".$$(cat %s)", java.ApiFingerprintPath(ctx).String())
- implicitInputs = append(implicitInputs, java.ApiFingerprintPath(ctx))
+ if useApiFingerprint, fingerprintMinSdkVersion, fingerprintDeps :=
+ java.UseApiFingerprint(ctx); useApiFingerprint {
+ minSdkVersion = fingerprintMinSdkVersion
+ implicitInputs = append(implicitInputs, fingerprintDeps)
}
}
// apex module doesn't have a concept of target_sdk_version, hence for the time
// being targetSdkVersion == default targetSdkVersion of the branch.
targetSdkVersion := strconv.Itoa(ctx.Config().DefaultAppTargetSdk(ctx).FinalOrFutureInt())
- if java.UseApiFingerprint(ctx) {
- targetSdkVersion = ctx.Config().PlatformSdkCodename() + fmt.Sprintf(".$$(cat %s)", java.ApiFingerprintPath(ctx).String())
- implicitInputs = append(implicitInputs, java.ApiFingerprintPath(ctx))
+ if useApiFingerprint, fingerprintTargetSdkVersion, fingerprintDeps :=
+ java.UseApiFingerprint(ctx); useApiFingerprint {
+ targetSdkVersion = fingerprintTargetSdkVersion
+ implicitInputs = append(implicitInputs, fingerprintDeps)
}
optFlags = append(optFlags, "--target_sdk_version "+targetSdkVersion)
optFlags = append(optFlags, "--min_sdk_version "+minSdkVersion)
diff --git a/apex/platform_bootclasspath_test.go b/apex/platform_bootclasspath_test.go
index 2bd3159..2be9c10 100644
--- a/apex/platform_bootclasspath_test.go
+++ b/apex/platform_bootclasspath_test.go
@@ -86,6 +86,7 @@
"bar-fragment",
],
updatable: false,
+ min_sdk_version: "30", // R
}
apex_key {
@@ -138,6 +139,7 @@
sdk_version: "none",
compile_dex: true,
permitted_packages: ["bar"],
+ min_sdk_version: "30", // R
}
java_sdk_library {
@@ -162,12 +164,12 @@
android.AssertPathsRelativeToTopEquals(t, message, expected, info.FlagsFilesByCategory[category])
}
- android.AssertPathsRelativeToTopEquals(t, "annotation flags", []string{"out/soong/.intermediates/bar-fragment/android_common_apex10000/modular-hiddenapi/annotation-flags.csv"}, info.AnnotationFlagsPaths)
- android.AssertPathsRelativeToTopEquals(t, "metadata flags", []string{"out/soong/.intermediates/bar-fragment/android_common_apex10000/modular-hiddenapi/metadata.csv"}, info.MetadataPaths)
- android.AssertPathsRelativeToTopEquals(t, "index flags", []string{"out/soong/.intermediates/bar-fragment/android_common_apex10000/modular-hiddenapi/index.csv"}, info.IndexPaths)
+ android.AssertPathsRelativeToTopEquals(t, "annotation flags", []string{"out/soong/.intermediates/bar-fragment/android_common_apex30/modular-hiddenapi/annotation-flags.csv"}, info.AnnotationFlagsPaths)
+ android.AssertPathsRelativeToTopEquals(t, "metadata flags", []string{"out/soong/.intermediates/bar-fragment/android_common_apex30/modular-hiddenapi/metadata.csv"}, info.MetadataPaths)
+ android.AssertPathsRelativeToTopEquals(t, "index flags", []string{"out/soong/.intermediates/bar-fragment/android_common_apex30/modular-hiddenapi/index.csv"}, info.IndexPaths)
- android.AssertArrayString(t, "stub flags", []string{"out/soong/.intermediates/bar-fragment/android_common_apex10000/modular-hiddenapi/filtered-stub-flags.csv:out/soong/.intermediates/bar-fragment/android_common_apex10000/modular-hiddenapi/signature-patterns.csv"}, info.StubFlagSubsets.RelativeToTop())
- android.AssertArrayString(t, "all flags", []string{"out/soong/.intermediates/bar-fragment/android_common_apex10000/modular-hiddenapi/filtered-flags.csv:out/soong/.intermediates/bar-fragment/android_common_apex10000/modular-hiddenapi/signature-patterns.csv"}, info.FlagSubsets.RelativeToTop())
+ android.AssertArrayString(t, "stub flags", []string{"out/soong/.intermediates/bar-fragment/android_common_apex30/modular-hiddenapi/filtered-stub-flags.csv:out/soong/.intermediates/bar-fragment/android_common_apex30/modular-hiddenapi/signature-patterns.csv"}, info.StubFlagSubsets.RelativeToTop())
+ android.AssertArrayString(t, "all flags", []string{"out/soong/.intermediates/bar-fragment/android_common_apex30/modular-hiddenapi/filtered-flags.csv:out/soong/.intermediates/bar-fragment/android_common_apex30/modular-hiddenapi/signature-patterns.csv"}, info.FlagSubsets.RelativeToTop())
}
// TestPlatformBootclasspath_LegacyPrebuiltFragment verifies that the
diff --git a/cc/afdo.go b/cc/afdo.go
index 6cc1746..00b2245 100644
--- a/cc/afdo.go
+++ b/cc/afdo.go
@@ -21,29 +21,17 @@
"android/soong/android"
"github.com/google/blueprint"
- "github.com/google/blueprint/proptools"
)
// This flag needs to be in both CFlags and LdFlags to ensure correct symbol ordering
const afdoFlagsFormat = "-fprofile-sample-use=%s -fprofile-sample-accurate"
-func recordMissingAfdoProfileFile(ctx android.BaseModuleContext, missing string) {
- getNamedMapForConfig(ctx.Config(), modulesMissingProfileFileKey).Store(missing, true)
-}
-
-type afdoRdep struct {
- VariationName *string
- ProfilePath *string
-}
-
type AfdoProperties struct {
// Afdo allows developers self-service enroll for
// automatic feedback-directed optimization using profile data.
Afdo bool
- FdoProfilePath *string `blueprint:"mutated"`
-
- AfdoRDeps []afdoRdep `blueprint:"mutated"`
+ AfdoDep bool `blueprint:"mutated"`
}
type afdo struct {
@@ -62,17 +50,32 @@
}
// afdoEnabled returns true for binaries and shared libraries
-// that set afdo prop to True and there is a profile available
+// that set afdo prop to True.
func (afdo *afdo) afdoEnabled() bool {
return afdo != nil && afdo.Properties.Afdo
}
+func (afdo *afdo) isAfdoCompile(ctx ModuleContext) bool {
+ fdoProfilePath := getFdoProfilePathFromDep(ctx)
+ return !ctx.Host() && (afdo.Properties.Afdo || afdo.Properties.AfdoDep) && (fdoProfilePath != "")
+}
+
+func getFdoProfilePathFromDep(ctx ModuleContext) string {
+ fdoProfileDeps := ctx.GetDirectDepsWithTag(FdoProfileTag)
+ if len(fdoProfileDeps) > 0 && fdoProfileDeps[0] != nil {
+ if info, ok := android.OtherModuleProvider(ctx, fdoProfileDeps[0], FdoProfileProvider); ok {
+ return info.Path.String()
+ }
+ }
+ return ""
+}
+
func (afdo *afdo) flags(ctx ModuleContext, flags Flags) Flags {
if ctx.Host() {
return flags
}
- if afdo.Properties.Afdo {
+ if afdo.Properties.Afdo || afdo.Properties.AfdoDep {
// We use `-funique-internal-linkage-names` to associate profiles to the right internal
// functions. This option should be used before generating a profile. Because a profile
// generated for a binary without unique names doesn't work well building a binary with
@@ -90,15 +93,15 @@
// TODO(b/266595187): Remove the following feature once it is enabled in LLVM by default.
flags.Local.CFlags = append([]string{"-mllvm", "-improved-fs-discriminator=true"}, flags.Local.CFlags...)
}
- if path := afdo.Properties.FdoProfilePath; path != nil {
+ if fdoProfilePath := getFdoProfilePathFromDep(ctx); fdoProfilePath != "" {
// The flags are prepended to allow overriding.
- profileUseFlag := fmt.Sprintf(afdoFlagsFormat, *path)
+ profileUseFlag := fmt.Sprintf(afdoFlagsFormat, fdoProfilePath)
flags.Local.CFlags = append([]string{profileUseFlag}, flags.Local.CFlags...)
flags.Local.LdFlags = append([]string{profileUseFlag, "-Wl,-mllvm,-no-warn-sample-unused=true"}, flags.Local.LdFlags...)
// Update CFlagsDeps and LdFlagsDeps so the module is rebuilt
// if profileFile gets updated
- pathForSrc := android.PathForSource(ctx, *path)
+ pathForSrc := android.PathForSource(ctx, fdoProfilePath)
flags.CFlagsDeps = append(flags.CFlagsDeps, pathForSrc)
flags.LdFlagsDeps = append(flags.LdFlagsDeps, pathForSrc)
}
@@ -106,130 +109,86 @@
return flags
}
-func (afdo *afdo) addDep(ctx BaseModuleContext, actx android.BottomUpMutatorContext) {
+func (a *afdo) addDep(ctx android.BottomUpMutatorContext, fdoProfileTarget string) {
+ if fdoProfileName, err := ctx.DeviceConfig().AfdoProfile(fdoProfileTarget); fdoProfileName != "" && err == nil {
+ ctx.AddFarVariationDependencies(
+ []blueprint.Variation{
+ {Mutator: "arch", Variation: ctx.Target().ArchVariation()},
+ {Mutator: "os", Variation: "android"},
+ },
+ FdoProfileTag,
+ fdoProfileName)
+ }
+}
+
+func afdoPropagateViaDepTag(tag blueprint.DependencyTag) bool {
+ libTag, isLibTag := tag.(libraryDependencyTag)
+ // Do not recurse down non-static dependencies
+ if isLibTag {
+ return libTag.static()
+ } else {
+ return tag == objDepTag || tag == reuseObjTag || tag == staticVariantTag
+ }
+}
+
+// afdoTransitionMutator creates afdo variants of cc modules.
+type afdoTransitionMutator struct{}
+
+func (a *afdoTransitionMutator) Split(ctx android.BaseModuleContext) []string {
+ return []string{""}
+}
+
+func (a *afdoTransitionMutator) OutgoingTransition(ctx android.OutgoingTransitionContext, sourceVariation string) string {
if ctx.Host() {
- return
+ return ""
}
- if ctx.static() && !ctx.staticBinary() {
- return
- }
-
- if c, ok := ctx.Module().(*Module); ok && c.Enabled() {
- if fdoProfileName, err := actx.DeviceConfig().AfdoProfile(actx.ModuleName()); fdoProfileName != nil && err == nil {
- actx.AddFarVariationDependencies(
- []blueprint.Variation{
- {Mutator: "arch", Variation: actx.Target().ArchVariation()},
- {Mutator: "os", Variation: "android"},
- },
- FdoProfileTag,
- []string{*fdoProfileName}...,
- )
+ if m, ok := ctx.Module().(*Module); ok && m.afdo != nil {
+ if !afdoPropagateViaDepTag(ctx.DepTag()) {
+ return ""
}
+
+ if sourceVariation != "" {
+ return sourceVariation
+ }
+
+ if !m.afdo.afdoEnabled() {
+ return ""
+ }
+
+ // TODO(b/324141705): this is designed to prevent propagating AFDO from static libraries that have afdo: true set, but
+ // it should be m.static() && !m.staticBinary() so that static binaries use AFDO variants of dependencies.
+ if m.static() {
+ return ""
+ }
+
+ return encodeTarget(ctx.Module().Name())
}
+ return ""
}
-// FdoProfileMutator reads the FdoProfileProvider from a direct dep with FdoProfileTag
-// assigns FdoProfileInfo.Path to the FdoProfilePath mutated property
-func (c *Module) fdoProfileMutator(ctx android.BottomUpMutatorContext) {
- if !c.Enabled() {
- return
+func (a *afdoTransitionMutator) IncomingTransition(ctx android.IncomingTransitionContext, incomingVariation string) string {
+ if m, ok := ctx.Module().(*Module); ok && m.afdo != nil {
+ return incomingVariation
}
-
- if !c.afdo.afdoEnabled() {
- return
- }
-
- ctx.VisitDirectDepsWithTag(FdoProfileTag, func(m android.Module) {
- if info, ok := android.OtherModuleProvider(ctx, m, FdoProfileProvider); ok {
- c.afdo.Properties.FdoProfilePath = proptools.StringPtr(info.Path.String())
- }
- })
+ return ""
}
-var _ FdoProfileMutatorInterface = (*Module)(nil)
-
-// Propagate afdo requirements down from binaries and shared libraries
-func afdoDepsMutator(mctx android.TopDownMutatorContext) {
- if mctx.Host() {
- return
- }
-
- if m, ok := mctx.Module().(*Module); ok && m.afdo.afdoEnabled() {
- path := m.afdo.Properties.FdoProfilePath
- mctx.WalkDeps(func(dep android.Module, parent android.Module) bool {
- tag := mctx.OtherModuleDependencyTag(dep)
- libTag, isLibTag := tag.(libraryDependencyTag)
-
- // Do not recurse down non-static dependencies
- if isLibTag {
- if !libTag.static() {
- return false
- }
- } else {
- if tag != objDepTag && tag != reuseObjTag {
- return false
- }
+func (a *afdoTransitionMutator) Mutate(ctx android.BottomUpMutatorContext, variation string) {
+ if m, ok := ctx.Module().(*Module); ok && m.afdo != nil {
+ if variation == "" {
+ // The empty variation is either a module that has enabled AFDO for itself, or the non-AFDO
+ // variant of a dependency.
+ if m.afdo.afdoEnabled() && !(m.static() && !m.staticBinary()) && !m.Host() {
+ m.afdo.addDep(ctx, ctx.ModuleName())
}
-
- if dep, ok := dep.(*Module); ok {
- dep.afdo.Properties.AfdoRDeps = append(
- dep.afdo.Properties.AfdoRDeps,
- afdoRdep{
- VariationName: proptools.StringPtr(encodeTarget(m.Name())),
- ProfilePath: path,
- },
- )
- }
-
- return true
- })
- }
-}
-
-// Create afdo variants for modules that need them
-func afdoMutator(mctx android.BottomUpMutatorContext) {
- if mctx.Host() {
- return
- }
-
- if m, ok := mctx.Module().(*Module); ok && m.afdo != nil {
- if !m.static() && m.afdo.Properties.Afdo {
- mctx.SetDependencyVariation(encodeTarget(m.Name()))
- return
- }
-
- variationNames := []string{""}
-
- variantNameToProfilePath := make(map[string]*string)
-
- for _, afdoRDep := range m.afdo.Properties.AfdoRDeps {
- variantName := *afdoRDep.VariationName
- // An rdep can be set twice in AfdoRDeps because there can be
- // more than one path from an afdo-enabled module to
- // a static dep such as
- // afdo_enabled_foo -> static_bar ----> static_baz
- // \ ^
- // ----------------------|
- // We only need to create one variant per unique rdep
- if _, exists := variantNameToProfilePath[variantName]; !exists {
- variationNames = append(variationNames, variantName)
- variantNameToProfilePath[variantName] = afdoRDep.ProfilePath
- }
- }
-
- if len(variationNames) > 1 {
- modules := mctx.CreateVariations(variationNames...)
- for i, name := range variationNames {
- if name == "" {
- continue
- }
- variation := modules[i].(*Module)
- variation.Properties.PreventInstall = true
- variation.Properties.HideFromMake = true
- variation.afdo.Properties.Afdo = true
- variation.afdo.Properties.FdoProfilePath = variantNameToProfilePath[name]
- }
+ } else {
+ // The non-empty variation is the AFDO variant of a dependency of a module that enabled AFDO
+ // for itself.
+ m.Properties.PreventInstall = true
+ m.Properties.HideFromMake = true
+ m.afdo.Properties.AfdoDep = true
+ m.afdo.addDep(ctx, decodeTarget(variation))
}
}
}
diff --git a/cc/cc.go b/cc/cc.go
index 449d38f..39024aa 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -55,7 +55,6 @@
ctx.BottomUp("test_per_src", TestPerSrcMutator).Parallel()
ctx.BottomUp("version", versionMutator).Parallel()
ctx.BottomUp("begin", BeginMutator).Parallel()
- ctx.BottomUp("fdo_profile", fdoProfileMutator)
})
ctx.PostDepsMutators(func(ctx android.RegisterMutatorsContext) {
@@ -70,8 +69,7 @@
ctx.Transition("coverage", &coverageTransitionMutator{})
- ctx.TopDown("afdo_deps", afdoDepsMutator)
- ctx.BottomUp("afdo", afdoMutator).Parallel()
+ ctx.Transition("afdo", &afdoTransitionMutator{})
ctx.Transition("orderfile", &orderfileTransitionMutator{})
@@ -527,7 +525,7 @@
selectedStl() string
baseModuleName() string
getVndkExtendsModuleName() string
- isAfdoCompile() bool
+ isAfdoCompile(ctx ModuleContext) bool
isOrderfileCompile() bool
isCfi() bool
isFuzzer() bool
@@ -1381,9 +1379,9 @@
return false
}
-func (c *Module) isAfdoCompile() bool {
+func (c *Module) isAfdoCompile(ctx ModuleContext) bool {
if afdo := c.afdo; afdo != nil {
- return afdo.Properties.FdoProfilePath != nil
+ return afdo.isAfdoCompile(ctx)
}
return false
}
@@ -1706,8 +1704,8 @@
return ctx.mod.IsVndk()
}
-func (ctx *moduleContextImpl) isAfdoCompile() bool {
- return ctx.mod.isAfdoCompile()
+func (ctx *moduleContextImpl) isAfdoCompile(mctx ModuleContext) bool {
+ return ctx.mod.isAfdoCompile(mctx)
}
func (ctx *moduleContextImpl) isOrderfileCompile() bool {
@@ -2351,10 +2349,6 @@
}
ctx.ctx = ctx
- if !actx.Host() || !ctx.static() || ctx.staticBinary() {
- c.afdo.addDep(ctx, actx)
- }
-
c.begin(ctx)
}
diff --git a/cc/coverage.go b/cc/coverage.go
index 43f5e07..f6092e4 100644
--- a/cc/coverage.go
+++ b/cc/coverage.go
@@ -91,7 +91,7 @@
}
func (cov *coverage) deps(ctx DepsContext, deps Deps) Deps {
- if cov.Properties.NeedCoverageVariant {
+ if cov.Properties.NeedCoverageVariant && ctx.Device() {
ctx.AddVariationDependencies([]blueprint.Variation{
{Mutator: "link", Variation: "static"},
}, CoverageDepTag, getGcovProfileLibraryName(ctx))
@@ -184,19 +184,22 @@
if gcovCoverage {
flags.Local.LdFlags = append(flags.Local.LdFlags, "--coverage")
- coverage := ctx.GetDirectDepWithTag(getGcovProfileLibraryName(ctx), CoverageDepTag).(*Module)
- deps.WholeStaticLibs = append(deps.WholeStaticLibs, coverage.OutputFile().Path())
-
- flags.Local.LdFlags = append(flags.Local.LdFlags, "-Wl,--wrap,getenv")
+ if ctx.Device() {
+ coverage := ctx.GetDirectDepWithTag(getGcovProfileLibraryName(ctx), CoverageDepTag).(*Module)
+ deps.WholeStaticLibs = append(deps.WholeStaticLibs, coverage.OutputFile().Path())
+ flags.Local.LdFlags = append(flags.Local.LdFlags, "-Wl,--wrap,getenv")
+ }
} else if clangCoverage {
flags.Local.LdFlags = append(flags.Local.LdFlags, profileInstrFlag)
if EnableContinuousCoverage(ctx) {
flags.Local.LdFlags = append(flags.Local.LdFlags, "-Wl,-mllvm=-runtime-counter-relocation")
}
- coverage := ctx.GetDirectDepWithTag(getClangProfileLibraryName(ctx), CoverageDepTag).(*Module)
- deps.WholeStaticLibs = append(deps.WholeStaticLibs, coverage.OutputFile().Path())
- flags.Local.LdFlags = append(flags.Local.LdFlags, "-Wl,--wrap,open")
+ if ctx.Device() {
+ coverage := ctx.GetDirectDepWithTag(getClangProfileLibraryName(ctx), CoverageDepTag).(*Module)
+ deps.WholeStaticLibs = append(deps.WholeStaticLibs, coverage.OutputFile().Path())
+ flags.Local.LdFlags = append(flags.Local.LdFlags, "-Wl,--wrap,open")
+ }
}
}
@@ -204,7 +207,7 @@
}
func (cov *coverage) begin(ctx BaseModuleContext) {
- if ctx.Host() {
+ if ctx.Host() && !ctx.Os().Linux() {
// TODO(dwillemsen): because of -nodefaultlibs, we must depend on libclang_rt.profile-*.a
// Just turn off for now.
} else {
diff --git a/cc/fdo_profile.go b/cc/fdo_profile.go
index 0893da5..1a33957 100644
--- a/cc/fdo_profile.go
+++ b/cc/fdo_profile.go
@@ -43,23 +43,10 @@
}
// FdoProfileProvider is used to provide path to an fdo profile
-var FdoProfileProvider = blueprint.NewMutatorProvider[FdoProfileInfo]("fdo_profile")
-
-// FdoProfileMutatorInterface is the interface implemented by fdo_profile module type
-// module types that can depend on an fdo_profile module
-type FdoProfileMutatorInterface interface {
- // FdoProfileMutator eithers set or get FdoProfileProvider
- fdoProfileMutator(ctx android.BottomUpMutatorContext)
-}
-
-var _ FdoProfileMutatorInterface = (*fdoProfile)(nil)
+var FdoProfileProvider = blueprint.NewProvider[FdoProfileInfo]()
// GenerateAndroidBuildActions of fdo_profile does not have any build actions
-func (fp *fdoProfile) GenerateAndroidBuildActions(ctx android.ModuleContext) {}
-
-// FdoProfileMutator sets FdoProfileProvider to fdo_profile module
-// or sets afdo.Properties.FdoProfilePath to path in FdoProfileProvider of the depended fdo_profile
-func (fp *fdoProfile) fdoProfileMutator(ctx android.BottomUpMutatorContext) {
+func (fp *fdoProfile) GenerateAndroidBuildActions(ctx android.ModuleContext) {
if fp.properties.Profile != nil {
path := android.PathForModuleSrc(ctx, *fp.properties.Profile)
android.SetProvider(ctx, FdoProfileProvider, FdoProfileInfo{
@@ -68,14 +55,6 @@
}
}
-// fdoProfileMutator calls the generic fdoProfileMutator function of fdoProfileMutator
-// which is implemented by cc and cc.FdoProfile
-func fdoProfileMutator(ctx android.BottomUpMutatorContext) {
- if f, ok := ctx.Module().(FdoProfileMutatorInterface); ok {
- f.fdoProfileMutator(ctx)
- }
-}
-
func FdoProfileFactory() android.Module {
m := &fdoProfile{}
m.AddProperties(&m.properties)
diff --git a/cc/lto.go b/cc/lto.go
index b2b4570..05fa8ee 100644
--- a/cc/lto.go
+++ b/cc/lto.go
@@ -100,7 +100,7 @@
lto.Properties.LtoEnabled = ltoEnabled
}
-func (lto *lto) flags(ctx BaseModuleContext, flags Flags) Flags {
+func (lto *lto) flags(ctx ModuleContext, flags Flags) Flags {
// TODO(b/131771163): CFI and Fuzzer controls LTO flags by themselves.
// This has be checked late because these properties can be mutated.
if ctx.isCfi() || ctx.isFuzzer() {
@@ -139,7 +139,7 @@
// Reduce the inlining threshold for a better balance of binary size and
// performance.
if !ctx.Darwin() {
- if ctx.isAfdoCompile() {
+ if ctx.isAfdoCompile(ctx) {
ltoLdFlags = append(ltoLdFlags, "-Wl,-plugin-opt,-import-instr-limit=40")
} else {
ltoLdFlags = append(ltoLdFlags, "-Wl,-plugin-opt,-import-instr-limit=5")
diff --git a/cmd/merge_zips/merge_zips.go b/cmd/merge_zips/merge_zips.go
index 1aa6f6f..2c57180 100644
--- a/cmd/merge_zips/merge_zips.go
+++ b/cmd/merge_zips/merge_zips.go
@@ -342,7 +342,8 @@
func (oz *OutputZip) getUninitializedPythonPackages(inputZips []InputZip) ([]string, error) {
// the runfiles packages needs to be populated with "__init__.py".
// the runfiles dirs have been treated as packages.
- allPackages := make(map[string]bool)
+ var allPackages []string // Using a slice to preserve input order.
+ seenPkgs := make(map[string]bool)
initedPackages := make(map[string]bool)
getPackage := func(path string) string {
ret := filepath.Dir(path)
@@ -369,16 +370,17 @@
initedPackages[pyPkg] = true
}
for pyPkg != "" {
- if _, found := allPackages[pyPkg]; found {
+ if _, found := seenPkgs[pyPkg]; found {
break
}
- allPackages[pyPkg] = true
+ seenPkgs[pyPkg] = true
+ allPackages = append(allPackages, pyPkg)
pyPkg = getPackage(pyPkg)
}
}
}
noInitPackages := make([]string, 0)
- for pyPkg := range allPackages {
+ for _, pyPkg := range allPackages {
if _, found := initedPackages[pyPkg]; !found {
noInitPackages = append(noInitPackages, pyPkg)
}
diff --git a/cmd/merge_zips/merge_zips_test.go b/cmd/merge_zips/merge_zips_test.go
index 64b08d0..17228c4 100644
--- a/cmd/merge_zips/merge_zips_test.go
+++ b/cmd/merge_zips/merge_zips_test.go
@@ -103,6 +103,7 @@
stripFiles []string
stripDirs []string
jar bool
+ par bool
sort bool
ignoreDuplicates bool
stripDirEntries bool
@@ -265,6 +266,34 @@
},
out: []testZipEntry{withoutTimestamp, a},
},
+ {
+ name: "emulate par",
+ in: [][]testZipEntry{
+ {
+ testZipEntry{name: "3/main.py"},
+ testZipEntry{name: "c/main.py"},
+ testZipEntry{name: "a/main.py"},
+ testZipEntry{name: "2/main.py"},
+ testZipEntry{name: "b/main.py"},
+ testZipEntry{name: "1/main.py"},
+ },
+ },
+ out: []testZipEntry{
+ testZipEntry{name: "3/__init__.py", mode: 0700, timestamp: jar.DefaultTime},
+ testZipEntry{name: "c/__init__.py", mode: 0700, timestamp: jar.DefaultTime},
+ testZipEntry{name: "a/__init__.py", mode: 0700, timestamp: jar.DefaultTime},
+ testZipEntry{name: "2/__init__.py", mode: 0700, timestamp: jar.DefaultTime},
+ testZipEntry{name: "b/__init__.py", mode: 0700, timestamp: jar.DefaultTime},
+ testZipEntry{name: "1/__init__.py", mode: 0700, timestamp: jar.DefaultTime},
+ testZipEntry{name: "3/main.py", timestamp: jar.DefaultTime},
+ testZipEntry{name: "c/main.py", timestamp: jar.DefaultTime},
+ testZipEntry{name: "a/main.py", timestamp: jar.DefaultTime},
+ testZipEntry{name: "2/main.py", timestamp: jar.DefaultTime},
+ testZipEntry{name: "b/main.py", timestamp: jar.DefaultTime},
+ testZipEntry{name: "1/main.py", timestamp: jar.DefaultTime},
+ },
+ par: true,
+ },
}
for _, test := range testCases {
@@ -280,7 +309,7 @@
writer := zip.NewWriter(out)
err := mergeZips(inputZips, writer, "", "",
- test.sort, test.jar, false, test.stripDirEntries, test.ignoreDuplicates,
+ test.sort, test.jar, test.par, test.stripDirEntries, test.ignoreDuplicates,
test.stripFiles, test.stripDirs, test.zipsToNotStrip)
closeErr := writer.Close()
diff --git a/java/android_manifest.go b/java/android_manifest.go
index 082b00e..8599003 100644
--- a/java/android_manifest.go
+++ b/java/android_manifest.go
@@ -152,9 +152,10 @@
if params.SdkContext != nil {
targetSdkVersion := targetSdkVersionForManifestFixer(ctx, params)
- if UseApiFingerprint(ctx) && ctx.ModuleName() != "framework-res" {
- targetSdkVersion = ctx.Config().PlatformSdkCodename() + fmt.Sprintf(".$$(cat %s)", ApiFingerprintPath(ctx).String())
- deps = append(deps, ApiFingerprintPath(ctx))
+ if useApiFingerprint, fingerprintTargetSdkVersion, fingerprintDeps :=
+ UseApiFingerprint(ctx); useApiFingerprint && ctx.ModuleName() != "framework-res" {
+ targetSdkVersion = fingerprintTargetSdkVersion
+ deps = append(deps, fingerprintDeps)
}
args = append(args, "--targetSdkVersion ", targetSdkVersion)
@@ -169,9 +170,10 @@
ctx.ModuleErrorf("invalid ReplaceMaxSdkVersionPlaceholder: %s", err)
}
- if UseApiFingerprint(ctx) && ctx.ModuleName() != "framework-res" {
- minSdkVersion = ctx.Config().PlatformSdkCodename() + fmt.Sprintf(".$$(cat %s)", ApiFingerprintPath(ctx).String())
- deps = append(deps, ApiFingerprintPath(ctx))
+ if useApiFingerprint, fingerprintMinSdkVersion, fingerprintDeps :=
+ UseApiFingerprint(ctx); useApiFingerprint && ctx.ModuleName() != "framework-res" {
+ minSdkVersion = fingerprintMinSdkVersion
+ deps = append(deps, fingerprintDeps)
}
if err != nil {
diff --git a/java/app.go b/java/app.go
index 0c56d81..9be3f6d 100755
--- a/java/app.go
+++ b/java/app.go
@@ -920,15 +920,39 @@
shouldCollectRecursiveNativeDeps bool,
checkNativeSdkVersion bool) ([]jniLib, android.Paths, []Certificate) {
- var jniLibs []jniLib
- var prebuiltJniPackages android.Paths
- var certificates []Certificate
- seenModulePaths := make(map[string]bool)
-
if checkNativeSdkVersion {
checkNativeSdkVersion = app.SdkVersion(ctx).Specified() &&
app.SdkVersion(ctx).Kind != android.SdkCorePlatform && !app.RequiresStableAPIs(ctx)
}
+ jniLib, prebuiltJniPackages := collectJniDeps(ctx, shouldCollectRecursiveNativeDeps,
+ checkNativeSdkVersion, func(dep cc.LinkableInterface) bool {
+ return !dep.IsNdk(ctx.Config()) && !dep.IsStubs()
+ })
+
+ var certificates []Certificate
+
+ ctx.VisitDirectDeps(func(module android.Module) {
+ otherName := ctx.OtherModuleName(module)
+ tag := ctx.OtherModuleDependencyTag(module)
+
+ if tag == certificateTag {
+ if dep, ok := module.(*AndroidAppCertificate); ok {
+ certificates = append(certificates, dep.Certificate)
+ } else {
+ ctx.ModuleErrorf("certificate dependency %q must be an android_app_certificate module", otherName)
+ }
+ }
+ })
+ return jniLib, prebuiltJniPackages, certificates
+}
+
+func collectJniDeps(ctx android.ModuleContext,
+ shouldCollectRecursiveNativeDeps bool,
+ checkNativeSdkVersion bool,
+ filter func(cc.LinkableInterface) bool) ([]jniLib, android.Paths) {
+ var jniLibs []jniLib
+ var prebuiltJniPackages android.Paths
+ seenModulePaths := make(map[string]bool)
ctx.WalkDeps(func(module android.Module, parent android.Module) bool {
otherName := ctx.OtherModuleName(module)
@@ -936,7 +960,7 @@
if IsJniDepTag(tag) || cc.IsSharedDepTag(tag) {
if dep, ok := module.(cc.LinkableInterface); ok {
- if dep.IsNdk(ctx.Config()) || dep.IsStubs() {
+ if filter != nil && !filter(dep) {
return false
}
@@ -977,18 +1001,10 @@
prebuiltJniPackages = append(prebuiltJniPackages, info.JniPackages...)
}
- if tag == certificateTag {
- if dep, ok := module.(*AndroidAppCertificate); ok {
- certificates = append(certificates, dep.Certificate)
- } else {
- ctx.ModuleErrorf("certificate dependency %q must be an android_app_certificate module", otherName)
- }
- }
-
return false
})
- return jniLibs, prebuiltJniPackages, certificates
+ return jniLibs, prebuiltJniPackages
}
func (a *AndroidApp) WalkPayloadDeps(ctx android.ModuleContext, do android.PayloadDepsCallback) {
diff --git a/java/hiddenapi_monolithic.go b/java/hiddenapi_monolithic.go
index a61018d..1e30c5f 100644
--- a/java/hiddenapi_monolithic.go
+++ b/java/hiddenapi_monolithic.go
@@ -68,7 +68,7 @@
case *ClasspathFragmentElement:
fragment := e.Module()
if info, ok := android.OtherModuleProvider(ctx, fragment, HiddenAPIInfoProvider); ok {
- monolithicInfo.append(&info)
+ monolithicInfo.append(ctx, fragment, &info)
} else {
ctx.ModuleErrorf("%s does not provide hidden API information", fragment)
}
@@ -79,14 +79,25 @@
}
// append appends all the files from the supplied info to the corresponding files in this struct.
-func (i *MonolithicHiddenAPIInfo) append(other *HiddenAPIInfo) {
+func (i *MonolithicHiddenAPIInfo) append(ctx android.ModuleContext, otherModule android.Module, other *HiddenAPIInfo) {
i.FlagsFilesByCategory.append(other.FlagFilesByCategory)
i.AnnotationFlagsPaths = append(i.AnnotationFlagsPaths, other.AnnotationFlagsPath)
i.MetadataPaths = append(i.MetadataPaths, other.MetadataPath)
i.IndexPaths = append(i.IndexPaths, other.IndexPath)
- i.StubFlagSubsets = append(i.StubFlagSubsets, other.StubFlagSubset())
- i.FlagSubsets = append(i.FlagSubsets, other.FlagSubset())
+ apexInfo, ok := android.OtherModuleProvider(ctx, otherModule, android.ApexInfoProvider)
+ if !ok {
+ ctx.ModuleErrorf("Could not determine min_version_version of %s\n", otherModule.Name())
+ return
+ }
+ if apexInfo.MinSdkVersion.LessThanOrEqualTo(android.ApiLevelR) {
+ // Restrict verify_overlaps to R and older modules.
+ // The runtime in S does not have the same restriction that
+ // requires the hiddenapi flags to be generated in a monolithic
+ // invocation.
+ i.StubFlagSubsets = append(i.StubFlagSubsets, other.StubFlagSubset())
+ i.FlagSubsets = append(i.FlagSubsets, other.FlagSubset())
+ }
}
var MonolithicHiddenAPIInfoProvider = blueprint.NewProvider[MonolithicHiddenAPIInfo]()
diff --git a/java/ravenwood.go b/java/ravenwood.go
index dcb5c8b..908619d 100644
--- a/java/ravenwood.go
+++ b/java/ravenwood.go
@@ -17,6 +17,7 @@
"android/soong/android"
"android/soong/tradefed"
+ "github.com/google/blueprint"
"github.com/google/blueprint/proptools"
)
@@ -29,12 +30,20 @@
ctx.RegisterModuleType("android_ravenwood_libgroup", ravenwoodLibgroupFactory)
}
-var ravenwoodTag = dependencyTag{name: "ravenwood"}
-var ravenwoodJniTag = dependencyTag{name: "ravenwood-jni"}
+var ravenwoodLibContentTag = dependencyTag{name: "ravenwoodlibcontent"}
+var ravenwoodUtilsTag = dependencyTag{name: "ravenwoodutils"}
+var ravenwoodRuntimeTag = dependencyTag{name: "ravenwoodruntime"}
const ravenwoodUtilsName = "ravenwood-utils"
const ravenwoodRuntimeName = "ravenwood-runtime"
+type ravenwoodLibgroupJniDepProviderInfo struct {
+ // All the jni_libs module names with transient dependencies.
+ names map[string]bool
+}
+
+var ravenwoodLibgroupJniDepProvider = blueprint.NewProvider[ravenwoodLibgroupJniDepProviderInfo]()
+
func getLibPath(archType android.ArchType) string {
if archType.Multilib == "lib64" {
return "lib64"
@@ -91,10 +100,10 @@
r.Library.DepsMutator(ctx)
// Generically depend on the runtime so that it's installed together with us
- ctx.AddVariationDependencies(nil, ravenwoodTag, ravenwoodRuntimeName)
+ ctx.AddVariationDependencies(nil, ravenwoodRuntimeTag, ravenwoodRuntimeName)
// Directly depend on any utils so that we link against them
- utils := ctx.AddVariationDependencies(nil, ravenwoodTag, ravenwoodUtilsName)[0]
+ utils := ctx.AddVariationDependencies(nil, ravenwoodUtilsTag, ravenwoodUtilsName)[0]
if utils != nil {
for _, lib := range utils.(*ravenwoodLibgroup).ravenwoodLibgroupProperties.Libs {
ctx.AddVariationDependencies(nil, libTag, lib)
@@ -103,7 +112,7 @@
// Add jni libs
for _, lib := range r.ravenwoodTestProperties.Jni_libs {
- ctx.AddVariationDependencies(ctx.Config().BuildOSTarget.Variations(), ravenwoodJniTag, lib)
+ ctx.AddVariationDependencies(ctx.Config().BuildOSTarget.Variations(), jniLibTag, lib)
}
}
@@ -122,24 +131,47 @@
r.Library.GenerateAndroidBuildActions(ctx)
- // Start by depending on all files installed by dependancies
+ // Start by depending on all files installed by dependencies
var installDeps android.InstallPaths
- for _, dep := range ctx.GetDirectDepsWithTag(ravenwoodTag) {
- for _, installFile := range dep.FilesToInstall() {
+
+ // All JNI libraries included in the runtime
+ var runtimeJniModuleNames map[string]bool
+
+ if utils := ctx.GetDirectDepsWithTag(ravenwoodUtilsTag)[0]; utils != nil {
+ for _, installFile := range utils.FilesToInstall() {
installDeps = append(installDeps, installFile)
}
+ jniDeps, ok := android.OtherModuleProvider(ctx, utils, ravenwoodLibgroupJniDepProvider)
+ if ok {
+ runtimeJniModuleNames = jniDeps.names
+ }
}
+ if runtime := ctx.GetDirectDepsWithTag(ravenwoodRuntimeTag)[0]; runtime != nil {
+ for _, installFile := range runtime.FilesToInstall() {
+ installDeps = append(installDeps, installFile)
+ }
+ jniDeps, ok := android.OtherModuleProvider(ctx, runtime, ravenwoodLibgroupJniDepProvider)
+ if ok {
+ runtimeJniModuleNames = jniDeps.names
+ }
+ }
+
+ // Also remember what JNI libs are in the runtime.
+
// Also depend on our config
installPath := android.PathForModuleInstall(ctx, r.BaseModuleName())
installConfig := ctx.InstallFile(installPath, ctx.ModuleName()+".config", r.testConfig)
installDeps = append(installDeps, installConfig)
- // Depend on the JNI libraries.
+ // Depend on the JNI libraries, but don't install the ones that the runtime already
+ // contains.
soInstallPath := installPath.Join(ctx, getLibPath(r.forceArchType))
- for _, dep := range ctx.GetDirectDepsWithTag(ravenwoodJniTag) {
- file := android.OutputFileForModule(ctx, dep, "")
- installJni := ctx.InstallFile(soInstallPath, file.Base(), file)
+ for _, jniLib := range collectTransitiveJniDeps(ctx) {
+ if _, ok := runtimeJniModuleNames[jniLib.name]; ok {
+ continue // Runtime already includes it.
+ }
+ installJni := ctx.InstallFile(soInstallPath, jniLib.path.Base(), jniLib.path)
installDeps = append(installDeps, installJni)
}
@@ -199,10 +231,10 @@
func (r *ravenwoodLibgroup) DepsMutator(ctx android.BottomUpMutatorContext) {
// Always depends on our underlying libs
for _, lib := range r.ravenwoodLibgroupProperties.Libs {
- ctx.AddVariationDependencies(nil, ravenwoodTag, lib)
+ ctx.AddVariationDependencies(nil, ravenwoodLibContentTag, lib)
}
for _, lib := range r.ravenwoodLibgroupProperties.Jni_libs {
- ctx.AddVariationDependencies(ctx.Config().BuildOSTarget.Variations(), ravenwoodJniTag, lib)
+ ctx.AddVariationDependencies(ctx.Config().BuildOSTarget.Variations(), jniLibTag, lib)
}
}
@@ -210,19 +242,37 @@
r.forceOSType = ctx.Config().BuildOS
r.forceArchType = ctx.Config().BuildArch
+ // Collect the JNI dependencies, including the transitive deps.
+ jniDepNames := make(map[string]bool)
+ jniLibs := collectTransitiveJniDeps(ctx)
+
+ for _, jni := range jniLibs {
+ jniDepNames[jni.name] = true
+ }
+ android.SetProvider(ctx, ravenwoodLibgroupJniDepProvider, ravenwoodLibgroupJniDepProviderInfo{
+ names: jniDepNames,
+ })
+
// Install our runtime into expected location for packaging
installPath := android.PathForModuleInstall(ctx, r.BaseModuleName())
for _, lib := range r.ravenwoodLibgroupProperties.Libs {
- libModule := ctx.GetDirectDepWithTag(lib, ravenwoodTag)
+ libModule := ctx.GetDirectDepWithTag(lib, ravenwoodLibContentTag)
libJar := android.OutputFileForModule(ctx, libModule, "")
ctx.InstallFile(installPath, lib+".jar", libJar)
}
soInstallPath := android.PathForModuleInstall(ctx, r.BaseModuleName()).Join(ctx, getLibPath(r.forceArchType))
- for _, dep := range ctx.GetDirectDepsWithTag(ravenwoodJniTag) {
- file := android.OutputFileForModule(ctx, dep, "")
- ctx.InstallFile(soInstallPath, file.Base(), file)
+
+ for _, jniLib := range jniLibs {
+ ctx.InstallFile(soInstallPath, jniLib.path.Base(), jniLib.path)
}
// Normal build should perform install steps
ctx.Phony(r.BaseModuleName(), android.PathForPhony(ctx, r.BaseModuleName()+"-install"))
}
+
+// collectTransitiveJniDeps returns all JNI dependencies, including transitive
+// ones, including NDK / stub libs. (Because Ravenwood has no "preinstalled" libraries)
+func collectTransitiveJniDeps(ctx android.ModuleContext) []jniLib {
+ libs, _ := collectJniDeps(ctx, true, false, nil)
+ return libs
+}
diff --git a/java/ravenwood_test.go b/java/ravenwood_test.go
index a71391c..5961264 100644
--- a/java/ravenwood_test.go
+++ b/java/ravenwood_test.go
@@ -27,7 +27,7 @@
}),
android.FixtureAddTextFile("ravenwood/Android.bp", `
cc_library_shared {
- name: "ravenwood-runtime-jni",
+ name: "ravenwood-runtime-jni1",
host_supported: true,
srcs: ["jni.cpp"],
}
@@ -36,6 +36,14 @@
host_supported: true,
srcs: ["jni.cpp"],
stem: "libred",
+ shared_libs: [
+ "ravenwood-runtime-jni3",
+ ],
+ }
+ cc_library_shared {
+ name: "ravenwood-runtime-jni3",
+ host_supported: true,
+ srcs: ["jni.cpp"],
}
java_library_static {
name: "framework-minus-apex.ravenwood",
@@ -55,7 +63,10 @@
"framework-minus-apex.ravenwood",
"framework-services.ravenwood",
],
- jni_libs: ["ravenwood-runtime-jni", "ravenwood-runtime-jni2"],
+ jni_libs: [
+ "ravenwood-runtime-jni1",
+ "ravenwood-runtime-jni2",
+ ],
}
android_ravenwood_libgroup {
name: "ravenwood-utils",
@@ -88,8 +99,9 @@
runtime := ctx.ModuleForTests("ravenwood-runtime", "android_common")
runtime.Output(installPathPrefix + "/ravenwood-runtime/framework-minus-apex.ravenwood.jar")
runtime.Output(installPathPrefix + "/ravenwood-runtime/framework-services.ravenwood.jar")
- runtime.Output(installPathPrefix + "/ravenwood-runtime/lib64/ravenwood-runtime-jni.so")
+ runtime.Output(installPathPrefix + "/ravenwood-runtime/lib64/ravenwood-runtime-jni1.so")
runtime.Output(installPathPrefix + "/ravenwood-runtime/lib64/libred.so")
+ runtime.Output(installPathPrefix + "/ravenwood-runtime/lib64/ravenwood-runtime-jni3.so")
utils := ctx.ModuleForTests("ravenwood-utils", "android_common")
utils.Output(installPathPrefix + "/ravenwood-utils/framework-rules.ravenwood.jar")
}
@@ -104,7 +116,7 @@
prepareRavenwoodRuntime,
).RunTestWithBp(t, `
cc_library_shared {
- name: "jni-lib",
+ name: "jni-lib1",
host_supported: true,
srcs: ["jni.cpp"],
}
@@ -113,11 +125,24 @@
host_supported: true,
srcs: ["jni.cpp"],
stem: "libblue",
+ shared_libs: [
+ "jni-lib3",
+ ],
+ }
+ cc_library_shared {
+ name: "jni-lib3",
+ host_supported: true,
+ srcs: ["jni.cpp"],
+ stem: "libpink",
}
android_ravenwood_test {
name: "ravenwood-test",
srcs: ["Test.java"],
- jni_libs: ["jni-lib", "jni-lib2"],
+ jni_libs: [
+ "jni-lib1",
+ "jni-lib2",
+ "ravenwood-runtime-jni2",
+ ],
sdk_version: "test_current",
}
`)
@@ -141,14 +166,21 @@
// Verify that we've emitted test artifacts in expected location
outputJar := module.Output(installPathPrefix + "/ravenwood-test/ravenwood-test.jar")
module.Output(installPathPrefix + "/ravenwood-test/ravenwood-test.config")
- module.Output(installPathPrefix + "/ravenwood-test/lib64/jni-lib.so")
+ module.Output(installPathPrefix + "/ravenwood-test/lib64/jni-lib1.so")
module.Output(installPathPrefix + "/ravenwood-test/lib64/libblue.so")
+ module.Output(installPathPrefix + "/ravenwood-test/lib64/libpink.so")
+
+ // ravenwood-runtime*.so are included in the runtime, so it shouldn't be emitted.
+ for _, o := range module.AllOutputs() {
+ android.AssertStringDoesNotContain(t, "runtime libs shouldn't be included", o, "/ravenwood-test/lib64/ravenwood-runtime")
+ }
// Verify that we're going to install underlying libs
orderOnly := outputJar.OrderOnly.Strings()
android.AssertStringListContains(t, "orderOnly", orderOnly, installPathPrefix+"/ravenwood-runtime/framework-minus-apex.ravenwood.jar")
android.AssertStringListContains(t, "orderOnly", orderOnly, installPathPrefix+"/ravenwood-runtime/framework-services.ravenwood.jar")
- android.AssertStringListContains(t, "orderOnly", orderOnly, installPathPrefix+"/ravenwood-runtime/lib64/ravenwood-runtime-jni.so")
+ android.AssertStringListContains(t, "orderOnly", orderOnly, installPathPrefix+"/ravenwood-runtime/lib64/ravenwood-runtime-jni1.so")
android.AssertStringListContains(t, "orderOnly", orderOnly, installPathPrefix+"/ravenwood-runtime/lib64/libred.so")
+ android.AssertStringListContains(t, "orderOnly", orderOnly, installPathPrefix+"/ravenwood-runtime/lib64/ravenwood-runtime-jni3.so")
android.AssertStringListContains(t, "orderOnly", orderOnly, installPathPrefix+"/ravenwood-utils/framework-rules.ravenwood.jar")
}
diff --git a/java/sdk.go b/java/sdk.go
index 81be991..3591ccd 100644
--- a/java/sdk.go
+++ b/java/sdk.go
@@ -33,13 +33,26 @@
var nonUpdatableFrameworkAidlPathKey = android.NewOnceKey("nonUpdatableFrameworkAidlPathKey")
var apiFingerprintPathKey = android.NewOnceKey("apiFingerprintPathKey")
-func UseApiFingerprint(ctx android.BaseModuleContext) bool {
- if ctx.Config().UnbundledBuild() &&
- !ctx.Config().AlwaysUsePrebuiltSdks() &&
- ctx.Config().IsEnvTrue("UNBUNDLED_BUILD_TARGET_SDK_WITH_API_FINGERPRINT") {
- return true
+func UseApiFingerprint(ctx android.BaseModuleContext) (useApiFingerprint bool, fingerprintSdkVersion string, fingerprintDeps android.OutputPath) {
+ if ctx.Config().UnbundledBuild() && !ctx.Config().AlwaysUsePrebuiltSdks() {
+ apiFingerprintTrue := ctx.Config().IsEnvTrue("UNBUNDLED_BUILD_TARGET_SDK_WITH_API_FINGERPRINT")
+ dessertShaIsSet := ctx.Config().Getenv("UNBUNDLED_BUILD_TARGET_SDK_WITH_DESSERT_SHA") != ""
+
+ // Error when both UNBUNDLED_BUILD_TARGET_SDK_WITH_API_FINGERPRINT and UNBUNDLED_BUILD_TARGET_SDK_WITH_DESSERT_SHA are set
+ if apiFingerprintTrue && dessertShaIsSet {
+ ctx.ModuleErrorf("UNBUNDLED_BUILD_TARGET_SDK_WITH_API_FINGERPRINT=true cannot be set alongside with UNBUNDLED_BUILD_TARGET_SDK_WITH_DESSERT_SHA")
+ }
+
+ useApiFingerprint = apiFingerprintTrue || dessertShaIsSet
+ if apiFingerprintTrue {
+ fingerprintSdkVersion = ctx.Config().PlatformSdkCodename() + fmt.Sprintf(".$$(cat %s)", ApiFingerprintPath(ctx).String())
+ fingerprintDeps = ApiFingerprintPath(ctx)
+ }
+ if dessertShaIsSet {
+ fingerprintSdkVersion = ctx.Config().Getenv("UNBUNDLED_BUILD_TARGET_SDK_WITH_DESSERT_SHA")
+ }
}
- return false
+ return useApiFingerprint, fingerprintSdkVersion, fingerprintDeps
}
func defaultJavaLanguageVersion(ctx android.EarlyModuleContext, s android.SdkSpec) javaVersion {
diff --git a/rust/afdo.go b/rust/afdo.go
index 323ee36..6116c5e 100644
--- a/rust/afdo.go
+++ b/rust/afdo.go
@@ -44,14 +44,14 @@
if err != nil {
ctx.ModuleErrorf("%s", err.Error())
}
- if fdoProfileName != nil {
+ if fdoProfileName != "" {
actx.AddFarVariationDependencies(
[]blueprint.Variation{
{Mutator: "arch", Variation: actx.Target().ArchVariation()},
{Mutator: "os", Variation: "android"},
},
cc.FdoProfileTag,
- []string{*fdoProfileName}...,
+ []string{fdoProfileName}...,
)
}
}
diff --git a/rust/config/lints.go b/rust/config/lints.go
index 9322981..7770af0 100644
--- a/rust/config/lints.go
+++ b/rust/config/lints.go
@@ -44,6 +44,7 @@
// Default Rust lints that applies to Google-authored modules.
defaultRustcLints = []string{
"-A deprecated",
+ "-A unknown_lints",
"-D missing-docs",
"-D warnings",
"-D unsafe_op_in_unsafe_fn",
@@ -53,6 +54,7 @@
// deny.
defaultClippyLints = []string{
"-A clippy::type-complexity",
+ "-A clippy::unnecessary_fallible_conversions",
"-A clippy::unnecessary-wraps",
"-A clippy::unusual-byte-groupings",
"-A clippy::upper-case-acronyms",
diff --git a/ui/build/dumpvars.go b/ui/build/dumpvars.go
index d364542..e17bd54 100644
--- a/ui/build/dumpvars.go
+++ b/ui/build/dumpvars.go
@@ -237,7 +237,6 @@
"BUILD_BROKEN_SRC_DIR_RW_ALLOWLIST",
// Not used, but useful to be in the soong.log
- "BOARD_VNDK_VERSION",
"TARGET_BUILD_TYPE",
"HOST_ARCH",
"HOST_2ND_ARCH",