Merge "Strip extended-timestap extra block in zip2zip."
diff --git a/Android.bp b/Android.bp
index 0875a2b..1f45e7a 100644
--- a/Android.bp
+++ b/Android.bp
@@ -150,6 +150,8 @@
"cc/llndk_library.go",
"cc/kernel_headers.go",
+
+ "cc/genrule.go",
],
testSrcs: [
"cc/cc_test.go",
diff --git a/cc/androidmk.go b/cc/androidmk.go
index fc45b7a..2db9d86 100644
--- a/cc/androidmk.go
+++ b/cc/androidmk.go
@@ -89,7 +89,7 @@
}
c.subAndroidMk(&ret, c.installer)
- if c.vndk() && Bool(c.Properties.Vendor_available) {
+ if c.vndk() && Bool(c.VendorProperties.Vendor_available) {
// .vendor suffix is added only when we will have two variants: core and vendor.
// The suffix is not added for vendor-only module.
ret.SubName += vendorSuffix
diff --git a/cc/cc.go b/cc/cc.go
index f0ba1c6..ea523ca 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -154,6 +154,14 @@
// cppflags, conlyflags, ldflags, or include_dirs
No_default_compiler_flags *bool
+ AndroidMkSharedLibs []string `blueprint:"mutated"`
+ HideFromMake bool `blueprint:"mutated"`
+ PreventInstall bool `blueprint:"mutated"`
+
+ UseVndk bool `blueprint:"mutated"`
+}
+
+type VendorProperties struct {
// whether this module should be allowed to install onto /vendor as
// well as /system. The two variants will be built separately, one
// like normal, and the other limited to the set of libraries and
@@ -166,12 +174,6 @@
//
// Nothing happens if BOARD_VNDK_VERSION isn't set in the BoardConfig.mk
Vendor_available *bool
-
- AndroidMkSharedLibs []string `blueprint:"mutated"`
- HideFromMake bool `blueprint:"mutated"`
- PreventInstall bool `blueprint:"mutated"`
-
- UseVndk bool `blueprint:"mutated"`
}
type UnusedProperties struct {
@@ -281,8 +283,9 @@
android.ModuleBase
android.DefaultableModuleBase
- Properties BaseProperties
- unused UnusedProperties
+ Properties BaseProperties
+ VendorProperties VendorProperties
+ unused UnusedProperties
// initialize before calling Init
hod android.HostOrDeviceSupported
@@ -313,7 +316,7 @@
}
func (c *Module) Init() android.Module {
- c.AddProperties(&c.Properties, &c.unused)
+ c.AddProperties(&c.Properties, &c.VendorProperties, &c.unused)
if c.compiler != nil {
c.AddProperties(c.compiler.compilerProps()...)
}
@@ -1127,7 +1130,7 @@
libName := strings.TrimSuffix(name, llndkLibrarySuffix)
libName = strings.TrimPrefix(libName, "prebuilt_")
isLLndk := inList(libName, llndkLibraries)
- if c.vndk() && (Bool(cc.Properties.Vendor_available) || isLLndk) {
+ if c.vndk() && (Bool(cc.VendorProperties.Vendor_available) || isLLndk) {
libName += vendorSuffix
}
// Note: the order of libs in this list is not important because
@@ -1178,6 +1181,13 @@
return c.outputFile
}
+func (c *Module) Srcs() android.Paths {
+ if c.outputFile.Valid() {
+ return android.Paths{c.outputFile.Path()}
+ }
+ return android.Paths{}
+}
+
//
// Defaults
//
@@ -1202,6 +1212,7 @@
module.AddProperties(props...)
module.AddProperties(
&BaseProperties{},
+ &VendorProperties{},
&BaseCompilerProperties{},
&BaseLinkerProperties{},
&LibraryProperties{},
@@ -1241,19 +1252,33 @@
return
}
+ if genrule, ok := mctx.Module().(*genrule.Module); ok {
+ if props, ok := genrule.Extra.(*VendorProperties); ok {
+ if !mctx.DeviceConfig().CompileVndk() {
+ mctx.CreateVariations(coreMode)
+ } else if Bool(props.Vendor_available) {
+ mctx.CreateVariations(coreMode, vendorMode)
+ } else if mctx.Vendor() {
+ mctx.CreateVariations(vendorMode)
+ } else {
+ mctx.CreateVariations(coreMode)
+ }
+ }
+ }
+
m, ok := mctx.Module().(*Module)
if !ok {
return
}
// Sanity check
- if Bool(m.Properties.Vendor_available) && mctx.Vendor() {
+ if Bool(m.VendorProperties.Vendor_available) && mctx.Vendor() {
mctx.PropertyErrorf("vendor_available",
"doesn't make sense at the same time as `vendor: true` or `proprietary: true`")
return
}
if vndk := m.vndkdep; vndk != nil {
- if vndk.isVndk() && !Bool(m.Properties.Vendor_available) {
+ if vndk.isVndk() && !Bool(m.VendorProperties.Vendor_available) {
mctx.PropertyErrorf("vndk",
"has to define `vendor_available: true` to enable vndk")
return
@@ -1273,7 +1298,7 @@
// LL-NDK stubs only exist in the vendor variant, since the
// real libraries will be used in the core variant.
mctx.CreateVariations(vendorMode)
- } else if Bool(m.Properties.Vendor_available) {
+ } else if Bool(m.VendorProperties.Vendor_available) {
// This will be available in both /system and /vendor
// or a /system directory that is available to vendor.
mod := mctx.CreateVariations(coreMode, vendorMode)
diff --git a/cc/genrule.go b/cc/genrule.go
new file mode 100644
index 0000000..51c0d16
--- /dev/null
+++ b/cc/genrule.go
@@ -0,0 +1,38 @@
+// Copyright 2017 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"
+ "android/soong/genrule"
+)
+
+func init() {
+ android.RegisterModuleType("cc_genrule", genRuleFactory)
+}
+
+// cc_genrule is a genrule that can depend on other cc_* objects.
+// The cmd may be run multiple times, once for each of the different arch/etc
+// variations.
+func genRuleFactory() android.Module {
+ module := genrule.NewGenRule()
+
+ module.Extra = &VendorProperties{}
+ module.AddProperties(module.Extra)
+
+ android.InitAndroidArchModule(module, android.HostAndDeviceSupported, android.MultilibBoth)
+
+ return module
+}
diff --git a/cc/linker.go b/cc/linker.go
index 59c979d..7c997d5 100644
--- a/cc/linker.go
+++ b/cc/linker.go
@@ -43,10 +43,6 @@
// list of module-specific flags that will be used for all link steps
Ldflags []string `android:"arch_variant"`
- // don't insert default compiler flags into asflags, cflags,
- // cppflags, conlyflags, ldflags, or include_dirs
- No_default_compiler_flags *bool
-
// list of system libraries that will be dynamically linked to
// shared library and executable modules. If unset, generally defaults to libc,
// libm, and libdl. Set to [] to prevent linking against the defaults.
diff --git a/cc/object.go b/cc/object.go
index 1478908..3cc089c 100644
--- a/cc/object.go
+++ b/cc/object.go
@@ -53,6 +53,11 @@
func (*objectLinker) linkerInit(ctx BaseModuleContext) {}
func (object *objectLinker) linkerDeps(ctx DepsContext, deps Deps) Deps {
+ if !ctx.noDefaultCompilerFlags() && ctx.toolchain().Bionic() {
+ // Needed for VNDK builds where bionic headers aren't automatically added.
+ deps.LateSharedLibs = append(deps.LateSharedLibs, "libc")
+ }
+
deps.ObjFiles = append(deps.ObjFiles, object.Properties.Objs...)
return deps
}
diff --git a/cc/test.go b/cc/test.go
index 1501a26..fddbe4a 100644
--- a/cc/test.go
+++ b/cc/test.go
@@ -43,7 +43,7 @@
// list of compatibility suites (for example "cts", "vts") that the module should be
// installed into.
- Test_suites []string
+ Test_suites []string `android:"arch_variant"`
}
func init() {
diff --git a/cmd/merge_zips/merge_zips.go b/cmd/merge_zips/merge_zips.go
index 3c1cb9a..9fd5ddd 100644
--- a/cmd/merge_zips/merge_zips.go
+++ b/cmd/merge_zips/merge_zips.go
@@ -19,6 +19,7 @@
"fmt"
"log"
"os"
+ "path/filepath"
"sort"
"strings"
@@ -26,26 +27,40 @@
"android/soong/third_party/zip"
)
-type strip struct{}
+type stripDir struct{}
-func (s *strip) String() string {
+func (s *stripDir) String() string {
return `""`
}
-func (s *strip) Set(path_prefix string) error {
- strippings = append(strippings, path_prefix)
+func (s *stripDir) Set(dir string) error {
+ stripDirs = append(stripDirs, filepath.Clean(dir))
+
+ return nil
+}
+
+type zipToNotStrip struct{}
+
+func (s *zipToNotStrip) String() string {
+ return `""`
+}
+
+func (s *zipToNotStrip) Set(zip_path string) error {
+ zipsToNotStrip[zip_path] = true
return nil
}
var (
- sortEntries = flag.Bool("s", false, "sort entries (defaults to the order from the input zip files)")
- emulateJar = flag.Bool("j", false, "sort zip entries using jar ordering (META-INF first)")
- strippings []string
+ sortEntries = flag.Bool("s", false, "sort entries (defaults to the order from the input zip files)")
+ emulateJar = flag.Bool("j", false, "sort zip entries using jar ordering (META-INF first)")
+ stripDirs []string
+ zipsToNotStrip = make(map[string]bool)
)
func init() {
- flag.Var(&strip{}, "strip", "the prefix of file path to be excluded from the output zip")
+ flag.Var(&stripDir{}, "stripDir", "the prefix of file path to be excluded from the output zip")
+ flag.Var(&zipToNotStrip{}, "zipToNotStrip", "the input zip file which is not applicable for stripping")
}
func main() {
@@ -132,11 +147,20 @@
orderedMappings := []fileMapping{}
for _, namedReader := range readers {
+ _, skipStripThisZip := zipsToNotStrip[namedReader.path]
FileLoop:
for _, file := range namedReader.reader.File {
- for _, path_prefix := range strippings {
- if strings.HasPrefix(file.Name, path_prefix) {
- continue FileLoop
+ if !skipStripThisZip {
+ for _, dir := range stripDirs {
+ if strings.HasPrefix(file.Name, dir+"/") {
+ if emulateJar {
+ if file.Name != jar.MetaDir && file.Name != jar.ManifestFile {
+ continue FileLoop
+ }
+ } else {
+ continue FileLoop
+ }
+ }
}
}
// check for other files or directories destined for the same path
diff --git a/genrule/filegroup.go b/genrule/filegroup.go
index 4029134..ed206b0 100644
--- a/genrule/filegroup.go
+++ b/genrule/filegroup.go
@@ -16,6 +16,9 @@
import (
"android/soong/android"
+ "io"
+ "strings"
+ "text/template"
)
func init() {
@@ -33,6 +36,10 @@
// the base path is stripped off the path and the remaining path is used as the
// installation directory.
Path string
+
+ // Create a make variable with the specified name that contains the list of files in the
+ // filegroup, relative to the root of the source tree.
+ Export_to_make_var string
}
type fileGroup struct {
@@ -64,3 +71,24 @@
func (fg *fileGroup) Srcs() android.Paths {
return fg.srcs
}
+
+var androidMkTemplate = template.Must(template.New("filegroup").Parse(`
+ifdef {{.makeVar}}
+ $(error variable {{.makeVar}} set by soong module is already set in make)
+endif
+{{.makeVar}} := {{.value}}
+.KATI_READONLY := {{.makeVar}}
+`))
+
+func (fg *fileGroup) AndroidMk() android.AndroidMkData {
+ return android.AndroidMkData{
+ Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
+ if makeVar := fg.properties.Export_to_make_var; makeVar != "" {
+ androidMkTemplate.Execute(w, map[string]string{
+ "makeVar": makeVar,
+ "value": strings.Join(fg.srcs.Strings(), " "),
+ })
+ }
+ },
+ }
+}
diff --git a/genrule/genrule.go b/genrule/genrule.go
index f390f81..479e67a 100644
--- a/genrule/genrule.go
+++ b/genrule/genrule.go
@@ -28,8 +28,8 @@
)
func init() {
- android.RegisterModuleType("gensrcs", GenSrcsFactory)
- android.RegisterModuleType("genrule", GenRuleFactory)
+ android.RegisterModuleType("gensrcs", genSrcsFactory)
+ android.RegisterModuleType("genrule", genRuleFactory)
}
var (
@@ -90,9 +90,13 @@
Srcs []string
}
-type generator struct {
+type Module struct {
android.ModuleBase
+ // For other packages to make their own genrules with extra
+ // properties
+ Extra interface{}
+
properties generatorProperties
tasks taskFunc
@@ -112,21 +116,21 @@
out android.WritablePaths
}
-func (g *generator) GeneratedSourceFiles() android.Paths {
+func (g *Module) GeneratedSourceFiles() android.Paths {
return g.outputFiles
}
-func (g *generator) Srcs() android.Paths {
+func (g *Module) Srcs() android.Paths {
return g.outputFiles
}
-func (g *generator) GeneratedHeaderDirs() android.Paths {
+func (g *Module) GeneratedHeaderDirs() android.Paths {
return g.exportedIncludeDirs
}
-func (g *generator) DepsMutator(ctx android.BottomUpMutatorContext) {
+func (g *Module) DepsMutator(ctx android.BottomUpMutatorContext) {
android.ExtractSourcesDeps(ctx, g.properties.Srcs)
- if g, ok := ctx.Module().(*generator); ok {
+ if g, ok := ctx.Module().(*Module); ok {
if len(g.properties.Tools) > 0 {
ctx.AddFarVariationDependencies([]blueprint.Variation{
{"arch", ctx.AConfig().BuildOsVariant},
@@ -135,7 +139,7 @@
}
}
-func (g *generator) GenerateAndroidBuildActions(ctx android.ModuleContext) {
+func (g *Module) GenerateAndroidBuildActions(ctx android.ModuleContext) {
if len(g.properties.Tools) == 0 && len(g.properties.Tool_files) == 0 {
ctx.ModuleErrorf("at least one `tools` or `tool_files` is required")
return
@@ -275,7 +279,7 @@
}
}
-func (g *generator) generateSourceFile(ctx android.ModuleContext, task generateTask) {
+func (g *Module) generateSourceFile(ctx android.ModuleContext, task generateTask) {
desc := "generate"
if len(task.out) == 1 {
desc += " " + task.out[0].Base()
@@ -299,20 +303,18 @@
}
}
-func generatorFactory(tasks taskFunc, props ...interface{}) android.Module {
- module := &generator{
+func generatorFactory(tasks taskFunc, props ...interface{}) *Module {
+ module := &Module{
tasks: tasks,
}
module.AddProperties(props...)
module.AddProperties(&module.properties)
- android.InitAndroidModule(module)
-
return module
}
-func GenSrcsFactory() android.Module {
+func NewGenSrcs() *Module {
properties := &genSrcsProperties{}
tasks := func(ctx android.ModuleContext, srcFiles android.Paths) []generateTask {
@@ -329,12 +331,18 @@
return generatorFactory(tasks, properties)
}
+func genSrcsFactory() android.Module {
+ m := NewGenSrcs()
+ android.InitAndroidModule(m)
+ return m
+}
+
type genSrcsProperties struct {
// extension that will be substituted for each output file
Output_extension string
}
-func GenRuleFactory() android.Module {
+func NewGenRule() *Module {
properties := &genRuleProperties{}
tasks := func(ctx android.ModuleContext, srcFiles android.Paths) []generateTask {
@@ -353,6 +361,12 @@
return generatorFactory(tasks, properties)
}
+func genRuleFactory() android.Module {
+ m := NewGenRule()
+ android.InitAndroidModule(m)
+ return m
+}
+
type genRuleProperties struct {
// names of the output files that will be generated
Out []string
diff --git a/java/config/config.go b/java/config/config.go
index 5773164..69d6fc3 100644
--- a/java/config/config.go
+++ b/java/config/config.go
@@ -40,6 +40,12 @@
`-encoding UTF-8`,
`-sourcepath ""`,
`-g`,
+ // Turbine leaves out bridges which can cause javac to unnecessarily insert them into
+ // subclasses (b/65645120). Setting this flag causes our custom javac to assume that
+ // the missing bridges will exist at runtime and not recreate them in subclasses.
+ // If a different javac is used the flag will be ignored and extra bridges will be inserted.
+ // The flag is implemented by https://android-review.googlesource.com/c/486427
+ `-XDskipDuplicateBridges=true`,
}, " "))
pctx.StaticVariable("DefaultJavaVersion", "1.8")