Always perform permitted package check when building a library
Previously, the permitted package check was designed to only be run
when building checkbuild. Although, that appears to now be broken.
This change uses a Validation dependency to ensure that the package
check is performed whenever the output file of a java_library is built
as part of the build. The package check runs in parallel with any other
rules that depend on the file.
Bug: 201753898
Test: - change the permitted_packages property in
frameworks/base/test-mock so that the package check will fail.
m out/soong/.intermediates/frameworks/base/test-mock/android.test.mock/android_common/package-check.stamp
- as expected the package check failed.
m droid
- as expected the package check did not fail.
# Made these changes then:
m droid
- as expected the package check now failed.
Merged-In: Id38fe280c79e5505ee4555b845c6da2ae6747bc4
Change-Id: Id38fe280c79e5505ee4555b845c6da2ae6747bc4
(cherry picked from commit 08a18bf74a
)
This commit is contained in:
19
java/base.go
19
java/base.go
@@ -1152,10 +1152,25 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) {
|
|||||||
|
|
||||||
// Check package restrictions if necessary.
|
// Check package restrictions if necessary.
|
||||||
if len(j.properties.Permitted_packages) > 0 {
|
if len(j.properties.Permitted_packages) > 0 {
|
||||||
// Check packages and copy to package-checked file.
|
// Time stamp file created by the package check rule.
|
||||||
pkgckFile := android.PathForModuleOut(ctx, "package-check.stamp")
|
pkgckFile := android.PathForModuleOut(ctx, "package-check.stamp")
|
||||||
|
|
||||||
|
// Create a rule to copy the output jar to another path and add a validate dependency that
|
||||||
|
// will check that the jar only contains the permitted packages. The new location will become
|
||||||
|
// the output file of this module.
|
||||||
|
inputFile := outputFile
|
||||||
|
outputFile = android.PathForModuleOut(ctx, "package-check", jarName).OutputPath
|
||||||
|
ctx.Build(pctx, android.BuildParams{
|
||||||
|
Rule: android.Cp,
|
||||||
|
Input: inputFile,
|
||||||
|
Output: outputFile,
|
||||||
|
// Make sure that any dependency on the output file will cause ninja to run the package check
|
||||||
|
// rule.
|
||||||
|
Validation: pkgckFile,
|
||||||
|
})
|
||||||
|
|
||||||
|
// Check packages and create a timestamp file when complete.
|
||||||
CheckJarPackages(ctx, pkgckFile, outputFile, j.properties.Permitted_packages)
|
CheckJarPackages(ctx, pkgckFile, outputFile, j.properties.Permitted_packages)
|
||||||
j.additionalCheckedModules = append(j.additionalCheckedModules, pkgckFile)
|
|
||||||
|
|
||||||
if ctx.Failed() {
|
if ctx.Failed() {
|
||||||
return
|
return
|
||||||
|
@@ -499,7 +499,7 @@ sdk_snapshot {
|
|||||||
.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/metadata.csv -> hiddenapi/metadata.csv
|
.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/metadata.csv -> hiddenapi/metadata.csv
|
||||||
.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/index.csv -> hiddenapi/index.csv
|
.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/index.csv -> hiddenapi/index.csv
|
||||||
.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/all-flags.csv -> hiddenapi/all-flags.csv
|
.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/all-flags.csv -> hiddenapi/all-flags.csv
|
||||||
.intermediates/mybootlib/android_common/javac/mybootlib.jar -> java/mybootlib.jar
|
.intermediates/mybootlib/android_common/package-check/mybootlib.jar -> java/mybootlib.jar
|
||||||
.intermediates/myothersdklibrary.stubs/android_common/javac/myothersdklibrary.stubs.jar -> sdk_library/public/myothersdklibrary-stubs.jar
|
.intermediates/myothersdklibrary.stubs/android_common/javac/myothersdklibrary.stubs.jar -> sdk_library/public/myothersdklibrary-stubs.jar
|
||||||
.intermediates/myothersdklibrary.stubs.source/android_common/metalava/myothersdklibrary.stubs.source_api.txt -> sdk_library/public/myothersdklibrary.txt
|
.intermediates/myothersdklibrary.stubs.source/android_common/metalava/myothersdklibrary.stubs.source_api.txt -> sdk_library/public/myothersdklibrary.txt
|
||||||
.intermediates/myothersdklibrary.stubs.source/android_common/metalava/myothersdklibrary.stubs.source_removed.txt -> sdk_library/public/myothersdklibrary-removed.txt
|
.intermediates/myothersdklibrary.stubs.source/android_common/metalava/myothersdklibrary.stubs.source_removed.txt -> sdk_library/public/myothersdklibrary-removed.txt
|
||||||
@@ -765,7 +765,7 @@ my-unsupported-packages.txt -> hiddenapi/my-unsupported-packages.txt
|
|||||||
.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/metadata.csv -> hiddenapi/metadata.csv
|
.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/metadata.csv -> hiddenapi/metadata.csv
|
||||||
.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/index.csv -> hiddenapi/index.csv
|
.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/index.csv -> hiddenapi/index.csv
|
||||||
.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/all-flags.csv -> hiddenapi/all-flags.csv
|
.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/all-flags.csv -> hiddenapi/all-flags.csv
|
||||||
.intermediates/mybootlib/android_common/javac/mybootlib.jar -> java/mybootlib.jar
|
.intermediates/mybootlib/android_common/package-check/mybootlib.jar -> java/mybootlib.jar
|
||||||
.intermediates/mysdklibrary.stubs/android_common/javac/mysdklibrary.stubs.jar -> sdk_library/public/mysdklibrary-stubs.jar
|
.intermediates/mysdklibrary.stubs/android_common/javac/mysdklibrary.stubs.jar -> sdk_library/public/mysdklibrary-stubs.jar
|
||||||
.intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt
|
.intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt
|
||||||
.intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_removed.txt -> sdk_library/public/mysdklibrary-removed.txt
|
.intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_removed.txt -> sdk_library/public/mysdklibrary-removed.txt
|
||||||
|
Reference in New Issue
Block a user