Merge "Build against SDKs for native libs only for unbundled apps."
diff --git a/androidmk/androidmk/androidmk.go b/androidmk/androidmk/androidmk.go
index 9d0c3ac..4aadbe8 100644
--- a/androidmk/androidmk/androidmk.go
+++ b/androidmk/androidmk/androidmk.go
@@ -124,6 +124,7 @@
var conds []*conditional
var assignmentCond *conditional
+ var tree *bpparser.File
for _, node := range nodes {
file.setMkPos(p.Unpack(node.Pos()), p.Unpack(node.End()))
@@ -200,24 +201,27 @@
}
}
- tree := &bpparser.File{
+ tree = &bpparser.File{
Defs: file.defs,
Comments: file.comments,
}
// check for common supported but undesirable structures and clean them up
fixer := bpfix.NewFixer(tree)
- tree, err := fixer.Fix(bpfix.NewFixRequest().AddAll())
- if err != nil {
- return "", []error{err}
+ fixedTree, fixerErr := fixer.Fix(bpfix.NewFixRequest().AddAll())
+ if fixerErr != nil {
+ errs = append(errs, fixerErr)
+ } else {
+ tree = fixedTree
}
out, err := bpparser.Print(tree)
if err != nil {
- return "", []error{err}
+ errs = append(errs, err)
+ return "", errs
}
- return string(out), nil
+ return string(out), errs
}
func handleAssignment(file *bpFile, assignment *mkparser.Assignment, c *conditional) {
diff --git a/androidmk/cmd/androidmk.go b/androidmk/cmd/androidmk.go
index 00488eb..d2f4324 100644
--- a/androidmk/cmd/androidmk.go
+++ b/androidmk/cmd/androidmk.go
@@ -45,12 +45,13 @@
}
output, errs := androidmk.ConvertFile(os.Args[1], bytes.NewBuffer(b))
+ if len(output) > 0 {
+ fmt.Print(output)
+ }
if len(errs) > 0 {
for _, err := range errs {
fmt.Fprintln(os.Stderr, "ERROR: ", err)
}
os.Exit(1)
}
-
- fmt.Print(output)
}
diff --git a/apex/androidmk.go b/apex/androidmk.go
index 774b62d..91a405c 100644
--- a/apex/androidmk.go
+++ b/apex/androidmk.go
@@ -233,8 +233,9 @@
for _, o := range a.overridableProperties.Overrides {
patterns = append(patterns, "%."+o+a.suffix)
}
- fmt.Fprintln(w, "LOCAL_OVERRIDES_MODULES :=", strings.Join(patterns, " "))
-
+ if len(patterns) > 0 {
+ fmt.Fprintln(w, "LOCAL_OVERRIDES_MODULES :=", strings.Join(patterns, " "))
+ }
if len(a.compatSymlinks) > 0 {
// For flattened apexes, compat symlinks are attached to apex_manifest.json which is guaranteed for every apex
postInstallCommands = append(postInstallCommands, a.compatSymlinks...)
@@ -307,7 +308,9 @@
fmt.Fprintln(w, "LOCAL_MODULE_PATH :=", a.installDir.ToMakePath().String())
fmt.Fprintln(w, "LOCAL_MODULE_STEM :=", name+apexType.suffix())
fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE :=", !a.installable())
- fmt.Fprintln(w, "LOCAL_OVERRIDES_MODULES :=", strings.Join(a.overridableProperties.Overrides, " "))
+ if len(a.overridableProperties.Overrides) > 0 {
+ fmt.Fprintln(w, "LOCAL_OVERRIDES_MODULES :=", strings.Join(a.overridableProperties.Overrides, " "))
+ }
if len(moduleNames) > 0 {
fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES +=", strings.Join(moduleNames, " "))
}
diff --git a/apex/apex.go b/apex/apex.go
index 2e4a328..ce5d663 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -986,7 +986,7 @@
Uses []string
// A txt file containing list of files that are allowed to be included in this APEX.
- Whitelisted_files *string
+ Allowed_files *string
// package format of this apex variant; could be non-flattened, flattened, or zip.
// imageApex, zipApex or flattened
diff --git a/apex/builder.go b/apex/builder.go
index 1293588..53c1193 100644
--- a/apex/builder.go
+++ b/apex/builder.go
@@ -391,7 +391,7 @@
emitCommands = append(emitCommands, "sort -o "+imageContentFile.String()+" "+imageContentFile.String())
implicitInputs = append(implicitInputs, a.manifestPbOut)
- if a.properties.Whitelisted_files != nil {
+ if a.properties.Allowed_files != nil {
ctx.Build(pctx, android.BuildParams{
Rule: emitApexContentRule,
Implicits: implicitInputs,
@@ -402,7 +402,7 @@
},
})
implicitInputs = append(implicitInputs, imageContentFile)
- allowedFilesFile := android.PathForModuleSrc(ctx, proptools.String(a.properties.Whitelisted_files))
+ allowedFilesFile := android.PathForModuleSrc(ctx, proptools.String(a.properties.Allowed_files))
phonyOutput := android.PathForModuleOut(ctx, a.Name()+"-diff-phony-output")
ctx.Build(pctx, android.BuildParams{
diff --git a/cc/cc.go b/cc/cc.go
index f80c229..ebdb46c 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -3099,10 +3099,19 @@
}
} else if vendorSpecific && String(m.Properties.Sdk_version) == "" {
// This will be available in /vendor (or /odm) only
- // We assume that modules under proprietary paths are compatible for
- // BOARD_VNDK_VERSION. The other modules are regarded as AOSP, or
- // PLATFORM_VNDK_VERSION.
- if isVendorProprietaryPath(mctx.ModuleDir()) {
+
+ // kernel_headers is a special module type whose exported headers
+ // are coming from DeviceKernelHeaders() which is always vendor
+ // dependent. They'll always have both vendor variants.
+ // For other modules, we assume that modules under proprietary
+ // paths are compatible for BOARD_VNDK_VERSION. The other modules
+ // are regarded as AOSP, which is PLATFORM_VNDK_VERSION.
+ if _, ok := m.linker.(*kernelHeadersDecorator); ok {
+ vendorVariants = append(vendorVariants,
+ platformVndkVersion,
+ boardVndkVersion,
+ )
+ } else if isVendorProprietaryPath(mctx.ModuleDir()) {
vendorVariants = append(vendorVariants, boardVndkVersion)
} else {
vendorVariants = append(vendorVariants, platformVndkVersion)
@@ -3200,6 +3209,10 @@
}
}
+func (c *Module) IsSdkVariant() bool {
+ return c.Properties.IsSdkVariant
+}
+
func getCurrentNdkPrebuiltVersion(ctx DepsContext) string {
if ctx.Config().PlatformSdkVersionInt() > config.NdkMaxPrebuiltVersionInt {
return strconv.Itoa(config.NdkMaxPrebuiltVersionInt)
diff --git a/cc/config/arm64_device.go b/cc/config/arm64_device.go
index 9383463..62d8cc8 100644
--- a/cc/config/arm64_device.go
+++ b/cc/config/arm64_device.go
@@ -32,7 +32,7 @@
"-march=armv8-a",
},
"armv8-2a": []string{
- "-march=armv8.2a",
+ "-march=armv8.2-a",
},
}
diff --git a/cc/library.go b/cc/library.go
index ba8b0f4..968702e 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -1077,9 +1077,14 @@
func (library *libraryDecorator) linkSAbiDumpFiles(ctx ModuleContext, objs Objects, fileName string, soFile android.Path) {
if library.shouldCreateSourceAbiDump(ctx) {
- vndkVersion := ctx.DeviceConfig().PlatformVndkVersion()
- if ver := ctx.DeviceConfig().VndkVersion(); ver != "" && ver != "current" {
- vndkVersion = ver
+ var vndkVersion string
+
+ if ctx.useVndk() {
+ // For modules linking against vndk, follow its vndk version
+ vndkVersion = ctx.Module().(*Module).VndkVersion()
+ } else {
+ // Regard the other modules as PLATFORM_VNDK_VERSION
+ vndkVersion = ctx.DeviceConfig().PlatformVndkVersion()
}
exportIncludeDirs := library.flagExporter.exportedIncludes(ctx)
@@ -1575,7 +1580,8 @@
// (which is unnamed) and zero or more stubs variants.
func VersionMutator(mctx android.BottomUpMutatorContext) {
if library, ok := mctx.Module().(LinkableInterface); ok && VersionVariantAvailable(library) {
- if library.CcLibrary() && library.BuildSharedVariant() && len(library.StubsVersions()) > 0 {
+ if library.CcLibrary() && library.BuildSharedVariant() && len(library.StubsVersions()) > 0 &&
+ !library.IsSdkVariant() {
versions := library.StubsVersions()
normalizeVersions(mctx, versions)
if mctx.Failed() {
diff --git a/cc/linkable.go b/cc/linkable.go
index de36f90..66b1c3f 100644
--- a/cc/linkable.go
+++ b/cc/linkable.go
@@ -56,6 +56,7 @@
SdkVersion() string
AlwaysSdk() bool
+ IsSdkVariant() bool
ToolchainLibrary() bool
NdkPrebuiltStl() bool
diff --git a/cc/vendor_snapshot.go b/cc/vendor_snapshot.go
index ea94544..4dad730 100644
--- a/cc/vendor_snapshot.go
+++ b/cc/vendor_snapshot.go
@@ -548,6 +548,10 @@
if !m.IsForPlatform() || m.isSnapshotPrebuilt() || !m.inVendor() {
return false
}
+ // skip kernel_headers which always depend on vendor
+ if _, ok := m.linker.(*kernelHeadersDecorator); ok {
+ return false
+ }
// Libraries
if l, ok := m.linker.(snapshotLibraryInterface); ok {
diff --git a/etc/prebuilt_etc.go b/etc/prebuilt_etc.go
index d6eb008..df6d79d 100644
--- a/etc/prebuilt_etc.go
+++ b/etc/prebuilt_etc.go
@@ -35,6 +35,7 @@
android.RegisterModuleType("prebuilt_usr_share_host", PrebuiltUserShareHostFactory)
android.RegisterModuleType("prebuilt_font", PrebuiltFontFactory)
android.RegisterModuleType("prebuilt_firmware", PrebuiltFirmwareFactory)
+ android.RegisterModuleType("prebuilt_dsp", PrebuiltDSPFactory)
}
type prebuiltEtcProperties struct {
@@ -293,3 +294,15 @@
android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
return module
}
+
+// prebuilt_dsp installs a DSP related file to <partition>/etc/dsp directory for system image.
+// If soc_specific property is set to true, the DSP related file is installed to the vendor <partition>/dsp
+// directory for vendor image.
+func PrebuiltDSPFactory() android.Module {
+ module := &PrebuiltEtc{}
+ module.socInstallDirBase = "dsp"
+ InitPrebuiltEtcModule(module, "etc/dsp")
+ // This module is device-only
+ android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
+ return module
+}
diff --git a/etc/prebuilt_etc_test.go b/etc/prebuilt_etc_test.go
index e13cb3c..4ce1984 100644
--- a/etc/prebuilt_etc_test.go
+++ b/etc/prebuilt_etc_test.go
@@ -65,6 +65,7 @@
ctx.RegisterModuleType("prebuilt_usr_share_host", PrebuiltUserShareHostFactory)
ctx.RegisterModuleType("prebuilt_font", PrebuiltFontFactory)
ctx.RegisterModuleType("prebuilt_firmware", PrebuiltFirmwareFactory)
+ ctx.RegisterModuleType("prebuilt_dsp", PrebuiltDSPFactory)
ctx.Register(config)
_, errs := ctx.ParseFileList(".", []string{"Android.bp"})
android.FailIfErrored(t, errs)
@@ -281,3 +282,39 @@
})
}
}
+
+func TestPrebuiltDSPDirPath(t *testing.T) {
+ targetPath := filepath.Join(buildDir, "/target/product/test_device")
+ tests := []struct {
+ description string
+ config string
+ expectedPath string
+ }{{
+ description: "prebuilt: system dsp",
+ config: `
+ prebuilt_dsp {
+ name: "foo.conf",
+ src: "foo.conf",
+ }`,
+ expectedPath: filepath.Join(targetPath, "system/etc/dsp"),
+ }, {
+ description: "prebuilt: vendor dsp",
+ config: `
+ prebuilt_dsp {
+ name: "foo.conf",
+ src: "foo.conf",
+ soc_specific: true,
+ sub_dir: "sub_dir",
+ }`,
+ expectedPath: filepath.Join(targetPath, "vendor/dsp/sub_dir"),
+ }}
+ for _, tt := range tests {
+ t.Run(tt.description, func(t *testing.T) {
+ ctx, _ := testPrebuiltEtc(t, tt.config)
+ p := ctx.ModuleForTests("foo.conf", "android_arm64_armv8-a").Module().(*PrebuiltEtc)
+ if p.installDirPath.String() != tt.expectedPath {
+ t.Errorf("expected %q, got %q", tt.expectedPath, p.installDirPath)
+ }
+ })
+ }
+}
diff --git a/java/app.go b/java/app.go
index 0fdede1..74c92a6 100755
--- a/java/app.go
+++ b/java/app.go
@@ -133,7 +133,7 @@
// We are assuming here that the master file in the APK
// set has `.apk` suffix. If it doesn't the build will fail.
// APK sets containing APEX files are handled elsewhere.
- as.masterFile = ctx.ModuleName() + ".apk"
+ as.masterFile = as.BaseModuleName() + ".apk"
screenDensities := "all"
if dpis := ctx.Config().ProductAAPTPrebuiltDPI(); len(dpis) > 0 {
screenDensities = strings.ToUpper(strings.Join(dpis, ","))
diff --git a/java/java.go b/java/java.go
index ab8f859..bd5f6b7 100644
--- a/java/java.go
+++ b/java/java.go
@@ -1167,9 +1167,9 @@
if flags.javaVersion.usesJavaModules() {
javacFlags = append(javacFlags, j.properties.Openjdk9.Javacflags...)
}
- if ctx.Config().MinimizeJavaDebugInfo() {
- // Override the -g flag passed globally to remove local variable debug info to reduce
- // disk and memory usage.
+ if ctx.Config().MinimizeJavaDebugInfo() && !ctx.Host() {
+ // For non-host binaries, override the -g flag passed globally to remove
+ // local variable debug info to reduce disk and memory usage.
javacFlags = append(javacFlags, "-g:source,lines")
}
javacFlags = append(javacFlags, "-Xlint:-dep-ann")
diff --git a/java/java_test.go b/java/java_test.go
index b74111b..1d07e70 100644
--- a/java/java_test.go
+++ b/java/java_test.go
@@ -466,7 +466,41 @@
t.Errorf("expected binary wrapper implicits [%q], got %v",
barJar, barWrapperDeps)
}
+}
+func TestHostBinaryNoJavaDebugInfoOverride(t *testing.T) {
+ bp := `
+ java_library {
+ name: "target_library",
+ srcs: ["a.java"],
+ }
+
+ java_binary_host {
+ name: "host_binary",
+ srcs: ["b.java"],
+ }
+ `
+ config := testConfig(nil, bp, nil)
+ config.TestProductVariables.MinimizeJavaDebugInfo = proptools.BoolPtr(true)
+
+ ctx, _ := testJavaWithConfig(t, config)
+
+ // first, sanity check that the -g flag is added to target modules
+ targetLibrary := ctx.ModuleForTests("target_library", "android_common")
+ targetJavaFlags := targetLibrary.Module().VariablesForTests()["javacFlags"]
+ if !strings.Contains(targetJavaFlags, "-g:source,lines") {
+ t.Errorf("target library javac flags %v should contain "+
+ "-g:source,lines override with MinimizeJavaDebugInfo", targetJavaFlags)
+ }
+
+ // check that -g is not overridden for host modules
+ buildOS := android.BuildOs.String()
+ hostBinary := ctx.ModuleForTests("host_binary", buildOS+"_common")
+ hostJavaFlags := hostBinary.Module().VariablesForTests()["javacFlags"]
+ if strings.Contains(hostJavaFlags, "-g:source,lines") {
+ t.Errorf("java_binary_host javac flags %v should not have "+
+ "-g:source,lines override with MinimizeJavaDebugInfo", hostJavaFlags)
+ }
}
func TestPrebuilts(t *testing.T) {
diff --git a/rust/binary.go b/rust/binary.go
index c25ae09..56d6f0b 100644
--- a/rust/binary.go
+++ b/rust/binary.go
@@ -24,9 +24,6 @@
}
type BinaryCompilerProperties struct {
- // path to the main source file that contains the program entry point (e.g. src/main.rs)
- Srcs []string `android:"path,arch_variant"`
-
// passes -C prefer-dynamic to rustc, which tells it to dynamically link the stdlib
// (assuming it has no dylib dependencies already)
Prefer_dynamic *bool
@@ -35,10 +32,7 @@
type binaryDecorator struct {
*baseCompiler
- Properties BinaryCompilerProperties
- distFile android.OptionalPath
- coverageOutputZipFile android.OptionalPath
- unstrippedOutputFile android.Path
+ Properties BinaryCompilerProperties
}
var _ compiler = (*binaryDecorator)(nil)
@@ -112,7 +106,7 @@
func (binary *binaryDecorator) compile(ctx ModuleContext, flags Flags, deps PathDeps) android.Path {
fileName := binary.getStem(ctx) + ctx.toolchain().ExecutableSuffix()
- srcPath := srcPathFromModuleSrcs(ctx, binary.Properties.Srcs)
+ srcPath := srcPathFromModuleSrcs(ctx, binary.baseCompiler.Properties.Srcs)
outputFile := android.PathForModuleOut(ctx, fileName)
binary.unstrippedOutputFile = outputFile
diff --git a/rust/compiler.go b/rust/compiler.go
index 5f098bc..efc1ce4 100644
--- a/rust/compiler.go
+++ b/rust/compiler.go
@@ -53,6 +53,9 @@
)
type BaseCompilerProperties struct {
+ // path to the source file that is the main entry point of the program (e.g. main.rs or lib.rs)
+ Srcs []string `android:"path,arch_variant"`
+
// whether to pass "-D warnings" to rustc. Defaults to true.
Deny_warnings *bool
@@ -100,17 +103,10 @@
}
type baseCompiler struct {
- Properties BaseCompilerProperties
- pathDeps android.Paths
- rustFlagsDeps android.Paths
- linkFlagsDeps android.Paths
- flags string
- linkFlags string
- depFlags []string
- linkDirs []string
- edition string
- src android.Path //rustc takes a single src file
- coverageFile android.Path //rustc generates a single gcno file
+ Properties BaseCompilerProperties
+ depFlags []string
+ linkDirs []string
+ coverageFile android.Path //rustc generates a single gcno file
// Install related
dir string
@@ -119,6 +115,10 @@
relative string
path android.InstallPath
location installLocation
+
+ coverageOutputZipFile android.OptionalPath
+ unstrippedOutputFile android.Path
+ distFile android.OptionalPath
}
func (compiler *baseCompiler) coverageOutputZipPath() android.OptionalPath {
diff --git a/rust/library.go b/rust/library.go
index 2e51266..704c77b 100644
--- a/rust/library.go
+++ b/rust/library.go
@@ -45,9 +45,6 @@
Shared VariantLibraryProperties `android:"arch_variant"`
Static VariantLibraryProperties `android:"arch_variant"`
- // path to the source file that is the main entry point of the program (e.g. src/lib.rs)
- Srcs []string `android:"path,arch_variant"`
-
// path to include directories to pass to cc_* modules, only relevant for static/shared variants.
Include_dirs []string `android:"path,arch_variant"`
}
@@ -75,12 +72,9 @@
type libraryDecorator struct {
*baseCompiler
- Properties LibraryCompilerProperties
- MutatedProperties LibraryMutatedProperties
- distFile android.OptionalPath
- coverageOutputZipFile android.OptionalPath
- unstrippedOutputFile android.Path
- includeDirs android.Paths
+ Properties LibraryCompilerProperties
+ MutatedProperties LibraryMutatedProperties
+ includeDirs android.Paths
}
type libraryInterface interface {
@@ -350,7 +344,7 @@
func (library *libraryDecorator) compile(ctx ModuleContext, flags Flags, deps PathDeps) android.Path {
var outputFile android.WritablePath
- srcPath := srcPathFromModuleSrcs(ctx, library.Properties.Srcs)
+ srcPath := srcPathFromModuleSrcs(ctx, library.baseCompiler.Properties.Srcs)
flags.RustFlags = append(flags.RustFlags, deps.depFlags...)
diff --git a/rust/proc_macro.go b/rust/proc_macro.go
index 10ea1e3..42c8537 100644
--- a/rust/proc_macro.go
+++ b/rust/proc_macro.go
@@ -23,20 +23,12 @@
}
type ProcMacroCompilerProperties struct {
- // path to the source file that is the main entry point of the program (e.g. src/lib.rs)
- Srcs []string `android:"path,arch_variant"`
-
- // set name of the procMacro
- Stem *string `android:"arch_variant"`
- Suffix *string `android:"arch_variant"`
}
type procMacroDecorator struct {
*baseCompiler
- Properties ProcMacroCompilerProperties
- distFile android.OptionalPath
- unstrippedOutputFile android.Path
+ Properties ProcMacroCompilerProperties
}
type procMacroInterface interface {
@@ -70,7 +62,7 @@
fileName := procMacro.getStem(ctx) + ctx.toolchain().ProcMacroSuffix()
outputFile := android.PathForModuleOut(ctx, fileName)
- srcPath := srcPathFromModuleSrcs(ctx, procMacro.Properties.Srcs)
+ srcPath := srcPathFromModuleSrcs(ctx, procMacro.baseCompiler.Properties.Srcs)
procMacro.unstrippedOutputFile = outputFile
diff --git a/rust/project_json.go b/rust/project_json.go
index 909aebc..a50e73a 100644
--- a/rust/project_json.go
+++ b/rust/project_json.go
@@ -114,7 +114,7 @@
return cInfo.ID, crateName, true
}
crate := rustProjectCrate{Deps: make([]rustProjectDep, 0), Cfgs: make([]string, 0)}
- src := rustLib.Properties.Srcs[0]
+ src := rustLib.baseCompiler.Properties.Srcs[0]
crate.RootModule = path.Join(ctx.ModuleDir(rModule), src)
crate.Edition = getEdition(rustLib.baseCompiler)
diff --git a/rust/rust.go b/rust/rust.go
index 6671dd3..7b82b1f 100644
--- a/rust/rust.go
+++ b/rust/rust.go
@@ -45,11 +45,10 @@
}
type Flags struct {
- GlobalRustFlags []string // Flags that apply globally to rust
- GlobalLinkFlags []string // Flags that apply globally to linker
- RustFlags []string // Flags that apply to rust
- LinkFlags []string // Flags that apply to linker
- RustFlagsDeps android.Paths // Files depended on by compiler flags
+ GlobalRustFlags []string // Flags that apply globally to rust
+ GlobalLinkFlags []string // Flags that apply globally to linker
+ RustFlags []string // Flags that apply to rust
+ LinkFlags []string // Flags that apply to linker
Toolchain config.Toolchain
Coverage bool
}
@@ -196,6 +195,10 @@
return false
}
+func (mod *Module) IsSdkVariant() bool {
+ return false
+}
+
func (mod *Module) ToolchainLibrary() bool {
return false
}