Merge "Verify the modular stub flags are subsets of the monolithic stub flags" am: 921d33d447
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1745334 Change-Id: I388c9697a5011a9283fc9584449fbd61c1ccfe8d
This commit is contained in:
@@ -236,7 +236,7 @@ func hiddenAPIRetrieveDexJarBuildPath(ctx android.ModuleContext, module android.
|
|||||||
//
|
//
|
||||||
// The rule is initialized but not built so that the caller can modify it and select an appropriate
|
// The rule is initialized but not built so that the caller can modify it and select an appropriate
|
||||||
// name.
|
// name.
|
||||||
func buildRuleToGenerateHiddenAPIStubFlagsFile(ctx android.BuilderContext, name, desc string, outputPath android.WritablePath, bootDexJars android.Paths, input HiddenAPIFlagInput) {
|
func buildRuleToGenerateHiddenAPIStubFlagsFile(ctx android.BuilderContext, name, desc string, outputPath android.WritablePath, bootDexJars android.Paths, input HiddenAPIFlagInput, moduleStubFlagsPaths android.Paths) {
|
||||||
// Singleton rule which applies hiddenapi on all boot class path dex files.
|
// Singleton rule which applies hiddenapi on all boot class path dex files.
|
||||||
rule := android.NewRuleBuilder(pctx, ctx)
|
rule := android.NewRuleBuilder(pctx, ctx)
|
||||||
|
|
||||||
@@ -276,6 +276,18 @@ func buildRuleToGenerateHiddenAPIStubFlagsFile(ctx android.BuilderContext, name,
|
|||||||
// Add the output path.
|
// Add the output path.
|
||||||
command.FlagWithOutput("--out-api-flags=", tempPath)
|
command.FlagWithOutput("--out-api-flags=", tempPath)
|
||||||
|
|
||||||
|
// If there are stub flag files that have been generated by fragments on which this depends then
|
||||||
|
// use them to validate the stub flag file generated by the rules created by this method.
|
||||||
|
if len(moduleStubFlagsPaths) > 0 {
|
||||||
|
validFile := buildRuleValidateOverlappingCsvFiles(ctx, name, desc, outputPath, moduleStubFlagsPaths)
|
||||||
|
|
||||||
|
// Add the file that indicates that the file generated by this is valid.
|
||||||
|
//
|
||||||
|
// This will cause the validation rule above to be run any time that the output of this rule
|
||||||
|
// changes but the validation will run in parallel with other rules that depend on this file.
|
||||||
|
command.Validation(validFile)
|
||||||
|
}
|
||||||
|
|
||||||
commitChangeForRestat(rule, tempPath, outputPath)
|
commitChangeForRestat(rule, tempPath, outputPath)
|
||||||
|
|
||||||
rule.Build(name, desc)
|
rule.Build(name, desc)
|
||||||
@@ -712,28 +724,6 @@ func buildRuleToGenerateHiddenApiFlags(ctx android.BuilderContext, name, desc st
|
|||||||
outputPath android.WritablePath, baseFlagsPath android.Path, annotationFlagPaths android.Paths,
|
outputPath android.WritablePath, baseFlagsPath android.Path, annotationFlagPaths android.Paths,
|
||||||
flagFilesByCategory FlagFilesByCategory, allFlagsPaths android.Paths, generatedRemovedDexSignatures android.OptionalPath) {
|
flagFilesByCategory FlagFilesByCategory, allFlagsPaths android.Paths, generatedRemovedDexSignatures android.OptionalPath) {
|
||||||
|
|
||||||
// The file which is used to record that the flags file is valid.
|
|
||||||
var validFile android.WritablePath
|
|
||||||
|
|
||||||
// If there are flag files that have been generated by fragments on which this depends then use
|
|
||||||
// them to validate the flag file generated by the rules created by this method.
|
|
||||||
if len(allFlagsPaths) > 0 {
|
|
||||||
// The flags file generated by the rule created by this method needs to be validated to ensure
|
|
||||||
// that it is consistent with the flag files generated by the individual fragments.
|
|
||||||
|
|
||||||
validFile = pathForValidation(ctx, outputPath)
|
|
||||||
|
|
||||||
// Create a rule to validate the output from the following rule.
|
|
||||||
rule := android.NewRuleBuilder(pctx, ctx)
|
|
||||||
rule.Command().
|
|
||||||
BuiltTool("verify_overlaps").
|
|
||||||
Input(outputPath).
|
|
||||||
Inputs(allFlagsPaths).
|
|
||||||
// If validation passes then update the file that records that.
|
|
||||||
Text("&& touch").Output(validFile)
|
|
||||||
rule.Build(name+"Validation", desc+" validation")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create the rule that will generate the flag files.
|
// Create the rule that will generate the flag files.
|
||||||
tempPath := tempPathForRestat(ctx, outputPath)
|
tempPath := tempPathForRestat(ctx, outputPath)
|
||||||
rule := android.NewRuleBuilder(pctx, ctx)
|
rule := android.NewRuleBuilder(pctx, ctx)
|
||||||
@@ -759,7 +749,11 @@ func buildRuleToGenerateHiddenApiFlags(ctx android.BuilderContext, name, desc st
|
|||||||
|
|
||||||
commitChangeForRestat(rule, tempPath, outputPath)
|
commitChangeForRestat(rule, tempPath, outputPath)
|
||||||
|
|
||||||
if validFile != nil {
|
// If there are flag files that have been generated by fragments on which this depends then use
|
||||||
|
// them to validate the flag file generated by the rules created by this method.
|
||||||
|
if len(allFlagsPaths) > 0 {
|
||||||
|
validFile := buildRuleValidateOverlappingCsvFiles(ctx, name, desc, outputPath, allFlagsPaths)
|
||||||
|
|
||||||
// Add the file that indicates that the file generated by this is valid.
|
// Add the file that indicates that the file generated by this is valid.
|
||||||
//
|
//
|
||||||
// This will cause the validation rule above to be run any time that the output of this rule
|
// This will cause the validation rule above to be run any time that the output of this rule
|
||||||
@@ -770,6 +764,25 @@ func buildRuleToGenerateHiddenApiFlags(ctx android.BuilderContext, name, desc st
|
|||||||
rule.Build(name, desc)
|
rule.Build(name, desc)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// buildRuleValidateOverlappingCsvFiles checks that the modular CSV files, i.e. the files generated
|
||||||
|
// by the individual bootclasspath_fragment modules are subsets of the monolithic CSV file.
|
||||||
|
func buildRuleValidateOverlappingCsvFiles(ctx android.BuilderContext, name string, desc string, monolithicFilePath android.WritablePath, modularFilePaths android.Paths) android.WritablePath {
|
||||||
|
// The file which is used to record that the flags file is valid.
|
||||||
|
validFile := pathForValidation(ctx, monolithicFilePath)
|
||||||
|
|
||||||
|
// Create a rule to validate the output from the following rule.
|
||||||
|
rule := android.NewRuleBuilder(pctx, ctx)
|
||||||
|
rule.Command().
|
||||||
|
BuiltTool("verify_overlaps").
|
||||||
|
Input(monolithicFilePath).
|
||||||
|
Inputs(modularFilePaths).
|
||||||
|
// If validation passes then update the file that records that.
|
||||||
|
Text("&& touch").Output(validFile)
|
||||||
|
rule.Build(name+"Validation", desc+" validation")
|
||||||
|
|
||||||
|
return validFile
|
||||||
|
}
|
||||||
|
|
||||||
// hiddenAPIRulesForBootclasspathFragment will generate all the flags for a fragment of the
|
// hiddenAPIRulesForBootclasspathFragment will generate all the flags for a fragment of the
|
||||||
// bootclasspath and then encode the flags into the boot dex files.
|
// bootclasspath and then encode the flags into the boot dex files.
|
||||||
//
|
//
|
||||||
@@ -793,7 +806,7 @@ func hiddenAPIRulesForBootclasspathFragment(ctx android.ModuleContext, contents
|
|||||||
|
|
||||||
// Generate the stub-flags.csv.
|
// Generate the stub-flags.csv.
|
||||||
stubFlagsCSV := android.PathForModuleOut(ctx, hiddenApiSubDir, "stub-flags.csv")
|
stubFlagsCSV := android.PathForModuleOut(ctx, hiddenApiSubDir, "stub-flags.csv")
|
||||||
buildRuleToGenerateHiddenAPIStubFlagsFile(ctx, "modularHiddenAPIStubFlagsFile", "modular hiddenapi stub flags", stubFlagsCSV, bootDexInfoByModule.bootDexJars(), input)
|
buildRuleToGenerateHiddenAPIStubFlagsFile(ctx, "modularHiddenAPIStubFlagsFile", "modular hiddenapi stub flags", stubFlagsCSV, bootDexInfoByModule.bootDexJars(), input, nil)
|
||||||
|
|
||||||
// Extract the classes jars from the contents.
|
// Extract the classes jars from the contents.
|
||||||
classesJars := extractClassesJarsFromModules(contents)
|
classesJars := extractClassesJarsFromModules(contents)
|
||||||
|
@@ -315,7 +315,7 @@ func (b *platformBootclasspathModule) generateHiddenAPIBuildActions(ctx android.
|
|||||||
|
|
||||||
// Generate the monolithic stub-flags.csv file.
|
// Generate the monolithic stub-flags.csv file.
|
||||||
stubFlags := hiddenAPISingletonPaths(ctx).stubFlags
|
stubFlags := hiddenAPISingletonPaths(ctx).stubFlags
|
||||||
buildRuleToGenerateHiddenAPIStubFlagsFile(ctx, "platform-bootclasspath-monolithic-hiddenapi-stub-flags", "monolithic hidden API stub flags", stubFlags, bootDexJarByModule.bootDexJars(), input)
|
buildRuleToGenerateHiddenAPIStubFlagsFile(ctx, "platform-bootclasspath-monolithic-hiddenapi-stub-flags", "monolithic hidden API stub flags", stubFlags, bootDexJarByModule.bootDexJars(), input, monolithicInfo.StubFlagsPaths)
|
||||||
|
|
||||||
// Generate the annotation-flags.csv file from all the module annotations.
|
// Generate the annotation-flags.csv file from all the module annotations.
|
||||||
annotationFlags := android.PathForModuleOut(ctx, "hiddenapi-monolithic", "annotation-flags-from-classes.csv")
|
annotationFlags := android.PathForModuleOut(ctx, "hiddenapi-monolithic", "annotation-flags-from-classes.csv")
|
||||||
|
@@ -47,9 +47,9 @@ for subsetPath in args.subsets:
|
|||||||
if signature in allFlagsBySignature:
|
if signature in allFlagsBySignature:
|
||||||
allFlags = allFlagsBySignature.get(signature)
|
allFlags = allFlagsBySignature.get(signature)
|
||||||
if allFlags != row:
|
if allFlags != row:
|
||||||
mismatchingSignatures.append((signature, row[None], allFlags[None]))
|
mismatchingSignatures.append((signature, row.get(None, []), allFlags.get(None, [])))
|
||||||
else:
|
else:
|
||||||
mismatchingSignatures.append((signature, row[None], []))
|
mismatchingSignatures.append((signature, row.get(None, []), []))
|
||||||
|
|
||||||
|
|
||||||
if mismatchingSignatures:
|
if mismatchingSignatures:
|
||||||
@@ -60,7 +60,7 @@ for subsetPath in args.subsets:
|
|||||||
for mismatch in mismatchingSignatures:
|
for mismatch in mismatchingSignatures:
|
||||||
print()
|
print()
|
||||||
print("< " + mismatch[0] + "," + ",".join(mismatch[1]))
|
print("< " + mismatch[0] + "," + ",".join(mismatch[1]))
|
||||||
if mismatch[2] != None:
|
if mismatch[2] != []:
|
||||||
print("> " + mismatch[0] + "," + ",".join(mismatch[2]))
|
print("> " + mismatch[0] + "," + ",".join(mismatch[2]))
|
||||||
else:
|
else:
|
||||||
print("> " + mismatch[0] + " - missing")
|
print("> " + mismatch[0] + " - missing")
|
||||||
|
Reference in New Issue
Block a user