Merge "Dedup hidden API rule generation" am: 2bc8b3a646
am: 93b312c2dd
am: 29c6e9fa55
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1707572 Change-Id: I584f17bd5ee9092730d4e37c5b34233805dd6b1a
This commit is contained in:
commit
f8b776e97f
|
@ -260,23 +260,40 @@ func (h *hiddenAPI) hiddenAPIExtractInformation(ctx android.ModuleContext, dexJa
|
||||||
stubFlagsCSV := hiddenAPISingletonPaths(ctx).stubFlags
|
stubFlagsCSV := hiddenAPISingletonPaths(ctx).stubFlags
|
||||||
|
|
||||||
flagsCSV := android.PathForModuleOut(ctx, "hiddenapi", "flags.csv")
|
flagsCSV := android.PathForModuleOut(ctx, "hiddenapi", "flags.csv")
|
||||||
|
h.flagsCSVPath = flagsCSV
|
||||||
|
buildRuleToGenerateAnnotationFlags(ctx, "hiddenapi flags", classesJars, stubFlagsCSV, flagsCSV)
|
||||||
|
|
||||||
|
metadataCSV := android.PathForModuleOut(ctx, "hiddenapi", "metadata.csv")
|
||||||
|
h.metadataCSVPath = metadataCSV
|
||||||
|
buildRuleToGenerateMetadata(ctx, "hiddenapi metadata", classesJars, stubFlagsCSV, metadataCSV)
|
||||||
|
|
||||||
|
indexCSV := android.PathForModuleOut(ctx, "hiddenapi", "index.csv")
|
||||||
|
h.indexCSVPath = indexCSV
|
||||||
|
buildRuleToGenerateIndex(ctx, "Merged Hidden API index", classesJars, indexCSV)
|
||||||
|
}
|
||||||
|
|
||||||
|
// buildRuleToGenerateAnnotationFlags builds a ninja rule to generate the annotation-flags.csv file
|
||||||
|
// from the classes jars and stub-flags.csv files.
|
||||||
|
func buildRuleToGenerateAnnotationFlags(ctx android.ModuleContext, desc string, classesJars android.Paths, stubFlagsCSV android.Path, outputPath android.WritablePath) {
|
||||||
ctx.Build(pctx, android.BuildParams{
|
ctx.Build(pctx, android.BuildParams{
|
||||||
Rule: hiddenAPIGenerateCSVRule,
|
Rule: hiddenAPIGenerateCSVRule,
|
||||||
Description: "hiddenapi flags",
|
Description: desc,
|
||||||
Inputs: classesJars,
|
Inputs: classesJars,
|
||||||
Output: flagsCSV,
|
Output: outputPath,
|
||||||
Implicit: stubFlagsCSV,
|
Implicit: stubFlagsCSV,
|
||||||
Args: map[string]string{
|
Args: map[string]string{
|
||||||
"outFlag": "--write-flags-csv",
|
"outFlag": "--write-flags-csv",
|
||||||
"stubAPIFlags": stubFlagsCSV.String(),
|
"stubAPIFlags": stubFlagsCSV.String(),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
h.flagsCSVPath = flagsCSV
|
}
|
||||||
|
|
||||||
metadataCSV := android.PathForModuleOut(ctx, "hiddenapi", "metadata.csv")
|
// buildRuleToGenerateMetadata builds a ninja rule to generate the metadata.csv file from
|
||||||
|
// the classes jars and stub-flags.csv files.
|
||||||
|
func buildRuleToGenerateMetadata(ctx android.ModuleContext, desc string, classesJars android.Paths, stubFlagsCSV android.Path, metadataCSV android.WritablePath) {
|
||||||
ctx.Build(pctx, android.BuildParams{
|
ctx.Build(pctx, android.BuildParams{
|
||||||
Rule: hiddenAPIGenerateCSVRule,
|
Rule: hiddenAPIGenerateCSVRule,
|
||||||
Description: "hiddenapi metadata",
|
Description: desc,
|
||||||
Inputs: classesJars,
|
Inputs: classesJars,
|
||||||
Output: metadataCSV,
|
Output: metadataCSV,
|
||||||
Implicit: stubFlagsCSV,
|
Implicit: stubFlagsCSV,
|
||||||
|
@ -285,9 +302,11 @@ func (h *hiddenAPI) hiddenAPIExtractInformation(ctx android.ModuleContext, dexJa
|
||||||
"stubAPIFlags": stubFlagsCSV.String(),
|
"stubAPIFlags": stubFlagsCSV.String(),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
h.metadataCSVPath = metadataCSV
|
}
|
||||||
|
|
||||||
indexCSV := android.PathForModuleOut(ctx, "hiddenapi", "index.csv")
|
// buildRuleToGenerateMetadata builds a ninja rule to generate the index.csv file from the classes
|
||||||
|
// jars.
|
||||||
|
func buildRuleToGenerateIndex(ctx android.ModuleContext, desc string, classesJars android.Paths, indexCSV android.WritablePath) {
|
||||||
rule := android.NewRuleBuilder(pctx, ctx)
|
rule := android.NewRuleBuilder(pctx, ctx)
|
||||||
rule.Command().
|
rule.Command().
|
||||||
BuiltTool("merge_csv").
|
BuiltTool("merge_csv").
|
||||||
|
@ -295,8 +314,7 @@ func (h *hiddenAPI) hiddenAPIExtractInformation(ctx android.ModuleContext, dexJa
|
||||||
Flag("--key_field signature").
|
Flag("--key_field signature").
|
||||||
FlagWithOutput("--output=", indexCSV).
|
FlagWithOutput("--output=", indexCSV).
|
||||||
Inputs(classesJars)
|
Inputs(classesJars)
|
||||||
rule.Build("merged-hiddenapi-index", "Merged Hidden API index")
|
rule.Build(desc, desc)
|
||||||
h.indexCSVPath = indexCSV
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var hiddenAPIEncodeDexRule = pctx.AndroidStaticRule("hiddenAPIEncodeDex", blueprint.RuleParams{
|
var hiddenAPIEncodeDexRule = pctx.AndroidStaticRule("hiddenAPIEncodeDex", blueprint.RuleParams{
|
||||||
|
|
|
@ -522,42 +522,15 @@ func hiddenAPIGenerateAllFlagsForBootclasspathFragment(ctx android.ModuleContext
|
||||||
|
|
||||||
// Generate the set of flags from the annotations in the source code.
|
// Generate the set of flags from the annotations in the source code.
|
||||||
annotationFlagsCSV := android.PathForModuleOut(ctx, hiddenApiSubDir, "annotation-flags.csv")
|
annotationFlagsCSV := android.PathForModuleOut(ctx, hiddenApiSubDir, "annotation-flags.csv")
|
||||||
ctx.Build(pctx, android.BuildParams{
|
buildRuleToGenerateAnnotationFlags(ctx, "modular hiddenapi annotation flags", classesJars, stubFlagsCSV, annotationFlagsCSV)
|
||||||
Rule: hiddenAPIGenerateCSVRule,
|
|
||||||
Description: "modular hiddenapi annotation flags",
|
|
||||||
Inputs: classesJars,
|
|
||||||
Output: annotationFlagsCSV,
|
|
||||||
Implicit: stubFlagsCSV,
|
|
||||||
Args: map[string]string{
|
|
||||||
"outFlag": "--write-flags-csv",
|
|
||||||
"stubAPIFlags": stubFlagsCSV.String(),
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
// Generate the metadata from the annotations in the source code.
|
// Generate the metadata from the annotations in the source code.
|
||||||
metadataCSV := android.PathForModuleOut(ctx, hiddenApiSubDir, "metadata.csv")
|
metadataCSV := android.PathForModuleOut(ctx, hiddenApiSubDir, "metadata.csv")
|
||||||
ctx.Build(pctx, android.BuildParams{
|
buildRuleToGenerateMetadata(ctx, "modular hiddenapi metadata", classesJars, stubFlagsCSV, metadataCSV)
|
||||||
Rule: hiddenAPIGenerateCSVRule,
|
|
||||||
Description: "modular hiddenapi metadata",
|
|
||||||
Inputs: classesJars,
|
|
||||||
Output: metadataCSV,
|
|
||||||
Implicit: stubFlagsCSV,
|
|
||||||
Args: map[string]string{
|
|
||||||
"outFlag": "--write-metadata-csv",
|
|
||||||
"stubAPIFlags": stubFlagsCSV.String(),
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
// Generate the index file from the annotations in the source code.
|
// Generate the index file from the annotations in the source code.
|
||||||
indexCSV := android.PathForModuleOut(ctx, hiddenApiSubDir, "index.csv")
|
indexCSV := android.PathForModuleOut(ctx, hiddenApiSubDir, "index.csv")
|
||||||
rule = android.NewRuleBuilder(pctx, ctx)
|
buildRuleToGenerateIndex(ctx, "modular hiddenapi index", classesJars, indexCSV)
|
||||||
rule.Command().
|
|
||||||
BuiltTool("merge_csv").
|
|
||||||
Flag("--zip_input").
|
|
||||||
Flag("--key_field signature").
|
|
||||||
FlagWithOutput("--output=", indexCSV).
|
|
||||||
Inputs(classesJars)
|
|
||||||
rule.Build("modular-hiddenapi-index", "modular hiddenapi index")
|
|
||||||
|
|
||||||
// Removed APIs need to be marked and in order to do that the flagFileInfo needs to specify files
|
// Removed APIs need to be marked and in order to do that the flagFileInfo needs to specify files
|
||||||
// containing dex signatures of all the removed APIs. In the monolithic files that is done by
|
// containing dex signatures of all the removed APIs. In the monolithic files that is done by
|
||||||
|
|
Loading…
Reference in New Issue