Merge "Fixed the issue of dependencyTag in prebuilt.go"
diff --git a/Android.bp b/Android.bp
index c6b6ee4..4d06710 100644
--- a/Android.bp
+++ b/Android.bp
@@ -95,6 +95,7 @@
"cc/config/x86_darwin_host.go",
"cc/config/x86_linux_host.go",
+ "cc/config/x86_linux_bionic_host.go",
"cc/config/x86_windows_host.go",
],
testSrcs: [
@@ -145,6 +146,8 @@
"cc/ndk_headers.go",
"cc/ndk_library.go",
"cc/ndk_sysroot.go",
+
+ "cc/vndk_library.go",
],
testSrcs: [
"cc/cc_test.go",
diff --git a/android/androidmk.go b/android/androidmk.go
index 793947e..ec3abe1 100644
--- a/android/androidmk.go
+++ b/android/androidmk.go
@@ -164,6 +164,11 @@
return err
}
+ // Make does not understand LinuxBionic
+ if amod.Os() == LinuxBionic {
+ return nil
+ }
+
if data.SubName != "" {
name += data.SubName
}
diff --git a/android/arch.go b/android/arch.go
index df50afa..3d56b37 100644
--- a/android/arch.go
+++ b/android/arch.go
@@ -217,7 +217,8 @@
type OsClass int
const (
- Device OsClass = iota
+ Generic OsClass = iota
+ Device
Host
HostCross
)
@@ -780,6 +781,10 @@
addTarget(BuildOs, *variables.HostSecondaryArch, nil, nil, nil)
}
+ if config.Host_bionic != nil && *config.Host_bionic {
+ addTarget(LinuxBionic, "x86_64", nil, nil, nil)
+ }
+
if variables.CrossHost != nil && *variables.CrossHost != "" {
crossHostOs := osByName(*variables.CrossHost)
if crossHostOs == NoOsType {
diff --git a/android/config.go b/android/config.go
index 1d8cdba..2413f52 100644
--- a/android/config.go
+++ b/android/config.go
@@ -40,6 +40,7 @@
type FileConfigurableOptions struct {
Mega_device *bool `json:",omitempty"`
Ndk_abis *bool `json:",omitempty"`
+ Host_bionic *bool `json:",omitempty"`
}
func (f *FileConfigurableOptions) SetDefaultConfig() {
@@ -496,3 +497,7 @@
}
return coverage
}
+
+func (c *deviceConfig) SameProcessHalDeps() []string {
+ return append([]string(nil), c.config.ProductVariables.SameProcessHalDeps...)
+}
diff --git a/android/module.go b/android/module.go
index 7b35d32..6474e47 100644
--- a/android/module.go
+++ b/android/module.go
@@ -631,7 +631,7 @@
a.module.base().hooks.runInstallHooks(a, fullInstallPath, false)
if !a.module.base().commonProperties.SkipInstall &&
- (a.Host() || !a.AConfig().SkipDeviceInstall()) {
+ (!a.Device() || !a.AConfig().SkipDeviceInstall()) {
deps = append(deps, a.installDeps...)
@@ -669,7 +669,7 @@
a.module.base().hooks.runInstallHooks(a, fullInstallPath, true)
if !a.module.base().commonProperties.SkipInstall &&
- (a.Host() || !a.AConfig().SkipDeviceInstall()) {
+ (!a.Device() || !a.AConfig().SkipDeviceInstall()) {
a.ModuleBuild(pctx, ModuleBuildParams{
Rule: Symlink,
diff --git a/android/mutator.go b/android/mutator.go
index 3420280..940b0ff 100644
--- a/android/mutator.go
+++ b/android/mutator.go
@@ -14,7 +14,11 @@
package android
-import "github.com/google/blueprint"
+import (
+ "sync"
+
+ "github.com/google/blueprint"
+)
// Mutator phases:
// Pre-arch
@@ -23,36 +27,68 @@
// Deps
// PostDeps
-func registerMutators() {
- ctx := registerMutatorsContext{}
+var registerMutatorsOnce sync.Once
+var registeredMutators []*mutator
- register := func(funcs []RegisterMutatorFunc) {
- for _, f := range funcs {
- f(ctx)
+func registerMutatorsToContext(ctx *blueprint.Context, mutators []*mutator) {
+ for _, t := range mutators {
+ var handle blueprint.MutatorHandle
+ if t.bottomUpMutator != nil {
+ handle = ctx.RegisterBottomUpMutator(t.name, t.bottomUpMutator)
+ } else if t.topDownMutator != nil {
+ handle = ctx.RegisterTopDownMutator(t.name, t.topDownMutator)
+ }
+ if t.parallel {
+ handle.Parallel()
}
}
-
- ctx.TopDown("load_hooks", loadHookMutator).Parallel()
- ctx.BottomUp("prebuilts", prebuiltMutator).Parallel()
- ctx.BottomUp("defaults_deps", defaultsDepsMutator).Parallel()
- ctx.TopDown("defaults", defaultsMutator).Parallel()
-
- register(preArch)
-
- ctx.BottomUp("arch", archMutator).Parallel()
- ctx.TopDown("arch_hooks", archHookMutator).Parallel()
-
- register(preDeps)
-
- ctx.BottomUp("deps", depsMutator).Parallel()
-
- ctx.TopDown("prebuilt_select", PrebuiltSelectModuleMutator).Parallel()
- ctx.BottomUp("prebuilt_replace", PrebuiltReplaceMutator).Parallel()
-
- register(postDeps)
}
-type registerMutatorsContext struct{}
+func registerMutators(ctx *blueprint.Context) {
+
+ registerMutatorsOnce.Do(func() {
+ ctx := ®isterMutatorsContext{}
+
+ register := func(funcs []RegisterMutatorFunc) {
+ for _, f := range funcs {
+ f(ctx)
+ }
+ }
+
+ ctx.TopDown("load_hooks", loadHookMutator).Parallel()
+ ctx.BottomUp("prebuilts", prebuiltMutator).Parallel()
+ ctx.BottomUp("defaults_deps", defaultsDepsMutator).Parallel()
+ ctx.TopDown("defaults", defaultsMutator).Parallel()
+
+ register(preArch)
+
+ ctx.BottomUp("arch", archMutator).Parallel()
+ ctx.TopDown("arch_hooks", archHookMutator).Parallel()
+
+ register(preDeps)
+
+ ctx.BottomUp("deps", depsMutator).Parallel()
+
+ ctx.TopDown("prebuilt_select", PrebuiltSelectModuleMutator).Parallel()
+ ctx.BottomUp("prebuilt_replace", PrebuiltReplaceMutator).Parallel()
+
+ register(postDeps)
+
+ registeredMutators = ctx.mutators
+ })
+
+ registerMutatorsToContext(ctx, registeredMutators)
+}
+
+func RegisterTestMutators(ctx *blueprint.Context) {
+ mutators := registerMutatorsContext{}
+ mutators.BottomUp("deps", depsMutator).Parallel()
+ registerMutatorsToContext(ctx, mutators.mutators)
+}
+
+type registerMutatorsContext struct {
+ mutators []*mutator
+}
type RegisterMutatorsContext interface {
TopDown(name string, m AndroidTopDownMutator) MutatorHandle
@@ -99,7 +135,7 @@
androidBaseContextImpl
}
-func (registerMutatorsContext) BottomUp(name string, m AndroidBottomUpMutator) MutatorHandle {
+func (x *registerMutatorsContext) BottomUp(name string, m AndroidBottomUpMutator) MutatorHandle {
f := func(ctx blueprint.BottomUpMutatorContext) {
if a, ok := ctx.Module().(Module); ok {
actx := &androidBottomUpMutatorContext{
@@ -110,11 +146,11 @@
}
}
mutator := &mutator{name: name, bottomUpMutator: f}
- mutators = append(mutators, mutator)
+ x.mutators = append(x.mutators, mutator)
return mutator
}
-func (registerMutatorsContext) TopDown(name string, m AndroidTopDownMutator) MutatorHandle {
+func (x *registerMutatorsContext) TopDown(name string, m AndroidTopDownMutator) MutatorHandle {
f := func(ctx blueprint.TopDownMutatorContext) {
if a, ok := ctx.Module().(Module); ok {
actx := &androidTopDownMutatorContext{
@@ -125,7 +161,7 @@
}
}
mutator := &mutator{name: name, topDownMutator: f}
- mutators = append(mutators, mutator)
+ x.mutators = append(x.mutators, mutator)
return mutator
}
diff --git a/android/register.go b/android/register.go
index d6b290d..9396664 100644
--- a/android/register.go
+++ b/android/register.go
@@ -15,8 +15,6 @@
package android
import (
- "sync"
-
"github.com/google/blueprint"
)
@@ -51,8 +49,6 @@
singletons = append(singletons, singleton{name, factory})
}
-var registerMutatorsOnce sync.Once
-
func NewContext() *blueprint.Context {
ctx := blueprint.NewContext()
@@ -64,19 +60,8 @@
ctx.RegisterSingletonType(t.name, t.factory)
}
- registerMutatorsOnce.Do(registerMutators)
+ registerMutators(ctx)
- for _, t := range mutators {
- var handle blueprint.MutatorHandle
- if t.bottomUpMutator != nil {
- handle = ctx.RegisterBottomUpMutator(t.name, t.bottomUpMutator)
- } else if t.topDownMutator != nil {
- handle = ctx.RegisterTopDownMutator(t.name, t.topDownMutator)
- }
- if t.parallel {
- handle.Parallel()
- }
- }
ctx.RegisterSingletonType("env", EnvSingleton)
return ctx
diff --git a/android/variable.go b/android/variable.go
index c5b957b..aefe1e3 100644
--- a/android/variable.go
+++ b/android/variable.go
@@ -135,6 +135,8 @@
ArtUseReadBarrier *bool `json:",omitempty"`
BtConfigIncludeDir *string `json:",omitempty"`
+
+ SameProcessHalDeps []string `json:",omitempty"`
}
func boolPtr(v bool) *bool {
diff --git a/androidmk/cmd/androidmk/android.go b/androidmk/cmd/androidmk/android.go
index 8f0ebdf..8d46a78 100644
--- a/androidmk/cmd/androidmk/android.go
+++ b/androidmk/cmd/androidmk/android.go
@@ -12,88 +12,115 @@
clear_vars = "__android_mk_clear_vars"
)
-var standardProperties = map[string]struct {
- string
- bpparser.Type
-}{
- // String properties
- "LOCAL_MODULE": {"name", bpparser.StringType},
- "LOCAL_MODULE_CLASS": {"class", bpparser.StringType},
- "LOCAL_CXX_STL": {"stl", bpparser.StringType},
- "LOCAL_STRIP_MODULE": {"strip", bpparser.StringType},
- "LOCAL_MULTILIB": {"compile_multilib", bpparser.StringType},
- "LOCAL_ARM_MODE_HACK": {"instruction_set", bpparser.StringType},
- "LOCAL_SDK_VERSION": {"sdk_version", bpparser.StringType},
- "LOCAL_NDK_STL_VARIANT": {"stl", bpparser.StringType},
- "LOCAL_JAR_MANIFEST": {"manifest", bpparser.StringType},
- "LOCAL_JARJAR_RULES": {"jarjar_rules", bpparser.StringType},
- "LOCAL_CERTIFICATE": {"certificate", bpparser.StringType},
- "LOCAL_PACKAGE_NAME": {"name", bpparser.StringType},
- "LOCAL_MODULE_RELATIVE_PATH": {"relative_install_path", bpparser.StringType},
- "LOCAL_PROTOC_OPTIMIZE_TYPE": {"proto.type", bpparser.StringType},
-
- // List properties
- "LOCAL_SRC_FILES_EXCLUDE": {"exclude_srcs", bpparser.ListType},
- "LOCAL_SHARED_LIBRARIES": {"shared_libs", bpparser.ListType},
- "LOCAL_STATIC_LIBRARIES": {"static_libs", bpparser.ListType},
- "LOCAL_WHOLE_STATIC_LIBRARIES": {"whole_static_libs", bpparser.ListType},
- "LOCAL_SYSTEM_SHARED_LIBRARIES": {"system_shared_libs", bpparser.ListType},
- "LOCAL_HEADER_LIBRARIES": {"header_libs", bpparser.ListType},
- "LOCAL_ASFLAGS": {"asflags", bpparser.ListType},
- "LOCAL_CLANG_ASFLAGS": {"clang_asflags", bpparser.ListType},
- "LOCAL_CFLAGS": {"cflags", bpparser.ListType},
- "LOCAL_CONLYFLAGS": {"conlyflags", bpparser.ListType},
- "LOCAL_CPPFLAGS": {"cppflags", bpparser.ListType},
- "LOCAL_REQUIRED_MODULES": {"required", bpparser.ListType},
- "LOCAL_MODULE_TAGS": {"tags", bpparser.ListType},
- "LOCAL_LDLIBS": {"host_ldlibs", bpparser.ListType},
- "LOCAL_CLANG_CFLAGS": {"clang_cflags", bpparser.ListType},
- "LOCAL_YACCFLAGS": {"yaccflags", bpparser.ListType},
- "LOCAL_SANITIZE_RECOVER": {"sanitize.recover", bpparser.ListType},
- "LOCAL_LOGTAGS_FILES": {"logtags", bpparser.ListType},
- "LOCAL_EXPORT_SHARED_LIBRARY_HEADERS": {"export_shared_lib_headers", bpparser.ListType},
- "LOCAL_EXPORT_STATIC_LIBRARY_HEADERS": {"export_static_lib_headers", bpparser.ListType},
- "LOCAL_INIT_RC": {"init_rc", bpparser.ListType},
- "LOCAL_TIDY_FLAGS": {"tidy_flags", bpparser.ListType},
- // TODO: This is comma-seperated, not space-separated
- "LOCAL_TIDY_CHECKS": {"tidy_checks", bpparser.ListType},
-
- "LOCAL_JAVA_RESOURCE_DIRS": {"java_resource_dirs", bpparser.ListType},
- "LOCAL_JAVACFLAGS": {"javacflags", bpparser.ListType},
- "LOCAL_DX_FLAGS": {"dxflags", bpparser.ListType},
- "LOCAL_JAVA_LIBRARIES": {"java_libs", bpparser.ListType},
- "LOCAL_STATIC_JAVA_LIBRARIES": {"java_static_libs", bpparser.ListType},
- "LOCAL_AIDL_INCLUDES": {"aidl_includes", bpparser.ListType},
- "LOCAL_AAPT_FLAGS": {"aaptflags", bpparser.ListType},
- "LOCAL_PACKAGE_SPLITS": {"package_splits", bpparser.ListType},
-
- // Bool properties
- "LOCAL_IS_HOST_MODULE": {"host", bpparser.BoolType},
- "LOCAL_CLANG": {"clang", bpparser.BoolType},
- "LOCAL_FORCE_STATIC_EXECUTABLE": {"static_executable", bpparser.BoolType},
- "LOCAL_NATIVE_COVERAGE": {"native_coverage", bpparser.BoolType},
- "LOCAL_NO_CRT": {"nocrt", bpparser.BoolType},
- "LOCAL_ALLOW_UNDEFINED_SYMBOLS": {"allow_undefined_symbols", bpparser.BoolType},
- "LOCAL_RTTI_FLAG": {"rtti", bpparser.BoolType},
- "LOCAL_NO_STANDARD_LIBRARIES": {"no_standard_libraries", bpparser.BoolType},
- "LOCAL_PACK_MODULE_RELOCATIONS": {"pack_relocations", bpparser.BoolType},
- "LOCAL_TIDY": {"tidy", bpparser.BoolType},
- "LOCAL_USE_VNDK": {"use_vndk", bpparser.BoolType},
- "LOCAL_PROPRIETARY_MODULE": {"proprietary", bpparser.BoolType},
-
- "LOCAL_EXPORT_PACKAGE_RESOURCES": {"export_package_resources", bpparser.BoolType},
+type bpVariable struct {
+ name string
+ variableType bpparser.Type
}
-var rewriteProperties = map[string]struct {
- f func(file *bpFile, prefix string, value *mkparser.MakeString, append bool) error
-}{
- "LOCAL_C_INCLUDES": {localIncludeDirs},
- "LOCAL_EXPORT_C_INCLUDE_DIRS": {exportIncludeDirs},
- "LOCAL_MODULE_STEM": {stem},
- "LOCAL_MODULE_HOST_OS": {hostOs},
- "LOCAL_SRC_FILES": {srcFiles},
- "LOCAL_SANITIZE": {sanitize},
- "LOCAL_LDFLAGS": {ldflags},
+type variableAssignmentContext struct {
+ file *bpFile
+ prefix string
+ mkvalue *mkparser.MakeString
+ append bool
+}
+
+var rewriteProperties = map[string](func(variableAssignmentContext) error){
+ // custom functions
+ "LOCAL_C_INCLUDES": localIncludeDirs,
+ "LOCAL_EXPORT_C_INCLUDE_DIRS": exportIncludeDirs,
+ "LOCAL_LDFLAGS": ldflags,
+ "LOCAL_MODULE_STEM": stem,
+ "LOCAL_MODULE_HOST_OS": hostOs,
+ "LOCAL_SRC_FILES": srcFiles,
+ "LOCAL_SANITIZE": sanitize,
+
+ // composite functions
+ "LOCAL_MODULE_TAGS": includeVariableIf(bpVariable{"tags", bpparser.ListType}, not(valueDumpEquals("optional"))),
+
+ // skip functions
+ "LOCAL_ADDITIONAL_DEPENDENCIES": skip, // TODO: check for only .mk files?
+ "LOCAL_CPP_EXTENSION": skip,
+ "LOCAL_PATH": skip, // Nothing to do, except maybe avoid the "./" in paths?
+}
+
+// adds a group of properties all having the same type
+func addStandardProperties(propertyType bpparser.Type, properties map[string]string) {
+ for key, val := range properties {
+ rewriteProperties[key] = includeVariable(bpVariable{val, propertyType})
+ }
+}
+
+func init() {
+ addStandardProperties(bpparser.StringType,
+ map[string]string{
+ "LOCAL_MODULE": "name",
+ "LOCAL_MODULE_CLASS": "class",
+ "LOCAL_CXX_STL": "stl",
+ "LOCAL_STRIP_MODULE": "strip",
+ "LOCAL_MULTILIB": "compile_multilib",
+ "LOCAL_ARM_MODE_HACK": "instruction_set",
+ "LOCAL_SDK_VERSION": "sdk_version",
+ "LOCAL_NDK_STL_VARIANT": "stl",
+ "LOCAL_JAR_MANIFEST": "manifest",
+ "LOCAL_JARJAR_RULES": "jarjar_rules",
+ "LOCAL_CERTIFICATE": "certificate",
+ "LOCAL_PACKAGE_NAME": "name",
+ "LOCAL_MODULE_RELATIVE_PATH": "relative_install_path",
+ "LOCAL_PROTOC_OPTIMIZE_TYPE": "proto.type",
+ "LOCAL_HEADER_LIBRARIES": "header_libs",
+ })
+ addStandardProperties(bpparser.ListType,
+ map[string]string{
+ "LOCAL_SRC_FILES_EXCLUDE": "exclude_srcs",
+ "LOCAL_SHARED_LIBRARIES": "shared_libs",
+ "LOCAL_STATIC_LIBRARIES": "static_libs",
+ "LOCAL_WHOLE_STATIC_LIBRARIES": "whole_static_libs",
+ "LOCAL_SYSTEM_SHARED_LIBRARIES": "system_shared_libs",
+ "LOCAL_ASFLAGS": "asflags",
+ "LOCAL_CLANG_ASFLAGS": "clang_asflags",
+ "LOCAL_CFLAGS": "cflags",
+ "LOCAL_CONLYFLAGS": "conlyflags",
+ "LOCAL_CPPFLAGS": "cppflags",
+ "LOCAL_REQUIRED_MODULES": "required",
+ "LOCAL_LDLIBS": "host_ldlibs",
+ "LOCAL_CLANG_CFLAGS": "clang_cflags",
+ "LOCAL_YACCFLAGS": "yaccflags",
+ "LOCAL_SANITIZE_RECOVER": "sanitize.recover",
+ "LOCAL_LOGTAGS_FILES": "logtags",
+ "LOCAL_EXPORT_SHARED_LIBRARY_HEADERS": "export_shared_lib_headers",
+ "LOCAL_EXPORT_STATIC_LIBRARY_HEADERS": "export_static_lib_headers",
+ "LOCAL_INIT_RC": "init_rc",
+ "LOCAL_TIDY_FLAGS": "tidy_flags",
+ // TODO: This is comma-separated, not space-separated
+ "LOCAL_TIDY_CHECKS": "tidy_checks",
+
+ "LOCAL_JAVA_RESOURCE_DIRS": "java_resource_dirs",
+ "LOCAL_JAVACFLAGS": "javacflags",
+ "LOCAL_DX_FLAGS": "dxflags",
+ "LOCAL_JAVA_LIBRARIES": "java_libs",
+ "LOCAL_STATIC_JAVA_LIBRARIES": "java_static_libs",
+ "LOCAL_AIDL_INCLUDES": "aidl_includes",
+ "LOCAL_AAPT_FLAGS": "aaptflags",
+ "LOCAL_PACKAGE_SPLITS": "package_splits",
+ })
+ addStandardProperties(bpparser.BoolType,
+ map[string]string{
+ // Bool properties
+ "LOCAL_IS_HOST_MODULE": "host",
+ "LOCAL_CLANG": "clang",
+ "LOCAL_FORCE_STATIC_EXECUTABLE": "static_executable",
+ "LOCAL_NATIVE_COVERAGE": "native_coverage",
+ "LOCAL_NO_CRT": "nocrt",
+ "LOCAL_ALLOW_UNDEFINED_SYMBOLS": "allow_undefined_symbols",
+ "LOCAL_RTTI_FLAG": "rtti",
+ "LOCAL_NO_STANDARD_LIBRARIES": "no_standard_libraries",
+ "LOCAL_PACK_MODULE_RELOCATIONS": "pack_relocations",
+ "LOCAL_TIDY": "tidy",
+ "LOCAL_USE_VNDK": "use_vndk",
+ "LOCAL_PROPRIETARY_MODULE": "proprietary",
+
+ "LOCAL_EXPORT_PACKAGE_RESOURCES": "export_package_resources",
+ })
}
type listSplitFunc func(bpparser.Expression) (string, bpparser.Expression, error)
@@ -220,8 +247,8 @@
}
}
-func localIncludeDirs(file *bpFile, prefix string, value *mkparser.MakeString, appendVariable bool) error {
- val, err := makeVariableToBlueprint(file, value, bpparser.ListType)
+func localIncludeDirs(ctx variableAssignmentContext) error {
+ val, err := makeVariableToBlueprint(ctx.file, ctx.mkvalue, bpparser.ListType)
if err != nil {
return err
}
@@ -232,14 +259,14 @@
}
if global, ok := lists["global"]; ok && !emptyList(global) {
- err = setVariable(file, appendVariable, prefix, "include_dirs", global, true)
+ err = setVariable(ctx.file, ctx.append, ctx.prefix, "include_dirs", global, true)
if err != nil {
return err
}
}
if local, ok := lists["local"]; ok && !emptyList(local) {
- err = setVariable(file, appendVariable, prefix, "local_include_dirs", local, true)
+ err = setVariable(ctx.file, ctx.append, ctx.prefix, "local_include_dirs", local, true)
if err != nil {
return err
}
@@ -248,8 +275,8 @@
return nil
}
-func exportIncludeDirs(file *bpFile, prefix string, value *mkparser.MakeString, appendVariable bool) error {
- val, err := makeVariableToBlueprint(file, value, bpparser.ListType)
+func exportIncludeDirs(ctx variableAssignmentContext) error {
+ val, err := makeVariableToBlueprint(ctx.file, ctx.mkvalue, bpparser.ListType)
if err != nil {
return err
}
@@ -260,17 +287,17 @@
}
if local, ok := lists["local"]; ok && !emptyList(local) {
- err = setVariable(file, appendVariable, prefix, "export_include_dirs", local, true)
+ err = setVariable(ctx.file, ctx.append, ctx.prefix, "export_include_dirs", local, true)
if err != nil {
return err
}
- appendVariable = true
+ ctx.append = true
}
// Add any paths that could not be converted to local relative paths to export_include_dirs
// anyways, they will cause an error if they don't exist and can be fixed manually.
if global, ok := lists["global"]; ok && !emptyList(global) {
- err = setVariable(file, appendVariable, prefix, "export_include_dirs", global, true)
+ err = setVariable(ctx.file, ctx.append, ctx.prefix, "export_include_dirs", global, true)
if err != nil {
return err
}
@@ -279,8 +306,8 @@
return nil
}
-func stem(file *bpFile, prefix string, value *mkparser.MakeString, appendVariable bool) error {
- val, err := makeVariableToBlueprint(file, value, bpparser.StringType)
+func stem(ctx variableAssignmentContext) error {
+ val, err := makeVariableToBlueprint(ctx.file, ctx.mkvalue, bpparser.StringType)
if err != nil {
return err
}
@@ -293,11 +320,11 @@
}
}
- return setVariable(file, appendVariable, prefix, varName, val, true)
+ return setVariable(ctx.file, ctx.append, ctx.prefix, varName, val, true)
}
-func hostOs(file *bpFile, prefix string, value *mkparser.MakeString, appendVariable bool) error {
- val, err := makeVariableToBlueprint(file, value, bpparser.ListType)
+func hostOs(ctx variableAssignmentContext) error {
+ val, err := makeVariableToBlueprint(ctx.file, ctx.mkvalue, bpparser.ListType)
if err != nil {
return err
}
@@ -320,15 +347,15 @@
}
if inList("windows") {
- err = setVariable(file, appendVariable, "target.windows", "enabled", trueValue, true)
+ err = setVariable(ctx.file, ctx.append, "target.windows", "enabled", trueValue, true)
}
if !inList("linux") && err == nil {
- err = setVariable(file, appendVariable, "target.linux", "enabled", falseValue, true)
+ err = setVariable(ctx.file, ctx.append, "target.linux", "enabled", falseValue, true)
}
if !inList("darwin") && err == nil {
- err = setVariable(file, appendVariable, "target.darwin", "enabled", falseValue, true)
+ err = setVariable(ctx.file, ctx.append, "target.darwin", "enabled", falseValue, true)
}
return err
@@ -353,8 +380,8 @@
}
-func srcFiles(file *bpFile, prefix string, value *mkparser.MakeString, appendVariable bool) error {
- val, err := makeVariableToBlueprint(file, value, bpparser.ListType)
+func srcFiles(ctx variableAssignmentContext) error {
+ val, err := makeVariableToBlueprint(ctx.file, ctx.mkvalue, bpparser.ListType)
if err != nil {
return err
}
@@ -362,14 +389,14 @@
lists, err := splitBpList(val, splitSrcsLogtags)
if srcs, ok := lists["srcs"]; ok && !emptyList(srcs) {
- err = setVariable(file, appendVariable, prefix, "srcs", srcs, true)
+ err = setVariable(ctx.file, ctx.append, ctx.prefix, "srcs", srcs, true)
if err != nil {
return err
}
}
if logtags, ok := lists["logtags"]; ok && !emptyList(logtags) {
- err = setVariable(file, true, prefix, "logtags", logtags, true)
+ err = setVariable(ctx.file, true, ctx.prefix, "logtags", logtags, true)
if err != nil {
return err
}
@@ -378,8 +405,8 @@
return nil
}
-func sanitize(file *bpFile, prefix string, mkvalue *mkparser.MakeString, appendVariable bool) error {
- val, err := makeVariableToBlueprint(file, mkvalue, bpparser.ListType)
+func sanitize(ctx variableAssignmentContext) error {
+ val, err := makeVariableToBlueprint(ctx.file, ctx.mkvalue, bpparser.ListType)
if err != nil {
return err
}
@@ -389,7 +416,7 @@
case *bpparser.Variable:
return "vars", value, nil
case *bpparser.Operator:
- file.errorf(mkvalue, "unknown sanitize expression")
+ ctx.file.errorf(ctx.mkvalue, "unknown sanitize expression")
return "unknown", value, nil
case *bpparser.String:
switch v.Value {
@@ -399,7 +426,7 @@
}
return v.Value, bpTrue, nil
default:
- file.errorf(mkvalue, "unknown sanitize argument: %s", v.Value)
+ ctx.file.errorf(ctx.mkvalue, "unknown sanitize argument: %s", v.Value)
return "unknown", value, nil
}
default:
@@ -417,13 +444,13 @@
switch k {
case "never", "address", "coverage", "integer", "thread", "undefined":
- err = setVariable(file, false, prefix, "sanitize."+k, lists[k].(*bpparser.List).Values[0], true)
+ err = setVariable(ctx.file, false, ctx.prefix, "sanitize."+k, lists[k].(*bpparser.List).Values[0], true)
case "unknown":
- // Nothing, we already added the error above
+ // Nothing, we already added the error above
case "vars":
fallthrough
default:
- err = setVariable(file, true, prefix, "sanitize", v, true)
+ err = setVariable(ctx.file, true, ctx.prefix, "sanitize", v, true)
}
if err != nil {
@@ -434,8 +461,8 @@
return err
}
-func ldflags(file *bpFile, prefix string, mkvalue *mkparser.MakeString, appendVariable bool) error {
- val, err := makeVariableToBlueprint(file, mkvalue, bpparser.ListType)
+func ldflags(ctx variableAssignmentContext) error {
+ val, err := makeVariableToBlueprint(ctx.file, ctx.mkvalue, bpparser.ListType)
if err != nil {
return err
}
@@ -457,13 +484,13 @@
}
if v, ok := exp2.Args[1].(*bpparser.Variable); !ok || v.Name != "LOCAL_PATH" {
- file.errorf(mkvalue, "Unrecognized version-script")
+ ctx.file.errorf(ctx.mkvalue, "Unrecognized version-script")
return "ldflags", value, nil
}
s, ok := exp1.Args[1].(*bpparser.String)
if !ok {
- file.errorf(mkvalue, "Unrecognized version-script")
+ ctx.file.errorf(ctx.mkvalue, "Unrecognized version-script")
return "ldflags", value, nil
}
@@ -476,7 +503,7 @@
}
if ldflags, ok := lists["ldflags"]; ok && !emptyList(ldflags) {
- err = setVariable(file, appendVariable, prefix, "ldflags", ldflags, true)
+ err = setVariable(ctx.file, ctx.append, ctx.prefix, "ldflags", ldflags, true)
if err != nil {
return err
}
@@ -484,9 +511,9 @@
if version_script, ok := lists["version"]; ok && !emptyList(version_script) {
if len(version_script.(*bpparser.List).Values) > 1 {
- file.errorf(mkvalue, "multiple version scripts found?")
+ ctx.file.errorf(ctx.mkvalue, "multiple version scripts found?")
}
- err = setVariable(file, false, prefix, "version_script", version_script.(*bpparser.List).Values[0], true)
+ err = setVariable(ctx.file, false, ctx.prefix, "version_script", version_script.(*bpparser.List).Values[0], true)
if err != nil {
return err
}
@@ -495,8 +522,52 @@
return nil
}
-var deleteProperties = map[string]struct{}{
- "LOCAL_CPP_EXTENSION": struct{}{},
+// given a conditional, returns a function that will insert a variable assignment or not, based on the conditional
+func includeVariableIf(bpVar bpVariable, conditional func(ctx variableAssignmentContext) bool) func(ctx variableAssignmentContext) error {
+ return func(ctx variableAssignmentContext) error {
+ var err error
+ if conditional(ctx) {
+ err = includeVariableNow(bpVar, ctx)
+ }
+ return err
+ }
+}
+
+// given a variable, returns a function that will always insert a variable assignment
+func includeVariable(bpVar bpVariable) func(ctx variableAssignmentContext) error {
+ return includeVariableIf(bpVar, always)
+}
+
+func includeVariableNow(bpVar bpVariable, ctx variableAssignmentContext) error {
+ var val bpparser.Expression
+ var err error
+ val, err = makeVariableToBlueprint(ctx.file, ctx.mkvalue, bpVar.variableType)
+ if err == nil {
+ err = setVariable(ctx.file, ctx.append, ctx.prefix, bpVar.name, val, true)
+ }
+ return err
+}
+
+// given a function that returns a bool, returns a function that returns the opposite
+func not(conditional func(ctx variableAssignmentContext) bool) func(ctx variableAssignmentContext) bool {
+ return func(ctx variableAssignmentContext) bool {
+ return !conditional(ctx)
+ }
+}
+
+// returns a function that tells whether mkvalue.Dump equals the given query string
+func valueDumpEquals(textToMatch string) func(ctx variableAssignmentContext) bool {
+ return func(ctx variableAssignmentContext) bool {
+ return (ctx.mkvalue.Dump() == textToMatch)
+ }
+}
+
+func always(ctx variableAssignmentContext) bool {
+ return true
+}
+
+func skip(ctx variableAssignmentContext) error {
+ return nil
}
// Shorter suffixes of other suffixes must be at the end of the list
diff --git a/androidmk/cmd/androidmk/androidmk.go b/androidmk/cmd/androidmk/androidmk.go
index 729e4f2..1d94b65 100644
--- a/androidmk/cmd/androidmk/androidmk.go
+++ b/androidmk/cmd/androidmk/androidmk.go
@@ -233,28 +233,16 @@
appendVariable := assignment.Type == "+="
var err error
- if prop, ok := standardProperties[name]; ok {
- var val bpparser.Expression
- val, err = makeVariableToBlueprint(file, assignment.Value, prop.Type)
- if err == nil {
- err = setVariable(file, appendVariable, prefix, prop.string, val, true)
- }
- } else if prop, ok := rewriteProperties[name]; ok {
- err = prop.f(file, prefix, assignment.Value, appendVariable)
- } else if _, ok := deleteProperties[name]; ok {
- return
+ if prop, ok := rewriteProperties[name]; ok {
+ err = prop(variableAssignmentContext{file, prefix, assignment.Value, appendVariable})
} else {
switch {
- case name == "LOCAL_PATH":
- // Nothing to do, except maybe avoid the "./" in paths?
case name == "LOCAL_ARM_MODE":
// This is a hack to get the LOCAL_ARM_MODE value inside
// of an arch: { arm: {} } block.
armModeAssign := assignment
armModeAssign.Name = mkparser.SimpleMakeString("LOCAL_ARM_MODE_HACK_arm", assignment.Name.Pos())
handleAssignment(file, armModeAssign, c)
- case name == "LOCAL_ADDITIONAL_DEPENDENCIES":
- // TODO: check for only .mk files?
case strings.HasPrefix(name, "LOCAL_"):
file.errorf(assignment, "unsupported assignment to %s", name)
return
diff --git a/androidmk/cmd/androidmk/androidmk_test.go b/androidmk/cmd/androidmk/androidmk_test.go
index 2f4daf7..0c44ea7 100644
--- a/androidmk/cmd/androidmk/androidmk_test.go
+++ b/androidmk/cmd/androidmk/androidmk_test.go
@@ -357,6 +357,34 @@
}
`,
},
+ {
+ desc: "Remove LOCAL_MODULE_TAGS optional",
+ in: `
+include $(CLEAR_VARS)
+LOCAL_MODULE_TAGS := optional
+include $(BUILD_SHARED_LIBRARY)
+`,
+
+ expected: `
+cc_library_shared {
+
+}
+`,
+ },
+ {
+ desc: "Keep LOCAL_MODULE_TAGS non-optional",
+ in: `
+include $(CLEAR_VARS)
+LOCAL_MODULE_TAGS := debug
+include $(BUILD_SHARED_LIBRARY)
+`,
+
+ expected: `
+cc_library_shared {
+ tags: ["debug"],
+}
+`,
+ },
}
func reformatBlueprint(input string) string {
diff --git a/cc/androidmk.go b/cc/androidmk.go
index f45fbbe..0cd6faf 100644
--- a/cc/androidmk.go
+++ b/cc/androidmk.go
@@ -156,6 +156,14 @@
}
}
+func (vndkLibrary *vndkExtLibraryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
+ ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) error {
+ fmt.Fprintln(w, "LOCAL_EXTENDS_MODULE := ", vndkLibrary.properties.Extends)
+ return nil
+ })
+ vndkLibrary.libraryDecorator.AndroidMk(ctx, ret)
+}
+
func (object *objectLinker) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
ret.Custom = func(w io.Writer, name, prefix, moduleDir string) error {
out := ret.OutputFile.Path()
diff --git a/cc/binary.go b/cc/binary.go
index 521ccb7..637f6c7 100644
--- a/cc/binary.go
+++ b/cc/binary.go
@@ -15,6 +15,8 @@
package cc
import (
+ "path/filepath"
+
"github.com/google/blueprint"
"github.com/google/blueprint/proptools"
@@ -236,7 +238,22 @@
if binary.Properties.DynamicLinker != "" {
flags.DynamicLinker = binary.Properties.DynamicLinker
} else {
- flags.DynamicLinker = "/system/bin/linker"
+ switch ctx.Os() {
+ case android.Android:
+ flags.DynamicLinker = "/system/bin/linker"
+ case android.LinuxBionic:
+ // The linux kernel expects the linker to be an
+ // absolute path
+ path := android.PathForOutput(ctx,
+ "host", "linux_bionic-x86", "bin", "linker")
+ if p, err := filepath.Abs(path.String()); err == nil {
+ flags.DynamicLinker = p
+ } else {
+ ctx.ModuleErrorf("can't find path to dynamic linker: %q", err)
+ }
+ default:
+ ctx.ModuleErrorf("unknown dynamic linker")
+ }
if flags.Toolchain.Is64Bit() {
flags.DynamicLinker += "64"
}
diff --git a/cc/builder.go b/cc/builder.go
index 9a871d5..f3a4bcb 100644
--- a/cc/builder.go
+++ b/cc/builder.go
@@ -184,6 +184,7 @@
type builderFlags struct {
globalFlags string
+ arFlags string
asFlags string
cFlags string
conlyFlags string
@@ -367,6 +368,9 @@
arCmd := gccCmd(flags.toolchain, "ar")
arFlags := "crsPD"
+ if flags.arFlags != "" {
+ arFlags += " " + flags.arFlags
+ }
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
Rule: ar,
diff --git a/cc/cc.go b/cc/cc.go
index d486db3..c5f1c35 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -96,6 +96,7 @@
type Flags struct {
GlobalFlags []string // Flags that apply to C, C++, and assembly source files
+ ArFlags []string // Flags that apply to ar
AsFlags []string // Flags that apply to assembly source files
CFlags []string // Flags that apply to C and C++ source files
ConlyFlags []string // Flags that apply to C source files
@@ -162,6 +163,9 @@
vndk() bool
selectedStl() string
baseModuleName() string
+ isNdk() bool
+ isVndk() bool
+ isSameProcessHal() bool
}
type ModuleContext interface {
@@ -404,6 +408,18 @@
return ctx.mod.ModuleBase.BaseModuleName()
}
+func (ctx *moduleContextImpl) isNdk() bool {
+ return inList(ctx.baseModuleName(), ndkPrebuiltSharedLibraries)
+}
+
+func (ctx *moduleContextImpl) isVndk() bool {
+ return config.IsVndkLibrary(ctx.baseModuleName())
+}
+
+func (ctx *moduleContextImpl) isSameProcessHal() bool {
+ return inList(ctx.baseModuleName(), ctx.ctx.DeviceConfig().SameProcessHalDeps())
+}
+
func newBaseModule(hod android.HostOrDeviceSupported, multilib android.Multilib) *Module {
return &Module{
hod: hod,
diff --git a/cc/compiler.go b/cc/compiler.go
index dc594e3..84ee652 100644
--- a/cc/compiler.go
+++ b/cc/compiler.go
@@ -262,10 +262,7 @@
flags.LdFlags = config.ClangFilterUnknownCflags(flags.LdFlags)
target := "-target " + tc.ClangTriple()
- var gccPrefix string
- if !ctx.Darwin() {
- gccPrefix = "-B" + filepath.Join(tc.GccRoot(), tc.GccTriple(), "bin")
- }
+ gccPrefix := "-B" + config.ToolPath(tc)
flags.CFlags = append(flags.CFlags, target, gccPrefix)
flags.AsFlags = append(flags.AsFlags, target, gccPrefix)
diff --git a/cc/config/global.go b/cc/config/global.go
index 1ce1cce..68de5d0 100644
--- a/cc/config/global.go
+++ b/cc/config/global.go
@@ -176,3 +176,11 @@
func VndkLibraries() []string {
return []string{}
}
+
+func VndkIndirectLibraries() []string {
+ return []string{}
+}
+
+func IsVndkLibrary(name string) bool {
+ return inList(name, VndkLibraries()) || inList(name, VndkIndirectLibraries())
+}
diff --git a/cc/config/toolchain.go b/cc/config/toolchain.go
index 995c8c6..8fc4a21 100644
--- a/cc/config/toolchain.go
+++ b/cc/config/toolchain.go
@@ -16,6 +16,7 @@
import (
"fmt"
+ "path/filepath"
"android/soong/android"
)
@@ -47,6 +48,7 @@
GccTriple() string
// GccVersion should return a real value, not a ninja reference
GccVersion() string
+ ToolPath() string
ToolchainCflags() string
ToolchainLdflags() string
@@ -145,6 +147,10 @@
return true
}
+func (t toolchainBase) ToolPath() string {
+ return ""
+}
+
type toolchain64Bit struct {
toolchainBase
}
@@ -216,3 +222,10 @@
}
return "libclang_rt.ubsan_standalone-" + arch + "-android.so"
}
+
+func ToolPath(t Toolchain) string {
+ if p := t.ToolPath(); p != "" {
+ return p
+ }
+ return filepath.Join(t.GccRoot(), t.GccTriple(), "bin")
+}
diff --git a/cc/config/x86_darwin_host.go b/cc/config/x86_darwin_host.go
index 18acef8..b6b08fe 100644
--- a/cc/config/x86_darwin_host.go
+++ b/cc/config/x86_darwin_host.go
@@ -17,6 +17,7 @@
import (
"fmt"
"os/exec"
+ "path/filepath"
"strings"
"android/soong/android"
@@ -131,6 +132,11 @@
return strings.TrimSpace(string(bytes)), err
})
+ pctx.VariableFunc("MacToolPath", func(config interface{}) (string, error) {
+ bytes, err := exec.Command("xcrun", "--find", "ld").Output()
+ return filepath.Dir(strings.TrimSpace(string(bytes))), err
+ })
+
pctx.StaticVariable("DarwinGccVersion", darwinGccVersion)
pctx.SourcePathVariable("DarwinGccRoot",
"prebuilts/gcc/${HostPrebuiltTag}/host/i686-apple-darwin-${DarwinGccVersion}")
@@ -276,6 +282,10 @@
return false
}
+func (t *toolchainDarwin) ToolPath() string {
+ return "${config.MacToolPath}"
+}
+
var toolchainDarwinX86Singleton Toolchain = &toolchainDarwinX86{}
var toolchainDarwinX8664Singleton Toolchain = &toolchainDarwinX8664{}
diff --git a/cc/config/x86_linux_bionic_host.go b/cc/config/x86_linux_bionic_host.go
new file mode 100644
index 0000000..bd6cd0e
--- /dev/null
+++ b/cc/config/x86_linux_bionic_host.go
@@ -0,0 +1,168 @@
+// Copyright 2016 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 config
+
+import (
+ "strings"
+
+ "android/soong/android"
+)
+
+var (
+ linuxBionicCflags = ClangFilterUnknownCflags([]string{
+ "-fno-exceptions", // from build/core/combo/select.mk
+ "-Wno-multichar", // from build/core/combo/select.mk
+
+ "-fdiagnostics-color",
+
+ "-Wa,--noexecstack",
+
+ "-fPIC",
+ "-no-canonical-prefixes",
+
+ "-U_FORTIFY_SOURCE",
+ "-D_FORTIFY_SOURCE=2",
+ "-fstack-protector-strong",
+
+ // From x86_64_device
+ "-ffunction-sections",
+ "-finline-functions",
+ "-finline-limit=300",
+ "-fno-short-enums",
+ "-funswitch-loops",
+ "-funwind-tables",
+ "-no-canonical-prefixes",
+ "-fno-canonical-system-headers",
+
+ // HOST_RELEASE_CFLAGS
+ "-O2", // from build/core/combo/select.mk
+ "-g", // from build/core/combo/select.mk
+ "-fno-strict-aliasing", // from build/core/combo/select.mk
+
+ // Tell clang where the gcc toolchain is
+ "--gcc-toolchain=${LinuxBionicGccRoot}",
+
+ // TODO: We're not really android, but we don't have a triple yet b/31393676
+ "-U__ANDROID__",
+ "-fno-emulated-tls",
+
+ // This is normally in ClangExtraTargetCflags, but this is considered host
+ "-nostdlibinc",
+ })
+
+ linuxBionicLdflags = ClangFilterUnknownCflags([]string{
+ "-Wl,-z,noexecstack",
+ "-Wl,-z,relro",
+ "-Wl,-z,now",
+ "-Wl,--build-id=md5",
+ "-Wl,--warn-shared-textrel",
+ "-Wl,--fatal-warnings",
+ "-Wl,--gc-sections",
+ "-Wl,--hash-style=gnu",
+ "-Wl,--no-undefined-version",
+
+ // Use the device gcc toolchain
+ "--gcc-toolchain=${LinuxBionicGccRoot}",
+ })
+)
+
+func init() {
+ pctx.StaticVariable("LinuxBionicCflags", strings.Join(linuxBionicCflags, " "))
+ pctx.StaticVariable("LinuxBionicLdflags", strings.Join(linuxBionicLdflags, " "))
+
+ pctx.StaticVariable("LinuxBionicIncludeFlags", bionicHeaders("x86_64", "x86"))
+
+ // Use the device gcc toolchain for now
+ pctx.StaticVariable("LinuxBionicGccRoot", "${X86_64GccRoot}")
+}
+
+type toolchainLinuxBionic struct {
+ toolchain64Bit
+}
+
+func (t *toolchainLinuxBionic) Name() string {
+ return "x86_64"
+}
+
+func (t *toolchainLinuxBionic) GccRoot() string {
+ return "${config.LinuxBionicGccRoot}"
+}
+
+func (t *toolchainLinuxBionic) GccTriple() string {
+ return "x86_64-linux-android"
+}
+
+func (t *toolchainLinuxBionic) GccVersion() string {
+ return "4.9"
+}
+
+func (t *toolchainLinuxBionic) Cflags() string {
+ return ""
+}
+
+func (t *toolchainLinuxBionic) Cppflags() string {
+ return ""
+}
+
+func (t *toolchainLinuxBionic) Ldflags() string {
+ return ""
+}
+
+func (t *toolchainLinuxBionic) IncludeFlags() string {
+ return "${config.LinuxBionicIncludeFlags}"
+}
+
+func (t *toolchainLinuxBionic) ClangTriple() string {
+ // TODO: we don't have a triple yet b/31393676
+ return "x86_64-linux-android"
+}
+
+func (t *toolchainLinuxBionic) ClangCflags() string {
+ return "${config.LinuxBionicCflags}"
+}
+
+func (t *toolchainLinuxBionic) ClangCppflags() string {
+ return ""
+}
+
+func (t *toolchainLinuxBionic) ClangLdflags() string {
+ return "${config.LinuxBionicLdflags}"
+}
+
+func (t *toolchainLinuxBionic) ToolchainClangCflags() string {
+ return "-m64 -march=x86-64"
+}
+
+func (t *toolchainLinuxBionic) ToolchainClangLdflags() string {
+ return "-m64"
+}
+
+func (t *toolchainLinuxBionic) AvailableLibraries() []string {
+ return nil
+}
+
+func (t *toolchainLinuxBionic) Bionic() bool {
+ return true
+}
+
+var toolchainLinuxBionicSingleton Toolchain = &toolchainLinuxBionic{}
+
+func linuxBionicToolchainFactory(arch android.Arch) Toolchain {
+ return toolchainLinuxBionicSingleton
+}
+
+func init() {
+ registerToolchainFactory(android.LinuxBionic, android.X86_64, linuxBionicToolchainFactory)
+}
diff --git a/cc/config/x86_windows_host.go b/cc/config/x86_windows_host.go
index 4aad9c8..4709823 100644
--- a/cc/config/x86_windows_host.go
+++ b/cc/config/x86_windows_host.go
@@ -69,6 +69,7 @@
windowsX86Ldflags = []string{
"-m32",
+ "-Wl,--large-address-aware",
"-L${WindowsGccRoot}/${WindowsGccTriple}/lib32",
}
diff --git a/cc/installer.go b/cc/installer.go
index 64f87d9..de04ab6 100644
--- a/cc/installer.go
+++ b/cc/installer.go
@@ -47,6 +47,7 @@
dir string
dir64 string
+ subDir string
relative string
location installLocation
@@ -60,14 +61,14 @@
}
func (installer *baseInstaller) installDir(ctx ModuleContext) android.OutputPath {
- subDir := installer.dir
+ dir := installer.dir
if ctx.toolchain().Is64Bit() && installer.dir64 != "" {
- subDir = installer.dir64
+ dir = installer.dir64
}
if !ctx.Host() && !ctx.Arch().Native {
- subDir = filepath.Join(subDir, ctx.Arch().ArchType.String())
+ dir = filepath.Join(dir, ctx.Arch().ArchType.String())
}
- return android.PathForModuleInstall(ctx, subDir, installer.Properties.Relative_install_path, installer.relative)
+ return android.PathForModuleInstall(ctx, dir, installer.subDir, installer.Properties.Relative_install_path, installer.relative)
}
func (installer *baseInstaller) install(ctx ModuleContext, file android.Path) {
diff --git a/cc/library.go b/cc/library.go
index f7194e4..0ce84a1 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -246,7 +246,7 @@
sharedFlag = "-shared"
}
var f []string
- if ctx.Device() {
+ if ctx.toolchain().Bionic() {
f = append(f,
"-nostdlib",
"-Wl,--gc-sections",
@@ -587,6 +587,26 @@
func (library *libraryDecorator) install(ctx ModuleContext, file android.Path) {
if !ctx.static() {
+ if ctx.Device() {
+ if ctx.isNdk() {
+ library.baseInstaller.subDir = "ndk"
+ if ctx.Proprietary() {
+ ctx.ModuleErrorf("NDK library must not be proprietary")
+ }
+ } else if ctx.isVndk() {
+ library.baseInstaller.subDir = "vndk"
+ if ctx.Proprietary() {
+ ctx.ModuleErrorf("VNDK library must not be proprietary")
+ }
+ } else if ctx.isSameProcessHal() {
+ library.baseInstaller.subDir = "sameprocess"
+ if !ctx.Proprietary() {
+ ctx.ModuleErrorf("SameProcess HAL library must be proprietary")
+ }
+ } else {
+ // Do nothing for other types of lib
+ }
+ }
library.baseInstaller.install(ctx, file)
}
}
diff --git a/cc/makevars.go b/cc/makevars.go
index e4d8fe6..3ab7955 100644
--- a/cc/makevars.go
+++ b/cc/makevars.go
@@ -16,7 +16,6 @@
import (
"fmt"
- "path/filepath"
"sort"
"strings"
@@ -59,6 +58,7 @@
ctx.Strict("BOARD_VNDK_VERSION", "")
}
ctx.Strict("VNDK_LIBRARIES", strings.Join(config.VndkLibraries(), " "))
+ ctx.Strict("VNDK_INDIRECT_LIBRARIES", strings.Join(config.VndkIndirectLibraries(), " "))
ctx.Strict("ADDRESS_SANITIZER_CONFIG_EXTRA_CFLAGS", asanCflags)
ctx.Strict("ADDRESS_SANITIZER_CONFIG_EXTRA_LDFLAGS", asanLdflags)
@@ -186,9 +186,7 @@
if toolchain.ClangSupported() {
clangPrefix := secondPrefix + "CLANG_" + typePrefix
clangExtras := "-target " + toolchain.ClangTriple()
- if target.Os != android.Darwin {
- clangExtras += " -B" + filepath.Join(toolchain.GccRoot(), toolchain.GccTriple(), "bin")
- }
+ clangExtras += " -B" + config.ToolPath(toolchain)
ctx.Strict(clangPrefix+"GLOBAL_CFLAGS", strings.Join([]string{
toolchain.ClangCflags(),
diff --git a/cc/ndk_headers.go b/cc/ndk_headers.go
index a40fc72..e4a790f 100644
--- a/cc/ndk_headers.go
+++ b/cc/ndk_headers.go
@@ -138,12 +138,7 @@
func ndkHeadersFactory() (blueprint.Module, []interface{}) {
module := &headerModule{}
- // Host module rather than device module because device module install steps
- // do not get run when embedded in make. We're not any of the existing
- // module types that can be exposed via the Android.mk exporter, so just use
- // a host module.
- return android.InitAndroidArchModule(module, android.HostSupportedNoCross,
- android.MultilibFirst, &module.properties)
+ return android.InitAndroidModule(module, &module.properties)
}
type preprocessedHeaderProperies struct {
diff --git a/cc/test_data_test.go b/cc/test_data_test.go
index e3b1214..9b5a85a 100644
--- a/cc/test_data_test.go
+++ b/cc/test_data_test.go
@@ -22,6 +22,8 @@
"testing"
"android/soong/android"
+ "android/soong/genrule"
+
"github.com/google/blueprint"
)
@@ -121,13 +123,15 @@
for _, test := range testDataTests {
t.Run(test.name, func(t *testing.T) {
- ctx := android.NewContext()
+ ctx := blueprint.NewContext()
+ android.RegisterTestMutators(ctx)
ctx.MockFileSystem(map[string][]byte{
"Blueprints": []byte(`subdirs = ["dir"]`),
"dir/Blueprints": []byte(test.modules),
"dir/baz": nil,
"dir/bar/baz": nil,
})
+ ctx.RegisterModuleType("filegroup", genrule.FileGroupFactory)
ctx.RegisterModuleType("test", newTest)
_, errs := ctx.ParseBlueprintsFiles("Blueprints")
diff --git a/cc/util.go b/cc/util.go
index 570052e..919e14c 100644
--- a/cc/util.go
+++ b/cc/util.go
@@ -88,6 +88,7 @@
func flagsToBuilderFlags(in Flags) builderFlags {
return builderFlags{
globalFlags: strings.Join(in.GlobalFlags, " "),
+ arFlags: strings.Join(in.ArFlags, " "),
asFlags: strings.Join(in.AsFlags, " "),
cFlags: strings.Join(in.CFlags, " "),
conlyFlags: strings.Join(in.ConlyFlags, " "),
diff --git a/cc/vndk_library.go b/cc/vndk_library.go
new file mode 100644
index 0000000..cca4f3f
--- /dev/null
+++ b/cc/vndk_library.go
@@ -0,0 +1,85 @@
+// 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 (
+ "github.com/google/blueprint"
+
+ "android/soong/android"
+ "android/soong/cc/config"
+)
+
+type vndkExtLibraryProperties struct {
+ // Name of the VNDK library module that this VNDK-ext library is extending.
+ // This library will have the same file name and soname as the original VNDK
+ // library, but will be installed in /system/lib/vndk-ext rather
+ // than /system/lib/vndk.
+ Extends string
+}
+
+type vndkExtLibraryDecorator struct {
+ *libraryDecorator
+
+ properties vndkExtLibraryProperties
+}
+
+func init() {
+ android.RegisterModuleType("vndk_ext_library", vndkExtLibraryFactory)
+}
+
+func (deco *vndkExtLibraryDecorator) linkerFlags(ctx ModuleContext, flags Flags) Flags {
+ extends := deco.properties.Extends
+ if extends != "" {
+ if config.IsVndkLibrary(extends) {
+ // TODO(jiyong): ensure that the module referenced by 'extends' exists. Don't know how...
+ // Adding a dependency was not successful because it leads to circular dependency
+ // in between this and the 'extends' module.
+ // Ideally, this should be something like follows:
+ // otherCtx = findModuleByName(deco.properties.Extends)
+ // if otherCtx != nil && otherCtx.isVndk() {
+ // deco.libaryDecorator.libName = otherCtx.getBaseName()
+ // }
+ deco.libraryDecorator.libName = extends
+ } else {
+ ctx.PropertyErrorf("extends", "%s should be a VNDK or VNDK-indirect library", extends)
+ }
+ } else {
+ ctx.PropertyErrorf("extends", "missing. A VNDK-ext library must extend existing VNDK library")
+ }
+ return deco.libraryDecorator.linkerFlags(ctx, flags)
+}
+
+func (deco *vndkExtLibraryDecorator) install(ctx ModuleContext, file android.Path) {
+ deco.libraryDecorator.baseInstaller.subDir = "vndk-ext"
+ deco.libraryDecorator.baseInstaller.install(ctx, file)
+}
+
+func vndkExtLibraryFactory() (blueprint.Module, []interface{}) {
+ module, library := NewLibrary(android.DeviceSupported)
+ library.BuildOnlyShared()
+
+ _, props := module.Init()
+
+ deco := &vndkExtLibraryDecorator{
+ libraryDecorator: library,
+ }
+
+ module.installer = deco
+ module.linker = deco
+
+ props = append(props, &deco.properties)
+
+ return module, props
+}
diff --git a/cmd/soong_zip/soong_zip.go b/cmd/soong_zip/soong_zip.go
index b0f3daa..1ec2265 100644
--- a/cmd/soong_zip/soong_zip.go
+++ b/cmd/soong_zip/soong_zip.go
@@ -357,6 +357,7 @@
func (z *zipWriter) writeFile(rel, file string) error {
var fileSize int64
+ var executable bool
if s, err := os.Lstat(file); err != nil {
return err
@@ -371,6 +372,7 @@
return fmt.Errorf("%s is not a file, directory, or symlink", file)
} else {
fileSize = s.Size()
+ executable = s.Mode()&0100 != 0
}
if z.directories {
@@ -395,6 +397,9 @@
},
}
ze.fh.SetModTime(z.time)
+ if executable {
+ ze.fh.SetMode(0700)
+ }
r, err := os.Open(file)
if err != nil {
@@ -445,7 +450,7 @@
f.Close()
}(wg, r)
} else {
- go z.compressWholeFile(rel, r, exec, compressChan)
+ go z.compressWholeFile(ze, r, exec, compressChan)
}
return nil
@@ -514,26 +519,19 @@
return buf, nil
}
-func (z *zipWriter) compressWholeFile(rel string, r *os.File, exec Execution, compressChan chan *zipEntry) {
+func (z *zipWriter) compressWholeFile(ze *zipEntry, r *os.File, exec Execution, compressChan chan *zipEntry) {
var bufSize int
defer r.Close()
- fileHeader := &zip.FileHeader{
- Name: rel,
- Method: zip.Deflate,
- }
- fileHeader.SetModTime(z.time)
-
crc := crc32.NewIEEE()
- count, err := io.Copy(crc, r)
+ _, err := io.Copy(crc, r)
if err != nil {
z.errors <- err
return
}
- fileHeader.CRC32 = crc.Sum32()
- fileHeader.UncompressedSize64 = uint64(count)
+ ze.fh.CRC32 = crc.Sum32()
_, err = r.Seek(0, 0)
if err != nil {
@@ -543,10 +541,7 @@
compressed, err := z.compressBlock(r, nil, true)
- ze := &zipEntry{
- fh: fileHeader,
- futureReaders: make(chan chan io.Reader, 1),
- }
+ ze.futureReaders = make(chan chan io.Reader, 1)
futureReader := make(chan io.Reader, 1)
ze.futureReaders <- futureReader
close(ze.futureReaders)
diff --git a/genrule/filegroup.go b/genrule/filegroup.go
index c1d08a8..71c5439 100644
--- a/genrule/filegroup.go
+++ b/genrule/filegroup.go
@@ -21,7 +21,7 @@
)
func init() {
- android.RegisterModuleType("filegroup", fileGroupFactory)
+ android.RegisterModuleType("filegroup", FileGroupFactory)
}
type fileGroupProperties struct {
@@ -48,7 +48,7 @@
// filegroup modules contain a list of files, and can be used to export files across package
// boundaries. filegroups (and genrules) can be referenced from srcs properties of other modules
// using the syntax ":module".
-func fileGroupFactory() (blueprint.Module, []interface{}) {
+func FileGroupFactory() (blueprint.Module, []interface{}) {
module := &fileGroup{}
return android.InitAndroidModule(module, &module.properties)