Merge "Refactor special handling of hidden API encoding for master-art" am: fdd9743609
am: 1b5e8cdbee
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1707569 Change-Id: I49f3ee3a7bb0eb9f26440a278c5f1ec56a6037bf
This commit is contained in:
@@ -4542,7 +4542,12 @@ func TestPrebuiltExportDexImplementationJars(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
|
func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
|
||||||
preparer := java.FixtureConfigureBootJars("myapex:libfoo", "myapex:libbar")
|
preparer := android.GroupFixturePreparers(
|
||||||
|
java.FixtureConfigureBootJars("myapex:libfoo", "myapex:libbar"),
|
||||||
|
// Make sure that the frameworks/base/Android.bp file exists as otherwise hidden API encoding
|
||||||
|
// is disabled.
|
||||||
|
android.FixtureAddTextFile("frameworks/base/Android.bp", ""),
|
||||||
|
)
|
||||||
|
|
||||||
checkBootDexJarPath := func(t *testing.T, ctx *android.TestContext, stem string, bootDexJarPath string) {
|
checkBootDexJarPath := func(t *testing.T, ctx *android.TestContext, stem string, bootDexJarPath string) {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
|
@@ -92,6 +92,12 @@ func (h *hiddenAPI) initHiddenAPI(ctx android.BaseModuleContext, configurationNa
|
|||||||
|
|
||||||
h.configurationName = configurationName
|
h.configurationName = configurationName
|
||||||
|
|
||||||
|
// If the frameworks/base directories does not exist and no prebuilt hidden API flag files have
|
||||||
|
// been configured then it is not possible to do hidden API encoding.
|
||||||
|
if !ctx.Config().FrameworksBaseDirExists(ctx) && ctx.Config().PrebuiltHiddenApiDir(ctx) == "" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// It is important that hiddenapi information is only gathered for/from modules that are actually
|
// It is important that hiddenapi information is only gathered for/from modules that are actually
|
||||||
// on the boot jars list because the runtime only enforces access to the hidden API for the
|
// on the boot jars list because the runtime only enforces access to the hidden API for the
|
||||||
// bootclassloader. If information is gathered for modules not on the list then that will cause
|
// bootclassloader. If information is gathered for modules not on the list then that will cause
|
||||||
@@ -303,11 +309,7 @@ func hiddenAPIEncodeDex(ctx android.ModuleContext, output android.WritablePath,
|
|||||||
}
|
}
|
||||||
|
|
||||||
enforceHiddenApiFlagsToAllMembers := true
|
enforceHiddenApiFlagsToAllMembers := true
|
||||||
// If frameworks/base doesn't exist we must be building with the 'master-art' manifest.
|
|
||||||
// Disable assertion that all methods/fields have hidden API flags assigned.
|
|
||||||
if !ctx.Config().FrameworksBaseDirExists(ctx) {
|
|
||||||
enforceHiddenApiFlagsToAllMembers = false
|
|
||||||
}
|
|
||||||
// b/149353192: when a module is instrumented, jacoco adds synthetic members
|
// b/149353192: when a module is instrumented, jacoco adds synthetic members
|
||||||
// $jacocoData and $jacocoInit. Since they don't exist when building the hidden API flags,
|
// $jacocoData and $jacocoInit. Since they don't exist when building the hidden API flags,
|
||||||
// don't complain when we don't find hidden API flags for the synthetic members.
|
// don't complain when we don't find hidden API flags for the synthetic members.
|
||||||
|
@@ -117,7 +117,6 @@ func hiddenAPISingletonFactory() android.Singleton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type hiddenAPISingleton struct {
|
type hiddenAPISingleton struct {
|
||||||
flags android.Path
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// hiddenAPI singleton rules
|
// hiddenAPI singleton rules
|
||||||
@@ -136,17 +135,10 @@ func (h *hiddenAPISingleton) GenerateBuildActions(ctx android.SingletonContext)
|
|||||||
// consistency.
|
// consistency.
|
||||||
|
|
||||||
if ctx.Config().PrebuiltHiddenApiDir(ctx) != "" {
|
if ctx.Config().PrebuiltHiddenApiDir(ctx) != "" {
|
||||||
h.flags = prebuiltFlagsRule(ctx)
|
prebuiltFlagsRule(ctx)
|
||||||
prebuiltIndexRule(ctx)
|
prebuiltIndexRule(ctx)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// These rules depend on files located in frameworks/base, skip them if running in a tree that doesn't have them.
|
|
||||||
if ctx.Config().FrameworksBaseDirExists(ctx) {
|
|
||||||
h.flags = flagsRule(ctx)
|
|
||||||
} else {
|
|
||||||
h.flags = emptyFlagsRule(ctx)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Checks to see whether the supplied module variant is in the list of boot jars.
|
// Checks to see whether the supplied module variant is in the list of boot jars.
|
||||||
@@ -187,7 +179,7 @@ func isModuleInConfiguredList(ctx android.BaseModuleContext, module android.Modu
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func prebuiltFlagsRule(ctx android.SingletonContext) android.Path {
|
func prebuiltFlagsRule(ctx android.SingletonContext) {
|
||||||
outputPath := hiddenAPISingletonPaths(ctx).flags
|
outputPath := hiddenAPISingletonPaths(ctx).flags
|
||||||
inputPath := android.PathForSource(ctx, ctx.Config().PrebuiltHiddenApiDir(ctx), "hiddenapi-flags.csv")
|
inputPath := android.PathForSource(ctx, ctx.Config().PrebuiltHiddenApiDir(ctx), "hiddenapi-flags.csv")
|
||||||
|
|
||||||
@@ -196,8 +188,6 @@ func prebuiltFlagsRule(ctx android.SingletonContext) android.Path {
|
|||||||
Output: outputPath,
|
Output: outputPath,
|
||||||
Input: inputPath,
|
Input: inputPath,
|
||||||
})
|
})
|
||||||
|
|
||||||
return outputPath
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func prebuiltIndexRule(ctx android.SingletonContext) {
|
func prebuiltIndexRule(ctx android.SingletonContext) {
|
||||||
@@ -211,28 +201,6 @@ func prebuiltIndexRule(ctx android.SingletonContext) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// flagsRule is a placeholder that simply returns the location of the file, the generation of the
|
|
||||||
// ninja rules is done in generateHiddenAPIBuildActions.
|
|
||||||
func flagsRule(ctx android.SingletonContext) android.Path {
|
|
||||||
outputPath := hiddenAPISingletonPaths(ctx).flags
|
|
||||||
return outputPath
|
|
||||||
}
|
|
||||||
|
|
||||||
// emptyFlagsRule creates a rule to build an empty hiddenapi-flags.csv, which is needed by master-art-host builds that
|
|
||||||
// have a partial manifest without frameworks/base but still need to build a boot image.
|
|
||||||
func emptyFlagsRule(ctx android.SingletonContext) android.Path {
|
|
||||||
rule := android.NewRuleBuilder(pctx, ctx)
|
|
||||||
|
|
||||||
outputPath := hiddenAPISingletonPaths(ctx).flags
|
|
||||||
|
|
||||||
rule.Command().Text("rm").Flag("-f").Output(outputPath)
|
|
||||||
rule.Command().Text("touch").Output(outputPath)
|
|
||||||
|
|
||||||
rule.Build("emptyHiddenAPIFlagsFile", "empty hiddenapi flags")
|
|
||||||
|
|
||||||
return outputPath
|
|
||||||
}
|
|
||||||
|
|
||||||
// tempPathForRestat creates a path of the same type as the supplied type but with a name of
|
// tempPathForRestat creates a path of the same type as the supplied type but with a name of
|
||||||
// <path>.tmp.
|
// <path>.tmp.
|
||||||
//
|
//
|
||||||
|
@@ -60,10 +60,7 @@ func TestHiddenAPISingleton(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestHiddenAPISingletonWithSourceAndPrebuiltPreferredButNoDex(t *testing.T) {
|
func TestHiddenAPISingletonWithSourceAndPrebuiltPreferredButNoDex(t *testing.T) {
|
||||||
expectedErrorMessage :=
|
expectedErrorMessage := "module prebuilt_foo{os:android,arch:common} does not provide a dex jar"
|
||||||
"hiddenapi has determined that the source module \"foo\" should be ignored as it has been" +
|
|
||||||
" replaced by the prebuilt module \"prebuilt_foo\" but unfortunately it does not provide a" +
|
|
||||||
" suitable boot dex jar"
|
|
||||||
|
|
||||||
android.GroupFixturePreparers(
|
android.GroupFixturePreparers(
|
||||||
hiddenApiFixtureFactory,
|
hiddenApiFixtureFactory,
|
||||||
|
Reference in New Issue
Block a user