Merge changes I2373d366,I908496d9
* changes:
rust: Add common interface for binaries
rust: Support whole static libraries with any name
diff --git a/android/androidmk.go b/android/androidmk.go
index f5a9f87..b6b04a6 100644
--- a/android/androidmk.go
+++ b/android/androidmk.go
@@ -516,6 +516,16 @@
a.AddStrings("LOCAL_HOST_REQUIRED_MODULES", a.Host_required...)
a.AddStrings("LOCAL_TARGET_REQUIRED_MODULES", a.Target_required...)
+ // If the install rule was generated by Soong tell Make about it.
+ if amod.InstallBypassMake() && len(base.katiInstalls) > 0 {
+ // Assume the primary install file is last since it probably needs to depend on any other
+ // installed files. If that is not the case we can add a method to specify the primary
+ // installed file.
+ a.SetPath("LOCAL_SOONG_INSTALLED_MODULE", base.katiInstalls[len(base.katiInstalls)-1].to)
+ a.SetString("LOCAL_SOONG_INSTALL_PAIRS", base.katiInstalls.BuiltInstalled())
+ a.SetPaths("LOCAL_SOONG_INSTALL_SYMLINKS", base.katiSymlinks.InstallPaths().Paths())
+ }
+
if am, ok := mod.(ApexModule); ok {
a.SetBoolIfTrue("LOCAL_NOT_AVAILABLE_FOR_PLATFORM", am.NotAvailableForPlatform())
}
@@ -911,6 +921,11 @@
return true
}
+ // Only expose the primary Darwin target, as Make does not understand Darwin+Arm64
+ if module.Os() == Darwin && module.Target().HostCross {
+ return true
+ }
+
return !module.Enabled() ||
module.commonProperties.HideFromMake ||
// Make does not understand LinuxBionic
diff --git a/android/arch.go b/android/arch.go
index 5e3e920..3bf54b7 100644
--- a/android/arch.go
+++ b/android/arch.go
@@ -308,7 +308,7 @@
// LinuxMusl is the OS for the Linux kernel plus the musl runtime.
LinuxMusl = newOsType("linux_musl", Host, false, X86, X86_64)
// Darwin is the OS for MacOS/Darwin host machines.
- Darwin = newOsType("darwin", Host, false, X86_64)
+ Darwin = newOsType("darwin", Host, false, Arm64, X86_64)
// LinuxBionic is the OS for the Linux kernel plus the Bionic libc runtime, but without the
// rest of Android.
LinuxBionic = newOsType("linux_bionic", Host, false, Arm64, X86_64)
@@ -696,6 +696,11 @@
for i, m := range modules {
addTargetProperties(m, targets[i], multiTargets, i == 0)
m.base().setArchProperties(mctx)
+
+ // Install support doesn't understand Darwin+Arm64
+ if os == Darwin && targets[i].HostCross {
+ m.base().commonProperties.SkipInstall = true
+ }
}
}
diff --git a/android/makevars.go b/android/makevars.go
index 40c0ccd..20db65a 100644
--- a/android/makevars.go
+++ b/android/makevars.go
@@ -17,6 +17,8 @@
import (
"bytes"
"fmt"
+ "path/filepath"
+ "runtime"
"sort"
"strings"
@@ -222,6 +224,9 @@
lateOutFile := absolutePath(PathForOutput(ctx,
"late"+proptools.String(ctx.Config().productVariables.Make_suffix)+".mk").String())
+ installsFile := absolutePath(PathForOutput(ctx,
+ "installs"+proptools.String(ctx.Config().productVariables.Make_suffix)+".mk").String())
+
if ctx.Failed() {
return
}
@@ -229,6 +234,8 @@
var vars []makeVarsVariable
var dists []dist
var phonies []phony
+ var katiInstalls []katiInstall
+ var katiSymlinks []katiInstall
providers := append([]makeVarsProvider(nil), makeVarsInitProviders...)
providers = append(providers, *ctx.Config().Get(singletonMakeVarsProvidersKey).(*[]makeVarsProvider)...)
@@ -258,6 +265,11 @@
phonies = append(phonies, mctx.phonies...)
dists = append(dists, mctx.dists...)
}
+
+ if m.ExportedToMake() {
+ katiInstalls = append(katiInstalls, m.base().katiInstalls...)
+ katiSymlinks = append(katiSymlinks, m.base().katiSymlinks...)
+ }
})
if ctx.Failed() {
@@ -297,6 +309,10 @@
ctx.Errorf(err.Error())
}
+ installsBytes := s.writeInstalls(katiInstalls, katiSymlinks)
+ if err := pathtools.WriteFileIfChanged(installsFile, installsBytes, 0666); err != nil {
+ ctx.Errorf(err.Error())
+ }
}
func (s *makeVarsSingleton) writeVars(vars []makeVarsVariable) []byte {
@@ -405,6 +421,84 @@
return buf.Bytes()
}
+// writeInstalls writes the list of install rules generated by Soong to a makefile. The rules
+// are exported to Make instead of written directly to the ninja file so that main.mk can add
+// the dependencies from the `required` property that are hard to resolve in Soong.
+func (s *makeVarsSingleton) writeInstalls(installs, symlinks []katiInstall) []byte {
+ buf := &bytes.Buffer{}
+
+ fmt.Fprint(buf, `# Autogenerated file
+
+# Values written by Soong to generate install rules that can be amended by Kati.
+
+
+`)
+
+ preserveSymlinksFlag := "-d"
+ if runtime.GOOS == "darwin" {
+ preserveSymlinksFlag = "-R"
+ }
+
+ for _, install := range installs {
+ // Write a rule for each install request in the form:
+ // to: from [ deps ] [ | order only deps ]
+ // cp -f -d $< $@ [ && chmod +x $@ ]
+ fmt.Fprintf(buf, "%s: %s", install.to.String(), install.from.String())
+ for _, dep := range install.implicitDeps {
+ fmt.Fprintf(buf, " %s", dep.String())
+ }
+ if len(install.orderOnlyDeps) > 0 {
+ fmt.Fprintf(buf, " |")
+ }
+ for _, dep := range install.orderOnlyDeps {
+ fmt.Fprintf(buf, " %s", dep.String())
+ }
+ fmt.Fprintln(buf)
+
+ fmt.Fprintf(buf, "\trm -f $@ && cp -f %s $< $@", preserveSymlinksFlag)
+ if install.executable {
+ fmt.Fprintf(buf, " && chmod +x $@")
+ }
+ fmt.Fprintln(buf)
+ fmt.Fprintln(buf)
+ }
+
+ for _, symlink := range symlinks {
+ fmt.Fprintf(buf, "%s:", symlink.to.String())
+ for _, dep := range symlink.implicitDeps {
+ fmt.Fprintf(buf, " %s", dep.String())
+ }
+ if symlink.from != nil || len(symlink.orderOnlyDeps) > 0 {
+ fmt.Fprintf(buf, " |")
+ }
+ if symlink.from != nil {
+ fmt.Fprintf(buf, " %s", symlink.from.String())
+ }
+ for _, dep := range symlink.orderOnlyDeps {
+ fmt.Fprintf(buf, " %s", dep.String())
+ }
+ fmt.Fprintln(buf)
+
+ fromStr := ""
+ if symlink.from != nil {
+ rel, err := filepath.Rel(filepath.Dir(symlink.to.String()), symlink.from.String())
+ if err != nil {
+ panic(fmt.Errorf("failed to find relative path for symlink from %q to %q: %w",
+ symlink.from.String(), symlink.to.String(), err))
+ }
+ fromStr = rel
+ } else {
+ fromStr = symlink.absFrom
+ }
+
+ fmt.Fprintf(buf, "\trm -f $@ && ln -sfn %s $@", fromStr)
+ fmt.Fprintln(buf)
+ fmt.Fprintln(buf)
+ }
+
+ return buf.Bytes()
+}
+
func (c *makeVarsContext) DeviceConfig() DeviceConfig {
return DeviceConfig{c.Config().deviceConfig}
}
diff --git a/android/module.go b/android/module.go
index 503fff3..3447f2b 100644
--- a/android/module.go
+++ b/android/module.go
@@ -1194,7 +1194,10 @@
packagingSpecs []PackagingSpec
packagingSpecsDepSet *packagingSpecsDepSet
noticeFiles Paths
- phonies map[string]Paths
+ // katiInstalls tracks the install rules that were created by Soong but are being exported
+ // to Make to convert to ninja rules so that Make can add additional dependencies.
+ katiInstalls katiInstalls
+ katiSymlinks katiInstalls
// The files to copy to the dist as explicitly specified in the .bp file.
distFiles TaggedDistFiles
@@ -2016,9 +2019,8 @@
m.checkbuildFiles = append(m.checkbuildFiles, ctx.checkbuildFiles...)
m.tidyFiles = append(m.tidyFiles, ctx.tidyFiles...)
m.packagingSpecs = append(m.packagingSpecs, ctx.packagingSpecs...)
- for k, v := range ctx.phonies {
- m.phonies[k] = append(m.phonies[k], v...)
- }
+ m.katiInstalls = append(m.katiInstalls, ctx.katiInstalls...)
+ m.katiSymlinks = append(m.katiSymlinks, ctx.katiSymlinks...)
} else if ctx.Config().AllowMissingDependencies() {
// If the module is not enabled it will not create any build rules, nothing will call
// ctx.GetMissingDependencies(), and blueprint will consider the missing dependencies to be unhandled
@@ -2217,12 +2219,52 @@
module Module
phonies map[string]Paths
+ katiInstalls []katiInstall
+ katiSymlinks []katiInstall
+
// For tests
buildParams []BuildParams
ruleParams map[blueprint.Rule]blueprint.RuleParams
variables map[string]string
}
+// katiInstall stores a request from Soong to Make to create an install rule.
+type katiInstall struct {
+ from Path
+ to InstallPath
+ implicitDeps Paths
+ orderOnlyDeps Paths
+ executable bool
+
+ absFrom string
+}
+
+type katiInstalls []katiInstall
+
+// BuiltInstalled returns the katiInstalls in the form used by $(call copy-many-files) in Make, a
+// space separated list of from:to tuples.
+func (installs katiInstalls) BuiltInstalled() string {
+ sb := strings.Builder{}
+ for i, install := range installs {
+ if i != 0 {
+ sb.WriteRune(' ')
+ }
+ sb.WriteString(install.from.String())
+ sb.WriteRune(':')
+ sb.WriteString(install.to.String())
+ }
+ return sb.String()
+}
+
+// InstallPaths returns the install path of each entry.
+func (installs katiInstalls) InstallPaths() InstallPaths {
+ paths := make(InstallPaths, 0, len(installs))
+ for _, install := range installs {
+ paths = append(paths, install.to)
+ }
+ return paths
+}
+
func (m *moduleContext) ninjaError(params BuildParams, err error) (PackageContext, BuildParams) {
return pctx, BuildParams{
Rule: ErrorRule,
@@ -2854,20 +2896,33 @@
orderOnlyDeps = deps
}
- rule := Cp
- if executable {
- rule = CpExecutable
- }
+ if m.Config().KatiEnabled() && m.InstallBypassMake() {
+ // When creating the install rule in Soong but embedding in Make, write the rule to a
+ // makefile instead of directly to the ninja file so that main.mk can add the
+ // dependencies from the `required` property that are hard to resolve in Soong.
+ m.katiInstalls = append(m.katiInstalls, katiInstall{
+ from: srcPath,
+ to: fullInstallPath,
+ implicitDeps: implicitDeps,
+ orderOnlyDeps: orderOnlyDeps,
+ executable: executable,
+ })
+ } else {
+ rule := Cp
+ if executable {
+ rule = CpExecutable
+ }
- m.Build(pctx, BuildParams{
- Rule: rule,
- Description: "install " + fullInstallPath.Base(),
- Output: fullInstallPath,
- Input: srcPath,
- Implicits: implicitDeps,
- OrderOnly: orderOnlyDeps,
- Default: !m.Config().KatiEnabled(),
- })
+ m.Build(pctx, BuildParams{
+ Rule: rule,
+ Description: "install " + fullInstallPath.Base(),
+ Output: fullInstallPath,
+ Input: srcPath,
+ Implicits: implicitDeps,
+ OrderOnly: orderOnlyDeps,
+ Default: !m.Config().KatiEnabled(),
+ })
+ }
m.installFiles = append(m.installFiles, fullInstallPath)
}
@@ -2889,16 +2944,26 @@
}
if !m.skipInstall() {
- m.Build(pctx, BuildParams{
- Rule: Symlink,
- Description: "install symlink " + fullInstallPath.Base(),
- Output: fullInstallPath,
- Input: srcPath,
- Default: !m.Config().KatiEnabled(),
- Args: map[string]string{
- "fromPath": relPath,
- },
- })
+ if m.Config().KatiEnabled() && m.InstallBypassMake() {
+ // When creating the symlink rule in Soong but embedding in Make, write the rule to a
+ // makefile instead of directly to the ninja file so that main.mk can add the
+ // dependencies from the `required` property that are hard to resolve in Soong.
+ m.katiSymlinks = append(m.katiSymlinks, katiInstall{
+ from: srcPath,
+ to: fullInstallPath,
+ })
+ } else {
+ m.Build(pctx, BuildParams{
+ Rule: Symlink,
+ Description: "install symlink " + fullInstallPath.Base(),
+ Output: fullInstallPath,
+ Input: srcPath,
+ Default: !m.Config().KatiEnabled(),
+ Args: map[string]string{
+ "fromPath": relPath,
+ },
+ })
+ }
m.installFiles = append(m.installFiles, fullInstallPath)
m.checkbuildFiles = append(m.checkbuildFiles, srcPath)
@@ -2921,15 +2986,25 @@
m.module.base().hooks.runInstallHooks(m, nil, fullInstallPath, true)
if !m.skipInstall() {
- m.Build(pctx, BuildParams{
- Rule: Symlink,
- Description: "install symlink " + fullInstallPath.Base() + " -> " + absPath,
- Output: fullInstallPath,
- Default: !m.Config().KatiEnabled(),
- Args: map[string]string{
- "fromPath": absPath,
- },
- })
+ if m.Config().KatiEnabled() && m.InstallBypassMake() {
+ // When creating the symlink rule in Soong but embedding in Make, write the rule to a
+ // makefile instead of directly to the ninja file so that main.mk can add the
+ // dependencies from the `required` property that are hard to resolve in Soong.
+ m.katiSymlinks = append(m.katiSymlinks, katiInstall{
+ absFrom: absPath,
+ to: fullInstallPath,
+ })
+ } else {
+ m.Build(pctx, BuildParams{
+ Rule: Symlink,
+ Description: "install symlink " + fullInstallPath.Base() + " -> " + absPath,
+ Output: fullInstallPath,
+ Default: !m.Config().KatiEnabled(),
+ Args: map[string]string{
+ "fromPath": absPath,
+ },
+ })
+ }
m.installFiles = append(m.installFiles, fullInstallPath)
}
diff --git a/bazel/configurability.go b/bazel/configurability.go
index e9641e7..f05c8e5 100644
--- a/bazel/configurability.go
+++ b/bazel/configurability.go
@@ -39,6 +39,7 @@
osArchAndroidArm64 = "android_arm64"
osArchAndroidX86 = "android_x86"
osArchAndroidX86_64 = "android_x86_64"
+ osArchDarwinArm64 = "darwin_arm64"
osArchDarwinX86_64 = "darwin_x86_64"
osArchLinuxX86 = "linux_glibc_x86"
osArchLinuxX86_64 = "linux_glibc_x86_64"
@@ -96,6 +97,7 @@
osArchAndroidArm64: "//build/bazel/platforms/os_arch:android_arm64",
osArchAndroidX86: "//build/bazel/platforms/os_arch:android_x86",
osArchAndroidX86_64: "//build/bazel/platforms/os_arch:android_x86_64",
+ osArchDarwinArm64: "//build/bazel/platforms/os_arch:darwin_arm64",
osArchDarwinX86_64: "//build/bazel/platforms/os_arch:darwin_x86_64",
osArchLinuxX86: "//build/bazel/platforms/os_arch:linux_glibc_x86",
osArchLinuxX86_64: "//build/bazel/platforms/os_arch:linux_glibc_x86_64",
diff --git a/cc/config/Android.bp b/cc/config/Android.bp
index 3e8ee48..7b7ee28 100644
--- a/cc/config/Android.bp
+++ b/cc/config/Android.bp
@@ -24,7 +24,7 @@
"x86_device.go",
"x86_64_device.go",
- "x86_darwin_host.go",
+ "darwin_host.go",
"x86_linux_host.go",
"x86_linux_bionic_host.go",
"x86_windows_host.go",
diff --git a/cc/config/x86_darwin_host.go b/cc/config/darwin_host.go
similarity index 81%
rename from cc/config/x86_darwin_host.go
rename to cc/config/darwin_host.go
index ad82b94..318acb4 100644
--- a/cc/config/x86_darwin_host.go
+++ b/cc/config/darwin_host.go
@@ -53,9 +53,6 @@
}
darwinSupportedSdkVersions = []string{
- "10.13",
- "10.14",
- "10.15",
"11",
}
@@ -174,19 +171,43 @@
toolchain64Bit
}
-func (t *toolchainDarwin) Name() string {
+type toolchainDarwinX86 struct {
+ toolchainDarwin
+}
+
+type toolchainDarwinArm struct {
+ toolchainDarwin
+}
+
+func (t *toolchainDarwinArm) Name() string {
+ return "arm64"
+}
+
+func (t *toolchainDarwinX86) Name() string {
return "x86_64"
}
-func (t *toolchainDarwin) GccRoot() string {
+func (t *toolchainDarwinArm) GccRoot() string {
+ panic("unimplemented")
+}
+
+func (t *toolchainDarwinArm) GccTriple() string {
+ panic("unimplemented")
+}
+
+func (t *toolchainDarwinArm) GccVersion() string {
+ panic("unimplemented")
+}
+
+func (t *toolchainDarwinX86) GccRoot() string {
return "${config.DarwinGccRoot}"
}
-func (t *toolchainDarwin) GccTriple() string {
+func (t *toolchainDarwinX86) GccTriple() string {
return "${config.DarwinGccTriple}"
}
-func (t *toolchainDarwin) GccVersion() string {
+func (t *toolchainDarwinX86) GccVersion() string {
return darwinGccVersion
}
@@ -194,7 +215,11 @@
return ""
}
-func (t *toolchainDarwin) ClangTriple() string {
+func (t *toolchainDarwinArm) ClangTriple() string {
+ return "aarch64-apple-darwin"
+}
+
+func (t *toolchainDarwinX86) ClangTriple() string {
return "x86_64-apple-darwin"
}
@@ -230,12 +255,18 @@
return "${config.MacToolPath}"
}
-var toolchainDarwinSingleton Toolchain = &toolchainDarwin{}
+var toolchainDarwinArmSingleton Toolchain = &toolchainDarwinArm{}
+var toolchainDarwinX86Singleton Toolchain = &toolchainDarwinX86{}
-func darwinToolchainFactory(arch android.Arch) Toolchain {
- return toolchainDarwinSingleton
+func darwinArmToolchainFactory(arch android.Arch) Toolchain {
+ return toolchainDarwinArmSingleton
+}
+
+func darwinX86ToolchainFactory(arch android.Arch) Toolchain {
+ return toolchainDarwinX86Singleton
}
func init() {
- registerToolchainFactory(android.Darwin, android.X86_64, darwinToolchainFactory)
+ registerToolchainFactory(android.Darwin, android.Arm64, darwinArmToolchainFactory)
+ registerToolchainFactory(android.Darwin, android.X86_64, darwinX86ToolchainFactory)
}
diff --git a/java/Android.bp b/java/Android.bp
index 78d0cc1..8835b44 100644
--- a/java/Android.bp
+++ b/java/Android.bp
@@ -93,6 +93,7 @@
"platform_bootclasspath_test.go",
"platform_compat_config_test.go",
"plugin_test.go",
+ "prebuilt_apis_test.go",
"rro_test.go",
"sdk_test.go",
"sdk_library_test.go",
diff --git a/java/bootclasspath_fragment.go b/java/bootclasspath_fragment.go
index 8f18790..bfa6838 100644
--- a/java/bootclasspath_fragment.go
+++ b/java/bootclasspath_fragment.go
@@ -616,6 +616,8 @@
// This is an exception to support end-to-end test for SdkExtensions, until such support exists.
if android.InList("test_framework-sdkextensions", possibleUpdatableModules) {
jars = jars.Append("com.android.sdkext", "test_framework-sdkextensions")
+ } else if android.InList("test_framework-apexd", possibleUpdatableModules) {
+ jars = jars.Append("com.android.apex.test_package", "test_framework-apexd")
} else if global.ApexBootJars.Len() != 0 && !android.IsModuleInVersionedSdk(ctx.Module()) {
unknown = android.RemoveListFromList(unknown, b.properties.Coverage.Contents)
_, unknown = android.RemoveFromList("core-icu4j", unknown)
diff --git a/java/core-libraries/Android.bp b/java/core-libraries/Android.bp
index b198c24..2eafe9d 100644
--- a/java/core-libraries/Android.bp
+++ b/java/core-libraries/Android.bp
@@ -28,6 +28,11 @@
default_applicable_licenses: ["Android-Apache-2.0"],
}
+dist_targets = [
+ "sdk",
+ "win_sdk",
+]
+
java_library {
name: "core.current.stubs",
visibility: ["//visibility:public"],
@@ -40,15 +45,16 @@
system_modules: "none",
dist: {
- targets: [
- "sdk",
- "win_sdk",
- ],
+ targets: dist_targets,
},
}
// Distributed with the SDK for turning into system modules to compile apps
// against.
+//
+// Also, produces dist files that are used by the
+// prebuilts/sdk/update_prebuilts.py script to update the prebuilts/sdk
+// directory.
java_library {
name: "core-current-stubs-for-system-modules",
visibility: ["//development/sdk"],
@@ -65,13 +71,17 @@
],
sdk_version: "none",
system_modules: "none",
- dist: {
- dest: "core-for-system-modules.jar",
- targets: [
- "sdk",
- "win_sdk",
- ],
- },
+ dists: [
+ {
+ // Legacy dist location for the public file.
+ dest: "core-for-system-modules.jar",
+ targets: dist_targets,
+ },
+ {
+ dest: "system-modules/public/core-for-system-modules.jar",
+ targets: dist_targets,
+ },
+ ],
}
// Used when compiling higher-level code against core.current.stubs.
@@ -103,10 +113,13 @@
visibility: ["//visibility:private"],
}
-// Used when compiling higher-level code with sdk_version "module_current"
-java_system_modules {
- name: "core-module-lib-stubs-system-modules",
- libs: [
+// Produces a dist file that is used by the
+// prebuilts/sdk/update_prebuilts.py script to update the prebuilts/sdk
+// directory.
+java_library {
+ name: "core-module-lib-stubs-for-system-modules",
+ visibility: ["//visibility:private"],
+ static_libs: [
"core.module_lib.stubs",
// This one is not on device but it's needed when javac compiles code
// containing lambdas.
@@ -117,6 +130,20 @@
// See http://b/123891440.
"core-generated-annotation-stubs",
],
+ sdk_version: "none",
+ system_modules: "none",
+ dist: {
+ dest: "system-modules/module-lib/core-for-system-modules.jar",
+ targets: dist_targets,
+ },
+}
+
+// Used when compiling higher-level code with sdk_version "module_current"
+java_system_modules {
+ name: "core-module-lib-stubs-system-modules",
+ libs: [
+ "core-module-lib-stubs-for-system-modules",
+ ],
visibility: ["//visibility:public"],
}
diff --git a/java/prebuilt_apis.go b/java/prebuilt_apis.go
index c33e6c2..c67e2bd 100644
--- a/java/prebuilt_apis.go
+++ b/java/prebuilt_apis.go
@@ -167,30 +167,24 @@
localPath := strings.TrimPrefix(f, mydir)
module, apiver, scope := parseJarPath(localPath)
createImport(mctx, module, scope, apiver, localPath, sdkVersion, compileDex)
+
+ if module == "core-for-system-modules" {
+ createSystemModules(mctx, apiver, scope)
+ }
}
}
-func createSystemModules(mctx android.LoadHookContext, apiver string) {
+func createSystemModules(mctx android.LoadHookContext, apiver string, scope string) {
props := struct {
Name *string
Libs []string
}{}
- props.Name = proptools.StringPtr(prebuiltApiModuleName(mctx, "system_modules", "public", apiver))
- props.Libs = append(props.Libs, prebuiltApiModuleName(mctx, "core-for-system-modules", "public", apiver))
+ props.Name = proptools.StringPtr(prebuiltApiModuleName(mctx, "system_modules", scope, apiver))
+ props.Libs = append(props.Libs, prebuiltApiModuleName(mctx, "core-for-system-modules", scope, apiver))
mctx.CreateModule(systemModulesImportFactory, &props)
}
-func prebuiltSdkSystemModules(mctx android.LoadHookContext, p *prebuiltApis) {
- for _, apiver := range p.properties.Api_dirs {
- jar := android.ExistentPathForSource(mctx,
- mctx.ModuleDir(), apiver, "public", "core-for-system-modules.jar")
- if jar.Valid() {
- createSystemModules(mctx, apiver)
- }
- }
-}
-
func prebuiltApiFiles(mctx android.LoadHookContext, p *prebuiltApis) {
mydir := mctx.ModuleDir() + "/"
// <apiver>/<scope>/api/<module>.txt
@@ -273,7 +267,6 @@
if p, ok := mctx.Module().(*prebuiltApis); ok {
prebuiltApiFiles(mctx, p)
prebuiltSdkStubs(mctx, p)
- prebuiltSdkSystemModules(mctx, p)
}
}
diff --git a/java/prebuilt_apis_test.go b/java/prebuilt_apis_test.go
new file mode 100644
index 0000000..7c2e526
--- /dev/null
+++ b/java/prebuilt_apis_test.go
@@ -0,0 +1,52 @@
+// Copyright 2021 Google Inc. All rights reserved.
+//
+// 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.
+
+package java
+
+import (
+ "sort"
+ "strings"
+ "testing"
+
+ "android/soong/android"
+ "github.com/google/blueprint"
+)
+
+func TestPrebuiltApis_SystemModulesCreation(t *testing.T) {
+ result := android.GroupFixturePreparers(
+ prepareForJavaTest,
+ FixtureWithPrebuiltApis(map[string][]string{
+ "31": {},
+ "current": {},
+ }),
+ ).RunTest(t)
+
+ sdkSystemModules := []string{}
+ result.VisitAllModules(func(module blueprint.Module) {
+ name := android.RemoveOptionalPrebuiltPrefix(module.Name())
+ if strings.HasPrefix(name, "sdk_") && strings.HasSuffix(name, "_system_modules") {
+ sdkSystemModules = append(sdkSystemModules, name)
+ }
+ })
+ sort.Strings(sdkSystemModules)
+ expected := []string{
+ // 31 only has public system modules.
+ "sdk_public_31_system_modules",
+
+ // current only has public system modules.
+ "sdk_public_current_system_modules",
+ }
+ sort.Strings(expected)
+ android.AssertArrayString(t, "sdk system modules", expected, sdkSystemModules)
+}
diff --git a/java/robolectric.go b/java/robolectric.go
index a3603ad..16af546 100644
--- a/java/robolectric.go
+++ b/java/robolectric.go
@@ -212,13 +212,7 @@
installDeps = append(installDeps, installedData)
}
- installed := ctx.InstallFile(installPath, ctx.ModuleName()+".jar", r.combinedJar, installDeps...)
-
- if r.ExportedToMake() {
- // Soong handles installation here, but Make is usually what creates the phony rule that atest
- // uses to build the module. Create it here for now.
- ctx.Phony(ctx.ModuleName(), installed)
- }
+ r.installFile = ctx.InstallFile(installPath, ctx.ModuleName()+".jar", r.combinedJar, installDeps...)
}
func generateRoboTestConfig(ctx android.ModuleContext, outputFile android.WritablePath,
@@ -282,6 +276,10 @@
func (r *robolectricTest) AndroidMkEntries() []android.AndroidMkEntries {
entriesList := r.Library.AndroidMkEntries()
entries := &entriesList[0]
+ entries.ExtraEntries = append(entries.ExtraEntries,
+ func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
+ entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", true)
+ })
entries.ExtraFooters = []android.AndroidMkExtraFootersFunc{
func(w io.Writer, name, prefix, moduleDir string) {
diff --git a/java/sdk.go b/java/sdk.go
index 3c6b234..42ed14f 100644
--- a/java/sdk.go
+++ b/java/sdk.go
@@ -60,6 +60,12 @@
}
}
+// systemModuleKind returns the kind of system modules to use.
+func systemModuleKind() android.SdkKind {
+ // Currently, every sdk version uses the system modules for the public API.
+ return android.SdkPublic
+}
+
func decodeSdkDep(ctx android.EarlyModuleContext, sdkContext android.SdkContext) sdkDep {
sdkVersion := sdkContext.SdkVersion(ctx)
if !sdkVersion.Valid() {
@@ -105,7 +111,8 @@
var systemModules string
if defaultJavaLanguageVersion(ctx, sdkVersion).usesJavaModules() {
- systemModules = "sdk_public_" + sdkVersion.ApiLevel.String() + "_system_modules"
+ systemModuleKind := systemModuleKind()
+ systemModules = fmt.Sprintf("sdk_%s_%s_system_modules", systemModuleKind, sdkVersion.ApiLevel)
}
return sdkDep{
diff --git a/java/systemserver_classpath_fragment.go b/java/systemserver_classpath_fragment.go
index b5f52fd..d75635c 100644
--- a/java/systemserver_classpath_fragment.go
+++ b/java/systemserver_classpath_fragment.go
@@ -124,8 +124,15 @@
// So ignore it even if it is not in PRODUCT_APEX_SYSTEM_SERVER_JARS.
// TODO(b/203233647): Add better mechanism to make it optional.
_, unknown = android.RemoveFromList("car-frameworks-service-module", unknown)
- // For non test apexes, make sure that all contents are actually declared in make.
- if global.ApexSystemServerJars.Len() > 0 && len(unknown) > 0 && !android.IsModuleInVersionedSdk(ctx.Module()) {
+
+ // TODO(satayev): for apex_test we want to include all contents unconditionally to classpaths
+ // config. However, any test specific jars would not be present in ApexSystemServerJars. Instead,
+ // we should check if we are creating a config for apex_test via ApexInfo and amend the values.
+ // This is an exception to support end-to-end test for ApexdUnitTests, until such support exists.
+ if android.InList("test_service-apexd", possibleUpdatableModules) {
+ jars = jars.Append("com.android.apex.test_package", "test_service-apexd")
+ } else if global.ApexSystemServerJars.Len() > 0 && len(unknown) > 0 && !android.IsModuleInVersionedSdk(ctx.Module()) {
+ // For non test apexes, make sure that all contents are actually declared in make.
ctx.ModuleErrorf("%s in contents must also be declared in PRODUCT_APEX_SYSTEM_SERVER_JARS", unknown)
}
diff --git a/java/testing.go b/java/testing.go
index 0a6a4fa..fafc8d7 100644
--- a/java/testing.go
+++ b/java/testing.go
@@ -159,8 +159,7 @@
`, strings.Join(android.SortedStringKeys(release2Modules), `", "`))
for release, modules := range release2Modules {
- libs := append([]string{"android", "core-for-system-modules"}, modules...)
- mockFS.Merge(prebuiltApisFilesForLibs([]string{release}, libs))
+ mockFS.Merge(prebuiltApisFilesForModules([]string{release}, modules))
}
return android.GroupFixturePreparers(
android.FixtureAddTextFile(path, bp),
@@ -168,16 +167,25 @@
)
}
-func prebuiltApisFilesForLibs(apiLevels []string, sdkLibs []string) map[string][]byte {
+func prebuiltApisFilesForModules(apiLevels []string, modules []string) map[string][]byte {
+ libs := append([]string{"android"}, modules...)
+
fs := make(map[string][]byte)
for _, level := range apiLevels {
- for _, lib := range sdkLibs {
- for _, scope := range []string{"public", "system", "module-lib", "system-server", "test"} {
- fs[fmt.Sprintf("prebuilts/sdk/%s/%s/%s.jar", level, scope, lib)] = nil
+ for _, sdkKind := range []android.SdkKind{android.SdkPublic, android.SdkSystem, android.SdkModule, android.SdkSystemServer, android.SdkTest} {
+ // A core-for-system-modules file must only be created for the sdk kind that supports it.
+ if sdkKind == systemModuleKind() {
+ fs[fmt.Sprintf("prebuilts/sdk/%s/%s/core-for-system-modules.jar", level, sdkKind)] = nil
+ }
+
+ for _, lib := range libs {
+ // Create a jar file for every library.
+ fs[fmt.Sprintf("prebuilts/sdk/%s/%s/%s.jar", level, sdkKind, lib)] = nil
+
// No finalized API files for "current"
if level != "current" {
- fs[fmt.Sprintf("prebuilts/sdk/%s/%s/api/%s.txt", level, scope, lib)] = nil
- fs[fmt.Sprintf("prebuilts/sdk/%s/%s/api/%s-removed.txt", level, scope, lib)] = nil
+ fs[fmt.Sprintf("prebuilts/sdk/%s/%s/api/%s.txt", level, sdkKind, lib)] = nil
+ fs[fmt.Sprintf("prebuilts/sdk/%s/%s/api/%s-removed.txt", level, sdkKind, lib)] = nil
}
}
}
diff --git a/rust/config/Android.bp b/rust/config/Android.bp
index 5b121c3..7757c79 100644
--- a/rust/config/Android.bp
+++ b/rust/config/Android.bp
@@ -16,7 +16,7 @@
"lints.go",
"toolchain.go",
"allowed_list.go",
- "x86_darwin_host.go",
+ "darwin_host.go",
"x86_linux_bionic_host.go",
"x86_linux_host.go",
"x86_device.go",
diff --git a/rust/config/x86_darwin_host.go b/rust/config/darwin_host.go
similarity index 67%
rename from rust/config/x86_darwin_host.go
rename to rust/config/darwin_host.go
index 8ff0dd4..03bea82 100644
--- a/rust/config/x86_darwin_host.go
+++ b/rust/config/darwin_host.go
@@ -25,41 +25,64 @@
DarwinRustLinkFlags = []string{
"-B${cc_config.MacToolPath}",
}
+ darwinArm64Rustflags = []string{}
+ darwinArm64Linkflags = []string{}
darwinX8664Rustflags = []string{}
darwinX8664Linkflags = []string{}
)
func init() {
+ registerToolchainFactory(android.Darwin, android.Arm64, darwinArm64ToolchainFactory)
registerToolchainFactory(android.Darwin, android.X86_64, darwinX8664ToolchainFactory)
+
pctx.StaticVariable("DarwinToolchainRustFlags", strings.Join(DarwinRustFlags, " "))
pctx.StaticVariable("DarwinToolchainLinkFlags", strings.Join(DarwinRustLinkFlags, " "))
+
+ pctx.StaticVariable("DarwinToolchainArm64RustFlags", strings.Join(darwinArm64Rustflags, " "))
+ pctx.StaticVariable("DarwinToolchainArm64LinkFlags", strings.Join(darwinArm64Linkflags, " "))
pctx.StaticVariable("DarwinToolchainX8664RustFlags", strings.Join(darwinX8664Rustflags, " "))
pctx.StaticVariable("DarwinToolchainX8664LinkFlags", strings.Join(darwinX8664Linkflags, " "))
}
type toolchainDarwin struct {
+ toolchain64Bit
toolchainRustFlags string
toolchainLinkFlags string
}
-type toolchainDarwinX8664 struct {
- toolchain64Bit
+type toolchainDarwinArm64 struct {
toolchainDarwin
}
+type toolchainDarwinX8664 struct {
+ toolchainDarwin
+}
+
+func (toolchainDarwinArm64) Supported() bool {
+ return true
+}
+
func (toolchainDarwinX8664) Supported() bool {
return true
}
-func (toolchainDarwinX8664) Bionic() bool {
+func (toolchainDarwin) Bionic() bool {
return false
}
+func (t *toolchainDarwinArm64) Name() string {
+ return "arm64"
+}
+
func (t *toolchainDarwinX8664) Name() string {
return "x86_64"
}
+func (t *toolchainDarwinArm64) RustTriple() string {
+ return "aarch64-apple-darwin"
+}
+
func (t *toolchainDarwinX8664) RustTriple() string {
return "x86_64-apple-darwin"
}
@@ -76,6 +99,15 @@
return ".dylib"
}
+func (t *toolchainDarwinArm64) ToolchainLinkFlags() string {
+ // Prepend the lld flags from cc_config so we stay in sync with cc
+ return "${cc_config.DarwinLldflags} ${config.DarwinToolchainLinkFlags} ${config.DarwinToolchainArm64LinkFlags}"
+}
+
+func (t *toolchainDarwinArm64) ToolchainRustFlags() string {
+ return "${config.DarwinToolchainRustFlags} ${config.DarwinToolchainArm64RustFlags}"
+}
+
func (t *toolchainDarwinX8664) ToolchainLinkFlags() string {
// Prepend the lld flags from cc_config so we stay in sync with cc
return "${cc_config.DarwinLldflags} ${config.DarwinToolchainLinkFlags} ${config.DarwinToolchainX8664LinkFlags}"
@@ -85,8 +117,13 @@
return "${config.DarwinToolchainRustFlags} ${config.DarwinToolchainX8664RustFlags}"
}
+func darwinArm64ToolchainFactory(arch android.Arch) Toolchain {
+ return toolchainDarwinArm64Singleton
+}
+
func darwinX8664ToolchainFactory(arch android.Arch) Toolchain {
return toolchainDarwinX8664Singleton
}
+var toolchainDarwinArm64Singleton Toolchain = &toolchainDarwinArm64{}
var toolchainDarwinX8664Singleton Toolchain = &toolchainDarwinX8664{}
diff --git a/scripts/check_boot_jars/package_allowed_list.txt b/scripts/check_boot_jars/package_allowed_list.txt
index b1b1e7e..ed63651 100644
--- a/scripts/check_boot_jars/package_allowed_list.txt
+++ b/scripts/check_boot_jars/package_allowed_list.txt
@@ -69,6 +69,7 @@
javax\.xml\.transform\.stream
javax\.xml\.validation
javax\.xml\.xpath
+jdk\.internal
jdk\.internal\.math
jdk\.internal\.misc
jdk\.internal\.reflect
diff --git a/scripts/manifest_check.py b/scripts/manifest_check.py
index b4936b8..8bed52a 100755
--- a/scripts/manifest_check.py
+++ b/scripts/manifest_check.py
@@ -84,6 +84,13 @@
return parser.parse_args()
+C_RED = "\033[1;31m"
+C_GREEN = "\033[1;32m"
+C_BLUE = "\033[1;34m"
+C_OFF = "\033[0m"
+C_BOLD = "\033[1m"
+
+
def enforce_uses_libraries(manifest, required, optional, relax, is_apk, path):
"""Verify that the <uses-library> tags in the manifest match those provided
@@ -119,22 +126,21 @@
errmsg = ''.join([
'mismatch in the <uses-library> tags between the build system and the '
'manifest:\n',
- '\t- required libraries in build system: [%s]\n' % ', '.join(required),
- '\t vs. in the manifest: [%s]\n' %
- ', '.join(manifest_required),
- '\t- optional libraries in build system: [%s]\n' % ', '.join(optional),
- '\t vs. in the manifest: [%s]\n' %
- ', '.join(manifest_optional),
+ '\t- required libraries in build system: %s[%s]%s\n' % (C_RED, ', '.join(required), C_OFF),
+ '\t vs. in the manifest: %s[%s]%s\n' % (C_RED, ', '.join(manifest_required), C_OFF),
+ '\t- optional libraries in build system: %s[%s]%s\n' % (C_RED, ', '.join(optional), C_OFF),
+ '\t vs. in the manifest: %s[%s]%s\n' % (C_RED, ', '.join(manifest_optional), C_OFF),
'\t- tags in the manifest (%s):\n' % path,
'\t\t%s\n' % '\t\t'.join(tags),
- 'note: the following options are available:\n',
+ '%snote:%s the following options are available:\n' % (C_BLUE, C_OFF),
'\t- to temporarily disable the check on command line, rebuild with ',
- 'RELAX_USES_LIBRARY_CHECK=true (this will set compiler filter "verify" ',
- 'and disable AOT-compilation in dexpreopt)\n',
+ '%sRELAX_USES_LIBRARY_CHECK=true%s' % (C_BOLD, C_OFF),
+ ' (this will set compiler filter "verify" and disable AOT-compilation in dexpreopt)\n',
'\t- to temporarily disable the check for the whole product, set ',
- 'PRODUCT_BROKEN_VERIFY_USES_LIBRARIES := true in the product makefiles\n',
- '\t- to fix the check, make build system properties coherent with the '
- 'manifest\n', '\t- see build/make/Changes.md for details\n'
+ '%sPRODUCT_BROKEN_VERIFY_USES_LIBRARIES := true%s in the product makefiles\n' % (C_BOLD, C_OFF),
+ '\t- to fix the check, make build system properties coherent with the manifest\n',
+ '\t- for details, see %sbuild/make/Changes.md%s' % (C_GREEN, C_OFF),
+ ' and %shttps://source.android.com/devices/tech/dalvik/art-class-loader-context%s\n' % (C_GREEN, C_OFF)
])
#pylint: enable=line-too-long
@@ -380,7 +386,7 @@
# pylint: disable=broad-except
except Exception as err:
- print('error: ' + str(err), file=sys.stderr)
+ print('%serror:%s ' % (C_RED, C_OFF) + str(err), file=sys.stderr)
sys.exit(-1)