Merge "Support Qualcomm Kryo 385 CPU variant."
diff --git a/Android.bp b/Android.bp
index 1b93c0d..9711c11 100644
--- a/Android.bp
+++ b/Android.bp
@@ -145,6 +145,7 @@
"cc/util.go",
"cc/vndk.go",
"cc/vndk_prebuilt.go",
+ "cc/xom.go",
"cc/cmakelists.go",
"cc/compdb.go",
@@ -435,6 +436,7 @@
src: "prebuilts/gcc/linux-x86/host/x86_64-w64-mingw32-4.8/x86_64-w64-mingw32/lib/libwinpthread.a",
},
},
+ notice: ":mingw-libwinpthread-notice",
}
toolchain_library {
diff --git a/android/androidmk.go b/android/androidmk.go
index 7030523..18b26d9 100644
--- a/android/androidmk.go
+++ b/android/androidmk.go
@@ -40,6 +40,7 @@
type AndroidMkData struct {
Class string
SubName string
+ DistFile OptionalPath
OutputFile OptionalPath
Disabled bool
Include string
@@ -220,6 +221,45 @@
}
}
+ if len(amod.commonProperties.Dist.Targets) > 0 {
+ distFile := data.DistFile
+ if !distFile.Valid() {
+ distFile = data.OutputFile
+ }
+ if distFile.Valid() {
+ dest := filepath.Base(distFile.String())
+
+ if amod.commonProperties.Dist.Dest != nil {
+ var err error
+ dest, err = validateSafePath(*amod.commonProperties.Dist.Dest)
+ if err != nil {
+ // This was checked in ModuleBase.GenerateBuildActions
+ panic(err)
+ }
+ }
+
+ if amod.commonProperties.Dist.Suffix != nil {
+ ext := filepath.Ext(dest)
+ suffix := *amod.commonProperties.Dist.Suffix
+ dest = strings.TrimSuffix(dest, ext) + suffix + ext
+ }
+
+ if amod.commonProperties.Dist.Dir != nil {
+ var err error
+ dest, err = validateSafePath(*amod.commonProperties.Dist.Dir, dest)
+ if err != nil {
+ // This was checked in ModuleBase.GenerateBuildActions
+ panic(err)
+ }
+ }
+
+ goals := strings.Join(amod.commonProperties.Dist.Targets, " ")
+ fmt.Fprintln(&data.preamble, ".PHONY:", goals)
+ fmt.Fprintf(&data.preamble, "$(call dist-for-goals,%s,%s:%s)\n",
+ goals, distFile.String(), dest)
+ }
+ }
+
fmt.Fprintln(&data.preamble, "\ninclude $(CLEAR_VARS)")
fmt.Fprintln(&data.preamble, "LOCAL_PATH :=", filepath.Dir(ctx.BlueprintFile(mod)))
fmt.Fprintln(&data.preamble, "LOCAL_MODULE :=", name+data.SubName)
@@ -275,9 +315,10 @@
if amod.commonProperties.Owner != nil {
fmt.Fprintln(&data.preamble, "LOCAL_MODULE_OWNER :=", *amod.commonProperties.Owner)
}
- if amod.commonProperties.Notice != nil {
- fmt.Fprintln(&data.preamble, "LOCAL_NOTICE_FILE :=", "$(LOCAL_PATH)/"+*amod.commonProperties.Notice)
- }
+ }
+
+ if amod.noticeFile != nil {
+ fmt.Fprintln(&data.preamble, "LOCAL_NOTICE_FILE :=", amod.noticeFile.String())
}
if host {
diff --git a/android/config.go b/android/config.go
index 367b42c..abb07ce 100644
--- a/android/config.go
+++ b/android/config.go
@@ -351,6 +351,10 @@
var _ bootstrap.ConfigBlueprintToolLocation = (*config)(nil)
+func (c *config) HostToolPath(ctx PathContext, tool string) Path {
+ return PathForOutput(ctx, "host", c.PrebuiltOS(), "bin", tool)
+}
+
// HostSystemTool looks for non-hermetic tools from the system we're running on.
// Generally shouldn't be used, but useful to find the XCode SDK, etc.
func (c *config) HostSystemTool(name string) string {
@@ -478,7 +482,7 @@
}
func (c *config) MinSupportedSdkVersion() int {
- return 14
+ return 16
}
func (c *config) DefaultAppTargetSdkInt() int {
@@ -622,6 +626,14 @@
}
}
+func (c *config) EnableXOM() bool {
+ if c.productVariables.EnableXOM == nil {
+ return false
+ } else {
+ return Bool(c.productVariables.EnableXOM)
+ }
+}
+
func (c *config) Android64() bool {
for _, t := range c.Targets[Android] {
if t.Arch.ArchType.Multilib == "lib64" {
@@ -859,6 +871,13 @@
return PrefixInList(path, *c.productVariables.CFIIncludePaths)
}
+func (c *config) XOMDisabledForPath(path string) bool {
+ if c.productVariables.XOMExcludePaths == nil {
+ return false
+ }
+ return PrefixInList(path, *c.productVariables.XOMExcludePaths)
+}
+
func (c *config) VendorConfig(name string) VendorConfig {
return vendorConfig(c.productVariables.VendorVars[name])
}
@@ -881,6 +900,10 @@
return Bool(c.productVariables.Ndk_abis)
}
+func (c *config) ExcludeDraftNdkApis() bool {
+ return Bool(c.productVariables.Exclude_draft_ndk_apis)
+}
+
func (c *config) FlattenApex() bool {
return Bool(c.productVariables.FlattenApex)
}
diff --git a/android/module.go b/android/module.go
index bf49ca2..dc0c856 100644
--- a/android/module.go
+++ b/android/module.go
@@ -265,6 +265,24 @@
// relative path to a file to include in the list of notices for the device
Notice *string
+ Dist struct {
+ // copy the output of this module to the $DIST_DIR when `dist` is specified on the
+ // command line and any of these targets are also on the command line, or otherwise
+ // built
+ Targets []string `android:"arch_variant"`
+
+ // The name of the output artifact. This defaults to the basename of the output of
+ // the module.
+ Dest *string `android:"arch_variant"`
+
+ // The directory within the dist directory to store the artifact. Defaults to the
+ // top level directory ("").
+ Dir *string `android:"arch_variant"`
+
+ // A suffix to add to the artifact file name (before any extension).
+ Suffix *string `android:"arch_variant"`
+ } `android:"arch_variant"`
+
// Set by TargetMutator
CompileTarget Target `blueprint:"mutated"`
CompileMultiTargets []Target `blueprint:"mutated"`
@@ -441,6 +459,7 @@
noAddressSanitizer bool
installFiles Paths
checkbuildFiles Paths
+ noticeFile Path
// Used by buildTargetSingleton to create checkbuild and per-directory build targets
// Only set on the final variant of each module
@@ -781,6 +800,25 @@
}
ctx.Variable(pctx, "moduleDescSuffix", s)
+ // Some common property checks for properties that will be used later in androidmk.go
+ if a.commonProperties.Dist.Dest != nil {
+ _, err := validateSafePath(*a.commonProperties.Dist.Dest)
+ if err != nil {
+ ctx.PropertyErrorf("dist.dest", "%s", err.Error())
+ }
+ }
+ if a.commonProperties.Dist.Dir != nil {
+ _, err := validateSafePath(*a.commonProperties.Dist.Dir)
+ if err != nil {
+ ctx.PropertyErrorf("dist.dir", "%s", err.Error())
+ }
+ }
+ if a.commonProperties.Dist.Suffix != nil {
+ if strings.Contains(*a.commonProperties.Dist.Suffix, "/") {
+ ctx.PropertyErrorf("dist.suffix", "Suffix may not contain a '/' character.")
+ }
+ }
+
if a.Enabled() {
a.module.GenerateAndroidBuildActions(ctx)
if ctx.Failed() {
@@ -789,6 +827,11 @@
a.installFiles = append(a.installFiles, ctx.installFiles...)
a.checkbuildFiles = append(a.checkbuildFiles, ctx.checkbuildFiles...)
+
+ if a.commonProperties.Notice != nil {
+ // For filegroup-based notice file references.
+ a.noticeFile = ctx.ExpandSource(*a.commonProperties.Notice, "notice")
+ }
}
if a == ctx.FinalModule().(Module).base() {
@@ -1310,6 +1353,13 @@
srcFiles := ctx.ExpandSourcesSubDir([]string{srcFile}, nil, "")
if len(srcFiles) == 1 {
return srcFiles[0]
+ } else if len(srcFiles) == 0 {
+ if ctx.Config().AllowMissingDependencies() {
+ ctx.AddMissingDependencies([]string{srcFile})
+ } else {
+ ctx.PropertyErrorf(prop, "%s path %s does not exist", prop, srcFile)
+ }
+ return nil
} else {
ctx.PropertyErrorf(prop, "module providing %s must produce exactly one file", prop)
return nil
diff --git a/android/mutator.go b/android/mutator.go
index b9c44e8..b77c2f0 100644
--- a/android/mutator.go
+++ b/android/mutator.go
@@ -207,6 +207,11 @@
func depsMutator(ctx BottomUpMutatorContext) {
if m, ok := ctx.Module().(Module); ok && m.Enabled() {
m.DepsMutator(ctx)
+
+ // For filegroup-based notice file references.
+ if m.base().commonProperties.Notice != nil {
+ ExtractSourceDeps(ctx, m.base().commonProperties.Notice)
+ }
}
}
diff --git a/android/variable.go b/android/variable.go
index 2763bf2..4534774 100644
--- a/android/variable.go
+++ b/android/variable.go
@@ -64,7 +64,13 @@
// Product_is_iot is true for Android Things devices.
Product_is_iot struct {
- Cflags []string
+ Cflags []string
+ Enabled bool
+ Exclude_srcs []string
+ Init_rc []string
+ Shared_libs []string
+ Srcs []string
+ Static_libs []string
}
// treble_linker_namespaces is true when the system/vendor linker namespace separation is
@@ -205,6 +211,9 @@
CFIExcludePaths *[]string `json:",omitempty"`
CFIIncludePaths *[]string `json:",omitempty"`
+ EnableXOM *bool `json:",omitempty"`
+ XOMExcludePaths *[]string `json:",omitempty"`
+
VendorPath *string `json:",omitempty"`
OdmPath *string `json:",omitempty"`
ProductPath *string `json:",omitempty"`
@@ -249,7 +258,8 @@
VendorVars map[string]map[string]string `json:",omitempty"`
- Ndk_abis *bool `json:",omitempty"`
+ Ndk_abis *bool `json:",omitempty"`
+ Exclude_draft_ndk_apis *bool `json:",omitempty"`
FlattenApex *bool `json:",omitempty"`
}
diff --git a/apex/apex.go b/apex/apex.go
index 177856e..8a652db 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -38,7 +38,7 @@
// TODO(b/113082813) make this configurable using config.fs syntax
generateFsConfig = pctx.StaticRule("generateFsConfig", blueprint.RuleParams{
Command: `echo '/ 1000 1000 0755' > ${out} && ` +
- `echo '/manifest.json 1000 1000 0644' >> ${out} && ` +
+ `echo '/apex_manifest.json 1000 1000 0644' >> ${out} && ` +
`echo ${ro_paths} | tr ' ' '\n' | awk '{print "/"$$1 " 1000 1000 0644"}' >> ${out} && ` +
`echo ${exec_paths} | tr ' ' '\n' | awk '{print "/"$$1 " 1000 1000 0755"}' >> ${out}`,
Description: "fs_config ${out}",
@@ -52,7 +52,7 @@
Command: `rm -rf ${image_dir} && mkdir -p ${image_dir} && ` +
`(${copy_commands}) && ` +
`APEXER_TOOL_PATH=${tool_path} ` +
- `${apexer} --verbose --force --manifest ${manifest} ` +
+ `${apexer} --force --manifest ${manifest} ` +
`--file_contexts ${file_contexts} ` +
`--canned_fs_config ${canned_fs_config} ` +
`--key ${key} ${image_dir} ${out} `,
@@ -61,6 +61,21 @@
"${soong_zip}", "${zipalign}", "${aapt2}"},
Description: "APEX ${image_dir} => ${out}",
}, "tool_path", "image_dir", "copy_commands", "manifest", "file_contexts", "canned_fs_config", "key")
+
+ apexProtoConvertRule = pctx.AndroidStaticRule("apexProtoConvertRule",
+ blueprint.RuleParams{
+ Command: `${aapt2} convert --output-format proto $in -o $out`,
+ CommandDeps: []string{"${aapt2}"},
+ })
+
+ apexBundleRule = pctx.StaticRule("apexBundleRule", blueprint.RuleParams{
+ Command: `${zip2zip} -i $in -o $out ` +
+ `apex_payload.img:apex/${abi}.img ` +
+ `apex_manifest.json:root/apex_manifest.json ` +
+ `AndroidManifest.xml:manifest/AndroidManifest.xml`,
+ CommandDeps: []string{"${zip2zip}"},
+ Description: "app bundle",
+ }, "abi")
)
var apexSuffix = ".apex"
@@ -102,6 +117,7 @@
pctx.HostBinToolVariable("resize2fs", "resize2fs")
pctx.HostBinToolVariable("sefcontext_compile", "sefcontext_compile")
pctx.HostBinToolVariable("soong_zip", "soong_zip")
+ pctx.HostBinToolVariable("zip2zip", "zip2zip")
pctx.HostBinToolVariable("zipalign", "zipalign")
android.RegisterModuleType("apex", apexBundleFactory)
@@ -123,10 +139,10 @@
// can be built for the apex bundles.
func apexDepsMutator(mctx android.TopDownMutatorContext) {
if _, ok := mctx.Module().(*apexBundle); ok {
- apexBundleName := mctx.Module().Name()
+ apexBundleName := mctx.ModuleName()
mctx.WalkDeps(func(child, parent android.Module) bool {
if am, ok := child.(android.ApexModule); ok && am.CanHaveApexVariants() {
- moduleName := am.Name() + "-" + am.Target().String()
+ moduleName := mctx.OtherModuleName(am) + "-" + am.Target().String()
bundleNames, ok := apexBundleNamesFor(mctx.Config())[moduleName]
if !ok {
bundleNames = make(map[string]bool)
@@ -144,7 +160,7 @@
// Create apex variations if a module is included in APEX(s).
func apexMutator(mctx android.BottomUpMutatorContext) {
if am, ok := mctx.Module().(android.ApexModule); ok && am.CanHaveApexVariants() {
- moduleName := am.Name() + "-" + am.Target().String()
+ moduleName := mctx.ModuleName() + "-" + am.Target().String()
if bundleNames, ok := apexBundleNamesFor(mctx.Config())[moduleName]; ok {
variations := []string{"platform"}
for bn := range bundleNames {
@@ -168,7 +184,7 @@
type apexBundleProperties struct {
// Json manifest file describing meta info of this APEX bundle. Default:
- // "manifest.json"
+ // "apex_manifest.json"
Manifest *string
// Determines the file contexts file for setting security context to each file in this APEX bundle.
@@ -268,8 +284,9 @@
properties apexBundleProperties
- outputFile android.WritablePath
- installDir android.OutputPath
+ bundleModuleFile android.WritablePath
+ outputFile android.WritablePath
+ installDir android.OutputPath
// list of files to be included in this apex
filesInfo []apexFile
@@ -518,7 +535,7 @@
filesInfo[i].moduleName = ctx.ModuleName() + "." + filesInfo[i].moduleName
}
- a.flattened = ctx.Config().FlattenApex()
+ a.flattened = ctx.Config().FlattenApex() && !ctx.Config().UnbundledBuild()
a.installDir = android.PathForModuleInstall(ctx, "apex")
a.filesInfo = filesInfo
if ctx.Config().FlattenApex() {
@@ -558,19 +575,20 @@
sort.Strings(readOnlyPaths)
sort.Strings(executablePaths)
cannedFsConfig := android.PathForModuleOut(ctx, "canned_fs_config")
- ctx.ModuleBuild(pctx, android.ModuleBuildParams{
- Rule: generateFsConfig,
- Output: cannedFsConfig,
+ ctx.Build(pctx, android.BuildParams{
+ Rule: generateFsConfig,
+ Output: cannedFsConfig,
+ Description: "generate fs config",
Args: map[string]string{
"ro_paths": strings.Join(readOnlyPaths, " "),
"exec_paths": strings.Join(executablePaths, " "),
},
})
- manifest := android.PathForModuleSrc(ctx, proptools.StringDefault(a.properties.Manifest, "manifest.json"))
+ manifest := android.PathForModuleSrc(ctx, proptools.StringDefault(a.properties.Manifest, "apex_manifest.json"))
- fcName := proptools.StringDefault(a.properties.File_contexts, a.ModuleBase.Name())
- fileContextsPath := "system/sepolicy/apex/" + fcName + "_file_contexts"
+ fcName := proptools.StringDefault(a.properties.File_contexts, ctx.ModuleName())
+ fileContextsPath := "system/sepolicy/apex/" + fcName + "-file_contexts"
fileContextsOptionalPath := android.ExistentPathForSource(ctx, fileContextsPath)
if !fileContextsOptionalPath.Valid() {
ctx.ModuleErrorf("Cannot find file_contexts file: %q", fileContextsPath)
@@ -578,7 +596,7 @@
}
fileContexts := fileContextsOptionalPath.Path()
- unsignedOutputFile := android.PathForModuleOut(ctx, a.ModuleBase.Name()+apexSuffix+".unsigned")
+ unsignedOutputFile := android.PathForModuleOut(ctx, ctx.ModuleName()+apexSuffix+".unsigned")
filesToCopy := []android.Path{}
for _, f := range a.filesInfo {
@@ -596,10 +614,11 @@
implicitInputs = append(implicitInputs, cannedFsConfig, manifest, fileContexts, keyFile)
outHostBinDir := android.PathForOutput(ctx, "host", ctx.Config().PrebuiltOS(), "bin").String()
prebuiltSdkToolsBinDir := filepath.Join("prebuilts", "sdk", "tools", runtime.GOOS, "bin")
- ctx.ModuleBuild(pctx, android.ModuleBuildParams{
- Rule: apexRule,
- Implicits: implicitInputs,
- Output: unsignedOutputFile,
+ ctx.Build(pctx, android.BuildParams{
+ Rule: apexRule,
+ Implicits: implicitInputs,
+ Output: unsignedOutputFile,
+ Description: "apex",
Args: map[string]string{
"tool_path": outHostBinDir + ":" + prebuiltSdkToolsBinDir,
"image_dir": android.PathForModuleOut(ctx, "image").String(),
@@ -611,7 +630,34 @@
},
})
- a.outputFile = android.PathForModuleOut(ctx, a.ModuleBase.Name()+apexSuffix)
+ var abis []string
+ for _, target := range ctx.MultiTargets() {
+ abis = append(abis, target.Arch.Abi[0])
+ }
+ abis = android.FirstUniqueStrings(abis)
+
+ apexProtoFile := android.PathForModuleOut(ctx, ctx.ModuleName()+".pb"+apexSuffix)
+ bundleModuleFile := android.PathForModuleOut(ctx, ctx.ModuleName()+"-base.zip")
+ a.bundleModuleFile = bundleModuleFile
+
+ ctx.Build(pctx, android.BuildParams{
+ Rule: apexProtoConvertRule,
+ Input: unsignedOutputFile,
+ Output: apexProtoFile,
+ Description: "apex proto convert",
+ })
+
+ ctx.Build(pctx, android.BuildParams{
+ Rule: apexBundleRule,
+ Input: apexProtoFile,
+ Output: bundleModuleFile,
+ Description: "apex bundle module",
+ Args: map[string]string{
+ "abi": strings.Join(abis, "."),
+ },
+ })
+
+ a.outputFile = android.PathForModuleOut(ctx, ctx.ModuleName()+apexSuffix)
ctx.Build(pctx, android.BuildParams{
Rule: java.Signapk,
Description: "signapk",
@@ -619,18 +665,19 @@
Input: unsignedOutputFile,
Args: map[string]string{
"certificates": strings.Join([]string{certificate.Pem.String(), certificate.Key.String()}, " "),
+ "flags": "-a 4096", //alignment
},
})
}
func (a *apexBundle) buildFlattenedApex(ctx android.ModuleContext) {
- // For flattened APEX, do nothing but make sure that manifest.json file is also copied along
+ // For flattened APEX, do nothing but make sure that apex_manifest.json file is also copied along
// with other ordinary files.
- manifest := android.PathForModuleSrc(ctx, proptools.StringDefault(a.properties.Manifest, "manifest.json"))
- a.filesInfo = append(a.filesInfo, apexFile{manifest, a.Name() + ".manifest.json", android.Common, ".", etc})
+ manifest := android.PathForModuleSrc(ctx, proptools.StringDefault(a.properties.Manifest, "apex_manifest.json"))
+ a.filesInfo = append(a.filesInfo, apexFile{manifest, ctx.ModuleName() + ".apex_manifest.json", android.Common, ".", etc})
for _, fi := range a.filesInfo {
- dir := filepath.Join("apex", a.Name(), fi.installDir)
+ dir := filepath.Join("apex", ctx.ModuleName(), fi.installDir)
ctx.InstallFile(android.PathForModuleInstall(ctx, dir), fi.builtFile.Base(), fi.builtFile)
}
}
@@ -684,6 +731,8 @@
fmt.Fprintln(w, "LOCAL_INSTALLED_MODULE_STEM :=", name+apexSuffix)
fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES :=", String(a.properties.Key))
fmt.Fprintln(w, "include $(BUILD_PREBUILT)")
+
+ fmt.Fprintln(w, "ALL_MODULES.$(LOCAL_MODULE).BUNDLE :=", a.bundleModuleFile.String())
}}
}
}
diff --git a/cc/androidmk.go b/cc/androidmk.go
index 324b5bc..f5e04bb 100644
--- a/cc/androidmk.go
+++ b/cc/androidmk.go
@@ -70,6 +70,12 @@
if len(c.Properties.AndroidMkSharedLibs) > 0 {
fmt.Fprintln(w, "LOCAL_SHARED_LIBRARIES := "+strings.Join(c.Properties.AndroidMkSharedLibs, " "))
}
+ if len(c.Properties.AndroidMkStaticLibs) > 0 {
+ fmt.Fprintln(w, "LOCAL_STATIC_LIBRARIES := "+strings.Join(c.Properties.AndroidMkStaticLibs, " "))
+ }
+ if len(c.Properties.AndroidMkWholeStaticLibs) > 0 {
+ fmt.Fprintln(w, "LOCAL_WHOLE_STATIC_LIBRARIES := "+strings.Join(c.Properties.AndroidMkWholeStaticLibs, " "))
+ }
fmt.Fprintln(w, "LOCAL_SOONG_LINK_TYPE :=", c.getMakeLinkType())
if c.useVndk() {
fmt.Fprintln(w, "LOCAL_USE_VNDK := true")
@@ -137,11 +143,15 @@
ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
fmt.Fprintln(w, "LOCAL_SOONG_TOC :=", library.toc().String())
fmt.Fprintln(w, "LOCAL_SOONG_UNSTRIPPED_BINARY :=", library.unstrippedOutputFile.String())
+ if len(library.Properties.Overrides) > 0 {
+ fmt.Fprintln(w, "LOCAL_OVERRIDES_MODULES := "+strings.Join(library.Properties.Overrides, " "))
+ }
})
} else if library.header() {
ret.Class = "HEADER_LIBRARIES"
}
+ ret.DistFile = library.distFile
ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
library.androidMkWriteExportedFlags(w)
fmt.Fprintln(w, "LOCAL_ADDITIONAL_DEPENDENCIES := ")
@@ -185,6 +195,7 @@
ctx.subAndroidMk(ret, binary.baseInstaller)
ret.Class = "EXECUTABLES"
+ ret.DistFile = binary.distFile
ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
fmt.Fprintln(w, "LOCAL_SOONG_UNSTRIPPED_BINARY :=", binary.unstrippedOutputFile.String())
if len(binary.symlinks) > 0 {
diff --git a/cc/binary.go b/cc/binary.go
index 15db2ad..6923f2b 100644
--- a/cc/binary.go
+++ b/cc/binary.go
@@ -88,6 +88,9 @@
// Output archive of gcno coverage information
coverageOutputFile android.OptionalPath
+
+ // Location of the file that should be copied to dist dir when requested
+ distFile android.OptionalPath
}
var _ linker = (*binaryDecorator)(nil)
@@ -330,10 +333,23 @@
flagsToBuilderFlags(flags), afterPrefixSymbols)
}
- if Bool(binary.baseLinker.Properties.Use_version_lib) && ctx.Host() {
- versionedOutputFile := outputFile
- outputFile = android.PathForModuleOut(ctx, "unversioned", fileName)
- binary.injectVersionSymbol(ctx, outputFile, versionedOutputFile)
+ if Bool(binary.baseLinker.Properties.Use_version_lib) {
+ if ctx.Host() {
+ versionedOutputFile := outputFile
+ outputFile = android.PathForModuleOut(ctx, "unversioned", fileName)
+ binary.injectVersionSymbol(ctx, outputFile, versionedOutputFile)
+ } else {
+ versionedOutputFile := android.PathForModuleOut(ctx, "versioned", fileName)
+ binary.distFile = android.OptionalPathForPath(versionedOutputFile)
+
+ if binary.stripper.needsStrip(ctx) {
+ out := android.PathForModuleOut(ctx, "versioned-stripped", fileName)
+ binary.distFile = android.OptionalPathForPath(out)
+ binary.stripper.strip(ctx, versionedOutputFile, out, builderFlags)
+ }
+
+ binary.injectVersionSymbol(ctx, outputFile, versionedOutputFile)
+ }
}
if ctx.Os() == android.LinuxBionic && !binary.static() {
diff --git a/cc/builder.go b/cc/builder.go
index 6d5b595..bf35f84 100644
--- a/cc/builder.go
+++ b/cc/builder.go
@@ -231,8 +231,6 @@
ldFlags string
libFlags string
yaccFlags string
- protoFlags string
- protoOutParams string
tidyFlags string
sAbiFlags string
yasmFlags string
@@ -242,7 +240,6 @@
tidy bool
coverage bool
sAbiDump bool
- protoRoot bool
systemIncludeFlags string
@@ -252,6 +249,14 @@
stripKeepMiniDebugInfo bool
stripAddGnuDebuglink bool
stripUseLlvmStrip bool
+
+ protoDeps android.Paths
+ protoFlags string
+ protoOutTypeFlag string
+ protoOutParams string
+ protoC bool
+ protoOptionsFile bool
+ protoRoot bool
}
type Objects struct {
diff --git a/cc/cc.go b/cc/cc.go
index 9a44bde..9fa7c3a 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -53,6 +53,9 @@
ctx.TopDown("cfi_deps", sanitizerDepsMutator(cfi))
ctx.BottomUp("cfi", sanitizerMutator(cfi)).Parallel()
+ ctx.TopDown("scs_deps", sanitizerDepsMutator(scs))
+ ctx.BottomUp("scs", sanitizerMutator(scs)).Parallel()
+
ctx.TopDown("tsan_deps", sanitizerDepsMutator(tsan))
ctx.BottomUp("tsan", sanitizerMutator(tsan)).Parallel()
@@ -130,8 +133,6 @@
CppFlags []string // Flags that apply to C++ source files
ToolingCppFlags []string // Flags that apply to C++ source files parsed by clang LibTooling tools
YaccFlags []string // Flags that apply to Yacc source files
- protoFlags []string // Flags that apply to proto source files
- protoOutParams []string // Flags that modify the output of proto generated files
aidlFlags []string // Flags that apply to aidl source files
rsFlags []string // Flags that apply to renderscript source files
LdFlags []string // Flags that apply to linker command lines
@@ -148,7 +149,6 @@
Tidy bool
Coverage bool
SAbiDump bool
- ProtoRoot bool
RequiredInstructionSet string
DynamicLinker string
@@ -157,6 +157,14 @@
LdFlagsDeps android.Paths // Files depended on by linker flags
GroupStaticLibs bool
+
+ protoDeps android.Paths
+ protoFlags []string // Flags that apply to proto source files
+ protoOutTypeFlag string // The output type, --cpp_out for example
+ protoOutParams []string // Flags that modify the output of proto generated files
+ protoC bool // Whether to use C instead of C++
+ protoOptionsFile bool // Whether to look for a .options file next to the .proto
+ ProtoRoot bool
}
type ObjectLinkerProperties struct {
@@ -175,10 +183,12 @@
// Minimum sdk version supported when compiling against the ndk
Sdk_version *string
- AndroidMkSharedLibs []string `blueprint:"mutated"`
- AndroidMkRuntimeLibs []string `blueprint:"mutated"`
- HideFromMake bool `blueprint:"mutated"`
- PreventInstall bool `blueprint:"mutated"`
+ AndroidMkSharedLibs []string `blueprint:"mutated"`
+ AndroidMkStaticLibs []string `blueprint:"mutated"`
+ AndroidMkRuntimeLibs []string `blueprint:"mutated"`
+ AndroidMkWholeStaticLibs []string `blueprint:"mutated"`
+ HideFromMake bool `blueprint:"mutated"`
+ PreventInstall bool `blueprint:"mutated"`
UseVndk bool `blueprint:"mutated"`
@@ -350,6 +360,7 @@
vndkdep *vndkdep
lto *lto
pgo *pgo
+ xom *xom
androidMkSharedLibDeps []string
@@ -407,6 +418,9 @@
if c.pgo != nil {
c.AddProperties(c.pgo.props()...)
}
+ if c.xom != nil {
+ c.AddProperties(c.xom.props()...)
+ }
for _, feature := range c.features {
c.AddProperties(feature.props()...)
}
@@ -648,6 +662,7 @@
module.vndkdep = &vndkdep{}
module.lto = <o{}
module.pgo = &pgo{}
+ module.xom = &xom{}
return module
}
@@ -764,6 +779,9 @@
if c.pgo != nil {
flags = c.pgo.flags(ctx, flags)
}
+ if c.xom != nil {
+ flags = c.xom.flags(ctx, flags)
+ }
for _, feature := range c.features {
flags = feature.flags(ctx, flags)
}
@@ -1265,7 +1283,8 @@
}
depIsDoubleLoadable := Bool(to.VendorProperties.Double_loadable)
if !depIsLlndk && !depIsVndkSp && !depIsDoubleLoadable && depIsVndk {
- ctx.ModuleErrorf("links VNDK library %q that isn't double_loadable.",
+ ctx.ModuleErrorf("links VNDK library %q that isn't double loadable (not also LL-NDK, "+
+ "VNDK-SP, or explicitly marked as 'double_loadable').",
ctx.OtherModuleName(to))
}
}
@@ -1478,9 +1497,15 @@
// they merely serve as Make dependencies and do not affect this lib itself.
c.Properties.AndroidMkSharedLibs = append(
c.Properties.AndroidMkSharedLibs, makeLibName(depName))
+ case staticDepTag, staticExportDepTag, lateStaticDepTag:
+ c.Properties.AndroidMkStaticLibs = append(
+ c.Properties.AndroidMkStaticLibs, makeLibName(depName))
case runtimeDepTag:
c.Properties.AndroidMkRuntimeLibs = append(
c.Properties.AndroidMkRuntimeLibs, makeLibName(depName))
+ case wholeStaticDepTag:
+ c.Properties.AndroidMkWholeStaticLibs = append(
+ c.Properties.AndroidMkWholeStaticLibs, makeLibName(depName))
}
})
@@ -1625,6 +1650,7 @@
&VndkProperties{},
<OProperties{},
&PgoProperties{},
+ &XomProperties{},
&android.ProtoProperties{},
)
diff --git a/cc/cc_test.go b/cc/cc_test.go
index d6ffe51..3e78ec7 100644
--- a/cc/cc_test.go
+++ b/cc/cc_test.go
@@ -1545,6 +1545,43 @@
checkRuntimeLibs(t, []string{"libvendor_available1", "libvendor1"}, module)
}
+func checkStaticLibs(t *testing.T, expected []string, module *Module) {
+ actual := module.Properties.AndroidMkStaticLibs
+ if !reflect.DeepEqual(actual, expected) {
+ t.Errorf("incorrect static_libs"+
+ "\nactual: %v"+
+ "\nexpected: %v",
+ actual,
+ expected,
+ )
+ }
+}
+
+const staticLibAndroidBp = `
+ cc_library {
+ name: "lib1",
+ }
+ cc_library {
+ name: "lib2",
+ static_libs: ["lib1"],
+ }
+`
+
+func TestStaticLibDepExport(t *testing.T) {
+ ctx := testCc(t, staticLibAndroidBp)
+
+ // Check the shared version of lib2.
+ variant := "android_arm64_armv8-a_core_shared"
+ module := ctx.ModuleForTests("lib2", variant).Module().(*Module)
+ checkStaticLibs(t, []string{"lib1", "libclang_rt.builtins-aarch64-android", "libatomic", "libgcc"}, module)
+
+ // Check the static version of lib2.
+ variant = "android_arm64_armv8-a_core_static"
+ module = ctx.ModuleForTests("lib2", variant).Module().(*Module)
+ // libc++_static is linked additionally.
+ checkStaticLibs(t, []string{"lib1", "libc++_static", "libclang_rt.builtins-aarch64-android", "libatomic", "libgcc"}, module)
+}
+
var compilerFlagsTestCases = []struct {
in string
out bool
diff --git a/cc/compiler.go b/cc/compiler.go
index 5ac5d79..ad1fc6d 100644
--- a/cc/compiler.go
+++ b/cc/compiler.go
@@ -299,6 +299,7 @@
}
if ctx.useSdk() {
+ // TODO: Switch to --sysroot.
// The NDK headers are installed to a common sysroot. While a more
// typical Soong approach would be to only make the headers for the
// library you're using available, we're trying to emulate the NDK
@@ -307,6 +308,7 @@
"-isystem "+getCurrentIncludePath(ctx).String(),
"-isystem "+getCurrentIncludePath(ctx).Join(ctx, config.NDKTriple(tc)).String())
+ // TODO: Migrate to API suffixed triple?
// Traditionally this has come from android/api-level.h, but with the
// libc headers unified it must be set by the build system since we
// don't have per-API level copies of that header now.
@@ -316,14 +318,6 @@
}
flags.GlobalFlags = append(flags.GlobalFlags,
"-D__ANDROID_API__="+version)
-
- // Until the full NDK has been migrated to using ndk_headers, we still
- // need to add the legacy sysroot includes to get the full set of
- // headers.
- legacyIncludes := fmt.Sprintf(
- "prebuilts/ndk/current/platforms/android-%s/arch-%s/usr/include",
- ctx.sdkVersion(), ctx.Arch().ArchType.String())
- flags.SystemIncludeFlags = append(flags.SystemIncludeFlags, "-isystem "+legacyIncludes)
}
if ctx.useVndk() {
diff --git a/cc/config/global.go b/cc/config/global.go
index e2377e3..8fd5914 100644
--- a/cc/config/global.go
+++ b/cc/config/global.go
@@ -116,7 +116,7 @@
CStdVersion = "gnu99"
CppStdVersion = "gnu++14"
ExperimentalCStdVersion = "gnu11"
- ExperimentalCppStdVersion = "gnu++1z"
+ ExperimentalCppStdVersion = "gnu++2a"
NdkMaxPrebuiltVersionInt = 27
diff --git a/cc/gen.go b/cc/gen.go
index 29a2bb2..4852794 100644
--- a/cc/gen.go
+++ b/cc/gen.go
@@ -182,8 +182,7 @@
srcFiles[i] = cppFile
genLex(ctx, srcFile, cppFile)
case ".proto":
- ccFile, headerFile := genProto(ctx, srcFile, buildFlags.protoFlags,
- buildFlags.protoOutParams, buildFlags.protoRoot)
+ ccFile, headerFile := genProto(ctx, srcFile, buildFlags)
srcFiles[i] = ccFile
deps = append(deps, headerFile)
case ".aidl":
diff --git a/cc/libbuildversion/libbuildversion.cpp b/cc/libbuildversion/libbuildversion.cpp
index d80d587..5242025 100644
--- a/cc/libbuildversion/libbuildversion.cpp
+++ b/cc/libbuildversion/libbuildversion.cpp
@@ -23,9 +23,19 @@
namespace android {
namespace build {
+#define PLACEHOLDER "SOONG BUILD NUMBER PLACEHOLDER"
+
+extern "C" {
+ char soong_build_number[128] = PLACEHOLDER;
+}
+
#ifdef __ANDROID__
std::string GetBuildNumber() {
+ if (strcmp(PLACEHOLDER, soong_build_number) != 0) {
+ return soong_build_number;
+ }
+
const prop_info* pi = __system_property_find("ro.build.version.incremental");
if (pi == nullptr) return "";
@@ -42,10 +52,6 @@
#else
-extern "C" {
- char soong_build_number[128] = "SOONG BUILD NUMBER PLACEHOLDER";
-}
-
std::string GetBuildNumber() {
return soong_build_number;
}
diff --git a/cc/libbuildversion/tests/Android.bp b/cc/libbuildversion/tests/Android.bp
index a18bc6c..b3b2061 100644
--- a/cc/libbuildversion/tests/Android.bp
+++ b/cc/libbuildversion/tests/Android.bp
@@ -2,10 +2,53 @@
name: "build_version_test_defaults",
use_version_lib: true,
host_supported: true,
+ dist: {
+ targets: ["test_build_version_test"],
+ },
target: {
+ android_arm: {
+ dist: {
+ dir: "android/arm",
+ },
+ },
+ android_arm64: {
+ dist: {
+ dir: "android/arm64",
+ },
+ },
+ android_x86: {
+ dist: {
+ dir: "android/x86",
+ },
+ },
+ android_x86_64: {
+ dist: {
+ dir: "android/x86_64",
+ },
+ },
+ darwin: {
+ dist: {
+ dir: "host/",
+ },
+ },
+ linux_glibc_x86: {
+ dist: {
+ dir: "host32/",
+ },
+ },
+ linux_glibc_x86_64: {
+ dist: {
+ dir: "host/",
+ },
+ },
windows: {
enabled: true,
},
+ windows_x86_64: {
+ dist: {
+ dest: "win64/build_ver_test.exe",
+ },
+ },
},
}
@@ -20,6 +63,11 @@
not_windows: {
shared_libs: ["libbuild_version_test"],
},
+ host: {
+ dist: {
+ suffix: "_host",
+ },
+ },
},
}
diff --git a/cc/library.go b/cc/library.go
index 975f325..a9d63f9 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -77,6 +77,16 @@
// List versions to generate stubs libs for.
Versions []string
}
+
+ // set the name of the output
+ Stem *string `android:"arch_variant"`
+
+ // Names of modules to be overridden. Listed modules can only be other shared libraries
+ // (in Make or Soong).
+ // This does not completely prevent installation of the overridden libraries, but if both
+ // binaries would be installed by default (in PRODUCT_PACKAGES) the other library will be removed
+ // from PRODUCT_PACKAGES.
+ Overrides []string
}
type LibraryMutatedProperties struct {
@@ -257,6 +267,9 @@
// Location of the linked, unstripped library for shared libraries
unstrippedOutputFile android.Path
+ // Location of the file that should be copied to dist dir when requested
+ distFile android.OptionalPath
+
versionScriptPath android.ModuleGenPath
// Decorated interafaces
@@ -429,7 +442,10 @@
func (library *libraryDecorator) getLibName(ctx ModuleContext) string {
name := library.libName
if name == "" {
- name = ctx.baseModuleName()
+ name = String(library.Properties.Stem)
+ if name == "" {
+ name = ctx.baseModuleName()
+ }
}
if ctx.isVndkExt() {
@@ -529,10 +545,16 @@
outputFile := android.PathForModuleOut(ctx, fileName)
builderFlags := flagsToBuilderFlags(flags)
- if Bool(library.baseLinker.Properties.Use_version_lib) && ctx.Host() {
- versionedOutputFile := outputFile
- outputFile = android.PathForModuleOut(ctx, "unversioned", fileName)
- library.injectVersionSymbol(ctx, outputFile, versionedOutputFile)
+ if Bool(library.baseLinker.Properties.Use_version_lib) {
+ if ctx.Host() {
+ versionedOutputFile := outputFile
+ outputFile = android.PathForModuleOut(ctx, "unversioned", fileName)
+ library.injectVersionSymbol(ctx, outputFile, versionedOutputFile)
+ } else {
+ versionedOutputFile := android.PathForModuleOut(ctx, "versioned", fileName)
+ library.distFile = android.OptionalPathForPath(versionedOutputFile)
+ library.injectVersionSymbol(ctx, outputFile, versionedOutputFile)
+ }
}
TransformObjToStaticLib(ctx, library.objects.objFiles, builderFlags, outputFile, objs.tidyFiles)
@@ -606,10 +628,23 @@
library.unstrippedOutputFile = outputFile
- if Bool(library.baseLinker.Properties.Use_version_lib) && ctx.Host() {
- versionedOutputFile := outputFile
- outputFile = android.PathForModuleOut(ctx, "unversioned", fileName)
- library.injectVersionSymbol(ctx, outputFile, versionedOutputFile)
+ if Bool(library.baseLinker.Properties.Use_version_lib) {
+ if ctx.Host() {
+ versionedOutputFile := outputFile
+ outputFile = android.PathForModuleOut(ctx, "unversioned", fileName)
+ library.injectVersionSymbol(ctx, outputFile, versionedOutputFile)
+ } else {
+ versionedOutputFile := android.PathForModuleOut(ctx, "versioned", fileName)
+ library.distFile = android.OptionalPathForPath(versionedOutputFile)
+
+ if library.stripper.needsStrip(ctx) {
+ out := android.PathForModuleOut(ctx, "versioned-stripped", fileName)
+ library.distFile = android.OptionalPathForPath(out)
+ library.stripper.strip(ctx, versionedOutputFile, out, builderFlags)
+ }
+
+ library.injectVersionSymbol(ctx, outputFile, versionedOutputFile)
+ }
}
sharedLibs := deps.SharedLibs
diff --git a/cc/ndk_headers.go b/cc/ndk_headers.go
index 8177ff1..504a6a0 100644
--- a/cc/ndk_headers.go
+++ b/cc/ndk_headers.go
@@ -77,6 +77,11 @@
// Path to the NOTICE file associated with the headers.
License *string
+
+ // True if this API is not yet ready to be shipped in the NDK. It will be
+ // available in the platform for testing, but will be excluded from the
+ // sysroot provided to the NDK proper.
+ Draft bool
}
type headerModule struct {
@@ -182,6 +187,11 @@
// Path to the NOTICE file associated with the headers.
License *string
+
+ // True if this API is not yet ready to be shipped in the NDK. It will be
+ // available in the platform for testing, but will be excluded from the
+ // sysroot provided to the NDK proper.
+ Draft bool
}
// Like ndk_headers, but preprocesses the headers with the bionic versioner:
@@ -309,6 +319,11 @@
// Path to the NOTICE file associated with the headers.
License *string
+
+ // True if this API is not yet ready to be shipped in the NDK. It will be
+ // available in the platform for testing, but will be excluded from the
+ // sysroot provided to the NDK proper.
+ Draft bool
}
type preprocessedHeadersModule struct {
diff --git a/cc/ndk_library.go b/cc/ndk_library.go
index 63d9f29..53fe314 100644
--- a/cc/ndk_library.go
+++ b/cc/ndk_library.go
@@ -91,6 +91,11 @@
// Private property for use by the mutator that splits per-API level.
ApiLevel string `blueprint:"mutated"`
+
+ // True if this API is not yet ready to be shipped in the NDK. It will be
+ // available in the platform for testing, but will be excluded from the
+ // sysroot provided to the NDK proper.
+ Draft bool
}
type stubDecorator struct {
diff --git a/cc/ndk_sysroot.go b/cc/ndk_sysroot.go
index 80b5c6a..9265bff 100644
--- a/cc/ndk_sysroot.go
+++ b/cc/ndk_sysroot.go
@@ -104,22 +104,38 @@
}
if m, ok := module.(*headerModule); ok {
+ if ctx.Config().ExcludeDraftNdkApis() && m.properties.Draft {
+ return
+ }
+
installPaths = append(installPaths, m.installPaths...)
licensePaths = append(licensePaths, m.licensePath)
}
if m, ok := module.(*versionedHeaderModule); ok {
+ if ctx.Config().ExcludeDraftNdkApis() && m.properties.Draft {
+ return
+ }
+
installPaths = append(installPaths, m.installPaths...)
licensePaths = append(licensePaths, m.licensePath)
}
if m, ok := module.(*preprocessedHeadersModule); ok {
+ if ctx.Config().ExcludeDraftNdkApis() && m.properties.Draft {
+ return
+ }
+
installPaths = append(installPaths, m.installPaths...)
licensePaths = append(licensePaths, m.licensePath)
}
if m, ok := module.(*Module); ok {
if installer, ok := m.installer.(*stubDecorator); ok {
+ if ctx.Config().ExcludeDraftNdkApis() &&
+ installer.properties.Draft {
+ return
+ }
installPaths = append(installPaths, installer.installPath)
}
diff --git a/cc/proto.go b/cc/proto.go
index 6e6f95e..61fd607 100644
--- a/cc/proto.go
+++ b/cc/proto.go
@@ -31,41 +31,56 @@
var (
proto = pctx.AndroidStaticRule("protoc",
blueprint.RuleParams{
- Command: "$protocCmd --cpp_out=$protoOutParams:$outDir --dependency_out=$out.d -I $protoBase $protoFlags $in && " +
+ Command: "$protocCmd $protoOut=$protoOutParams:$outDir --dependency_out=$out.d -I $protoBase $protoFlags $in && " +
`$depFixCmd $out.d`,
CommandDeps: []string{"$protocCmd", "$depFixCmd"},
Depfile: "${out}.d",
Deps: blueprint.DepsGCC,
- }, "protoFlags", "protoOutParams", "protoBase", "outDir")
+ }, "protoFlags", "protoOut", "protoOutParams", "protoBase", "outDir")
)
// genProto creates a rule to convert a .proto file to generated .pb.cc and .pb.h files and returns
// the paths to the generated files.
-func genProto(ctx android.ModuleContext, protoFile android.Path,
- protoFlags, protoOutParams string, root bool) (ccFile, headerFile android.WritablePath) {
+func genProto(ctx android.ModuleContext, protoFile android.Path, flags builderFlags) (ccFile, headerFile android.WritablePath) {
+
+ srcSuffix := ".cc"
+ if flags.protoC {
+ srcSuffix = ".c"
+ }
var protoBase string
- if root {
+ if flags.protoRoot {
protoBase = "."
- ccFile = android.GenPathWithExt(ctx, "proto", protoFile, "pb.cc")
+ ccFile = android.GenPathWithExt(ctx, "proto", protoFile, "pb"+srcSuffix)
headerFile = android.GenPathWithExt(ctx, "proto", protoFile, "pb.h")
} else {
rel := protoFile.Rel()
protoBase = strings.TrimSuffix(protoFile.String(), rel)
- ccFile = android.PathForModuleGen(ctx, "proto", pathtools.ReplaceExtension(rel, "pb.cc"))
+ ccFile = android.PathForModuleGen(ctx, "proto", pathtools.ReplaceExtension(rel, "pb"+srcSuffix))
headerFile = android.PathForModuleGen(ctx, "proto", pathtools.ReplaceExtension(rel, "pb.h"))
}
+ protoDeps := flags.protoDeps
+ if flags.protoOptionsFile {
+ optionsFile := pathtools.ReplaceExtension(protoFile.String(), "options")
+ optionsPath := android.ExistentPathForSource(ctx, optionsFile)
+ if optionsPath.Valid() {
+ protoDeps = append(android.Paths{optionsPath.Path()}, protoDeps...)
+ }
+ }
+
ctx.Build(pctx, android.BuildParams{
Rule: proto,
Description: "protoc " + protoFile.Rel(),
Output: ccFile,
ImplicitOutput: headerFile,
Input: protoFile,
+ Implicits: protoDeps,
Args: map[string]string{
"outDir": android.ProtoDir(ctx).String(),
- "protoFlags": protoFlags,
- "protoOutParams": protoOutParams,
+ "protoFlags": flags.protoFlags,
+ "protoOut": flags.protoOutTypeFlag,
+ "protoOutParams": flags.protoOutParams,
"protoBase": protoBase,
},
})
@@ -91,6 +106,12 @@
} else {
lib = "libprotobuf-cpp-lite"
}
+ case "nanopb-c":
+ lib = "libprotobuf-c-nano"
+ static = true
+ case "nanopb-c-enable_malloc":
+ lib = "libprotobuf-c-nano-enable_malloc"
+ static = true
default:
ctx.PropertyErrorf("proto.type", "unknown proto type %q",
String(p.Proto.Type))
@@ -118,8 +139,33 @@
flags.protoFlags = android.ProtoFlags(ctx, p)
- if String(p.Proto.Type) == "lite" {
+ var plugin string
+
+ switch String(p.Proto.Type) {
+ case "nanopb-c", "nanopb-c-enable_malloc":
+ flags.protoC = true
+ flags.protoOptionsFile = true
+ flags.protoOutTypeFlag = "--nanopb_out"
+ plugin = "protoc-gen-nanopb"
+ case "full":
+ flags.protoOutTypeFlag = "--cpp_out"
+ case "lite":
+ flags.protoOutTypeFlag = "--cpp_out"
flags.protoOutParams = append(flags.protoOutParams, "lite")
+ case "":
+ // TODO(b/119714316): this should be equivalent to "lite" in
+ // order to match protoDeps, but some modules are depending on
+ // this behavior
+ flags.protoOutTypeFlag = "--cpp_out"
+ default:
+ ctx.PropertyErrorf("proto.type", "unknown proto type %q",
+ String(p.Proto.Type))
+ }
+
+ if plugin != "" {
+ path := ctx.Config().HostToolPath(ctx, plugin)
+ flags.protoDeps = append(flags.protoDeps, path)
+ flags.protoFlags = append(flags.protoFlags, "--plugin="+path.String())
}
return flags
diff --git a/cc/rs.go b/cc/rs.go
index 7c9f5d3..5421b92 100644
--- a/cc/rs.go
+++ b/cc/rs.go
@@ -16,13 +16,22 @@
import (
"android/soong/android"
+ "path/filepath"
+ "runtime"
"strings"
"github.com/google/blueprint"
)
func init() {
- pctx.HostBinToolVariable("rsCmd", "llvm-rs-cc")
+ pctx.VariableFunc("rsCmd", func(ctx android.PackageVarContext) string {
+ if ctx.Config().UnbundledBuild() {
+ // Use RenderScript prebuilts for unbundled builds but not PDK builds
+ return filepath.Join("prebuilts/sdk/tools", runtime.GOOS, "bin/llvm-rs-cc")
+ } else {
+ return pctx.HostBinToolPath(ctx, "llvm-rs-cc").String()
+ }
+ })
}
var rsCppCmdLine = strings.Replace(`
diff --git a/cc/sanitize.go b/cc/sanitize.go
index cd3b3e9..96c149a 100644
--- a/cc/sanitize.go
+++ b/cc/sanitize.go
@@ -50,7 +50,13 @@
hwasanStaticLibsMutex sync.Mutex
intOverflowCflags = []string{"-fsanitize-blacklist=build/soong/cc/config/integer_overflow_blacklist.txt"}
- minimalRuntimeFlags = []string{"-fsanitize-minimal-runtime", "-fno-sanitize-trap=integer,undefined",
+
+ // Pass -Xclang before -fsanitize-minimal-runtime to work around a driver
+ // check which rejects -fsanitize-minimal-runtime together with
+ // -fsanitize=shadow-call-stack even though this combination of flags
+ // is valid.
+ // TODO(pcc): Remove the -Xclang once LLVM r346526 is rolled into the compiler.
+ minimalRuntimeFlags = []string{"-Xclang", "-fsanitize-minimal-runtime", "-fno-sanitize-trap=integer,undefined",
"-fno-sanitize-recover=integer,undefined"}
hwasanGlobalOptions = []string{"heap_history_size=4095"}
)
@@ -71,6 +77,7 @@
tsan
intOverflow
cfi
+ scs
)
func (t sanitizerType) String() string {
@@ -85,6 +92,8 @@
return "intOverflow"
case cfi:
return "cfi"
+ case scs:
+ return "scs"
default:
panic(fmt.Errorf("unknown sanitizerType %d", t))
}
@@ -109,6 +118,7 @@
Cfi *bool `android:"arch_variant"`
Integer_overflow *bool `android:"arch_variant"`
Scudo *bool `android:"arch_variant"`
+ Scs *bool `android:"arch_variant"`
// Sanitizers to run in the diagnostic mode (as opposed to the release mode).
// Replaces abort() on error with a human-readable error message.
@@ -276,6 +286,14 @@
s.Hwaddress = nil
}
+ // SCS is only implemented on AArch64.
+ // We also disable SCS if ASAN, TSAN or HWASAN are enabled because Clang considers
+ // them to be incompatible, although they are in fact compatible.
+ // TODO(pcc): Remove these checks once r347282 is rolled into the compiler.
+ if ctx.Arch().ArchType != android.Arm64 || Bool(s.Address) || Bool(s.Thread) || Bool(s.Hwaddress) {
+ s.Scs = nil
+ }
+
// Also disable CFI if ASAN is enabled.
if Bool(s.Address) || Bool(s.Hwaddress) {
s.Cfi = nil
@@ -299,7 +317,8 @@
}
// HWASan ramdisk (which is built from recovery) goes over some bootloader limit.
- if ctx.inRecovery() {
+ // Keep libc instrumented so that recovery can run hwasan-instrumented code if necessary.
+ if ctx.inRecovery() && !strings.HasPrefix(ctx.ModuleDir(), "bionic/libc") {
s.Hwaddress = nil
}
@@ -322,7 +341,7 @@
if ctx.Os() != android.Windows && (Bool(s.All_undefined) || Bool(s.Undefined) || Bool(s.Address) || Bool(s.Thread) ||
Bool(s.Coverage) || Bool(s.Safestack) || Bool(s.Cfi) || Bool(s.Integer_overflow) || len(s.Misc_undefined) > 0 ||
- Bool(s.Scudo) || Bool(s.Hwaddress)) {
+ Bool(s.Scudo) || Bool(s.Hwaddress) || Bool(s.Scs)) {
sanitize.Properties.SanitizerEnabled = true
}
@@ -490,6 +509,10 @@
sanitizers = append(sanitizers, "scudo")
}
+ if Bool(sanitize.Properties.Sanitize.Scs) {
+ sanitizers = append(sanitizers, "shadow-call-stack")
+ }
+
if len(sanitizers) > 0 {
sanitizeArg := "-fsanitize=" + strings.Join(sanitizers, ",")
@@ -583,6 +606,9 @@
if ret.Class == "STATIC_LIBRARIES" && Bool(sanitize.Properties.Sanitize.Hwaddress) {
ret.SubName += ".hwasan"
}
+ if ret.Class == "STATIC_LIBRARIES" && Bool(sanitize.Properties.Sanitize.Scs) {
+ ret.SubName += ".scs"
+ }
}
func (sanitize *sanitize) inSanitizerDir() bool {
@@ -601,6 +627,8 @@
return sanitize.Properties.Sanitize.Integer_overflow
case cfi:
return sanitize.Properties.Sanitize.Cfi
+ case scs:
+ return sanitize.Properties.Sanitize.Scs
default:
panic(fmt.Errorf("unknown sanitizerType %d", t))
}
@@ -610,7 +638,8 @@
return !sanitize.isSanitizerEnabled(asan) &&
!sanitize.isSanitizerEnabled(hwasan) &&
!sanitize.isSanitizerEnabled(tsan) &&
- !sanitize.isSanitizerEnabled(cfi)
+ !sanitize.isSanitizerEnabled(cfi) &&
+ !sanitize.isSanitizerEnabled(scs)
}
func (sanitize *sanitize) isVariantOnProductionDevice() bool {
@@ -634,6 +663,8 @@
sanitize.Properties.Sanitize.Integer_overflow = boolPtr(b)
case cfi:
sanitize.Properties.Sanitize.Cfi = boolPtr(b)
+ case scs:
+ sanitize.Properties.Sanitize.Scs = boolPtr(b)
default:
panic(fmt.Errorf("unknown sanitizerType %d", t))
}
@@ -683,7 +714,7 @@
if d, ok := child.(*Module); ok && d.sanitize != nil &&
!Bool(d.sanitize.Properties.Sanitize.Never) &&
!d.sanitize.isSanitizerExplicitlyDisabled(t) {
- if t == cfi || t == hwasan {
+ if t == cfi || t == hwasan || t == scs {
if d.static() {
d.sanitize.Properties.SanitizeDep = true
}
@@ -779,6 +810,19 @@
modules[1].(*Module).Properties.PreventInstall = true
modules[1].(*Module).Properties.HideFromMake = true
}
+ } else if t == scs {
+ // We don't currently link any static libraries built with make into
+ // libraries built with SCS, so we don't need logic for propagating
+ // SCSness of dependencies into make.
+ if !c.static() {
+ if isSanitizerEnabled {
+ modules[0].(*Module).Properties.PreventInstall = true
+ modules[0].(*Module).Properties.HideFromMake = true
+ } else {
+ modules[1].(*Module).Properties.PreventInstall = true
+ modules[1].(*Module).Properties.HideFromMake = true
+ }
+ }
} else if t == hwasan {
if mctx.Device() {
// CFI and HWASAN are currently mutually exclusive so disable
diff --git a/cc/stl.go b/cc/stl.go
index 8eee612..9dc8107 100644
--- a/cc/stl.go
+++ b/cc/stl.go
@@ -17,6 +17,7 @@
import (
"android/soong/android"
"fmt"
+ "strconv"
)
func getNdkStlFamily(m *Module) string {
@@ -110,6 +111,26 @@
}()
}
+func needsLibAndroidSupport(ctx BaseModuleContext) bool {
+ versionStr, err := normalizeNdkApiLevel(ctx, ctx.sdkVersion(), ctx.Arch())
+ if err != nil {
+ ctx.PropertyErrorf("sdk_version", err.Error())
+ }
+
+ if versionStr == "current" {
+ return false
+ }
+
+ version, err := strconv.Atoi(versionStr)
+ if err != nil {
+ panic(fmt.Sprintf(
+ "invalid API level returned from normalizeNdkApiLevel: %q",
+ versionStr))
+ }
+
+ return version < 21
+}
+
func (stl *stl) deps(ctx BaseModuleContext, deps Deps) Deps {
switch stl.Properties.SelectedStl {
case "libstdc++":
@@ -141,7 +162,9 @@
} else {
deps.StaticLibs = append(deps.StaticLibs, stl.Properties.SelectedStl, "ndk_libc++abi")
}
- deps.StaticLibs = append(deps.StaticLibs, "ndk_libandroid_support")
+ if needsLibAndroidSupport(ctx) {
+ deps.StaticLibs = append(deps.StaticLibs, "ndk_libandroid_support")
+ }
if ctx.Arch().ArchType == android.Arm {
deps.StaticLibs = append(deps.StaticLibs, "ndk_libunwind")
}
diff --git a/cc/util.go b/cc/util.go
index c900423..925dd74 100644
--- a/cc/util.go
+++ b/cc/util.go
@@ -68,8 +68,6 @@
conlyFlags: strings.Join(in.ConlyFlags, " "),
cppFlags: strings.Join(in.CppFlags, " "),
yaccFlags: strings.Join(in.YaccFlags, " "),
- protoFlags: strings.Join(in.protoFlags, " "),
- protoOutParams: strings.Join(in.protoOutParams, ","),
aidlFlags: strings.Join(in.aidlFlags, " "),
rsFlags: strings.Join(in.rsFlags, " "),
ldFlags: strings.Join(in.LdFlags, " "),
@@ -81,11 +79,18 @@
coverage: in.Coverage,
tidy: in.Tidy,
sAbiDump: in.SAbiDump,
- protoRoot: in.ProtoRoot,
systemIncludeFlags: strings.Join(in.SystemIncludeFlags, " "),
groupStaticLibs: in.GroupStaticLibs,
+
+ protoDeps: in.protoDeps,
+ protoFlags: strings.Join(in.protoFlags, " "),
+ protoOutTypeFlag: in.protoOutTypeFlag,
+ protoOutParams: strings.Join(in.protoOutParams, ","),
+ protoC: in.protoC,
+ protoOptionsFile: in.protoOptionsFile,
+ protoRoot: in.ProtoRoot,
}
}
diff --git a/cc/xom.go b/cc/xom.go
new file mode 100644
index 0000000..f65fc24
--- /dev/null
+++ b/cc/xom.go
@@ -0,0 +1,75 @@
+// Copyright 2018 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 cc
+
+import (
+ "android/soong/android"
+)
+
+type XomProperties struct {
+ Xom *bool
+}
+
+type xom struct {
+ Properties XomProperties
+}
+
+func (xom *xom) props() []interface{} {
+ return []interface{}{&xom.Properties}
+}
+
+func (xom *xom) begin(ctx BaseModuleContext) {}
+
+func (xom *xom) deps(ctx BaseModuleContext, deps Deps) Deps {
+ return deps
+}
+
+func (xom *xom) flags(ctx ModuleContext, flags Flags) Flags {
+ disableXom := false
+
+ if !ctx.Config().EnableXOM() || ctx.Config().XOMDisabledForPath(ctx.ModuleDir()) {
+ disableXom = true
+ }
+
+ if xom.Properties.Xom != nil && !*xom.Properties.Xom {
+ return flags
+ }
+
+ // If any static dependencies have XOM disabled, we should disable XOM in this module,
+ // the assumption being if it's been explicitly disabled then there's probably incompatible
+ // code in the library which may get pulled in.
+ if !ctx.static() && !disableXom {
+ ctx.VisitDirectDeps(func(m android.Module) {
+ cc, ok := m.(*Module)
+ if !ok || cc.xom == nil || !cc.static() {
+ return
+ }
+ if cc.xom.Properties.Xom != nil && !*cc.xom.Properties.Xom {
+ disableXom = true
+ return
+ }
+ })
+ }
+
+ // Enable execute-only if none of the dependencies disable it,
+ // also if it's explicitly set true (allows overriding dependencies disabling it).
+ if !disableXom || (xom.Properties.Xom != nil && *xom.Properties.Xom) {
+ if ctx.Arch().ArchType == android.Arm64 {
+ flags.LdFlags = append(flags.LdFlags, "-Wl,-execute-only")
+ }
+ }
+
+ return flags
+}
diff --git a/java/aar.go b/java/aar.go
index a49aef0..99e9136 100644
--- a/java/aar.go
+++ b/java/aar.go
@@ -157,11 +157,9 @@
}
func (a *aapt) deps(ctx android.BottomUpMutatorContext, sdkContext sdkContext) {
- if !ctx.Config().UnbundledBuild() {
- sdkDep := decodeSdkDep(ctx, sdkContext)
- if sdkDep.frameworkResModule != "" {
- ctx.AddVariationDependencies(nil, frameworkResTag, sdkDep.frameworkResModule)
- }
+ sdkDep := decodeSdkDep(ctx, sdkContext)
+ if sdkDep.frameworkResModule != "" {
+ ctx.AddVariationDependencies(nil, frameworkResTag, sdkDep.frameworkResModule)
}
}
diff --git a/java/app_builder.go b/java/app_builder.go
index b0983bd..28fc4c4 100644
--- a/java/app_builder.go
+++ b/java/app_builder.go
@@ -32,10 +32,10 @@
Signapk = pctx.AndroidStaticRule("signapk",
blueprint.RuleParams{
Command: `${config.JavaCmd} -Djava.library.path=$$(dirname $signapkJniLibrary) ` +
- `-jar $signapkCmd $certificates $in $out`,
+ `-jar $signapkCmd $flags $certificates $in $out`,
CommandDeps: []string{"$signapkCmd", "$signapkJniLibrary"},
},
- "certificates")
+ "flags", "certificates")
androidManifestMerger = pctx.AndroidStaticRule("androidManifestMerger",
blueprint.RuleParams{
diff --git a/java/droiddoc.go b/java/droiddoc.go
index 9dadb30..0c4877a 100644
--- a/java/droiddoc.go
+++ b/java/droiddoc.go
@@ -360,6 +360,9 @@
// a list of top-level directories containing Java stub files to merge show/hide annotations from.
Merge_inclusion_annotations_dirs []string
+ // a file containing a list of classes to do nullability validation for.
+ Validate_nullability_from_list *string
+
// a file containing expected warnings produced by validation of nullability annotations.
Check_nullability_warnings *string
@@ -1302,6 +1305,9 @@
}
}
+ if String(d.properties.Validate_nullability_from_list) != "" {
+ android.ExtractSourceDeps(ctx, d.properties.Validate_nullability_from_list)
+ }
if String(d.properties.Check_nullability_warnings) != "" {
android.ExtractSourceDeps(ctx, d.properties.Check_nullability_warnings)
}
@@ -1411,7 +1417,9 @@
var flags string
if Bool(d.properties.Annotations_enabled) {
flags += " --include-annotations"
- validatingNullability := strings.Contains(d.Javadoc.args, "--validate-nullability-from-merged-stubs")
+ validatingNullability :=
+ strings.Contains(d.Javadoc.args, "--validate-nullability-from-merged-stubs") ||
+ String(d.properties.Validate_nullability_from_list) != ""
migratingNullability := String(d.properties.Previous_api) != ""
if !(migratingNullability || validatingNullability) {
ctx.PropertyErrorf("previous_api",
@@ -1422,6 +1430,9 @@
*implicits = append(*implicits, previousApi)
flags += " --migrate-nullness " + previousApi.String()
}
+ if s := String(d.properties.Validate_nullability_from_list); s != "" {
+ flags += " --validate-nullability-from-list " + ctx.ExpandSource(s, "validate_nullability_from_list").String()
+ }
if validatingNullability {
d.nullabilityWarningsFile = android.PathForModuleOut(ctx, ctx.ModuleName()+"_nullability_warnings.txt")
*implicitOutputs = append(*implicitOutputs, d.nullabilityWarningsFile)
diff --git a/java/sdk_library.go b/java/sdk_library.go
index e513a59..573fc8e 100644
--- a/java/sdk_library.go
+++ b/java/sdk_library.go
@@ -229,19 +229,19 @@
// Create dist rules to install the stubs libs to the dist dir
if len(module.publicApiStubsPath) == 1 {
fmt.Fprintln(w, "$(call dist-for-goals,sdk win_sdk,"+
- module.publicApiStubsPath.Strings()[0]+
+ module.publicApiStubsImplPath.Strings()[0]+
":"+path.Join("apistubs", owner, "public",
module.BaseModuleName()+".jar")+")")
}
if len(module.systemApiStubsPath) == 1 {
fmt.Fprintln(w, "$(call dist-for-goals,sdk win_sdk,"+
- module.systemApiStubsPath.Strings()[0]+
+ module.systemApiStubsImplPath.Strings()[0]+
":"+path.Join("apistubs", owner, "system",
module.BaseModuleName()+".jar")+")")
}
if len(module.testApiStubsPath) == 1 {
fmt.Fprintln(w, "$(call dist-for-goals,sdk win_sdk,"+
- module.testApiStubsPath.Strings()[0]+
+ module.testApiStubsImplPath.Strings()[0]+
":"+path.Join("apistubs", owner, "test",
module.BaseModuleName()+".jar")+")")
}
diff --git a/scripts/build-ndk-prebuilts.sh b/scripts/build-ndk-prebuilts.sh
index 81f8564..947458a 100755
--- a/scripts/build-ndk-prebuilts.sh
+++ b/scripts/build-ndk-prebuilts.sh
@@ -48,7 +48,8 @@
"Malloc_not_svelte": false,
"Safestack": false,
- "Ndk_abis": true
+ "Ndk_abis": true,
+ "Exclude_draft_ndk_apis": true
}
EOF
m --skip-make ${SOONG_OUT}/ndk.timestamp
diff --git a/scripts/manifest_fixer.py b/scripts/manifest_fixer.py
index 07925df..64f49cb 100755
--- a/scripts/manifest_fixer.py
+++ b/scripts/manifest_fixer.py
@@ -61,7 +61,7 @@
help='specify additional <uses-library> tag to add. android:requred is set to false')
parser.add_argument('--uses-non-sdk-api', dest='uses_non_sdk_api', action='store_true',
help='manifest is for a package built against the platform')
- parser.add_argument('--prefer-integrity', type=bool, dest='prefer_integrity',
+ parser.add_argument('--prefer-integrity', dest='prefer_integrity', action='store_true',
help=('specify if the app prefers strict integrity. Should not be conflict if ' +
'already declared in the manifest.'))
parser.add_argument('input', help='input AndroidManifest.xml file')
diff --git a/ui/build/paths/config.go b/ui/build/paths/config.go
index 4034533..5e68db8 100644
--- a/ui/build/paths/config.go
+++ b/ui/build/paths/config.go
@@ -81,7 +81,6 @@
"bzip2": Allowed,
"chmod": Allowed,
"cmp": Allowed,
- "comm": Allowed,
"cp": Allowed,
"cut": Allowed,
"date": Allowed,
@@ -91,7 +90,6 @@
"du": Allowed,
"echo": Allowed,
"egrep": Allowed,
- "env": Allowed,
"expr": Allowed,
"find": Allowed,
"fuser": Allowed,
@@ -114,7 +112,6 @@
"mkdir": Allowed,
"mktemp": Allowed,
"mv": Allowed,
- "od": Allowed,
"openssl": Allowed,
"paste": Allowed,
"patch": Allowed,
@@ -122,7 +119,6 @@
"pkill": Allowed,
"ps": Allowed,
"pstree": Allowed,
- "pwd": Allowed,
"python": Allowed,
"python2.7": Allowed,
"python3": Allowed,
@@ -137,11 +133,9 @@
"sha1sum": Allowed,
"sha256sum": Allowed,
"sha512sum": Allowed,
- "sleep": Allowed,
"sort": Allowed,
"stat": Allowed,
"tar": Allowed,
- "tail": Allowed,
"tee": Allowed,
"timeout": Allowed,
"todos": Allowed,
@@ -173,7 +167,13 @@
// On linux we'll use the toybox version of these instead
"cat": Toybox,
+ "comm": Toybox,
+ "env": Toybox,
"id": Toybox,
+ "od": Toybox,
+ "pwd": Toybox,
+ "sleep": Toybox,
+ "tail": Toybox,
"true": Toybox,
"uname": Toybox,
"uniq": Toybox,