Merge "Separate apex selection from apex.Prebuilt"
diff --git a/cmd/pom2bp/pom2bp.go b/cmd/pom2bp/pom2bp.go
index d9116b0..d31489e 100644
--- a/cmd/pom2bp/pom2bp.go
+++ b/cmd/pom2bp/pom2bp.go
@@ -401,6 +401,8 @@
{{- end}}
],
{{- end}}
+ {{- else if not .IsHostOnly}}
+ min_sdk_version: "{{.DefaultMinSdkVersion}}",
{{- end}}
}
`))
@@ -442,6 +444,8 @@
{{- end}}
],
{{- end}}
+ {{- else if not .IsHostOnly}}
+ min_sdk_version: "{{.DefaultMinSdkVersion}}",
{{- end}}
}
diff --git a/java/hiddenapi_singleton.go b/java/hiddenapi_singleton.go
index 6ad4ff3..7e9477b 100644
--- a/java/hiddenapi_singleton.go
+++ b/java/hiddenapi_singleton.go
@@ -186,17 +186,6 @@
// We do not have prebuilts of the core platform api yet
corePlatformStubModules = append(corePlatformStubModules, "legacy.core.platform.api.stubs")
- // Add the android.test.base to the set of stubs only if the android.test.base module is on
- // the boot jars list as the runtime will only enforce hiddenapi access against modules on
- // that list.
- if inList("android.test.base", ctx.Config().BootJars()) {
- if ctx.Config().AlwaysUsePrebuiltSdks() {
- publicStubModules = append(publicStubModules, "sdk_public_current_android.test.base")
- } else {
- publicStubModules = append(publicStubModules, "android.test.base.stubs")
- }
- }
-
// Allow products to define their own stubs for custom product jars that apps can use.
publicStubModules = append(publicStubModules, ctx.Config().ProductHiddenAPIStubs()...)
systemStubModules = append(systemStubModules, ctx.Config().ProductHiddenAPIStubsSystem()...)
@@ -369,20 +358,20 @@
FlagWithInput("--csv ", stubFlags).
Inputs(flagsCSV).
FlagWithInput("--unsupported ",
- android.PathForSource(ctx, "frameworks/base/config/hiddenapi-unsupported.txt")).
+ android.PathForSource(ctx, "frameworks/base/boot/hiddenapi/hiddenapi-unsupported.txt")).
FlagWithInput("--unsupported ", combinedRemovedApis).Flag("--ignore-conflicts ").FlagWithArg("--tag ", "removed").
FlagWithInput("--max-target-r ",
- android.PathForSource(ctx, "frameworks/base/config/hiddenapi-max-target-r-loprio.txt")).FlagWithArg("--tag ", "lo-prio").
+ android.PathForSource(ctx, "frameworks/base/boot/hiddenapi/hiddenapi-max-target-r-loprio.txt")).FlagWithArg("--tag ", "lo-prio").
FlagWithInput("--max-target-q ",
- android.PathForSource(ctx, "frameworks/base/config/hiddenapi-max-target-q.txt")).
+ android.PathForSource(ctx, "frameworks/base/boot/hiddenapi/hiddenapi-max-target-q.txt")).
FlagWithInput("--max-target-p ",
- android.PathForSource(ctx, "frameworks/base/config/hiddenapi-max-target-p.txt")).
+ android.PathForSource(ctx, "frameworks/base/boot/hiddenapi/hiddenapi-max-target-p.txt")).
FlagWithInput("--max-target-o ", android.PathForSource(
- ctx, "frameworks/base/config/hiddenapi-max-target-o.txt")).Flag("--ignore-conflicts ").FlagWithArg("--tag ", "lo-prio").
+ ctx, "frameworks/base/boot/hiddenapi/hiddenapi-max-target-o.txt")).Flag("--ignore-conflicts ").FlagWithArg("--tag ", "lo-prio").
FlagWithInput("--blocked ",
- android.PathForSource(ctx, "frameworks/base/config/hiddenapi-force-blocked.txt")).
+ android.PathForSource(ctx, "frameworks/base/boot/hiddenapi/hiddenapi-force-blocked.txt")).
FlagWithInput("--unsupported ", android.PathForSource(
- ctx, "frameworks/base/config/hiddenapi-unsupported-packages.txt")).Flag("--packages ").
+ ctx, "frameworks/base/boot/hiddenapi/hiddenapi-unsupported-packages.txt")).Flag("--packages ").
FlagWithOutput("--output ", tempPath)
commitChangeForRestat(rule, tempPath, outputPath)
diff --git a/java/lint.go b/java/lint.go
index a91278a..30843dc 100644
--- a/java/lint.go
+++ b/java/lint.go
@@ -347,7 +347,7 @@
cmd := rule.Command()
- cmd.Flag("JAVA_OPTS=-Xmx3072m").
+ cmd.Flag(`JAVA_OPTS="-Xmx3072m --add-opens java.base/java.util=ALL-UNNAMED"`).
FlagWithArg("ANDROID_SDK_HOME=", lintPaths.homeDir.String()).
FlagWithInput("SDK_ANNOTATIONS=", annotationsZipPath).
FlagWithInput("LINT_OPTS=-DLINT_API_DATABASE=", apiVersionsXMLPath)
diff --git a/java/lint_defaults.txt b/java/lint_defaults.txt
index 0786b7c..2de05b0 100644
--- a/java/lint_defaults.txt
+++ b/java/lint_defaults.txt
@@ -76,3 +76,5 @@
# TODO(b/158390965): remove this when lint doesn't crash
--disable_check HardcodedDebugMode
+
+--warning_check QueryAllPackagesPermission
diff --git a/rust/androidmk.go b/rust/androidmk.go
index 0f9a17d..b0e6967 100644
--- a/rust/androidmk.go
+++ b/rust/androidmk.go
@@ -50,7 +50,7 @@
}
ret := android.AndroidMkEntries{
- OutputFile: mod.outputFile,
+ OutputFile: mod.unstrippedOutputFile,
Include: "$(BUILD_SYSTEM)/soong_rust_prebuilt.mk",
ExtraEntries: []android.AndroidMkExtraEntriesFunc{
func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
diff --git a/rust/compiler.go b/rust/compiler.go
index 41b7371..2e85f5a 100644
--- a/rust/compiler.go
+++ b/rust/compiler.go
@@ -272,6 +272,10 @@
return false
}
+func (compiler *baseCompiler) strippedOutputFilePath() android.OptionalPath {
+ return compiler.strippedOutputFile
+}
+
func (compiler *baseCompiler) compilerDeps(ctx DepsContext, deps Deps) Deps {
deps.Rlibs = append(deps.Rlibs, compiler.Properties.Rlibs...)
deps.Dylibs = append(deps.Dylibs, compiler.Properties.Dylibs...)
@@ -337,10 +341,7 @@
}
func (compiler *baseCompiler) install(ctx ModuleContext) {
- path := ctx.RustModule().outputFile
- if compiler.strippedOutputFile.Valid() {
- path = compiler.strippedOutputFile
- }
+ path := ctx.RustModule().OutputFile()
compiler.path = ctx.InstallFile(compiler.installDir(ctx), path.Path().Base(), path.Path())
}
diff --git a/rust/rust.go b/rust/rust.go
index f0d0e36..566ad37 100644
--- a/rust/rust.go
+++ b/rust/rust.go
@@ -114,7 +114,10 @@
sourceProvider SourceProvider
subAndroidMkOnce map[SubAndroidMkProvider]bool
- outputFile android.OptionalPath
+ // Unstripped output. This is usually used when this module is linked to another module
+ // as a library. The stripped output which is used for installation can be found via
+ // compiler.strippedOutputFile if it exists.
+ unstrippedOutputFile android.OptionalPath
hideApexVariantFromMake bool
}
@@ -163,8 +166,8 @@
if mod.sourceProvider != nil && (mod.compiler == nil || mod.compiler.Disabled()) {
return mod.sourceProvider.Srcs(), nil
} else {
- if mod.outputFile.Valid() {
- return android.Paths{mod.outputFile.Path()}, nil
+ if mod.OutputFile().Valid() {
+ return android.Paths{mod.OutputFile().Path()}, nil
}
return android.Paths{}, nil
}
@@ -346,6 +349,8 @@
stdLinkage(ctx *depsContext) RustLinkage
isDependencyRoot() bool
+
+ strippedOutputFilePath() android.OptionalPath
}
type exportedFlagsProducer interface {
@@ -523,7 +528,10 @@
}
func (mod *Module) OutputFile() android.OptionalPath {
- return mod.outputFile
+ if mod.compiler != nil && mod.compiler.strippedOutputFilePath().Valid() {
+ return mod.compiler.strippedOutputFilePath()
+ }
+ return mod.unstrippedOutputFile
}
func (mod *Module) CoverageFiles() android.Paths {
@@ -540,7 +548,7 @@
return false
}
- return mod.outputFile.Valid() && !mod.Properties.PreventInstall
+ return mod.OutputFile().Valid() && !mod.Properties.PreventInstall
}
var _ cc.LinkableInterface = (*Module)(nil)
@@ -721,9 +729,9 @@
if mod.compiler != nil && !mod.compiler.Disabled() {
mod.compiler.initialize(ctx)
- outputFile := mod.compiler.compile(ctx, flags, deps)
+ unstrippedOutputFile := mod.compiler.compile(ctx, flags, deps)
- mod.outputFile = android.OptionalPathForPath(outputFile)
+ mod.unstrippedOutputFile = android.OptionalPathForPath(unstrippedOutputFile)
apexInfo := actx.Provider(android.ApexInfoProvider).(android.ApexInfo)
if mod.installable(apexInfo) {
@@ -882,7 +890,7 @@
}
if depTag == dylibDepTag || depTag == rlibDepTag || depTag == procMacroDepTag {
- linkFile := rustDep.outputFile
+ linkFile := rustDep.unstrippedOutputFile
if !linkFile.Valid() {
ctx.ModuleErrorf("Invalid output file when adding dep %q to %q",
depName, ctx.ModuleName())
@@ -978,15 +986,15 @@
var rlibDepFiles RustLibraries
for _, dep := range directRlibDeps {
- rlibDepFiles = append(rlibDepFiles, RustLibrary{Path: dep.outputFile.Path(), CrateName: dep.CrateName()})
+ rlibDepFiles = append(rlibDepFiles, RustLibrary{Path: dep.unstrippedOutputFile.Path(), CrateName: dep.CrateName()})
}
var dylibDepFiles RustLibraries
for _, dep := range directDylibDeps {
- dylibDepFiles = append(dylibDepFiles, RustLibrary{Path: dep.outputFile.Path(), CrateName: dep.CrateName()})
+ dylibDepFiles = append(dylibDepFiles, RustLibrary{Path: dep.unstrippedOutputFile.Path(), CrateName: dep.CrateName()})
}
var procMacroDepFiles RustLibraries
for _, dep := range directProcMacroDeps {
- procMacroDepFiles = append(procMacroDepFiles, RustLibrary{Path: dep.outputFile.Path(), CrateName: dep.CrateName()})
+ procMacroDepFiles = append(procMacroDepFiles, RustLibrary{Path: dep.unstrippedOutputFile.Path(), CrateName: dep.CrateName()})
}
var staticLibDepFiles android.Paths
diff --git a/scripts/Android.bp b/scripts/Android.bp
index 9e8a602..c54b2bc 100644
--- a/scripts/Android.bp
+++ b/scripts/Android.bp
@@ -254,3 +254,22 @@
"linker_config_proto",
],
}
+
+python_binary_host {
+ name: "conv_classpaths_proto",
+ srcs: [
+ "conv_classpaths_proto.py",
+ ],
+ version: {
+ py2: {
+ enabled: false,
+ },
+ py3: {
+ enabled: true,
+ embedded_launcher: true,
+ },
+ },
+ libs: [
+ "classpaths_proto_python",
+ ],
+}
diff --git a/scripts/conv_classpaths_proto.py b/scripts/conv_classpaths_proto.py
new file mode 100644
index 0000000..f49fbbb
--- /dev/null
+++ b/scripts/conv_classpaths_proto.py
@@ -0,0 +1,76 @@
+# Copyright (C) 2021 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import argparse
+
+import classpaths_pb2
+
+import google.protobuf.json_format as json_format
+import google.protobuf.text_format as text_format
+
+
+def encode(args):
+ pb = classpaths_pb2.ExportedClasspathsJars()
+ if args.format == 'json':
+ json_format.Parse(args.input.read(), pb)
+ else:
+ text_format.Parse(args.input.read(), pb)
+ args.output.write(pb.SerializeToString())
+ args.input.close()
+ args.output.close()
+
+
+def decode(args):
+ pb = classpaths_pb2.ExportedClasspathsJars()
+ pb.ParseFromString(args.input.read())
+ if args.format == 'json':
+ args.output.write(json_format.MessageToJson(pb))
+ else:
+ args.output.write(text_format.MessageToString(pb).encode('utf_8'))
+ args.input.close()
+ args.output.close()
+
+
+def main():
+ parser = argparse.ArgumentParser('Convert classpaths.proto messages between binary and '
+ 'human-readable formats.')
+ parser.add_argument('-f', '--format', default='textproto',
+ help='human-readable format, either json or text(proto), '
+ 'defaults to textproto')
+ parser.add_argument('-i', '--input',
+ nargs='?', type=argparse.FileType('rb'), default=sys.stdin.buffer)
+ parser.add_argument('-o', '--output',
+ nargs='?', type=argparse.FileType('wb'),
+ default=sys.stdout.buffer)
+
+ subparsers = parser.add_subparsers()
+
+ parser_encode = subparsers.add_parser('encode',
+ help='convert classpaths protobuf message from '
+ 'JSON to binary format',
+ parents=[parser], add_help=False)
+
+ parser_encode.set_defaults(func=encode)
+
+ parser_decode = subparsers.add_parser('decode',
+ help='print classpaths config in JSON format',
+ parents=[parser], add_help=False)
+ parser_decode.set_defaults(func=decode)
+
+ args = parser.parse_args()
+ args.func(args)
+
+
+if __name__ == '__main__':
+ main()