Merge "vendor_available:false hides a lib from vendors"
diff --git a/android/androidmk.go b/android/androidmk.go
index 5ce486d..759d328 100644
--- a/android/androidmk.go
+++ b/android/androidmk.go
@@ -43,6 +43,7 @@
OutputFile OptionalPath
Disabled bool
Include string
+ Required []string
Custom func(w io.Writer, name, prefix, moduleDir string, data AndroidMkData)
@@ -168,6 +169,8 @@
data.Include = "$(BUILD_PREBUILT)"
}
+ data.Required = amod.commonProperties.Required
+
// Make does not understand LinuxBionic
if amod.Os() == LinuxBionic {
return nil
@@ -197,8 +200,8 @@
fmt.Fprintln(&data.preamble, "LOCAL_MODULE_CLASS :=", data.Class)
fmt.Fprintln(&data.preamble, "LOCAL_PREBUILT_MODULE_FILE :=", data.OutputFile.String())
- if len(amod.commonProperties.Required) > 0 {
- fmt.Fprintln(&data.preamble, "LOCAL_REQUIRED_MODULES := "+strings.Join(amod.commonProperties.Required, " "))
+ if len(data.Required) > 0 {
+ fmt.Fprintln(&data.preamble, "LOCAL_REQUIRED_MODULES := "+strings.Join(data.Required, " "))
}
archStr := amod.Arch().ArchType.String()
diff --git a/android/arch.go b/android/arch.go
index db017fd..eaa35a4 100644
--- a/android/arch.go
+++ b/android/arch.go
@@ -468,7 +468,7 @@
"Android64",
"Android32",
"Bionic",
- // TODO(dwillemsen): "Linux",
+ "Linux",
"Not_windows",
"Arm_on_x86",
"Arm_on_x86_64",
@@ -479,7 +479,7 @@
for _, archType := range osArchTypeMap[os] {
targets = append(targets, os.Field+"_"+archType.Name)
- if false { // TODO(dwillemsen): os.Linux()
+ if os.Linux() {
target := "Linux_" + archType.Name
if !inList(target, targets) {
targets = append(targets, target)
@@ -696,7 +696,7 @@
// key: value,
// },
// }
- if false { // TODO(dwillemsen): os.Linux()
+ if os.Linux() {
field = "Linux"
prefix = "target.linux"
a.appendProperties(ctx, genProps, targetProp, field, prefix)
diff --git a/android/module.go b/android/module.go
index 2890b60..9d7f942 100644
--- a/android/module.go
+++ b/android/module.go
@@ -882,10 +882,10 @@
}
} else if pathtools.IsGlob(s) {
globbedSrcFiles := ctx.Glob(filepath.Join(prefix, s), excludes)
- expandedSrcFiles = append(expandedSrcFiles, globbedSrcFiles...)
- for i, s := range expandedSrcFiles {
- expandedSrcFiles[i] = s.(ModuleSrcPath).WithSubDir(ctx, subDir)
+ for i, s := range globbedSrcFiles {
+ globbedSrcFiles[i] = s.(ModuleSrcPath).WithSubDir(ctx, subDir)
}
+ expandedSrcFiles = append(expandedSrcFiles, globbedSrcFiles...)
} else {
s := PathForModuleSrc(ctx, s).WithSubDir(ctx, subDir)
expandedSrcFiles = append(expandedSrcFiles, s)
diff --git a/androidmk/cmd/androidmk/androidmk.go b/androidmk/cmd/androidmk/androidmk.go
index 5fad586..a49f620 100644
--- a/androidmk/cmd/androidmk/androidmk.go
+++ b/androidmk/cmd/androidmk/androidmk.go
@@ -2,6 +2,7 @@
import (
"bytes"
+ "flag"
"fmt"
"io/ioutil"
"os"
@@ -15,6 +16,13 @@
bpparser "github.com/google/blueprint/parser"
)
+var usage = func() {
+ fmt.Fprintf(os.Stderr, "usage: androidmk [flags] <inputFile>\n"+
+ "\nandroidmk parses <inputFile> as an Android.mk file and attempts to output an analogous Android.bp file (to standard out)\n")
+ flag.PrintDefaults()
+ os.Exit(1)
+}
+
// TODO: non-expanded variables with expressions
type bpFile struct {
@@ -85,7 +93,13 @@
}
func main() {
- b, err := ioutil.ReadFile(os.Args[1])
+ flag.Usage = usage
+ flag.Parse()
+ if len(flag.Args()) != 1 {
+ usage()
+ }
+ filePathToRead := flag.Arg(0)
+ b, err := ioutil.ReadFile(filePathToRead)
if err != nil {
fmt.Println(err.Error())
return
diff --git a/build_test.bash b/build_test.bash
index 065d7f6..4c43224 100755
--- a/build_test.bash
+++ b/build_test.bash
@@ -28,11 +28,14 @@
export TRACE_BEGIN_SOONG=$(date +%s%N)
export TOP=$(cd $(dirname ${BASH_SOURCE[0]})/../..; PWD= /bin/pwd)
+cd "${TOP}"
source "${TOP}/build/soong/scripts/microfactory.bash"
case $(uname) in
Linux)
export LD_PRELOAD=/lib/x86_64-linux-gnu/libSegFault.so
+ export SEGFAULT_USE_ALTSTACK=1
+ ulimit -a
;;
esac
diff --git a/cc/pgo.go b/cc/pgo.go
index a99cbad..c5e4e86 100644
--- a/cc/pgo.go
+++ b/cc/pgo.go
@@ -63,37 +63,55 @@
return []interface{}{&pgo.Properties}
}
-func (pgo *pgo) addProfileGatherFlags(ctx ModuleContext, flags Flags) Flags {
- if pgo.Properties.isInstrumentation() {
+func (props *PgoProperties) addProfileGatherFlags(ctx ModuleContext, flags Flags) Flags {
+ if props.isInstrumentation() {
flags.CFlags = append(flags.CFlags, profileInstrumentFlag)
// The profile runtime is added below in deps(). Add the below
// flag, which is the only other link-time action performed by
// the Clang driver during link.
flags.LdFlags = append(flags.LdFlags, "-u__llvm_profile_runtime")
}
- if pgo.Properties.isSampling() {
+ if props.isSampling() {
flags.CFlags = append(flags.CFlags, profileSamplingFlag)
flags.LdFlags = append(flags.LdFlags, profileSamplingFlag)
}
return flags
}
-func (pgo *pgo) profileUseFlag(ctx ModuleContext, file string) string {
- if pgo.Properties.isInstrumentation() {
+func (props *PgoProperties) profileUseFlag(ctx ModuleContext, file string) string {
+ if props.isInstrumentation() {
return fmt.Sprintf(profileUseInstrumentFormat, file)
}
- if pgo.Properties.isSampling() {
+ if props.isSampling() {
return fmt.Sprintf(profileUseSamplingFormat, file)
}
return ""
}
-func (pgo *pgo) profileUseFlags(ctx ModuleContext, file string) []string {
- flags := []string{pgo.profileUseFlag(ctx, file)}
+func (props *PgoProperties) profileUseFlags(ctx ModuleContext, file string) []string {
+ flags := []string{props.profileUseFlag(ctx, file)}
flags = append(flags, profileUseOtherFlags...)
return flags
}
+func (props *PgoProperties) addProfileUseFlags(ctx ModuleContext, flags Flags) Flags {
+ // If the PGO profiles project is found, and this module has PGO
+ // enabled, add flags to use the profile
+ if profilesDir := getPgoProfilesDir(ctx); props.PgoPresent && profilesDir.Valid() {
+ profileFile := android.PathForSource(ctx, profilesDir.String(), *props.Pgo.Profile_file)
+ profileUseFlags := props.profileUseFlags(ctx, profileFile.String())
+
+ flags.CFlags = append(flags.CFlags, profileUseFlags...)
+ flags.LdFlags = append(flags.LdFlags, profileUseFlags...)
+
+ // Update CFlagsDeps and LdFlagsDeps so the module is rebuilt
+ // if profileFile gets updated
+ flags.CFlagsDeps = append(flags.CFlagsDeps, profileFile)
+ flags.LdFlagsDeps = append(flags.LdFlagsDeps, profileFile)
+ }
+ return flags
+}
+
func (props *PgoProperties) isPGO(ctx BaseModuleContext) bool {
isInstrumentation := props.isInstrumentation()
isSampling := props.isSampling()
@@ -188,22 +206,11 @@
// Add flags to profile this module based on its profile_kind
if props.ShouldProfileModule {
- return pgo.addProfileGatherFlags(ctx, flags)
+ return props.addProfileGatherFlags(ctx, flags)
}
- // If the PGO profiles project is found, and this module has PGO
- // enabled, add flags to use the profile
- if profilesDir := getPgoProfilesDir(ctx); props.PgoPresent && profilesDir.Valid() {
- profileFile := android.PathForSource(ctx, profilesDir.String(), *(props.Pgo.Profile_file))
- profileUseFlags := pgo.profileUseFlags(ctx, profileFile.String())
-
- flags.CFlags = append(flags.CFlags, profileUseFlags...)
- flags.LdFlags = append(flags.LdFlags, profileUseFlags...)
-
- // Update CFlagsDeps and LdFlagsDeps so the module is rebuilt
- // if profileFile gets updated
- flags.CFlagsDeps = append(flags.CFlagsDeps, profileFile)
- flags.LdFlagsDeps = append(flags.LdFlagsDeps, profileFile)
+ if !ctx.AConfig().IsEnvTrue("ANDROID_PGO_NO_PROFILE_USE") {
+ return props.addProfileUseFlags(ctx, flags)
}
return flags
diff --git a/cmd/multiproduct_kati/main.go b/cmd/multiproduct_kati/main.go
index e771c15..296000b 100644
--- a/cmd/multiproduct_kati/main.go
+++ b/cmd/multiproduct_kati/main.go
@@ -55,6 +55,8 @@
var buildVariant = flag.String("variant", "eng", "build variant to use")
+var skipProducts = flag.String("skip-products", "", "comma-separated list of products to skip (known failures, etc)")
+
const errorLeadingLines = 20
const errorTrailingLines = 20
@@ -225,8 +227,27 @@
if err != nil {
log.Fatal(err)
}
- products := strings.Fields(vars["all_named_products"])
- log.Verbose("Got product list:", products)
+ productsList := strings.Fields(vars["all_named_products"])
+
+ products := make([]string, 0, len(productsList))
+ skipList := strings.Split(*skipProducts, ",")
+ skipProduct := func(p string) bool {
+ for _, s := range skipList {
+ if p == s {
+ return true
+ }
+ }
+ return false
+ }
+ for _, product := range productsList {
+ if !skipProduct(product) {
+ products = append(products, product)
+ } else {
+ log.Verbose("Skipping: ", product)
+ }
+ }
+
+ log.Verbose("Got product list: ", products)
status.SetTotal(len(products))
diff --git a/genrule/genrule.go b/genrule/genrule.go
index 479e67a..7c1350e 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 (
@@ -331,7 +331,7 @@
return generatorFactory(tasks, properties)
}
-func genSrcsFactory() android.Module {
+func GenSrcsFactory() android.Module {
m := NewGenSrcs()
android.InitAndroidModule(m)
return m
@@ -361,7 +361,7 @@
return generatorFactory(tasks, properties)
}
-func genRuleFactory() android.Module {
+func GenRuleFactory() android.Module {
m := NewGenRule()
android.InitAndroidModule(m)
return m
diff --git a/java/androidmk.go b/java/androidmk.go
index 89d7d51..e349de4 100644
--- a/java/androidmk.go
+++ b/java/androidmk.go
@@ -19,6 +19,8 @@
"io"
"strings"
+ "github.com/google/blueprint/proptools"
+
"android/soong/android"
)
@@ -38,6 +40,25 @@
fmt.Fprintln(w, "LOCAL_SDK_VERSION :=", library.deviceProperties.Sdk_version)
},
},
+ Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
+ android.WriteAndroidMkData(w, data)
+
+ if proptools.Bool(library.deviceProperties.Hostdex) && !library.Host() {
+ fmt.Fprintln(w, "include $(CLEAR_VARS)")
+ fmt.Fprintln(w, "LOCAL_MODULE := "+name+"-hostdex")
+ fmt.Fprintln(w, "LOCAL_IS_HOST_MODULE := true")
+ fmt.Fprintln(w, "LOCAL_MODULE_CLASS := JAVA_LIBRARIES")
+ fmt.Fprintln(w, "LOCAL_PREBUILT_MODULE_FILE :=", library.classpathFile.String())
+ if library.properties.Installable != nil && *library.properties.Installable == false {
+ fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true")
+ }
+ if library.dexJarFile != nil {
+ fmt.Fprintln(w, "LOCAL_SOONG_DEX_JAR :=", library.dexJarFile.String())
+ }
+ fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES := "+strings.Join(data.Required, " "))
+ fmt.Fprintln(w, "include $(BUILD_SYSTEM)/soong_java_prebuilt.mk")
+ }
+ },
}
}
diff --git a/java/app.go b/java/app.go
index e40478a..490a03d 100644
--- a/java/app.go
+++ b/java/app.go
@@ -274,8 +274,6 @@
func AndroidAppFactory() android.Module {
module := &AndroidApp{}
- module.deviceProperties.Dex = true
-
module.AddProperties(
&module.Module.properties,
&module.Module.deviceProperties,
diff --git a/java/java.go b/java/java.go
index bab77c5..5393b06 100644
--- a/java/java.go
+++ b/java/java.go
@@ -28,7 +28,6 @@
"github.com/google/blueprint/proptools"
"android/soong/android"
- "android/soong/genrule"
"android/soong/java/config"
)
@@ -126,16 +125,15 @@
// if not blank, set to the version of the sdk to compile against
Sdk_version string
- // Set for device java libraries, and for host versions of device java libraries
- // built for testing
- Dex bool `blueprint:"mutated"`
-
// directories to pass to aidl tool
Aidl_includes []string
// directories that should be added as include directories
// for any aidl sources of modules that depend on this module
Export_aidl_include_dirs []string
+
+ // If true, export a copy of the module as a -hostdex module for host testing.
+ Hostdex *bool
}
// Module contains the properties and members used by all java module types
@@ -280,8 +278,6 @@
if sdkDep.useModule {
ctx.AddDependency(ctx.Module(), bootClasspathTag, sdkDep.module)
}
- } else {
- // TODO(ccross): add hostdex support
}
}
ctx.AddDependency(ctx.Module(), libTag, j.properties.Libs...)
@@ -437,12 +433,6 @@
srcFileLists = append(srcFileLists, deps.srcFileLists...)
- ctx.VisitDirectDeps(func(module blueprint.Module) {
- if gen, ok := module.(genrule.SourceFileGenerator); ok {
- srcFiles = append(srcFiles, gen.GeneratedSourceFiles()...)
- }
- })
-
srcFileLists = append(srcFileLists, j.ExtraSrcLists...)
var jars android.Paths
@@ -515,7 +505,6 @@
j.classpathFile = outputFile
- // TODO(ccross): handle hostdex
if ctx.Device() && j.installable() {
dxFlags := j.deviceProperties.Dxflags
if false /* emma enabled */ {
@@ -629,7 +618,6 @@
if !installable {
module.properties.Installable = proptools.BoolPtr(false)
}
- module.deviceProperties.Dex = true
module.AddProperties(
&module.Module.properties,
@@ -687,8 +675,6 @@
func BinaryFactory() android.Module {
module := &Binary{}
- module.deviceProperties.Dex = true
-
module.AddProperties(
&module.Module.properties,
&module.Module.deviceProperties,
diff --git a/java/java_test.go b/java/java_test.go
index c2c7ee2..4034340 100644
--- a/java/java_test.go
+++ b/java/java_test.go
@@ -61,6 +61,7 @@
ctx.RegisterModuleType("java_import", android.ModuleFactoryAdaptor(ImportFactory))
ctx.RegisterModuleType("java_defaults", android.ModuleFactoryAdaptor(defaultsFactory))
ctx.RegisterModuleType("filegroup", android.ModuleFactoryAdaptor(genrule.FileGroupFactory))
+ ctx.RegisterModuleType("genrule", android.ModuleFactoryAdaptor(genrule.GenRuleFactory))
ctx.PreArchMutators(android.RegisterPrebuiltsPreArchMutators)
ctx.PreArchMutators(android.RegisterPrebuiltsPostDepsMutators)
ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators)
@@ -506,6 +507,39 @@
}
}
+func TestGeneratedSources(t *testing.T) {
+ ctx := testJava(t, `
+ java_library {
+ name: "foo",
+ srcs: [
+ "a*.java",
+ ":gen",
+ "b*.java",
+ ],
+ }
+
+ genrule {
+ name: "gen",
+ tool_files: ["res/a"],
+ out: ["gen.java"],
+ }
+ `)
+
+ javac := ctx.ModuleForTests("foo", "android_common").Rule("javac")
+ genrule := ctx.ModuleForTests("gen", "").Rule("generator")
+
+ if len(genrule.Outputs) != 1 || filepath.Base(genrule.Outputs[0].String()) != "gen.java" {
+ t.Fatalf(`gen output file %v is not [".../gen.java"]`, genrule.Outputs.Strings())
+ }
+
+ if len(javac.Inputs) != 3 ||
+ javac.Inputs[0].String() != "a.java" ||
+ javac.Inputs[1].String() != genrule.Outputs[0].String() ||
+ javac.Inputs[2].String() != "b.java" {
+ t.Errorf(`foo inputs %v != ["a.java", ".../gen.java", "b.java"]`, javac.Inputs)
+ }
+}
+
func fail(t *testing.T, errs []error) {
if len(errs) > 0 {
for _, err := range errs {