Merge "Add C++ Host support on sysprop_library"
diff --git a/android/config.go b/android/config.go
index 1fe6f05..32e32ae 100644
--- a/android/config.go
+++ b/android/config.go
@@ -265,7 +265,7 @@
config.Targets = map[OsType][]Target{
Fuchsia: []Target{
- {Fuchsia, Arch{ArchType: Arm64, ArchVariant: ""}, NativeBridgeDisabled, "", ""},
+ {Fuchsia, Arch{ArchType: Arm64, ArchVariant: "", Abi: []string{"arm64-v8a"}}, NativeBridgeDisabled, "", ""},
},
BuildOs: []Target{
{BuildOs, Arch{ArchType: X86_64}, NativeBridgeDisabled, "", ""},
diff --git a/android/visibility.go b/android/visibility.go
index a597687..3f04123 100644
--- a/android/visibility.go
+++ b/android/visibility.go
@@ -186,8 +186,8 @@
var visibilityRuleMap = NewOnceKey("visibilityRuleMap")
// The map from qualifiedModuleName to visibilityRule.
-func moduleToVisibilityRuleMap(ctx BaseModuleContext) *sync.Map {
- return ctx.Config().Once(visibilityRuleMap, func() interface{} {
+func moduleToVisibilityRuleMap(config Config) *sync.Map {
+ return config.Once(visibilityRuleMap, func() interface{} {
return &sync.Map{}
}).(*sync.Map)
}
@@ -304,7 +304,7 @@
if visibility := m.visibility(); visibility != nil {
rule := parseRules(ctx, currentPkg, m.visibility())
if rule != nil {
- moduleToVisibilityRuleMap(ctx).Store(qualifiedModuleId, rule)
+ moduleToVisibilityRuleMap(ctx.Config()).Store(qualifiedModuleId, rule)
}
}
}
@@ -312,6 +312,7 @@
func parseRules(ctx BaseModuleContext, currentPkg string, visibility []string) compositeRule {
rules := make(compositeRule, 0, len(visibility))
hasPrivateRule := false
+ hasPublicRule := false
hasNonPrivateRule := false
for _, v := range visibility {
ok, pkg, name := splitRule(v, currentPkg)
@@ -328,6 +329,7 @@
isPrivateRule = true
case "public":
r = publicRule{}
+ hasPublicRule = true
}
} else {
switch name {
@@ -355,6 +357,11 @@
return compositeRule{privateRule{}}
}
+ if hasPublicRule {
+ // Public overrides all other rules so just return it.
+ return compositeRule{publicRule{}}
+ }
+
return rules
}
@@ -415,21 +422,21 @@
return
}
- rule := effectiveVisibilityRules(ctx, depQualified)
+ rule := effectiveVisibilityRules(ctx.Config(), depQualified)
if rule != nil && !rule.matches(qualified) {
ctx.ModuleErrorf("depends on %s which is not visible to this module", depQualified)
}
})
}
-func effectiveVisibilityRules(ctx BaseModuleContext, qualified qualifiedModuleName) compositeRule {
- moduleToVisibilityRule := moduleToVisibilityRuleMap(ctx)
+func effectiveVisibilityRules(config Config, qualified qualifiedModuleName) compositeRule {
+ moduleToVisibilityRule := moduleToVisibilityRuleMap(config)
value, ok := moduleToVisibilityRule.Load(qualified)
var rule compositeRule
if ok {
rule = value.(compositeRule)
} else {
- rule = packageDefaultVisibility(ctx, qualified)
+ rule = packageDefaultVisibility(config, qualified)
}
return rule
}
@@ -441,8 +448,8 @@
return qualified
}
-func packageDefaultVisibility(ctx BaseModuleContext, moduleId qualifiedModuleName) compositeRule {
- moduleToVisibilityRule := moduleToVisibilityRuleMap(ctx)
+func packageDefaultVisibility(config Config, moduleId qualifiedModuleName) compositeRule {
+ moduleToVisibilityRule := moduleToVisibilityRuleMap(config)
packageQualifiedId := moduleId.getContainingPackageId()
for {
value, ok := moduleToVisibilityRule.Load(packageQualifiedId)
@@ -469,7 +476,7 @@
dir := ctx.OtherModuleDir(module)
qualified := qualifiedModuleName{dir, moduleName}
- rule := effectiveVisibilityRules(ctx, qualified)
+ rule := effectiveVisibilityRules(ctx.Config(), qualified)
return rule.Strings()
}
diff --git a/android/visibility_test.go b/android/visibility_test.go
index 6006072..8dd6a8f 100644
--- a/android/visibility_test.go
+++ b/android/visibility_test.go
@@ -1,15 +1,17 @@
package android
import (
+ "reflect"
"testing"
"github.com/google/blueprint"
)
var visibilityTests = []struct {
- name string
- fs map[string][]byte
- expectedErrors []string
+ name string
+ fs map[string][]byte
+ expectedErrors []string
+ effectiveVisibility map[qualifiedModuleName][]string
}{
{
name: "invalid visibility: empty list",
@@ -493,6 +495,9 @@
deps: ["libexample"],
}`),
},
+ effectiveVisibility: map[qualifiedModuleName][]string{
+ qualifiedModuleName{pkg: "top", name: "libexample"}: {"//visibility:public"},
+ },
},
{
name: "//visibility:public mixed with other from different defaults 1",
@@ -903,13 +908,27 @@
func TestVisibility(t *testing.T) {
for _, test := range visibilityTests {
t.Run(test.name, func(t *testing.T) {
- _, errs := testVisibility(buildDir, test.fs)
+ ctx, errs := testVisibility(buildDir, test.fs)
CheckErrorsAgainstExpectations(t, errs, test.expectedErrors)
+
+ if test.effectiveVisibility != nil {
+ checkEffectiveVisibility(t, ctx, test.effectiveVisibility)
+ }
})
}
}
+func checkEffectiveVisibility(t *testing.T, ctx *TestContext, effectiveVisibility map[qualifiedModuleName][]string) {
+ for moduleName, expectedRules := range effectiveVisibility {
+ rule := effectiveVisibilityRules(ctx.config, moduleName)
+ stringRules := rule.Strings()
+ if !reflect.DeepEqual(expectedRules, stringRules) {
+ t.Errorf("effective rules mismatch: expected %q, found %q", expectedRules, stringRules)
+ }
+ }
+}
+
func testVisibility(buildDir string, fs map[string][]byte) (*TestContext, []error) {
// Create a new config per test as visibility information is stored in the config.
diff --git a/apex/apex.go b/apex/apex.go
index 79fdb71..42cc9a6 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -1316,6 +1316,9 @@
// binaries would be installed by default (in PRODUCT_PACKAGES) the other binary will be removed
// from PRODUCT_PACKAGES.
Overrides []string
+
+ // Logging Parent value
+ Logging_parent string
}
type apexPackaging int
diff --git a/apex/apex_test.go b/apex/apex_test.go
index e5847ab..e694435 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -99,112 +99,6 @@
android.ClearApexDependency()
bp = bp + `
- toolchain_library {
- name: "libcompiler_rt-extras",
- src: "",
- vendor_available: true,
- recovery_available: true,
- }
-
- toolchain_library {
- name: "libatomic",
- src: "",
- vendor_available: true,
- recovery_available: true,
- native_bridge_supported: true,
- }
-
- toolchain_library {
- name: "libgcc",
- src: "",
- vendor_available: true,
- recovery_available: true,
- }
-
- toolchain_library {
- name: "libgcc_stripped",
- src: "",
- vendor_available: true,
- recovery_available: true,
- native_bridge_supported: true,
- }
-
- toolchain_library {
- name: "libclang_rt.builtins-aarch64-android",
- src: "",
- vendor_available: true,
- recovery_available: true,
- native_bridge_supported: true,
- }
-
- toolchain_library {
- name: "libclang_rt.builtins-arm-android",
- src: "",
- vendor_available: true,
- recovery_available: true,
- native_bridge_supported: true,
- }
-
- toolchain_library {
- name: "libclang_rt.builtins-x86_64-android",
- src: "",
- vendor_available: true,
- recovery_available: true,
- native_bridge_supported: true,
- }
-
- toolchain_library {
- name: "libclang_rt.builtins-i686-android",
- src: "",
- vendor_available: true,
- recovery_available: true,
- native_bridge_supported: true,
- }
-
- cc_object {
- name: "crtbegin_so",
- stl: "none",
- vendor_available: true,
- recovery_available: true,
- native_bridge_supported: true,
- }
-
- cc_object {
- name: "crtend_so",
- stl: "none",
- vendor_available: true,
- recovery_available: true,
- native_bridge_supported: true,
- }
-
- cc_object {
- name: "crtbegin_static",
- stl: "none",
- }
-
- cc_object {
- name: "crtend_android",
- stl: "none",
- }
-
- llndk_library {
- name: "libc",
- symbol_file: "",
- native_bridge_supported: true,
- }
-
- llndk_library {
- name: "libm",
- symbol_file: "",
- native_bridge_supported: true,
- }
-
- llndk_library {
- name: "libdl",
- symbol_file: "",
- native_bridge_supported: true,
- }
-
filegroup {
name: "myapex-file_contexts",
srcs: [
@@ -213,6 +107,8 @@
}
`
+ bp = bp + cc.GatherRequiredDepsForTest(android.Android)
+
bp = bp + java.GatherRequiredDepsForTest()
fs := map[string][]byte{
@@ -259,6 +155,8 @@
"dummy.txt": nil,
}
+ cc.GatherRequiredFilesForTest(fs)
+
for _, handler := range handlers {
// The fs now needs to be populated before creating the config, call handlers twice
// for now, once to get any fs changes, and later after the config was created to
@@ -1014,47 +912,6 @@
}
cc_library {
- name: "libc",
- no_libcrt: true,
- nocrt: true,
- system_shared_libs: [],
- stl: "none",
- stubs: {
- versions: ["27", "28", "29"],
- },
- }
-
- cc_library {
- name: "libm",
- no_libcrt: true,
- nocrt: true,
- system_shared_libs: [],
- stl: "none",
- stubs: {
- versions: ["27", "28", "29"],
- },
- apex_available: [
- "//apex_available:platform",
- "myapex"
- ],
- }
-
- cc_library {
- name: "libdl",
- no_libcrt: true,
- nocrt: true,
- system_shared_libs: [],
- stl: "none",
- stubs: {
- versions: ["27", "28", "29"],
- },
- apex_available: [
- "//apex_available:platform",
- "myapex"
- ],
- }
-
- cc_library {
name: "libBootstrap",
srcs: ["mylib.cpp"],
stl: "none",
@@ -3373,6 +3230,7 @@
base: "myapex",
apps: ["override_app"],
overrides: ["unknownapex"],
+ logging_parent: "com.foo.bar",
}
apex_key {
@@ -3419,6 +3277,10 @@
t.Errorf("name should be \"override_myapex\", but was %q", name)
}
+ if apexBundle.overridableProperties.Logging_parent != "com.foo.bar" {
+ t.Errorf("override_myapex should have logging parent (com.foo.bar), but was %q.", apexBundle.overridableProperties.Logging_parent)
+ }
+
data := android.AndroidMkDataForTest(t, config, "", apexBundle)
var builder strings.Builder
data.Custom(&builder, name, "TARGET_", "", data)
@@ -3455,28 +3317,6 @@
system_shared_libs: [],
apex_available: [ "myapex" ],
}
-
- cc_library {
- name: "libc++",
- srcs: ["mylib.cpp"],
- stl: "none",
- system_shared_libs: [],
- apex_available: [ "myapex" ],
- }
-
- cc_library_static {
- name: "libc++demangle",
- srcs: ["mylib.cpp"],
- stl: "none",
- system_shared_libs: [],
- }
-
- cc_library_static {
- name: "libunwind_llvm",
- srcs: ["mylib.cpp"],
- stl: "none",
- system_shared_libs: [],
- }
`, withUnbundledBuild)
module := ctx.ModuleForTests("myapex", "android_common_myapex_image")
diff --git a/apex/builder.go b/apex/builder.go
index 5e0baf4..adb3219 100644
--- a/apex/builder.go
+++ b/apex/builder.go
@@ -383,6 +383,16 @@
targetSdkVersion := ctx.Config().DefaultAppTargetSdk()
minSdkVersion := ctx.Config().DefaultAppTargetSdk()
+
+ if proptools.Bool(a.properties.Legacy_android10_support) {
+ if !java.UseApiFingerprint(ctx, targetSdkVersion) {
+ targetSdkVersion = "29"
+ }
+ if !java.UseApiFingerprint(ctx, minSdkVersion) {
+ minSdkVersion = "29"
+ }
+ }
+
if java.UseApiFingerprint(ctx, targetSdkVersion) {
targetSdkVersion += fmt.Sprintf(".$$(cat %s)", java.ApiFingerprintPath(ctx).String())
implicitInputs = append(implicitInputs, java.ApiFingerprintPath(ctx))
@@ -394,6 +404,10 @@
optFlags = append(optFlags, "--target_sdk_version "+targetSdkVersion)
optFlags = append(optFlags, "--min_sdk_version "+minSdkVersion)
+ if a.overridableProperties.Logging_parent != "" {
+ optFlags = append(optFlags, "--logging_parent ", a.overridableProperties.Logging_parent)
+ }
+
a.mergedNotices = a.buildNoticeFiles(ctx, a.Name()+suffix)
if a.mergedNotices.HtmlGzOutput.Valid() {
// If there's a NOTICE file, embed it as an asset file in the APEX.
diff --git a/apex/vndk_test.go b/apex/vndk_test.go
index dd08f03..a9e26ad 100644
--- a/apex/vndk_test.go
+++ b/apex/vndk_test.go
@@ -68,6 +68,7 @@
cc_library {
name: "libprofile-extras",
vendor_available: true,
+ recovery_available: true,
native_coverage: false,
system_shared_libs: [],
stl: "none",
@@ -76,6 +77,23 @@
cc_library {
name: "libprofile-clang-extras",
vendor_available: true,
+ recovery_available: true,
+ native_coverage: false,
+ system_shared_libs: [],
+ stl: "none",
+ notice: "custom_notice",
+ }
+ cc_library {
+ name: "libprofile-extras_ndk",
+ vendor_available: true,
+ native_coverage: false,
+ system_shared_libs: [],
+ stl: "none",
+ notice: "custom_notice",
+ }
+ cc_library {
+ name: "libprofile-clang-extras_ndk",
+ vendor_available: true,
native_coverage: false,
system_shared_libs: [],
stl: "none",
diff --git a/bpf/bpf.go b/bpf/bpf.go
index 1d792ef..59d1502 100644
--- a/bpf/bpf.go
+++ b/bpf/bpf.go
@@ -66,6 +66,8 @@
// The architecture doesn't matter here, but asm/types.h is included by linux/types.h.
"-isystem bionic/libc/kernel/uapi/asm-arm64",
"-isystem bionic/libc/kernel/android/uapi",
+ // TODO(b/149785767): only give access to specific file with AID_* constants
+ "-I system/core/libcutils/include",
"-I system/bpf/progs/include",
"-I " + ctx.ModuleDir(),
}
diff --git a/cc/binary_sdk_member.go b/cc/binary_sdk_member.go
index 53bc065..58d6ad0 100644
--- a/cc/binary_sdk_member.go
+++ b/cc/binary_sdk_member.go
@@ -16,6 +16,7 @@
import (
"path/filepath"
+ "strings"
"android/soong/android"
"github.com/google/blueprint"
@@ -98,7 +99,23 @@
func buildSharedNativeBinarySnapshot(info *nativeBinaryInfo, builder android.SnapshotBuilder, member android.SdkMember) {
pbm := builder.AddPrebuiltModule(member, "cc_prebuilt_binary")
- pbm.AddProperty("compile_multilib", "both")
+ archVariantCount := len(info.archVariantProperties)
+
+ // Choose setting for compile_multilib that is appropriate for the arch variants supplied.
+ var multilib string
+ if archVariantCount == 2 {
+ multilib = "both"
+ } else if archVariantCount == 1 {
+ if strings.HasSuffix(info.archVariantProperties[0].archType, "64") {
+ multilib = "64"
+ } else {
+ multilib = "32"
+ }
+ }
+ if multilib != "" {
+ pbm.AddProperty("compile_multilib", multilib)
+ }
+
archProperties := pbm.AddPropertySet("arch")
for _, av := range info.archVariantProperties {
archTypeProperties := archProperties.AddPropertySet(av.archType)
diff --git a/cc/cc_test.go b/cc/cc_test.go
index b78f1f3..30ba733 100644
--- a/cc/cc_test.go
+++ b/cc/cc_test.go
@@ -2674,20 +2674,20 @@
cc_binary {
name: "mybin",
srcs: ["foo.c"],
- static_libs: ["libB"],
+ static_libs: ["libfooB"],
static_executable: true,
stl: "none",
}
cc_library {
- name: "libB",
+ name: "libfooB",
srcs: ["foo.c"],
- shared_libs: ["libC"],
+ shared_libs: ["libfooC"],
stl: "none",
}
cc_library {
- name: "libC",
+ name: "libfooC",
srcs: ["foo.c"],
stl: "none",
stubs: {
@@ -2697,7 +2697,7 @@
mybin := ctx.ModuleForTests("mybin", "android_arm64_armv8-a").Module().(*Module)
actual := mybin.depsInLinkOrder
- expected := getOutputPaths(ctx, "android_arm64_armv8-a_static", []string{"libB", "libC"})
+ expected := getOutputPaths(ctx, "android_arm64_armv8-a_static", []string{"libfooB", "libfooC"})
if !reflect.DeepEqual(actual, expected) {
t.Errorf("staticDeps orderings were not propagated correctly"+
diff --git a/cc/config/clang.go b/cc/config/clang.go
index 0d03699..d849906 100644
--- a/cc/config/clang.go
+++ b/cc/config/clang.go
@@ -170,10 +170,9 @@
// http://b/145211066
"-Wno-implicit-int-float-conversion",
// New warnings to be fixed after clang-r377782.
- "-Wno-bitwise-conditional-parentheses", // http://b/148286937
- "-Wno-int-in-bool-context", // http://b/148287349
- "-Wno-sizeof-array-div", // http://b/148815709
- "-Wno-tautological-overlap-compare", // http://b/148815696
+ "-Wno-int-in-bool-context", // http://b/148287349
+ "-Wno-sizeof-array-div", // http://b/148815709
+ "-Wno-tautological-overlap-compare", // http://b/148815696
}, " "))
// Extra cflags for external third-party projects to disable warnings that
diff --git a/cc/config/x86_linux_host.go b/cc/config/x86_linux_host.go
index f08a379..13b5511 100644
--- a/cc/config/x86_linux_host.go
+++ b/cc/config/x86_linux_host.go
@@ -234,7 +234,7 @@
}
func (toolchainLinuxX86) LibclangRuntimeLibraryArch() string {
- return "i686"
+ return "i386"
}
func (toolchainLinuxX8664) LibclangRuntimeLibraryArch() string {
diff --git a/cc/library_sdk_member.go b/cc/library_sdk_member.go
index 165901d..dd097cf 100644
--- a/cc/library_sdk_member.go
+++ b/cc/library_sdk_member.go
@@ -115,7 +115,7 @@
name: memberName,
archType: ccModule.Target().Arch.ArchType.String(),
ExportedIncludeDirs: exportedIncludeDirs,
- ExportedGeneratedIncludeDirs: exportedGeneratedIncludeDirs,
+ exportedGeneratedIncludeDirs: exportedGeneratedIncludeDirs,
ExportedSystemIncludeDirs: ccModule.ExportedSystemIncludeDirs(),
ExportedFlags: ccModule.ExportedFlags(),
exportedGeneratedHeaders: ccModule.ExportedGeneratedHeaders(),
@@ -200,7 +200,7 @@
func buildSharedNativeLibSnapshot(sdkModuleContext android.ModuleContext, info *nativeLibInfo, builder android.SnapshotBuilder, member android.SdkMember) {
// a function for emitting include dirs
addExportedDirCopyCommandsForNativeLibs := func(lib nativeLibInfoProperties) {
- // Do not include ExportedGeneratedIncludeDirs in the list of directories whose
+ // Do not include exportedGeneratedIncludeDirs in the list of directories whose
// contents are copied as they are copied from exportedGeneratedHeaders below.
includeDirs := lib.ExportedIncludeDirs
includeDirs = append(includeDirs, lib.ExportedSystemIncludeDirs...)
@@ -296,7 +296,7 @@
var includeDirs []android.Path
if !systemInclude {
// Include the generated include dirs in the exported include dirs.
- includeDirs = append(lib.ExportedIncludeDirs, lib.ExportedGeneratedIncludeDirs...)
+ includeDirs = append(lib.ExportedIncludeDirs, lib.exportedGeneratedIncludeDirs...)
} else {
includeDirs = lib.ExportedSystemIncludeDirs
}
@@ -327,14 +327,31 @@
// This is "" for common properties.
archType string
- ExportedIncludeDirs android.Paths
- ExportedGeneratedIncludeDirs android.Paths
- ExportedSystemIncludeDirs android.Paths
- ExportedFlags []string
+ // The list of possibly common exported include dirs.
+ //
+ // This field is exported as its contents may not be arch specific.
+ ExportedIncludeDirs android.Paths
- // exportedGeneratedHeaders is not exported as if set it is always arch specific.
+ // The list of arch specific exported generated include dirs.
+ //
+ // This field is not exported as its contents are always arch specific.
+ exportedGeneratedIncludeDirs android.Paths
+
+ // The list of arch specific exported generated header files.
+ //
+ // This field is not exported as its contents are is always arch specific.
exportedGeneratedHeaders android.Paths
+ // The list of possibly common exported system include dirs.
+ //
+ // This field is exported as its contents may not be arch specific.
+ ExportedSystemIncludeDirs android.Paths
+
+ // The list of possibly common exported flags.
+ //
+ // This field is exported as its contents may not be arch specific.
+ ExportedFlags []string
+
// outputFile is not exported as it is always arch specific.
outputFile android.Path
}
diff --git a/cc/linker.go b/cc/linker.go
index 5a16cbd..af4cbf3 100644
--- a/cc/linker.go
+++ b/cc/linker.go
@@ -101,6 +101,10 @@
// variant of the C/C++ module.
Shared_libs []string
+ // list of static libs that only should be used to build the vendor
+ // variant of the C/C++ module.
+ Static_libs []string
+
// list of shared libs that should not be used to build the vendor variant
// of the C/C++ module.
Exclude_shared_libs []string
@@ -222,6 +226,7 @@
deps.SharedLibs = append(deps.SharedLibs, linker.Properties.Target.Vendor.Shared_libs...)
deps.SharedLibs = removeListFromList(deps.SharedLibs, linker.Properties.Target.Vendor.Exclude_shared_libs)
deps.ReexportSharedLibHeaders = removeListFromList(deps.ReexportSharedLibHeaders, linker.Properties.Target.Vendor.Exclude_shared_libs)
+ deps.StaticLibs = append(deps.StaticLibs, linker.Properties.Target.Vendor.Static_libs...)
deps.StaticLibs = removeListFromList(deps.StaticLibs, linker.Properties.Target.Vendor.Exclude_static_libs)
deps.HeaderLibs = removeListFromList(deps.HeaderLibs, linker.Properties.Target.Vendor.Exclude_header_libs)
deps.ReexportStaticLibHeaders = removeListFromList(deps.ReexportStaticLibHeaders, linker.Properties.Target.Vendor.Exclude_static_libs)
diff --git a/cc/sanitize.go b/cc/sanitize.go
index 5663aa7..5ea8ee08 100644
--- a/cc/sanitize.go
+++ b/cc/sanitize.go
@@ -179,6 +179,7 @@
SanitizerEnabled bool `blueprint:"mutated"`
SanitizeDep bool `blueprint:"mutated"`
MinimalRuntimeDep bool `blueprint:"mutated"`
+ BuiltinsDep bool `blueprint:"mutated"`
UbsanRuntimeDep bool `blueprint:"mutated"`
InSanitizerDir bool `blueprint:"mutated"`
Sanitizers []string `blueprint:"mutated"`
@@ -334,8 +335,8 @@
s.Diag.Cfi = nil
}
- // Disable sanitizers that depend on the UBSan runtime for host builds.
- if ctx.Host() {
+ // Disable sanitizers that depend on the UBSan runtime for windows/darwin builds.
+ if !ctx.Os().Linux() {
s.Cfi = nil
s.Diag.Cfi = nil
s.Misc_undefined = nil
@@ -439,12 +440,19 @@
func (sanitize *sanitize) flags(ctx ModuleContext, flags Flags) Flags {
minimalRuntimeLib := config.UndefinedBehaviorSanitizerMinimalRuntimeLibrary(ctx.toolchain()) + ".a"
minimalRuntimePath := "${config.ClangAsanLibDir}/" + minimalRuntimeLib
+ builtinsRuntimeLib := config.BuiltinsRuntimeLibrary(ctx.toolchain()) + ".a"
+ builtinsRuntimePath := "${config.ClangAsanLibDir}/" + builtinsRuntimeLib
- if ctx.Device() && sanitize.Properties.MinimalRuntimeDep {
+ if sanitize.Properties.MinimalRuntimeDep {
flags.Local.LdFlags = append(flags.Local.LdFlags,
minimalRuntimePath,
"-Wl,--exclude-libs,"+minimalRuntimeLib)
}
+
+ if sanitize.Properties.BuiltinsDep {
+ flags.libFlags = append([]string{builtinsRuntimePath}, flags.libFlags...)
+ }
+
if !sanitize.Properties.SanitizerEnabled && !sanitize.Properties.UbsanRuntimeDep {
return flags
}
@@ -547,11 +555,19 @@
// there will always be undefined symbols in intermediate libraries.
_, flags.Global.LdFlags = removeFromList("-Wl,--no-undefined", flags.Global.LdFlags)
flags.Local.LdFlags = append(flags.Local.LdFlags, sanitizeArg)
- } else {
- if enableMinimalRuntime(sanitize) {
- flags.Local.CFlags = append(flags.Local.CFlags, strings.Join(minimalRuntimeFlags, " "))
- flags.libFlags = append([]string{minimalRuntimePath}, flags.libFlags...)
- flags.Local.LdFlags = append(flags.Local.LdFlags, "-Wl,--exclude-libs,"+minimalRuntimeLib)
+
+ // non-Bionic toolchain prebuilts are missing UBSan's vptr and function sanitizers
+ if !ctx.toolchain().Bionic() {
+ flags.Local.CFlags = append(flags.Local.CFlags, "-fno-sanitize=vptr,function")
+ }
+ }
+
+ if enableMinimalRuntime(sanitize) {
+ flags.Local.CFlags = append(flags.Local.CFlags, strings.Join(minimalRuntimeFlags, " "))
+ flags.libFlags = append([]string{minimalRuntimePath}, flags.libFlags...)
+ flags.Local.LdFlags = append(flags.Local.LdFlags, "-Wl,--exclude-libs,"+minimalRuntimeLib)
+ if !ctx.toolchain().Bionic() {
+ flags.libFlags = append([]string{builtinsRuntimePath}, flags.libFlags...)
}
}
@@ -766,6 +782,10 @@
return false
}
+ if c.Os() == android.Linux {
+ c.sanitize.Properties.BuiltinsDep = true
+ }
+
return true
}
@@ -902,11 +922,14 @@
runtimeLibrary = config.ScudoRuntimeLibrary(toolchain)
}
} else if len(diagSanitizers) > 0 || c.sanitize.Properties.UbsanRuntimeDep ||
- Bool(c.sanitize.Properties.Sanitize.Fuzzer) {
+ Bool(c.sanitize.Properties.Sanitize.Fuzzer) ||
+ Bool(c.sanitize.Properties.Sanitize.Undefined) ||
+ Bool(c.sanitize.Properties.Sanitize.All_undefined) {
runtimeLibrary = config.UndefinedBehaviorSanitizerRuntimeLibrary(toolchain)
}
- if mctx.Device() && runtimeLibrary != "" {
+ if runtimeLibrary != "" && (toolchain.Bionic() || c.sanitize.Properties.UbsanRuntimeDep) {
+ // UBSan is supported on non-bionic linux host builds as well
if isLlndkLibrary(runtimeLibrary, mctx.Config()) && !c.static() && c.UseVndk() {
runtimeLibrary = runtimeLibrary + llndkLibrarySuffix
}
@@ -1079,11 +1102,17 @@
if !Bool(sanitize.Properties.Sanitize.Address) &&
!Bool(sanitize.Properties.Sanitize.Hwaddress) &&
!Bool(sanitize.Properties.Sanitize.Fuzzer) &&
+
(Bool(sanitize.Properties.Sanitize.Integer_overflow) ||
- len(sanitize.Properties.Sanitize.Misc_undefined) > 0) &&
+ len(sanitize.Properties.Sanitize.Misc_undefined) > 0 ||
+ Bool(sanitize.Properties.Sanitize.Undefined) ||
+ Bool(sanitize.Properties.Sanitize.All_undefined)) &&
+
!(Bool(sanitize.Properties.Sanitize.Diag.Integer_overflow) ||
Bool(sanitize.Properties.Sanitize.Diag.Cfi) ||
+ Bool(sanitize.Properties.Sanitize.Diag.Undefined) ||
len(sanitize.Properties.Sanitize.Diag.Misc_undefined) > 0) {
+
return true
}
return false
@@ -1091,6 +1120,7 @@
func enableUbsanRuntime(sanitize *sanitize) bool {
return Bool(sanitize.Properties.Sanitize.Diag.Integer_overflow) ||
+ Bool(sanitize.Properties.Sanitize.Diag.Undefined) ||
len(sanitize.Properties.Sanitize.Diag.Misc_undefined) > 0
}
diff --git a/cc/testing.go b/cc/testing.go
index aceb8c8..368580f 100644
--- a/cc/testing.go
+++ b/cc/testing.go
@@ -29,6 +29,8 @@
ctx.RegisterModuleType("toolchain_library", ToolchainLibraryFactory)
ctx.RegisterModuleType("llndk_library", LlndkLibraryFactory)
ctx.RegisterModuleType("cc_object", ObjectFactory)
+ ctx.RegisterModuleType("ndk_prebuilt_shared_stl", NdkPrebuiltSharedStlFactory)
+ ctx.RegisterModuleType("ndk_prebuilt_object", NdkPrebuiltObjectFactory)
}
func GatherRequiredDepsForTest(os android.OsType) string {
@@ -37,6 +39,7 @@
name: "libatomic",
vendor_available: true,
recovery_available: true,
+ native_bridge_supported: true,
src: "",
}
@@ -51,6 +54,7 @@
name: "libclang_rt.builtins-arm-android",
vendor_available: true,
recovery_available: true,
+ native_bridge_supported: true,
src: "",
}
@@ -58,6 +62,7 @@
name: "libclang_rt.builtins-aarch64-android",
vendor_available: true,
recovery_available: true,
+ native_bridge_supported: true,
src: "",
}
@@ -65,6 +70,7 @@
name: "libclang_rt.builtins-i686-android",
vendor_available: true,
recovery_available: true,
+ native_bridge_supported: true,
src: "",
}
@@ -72,6 +78,7 @@
name: "libclang_rt.builtins-x86_64-android",
vendor_available: true,
recovery_available: true,
+ native_bridge_supported: true,
src: "",
}
@@ -115,6 +122,7 @@
name: "libclang_rt.ubsan_standalone-aarch64-android",
vendor_available: true,
recovery_available: true,
+ system_shared_libs: [],
srcs: [""],
}
@@ -139,6 +147,9 @@
stl: "none",
system_shared_libs: [],
recovery_available: true,
+ stubs: {
+ versions: ["27", "28", "29"],
+ },
}
llndk_library {
name: "libc",
@@ -151,6 +162,13 @@
stl: "none",
system_shared_libs: [],
recovery_available: true,
+ stubs: {
+ versions: ["27", "28", "29"],
+ },
+ apex_available: [
+ "//apex_available:platform",
+ "myapex"
+ ],
}
llndk_library {
name: "libm",
@@ -163,6 +181,13 @@
stl: "none",
system_shared_libs: [],
recovery_available: true,
+ stubs: {
+ versions: ["27", "28", "29"],
+ },
+ apex_available: [
+ "//apex_available:platform",
+ "myapex"
+ ],
}
llndk_library {
name: "libdl",
@@ -203,6 +228,10 @@
enabled: true,
support_system_process: true,
},
+ apex_available: [
+ "//apex_available:platform",
+ "myapex"
+ ],
}
cc_library {
name: "libc++demangle",
@@ -228,6 +257,7 @@
name: "crtbegin_so",
recovery_available: true,
vendor_available: true,
+ native_bridge_supported: true,
stl: "none",
}
@@ -235,18 +265,23 @@
name: "crtbegin_dynamic",
recovery_available: true,
vendor_available: true,
+ native_bridge_supported: true,
+ stl: "none",
}
cc_object {
name: "crtbegin_static",
recovery_available: true,
vendor_available: true,
+ native_bridge_supported: true,
+ stl: "none",
}
cc_object {
name: "crtend_so",
recovery_available: true,
vendor_available: true,
+ native_bridge_supported: true,
stl: "none",
}
@@ -254,12 +289,57 @@
name: "crtend_android",
recovery_available: true,
vendor_available: true,
+ native_bridge_supported: true,
+ stl: "none",
}
cc_library {
name: "libprotobuf-cpp-lite",
}
- `
+
+ cc_library {
+ name: "ndk_libunwind",
+ sdk_version: "current",
+ stl: "none",
+ system_shared_libs: [],
+ }
+
+ cc_library {
+ name: "libc.ndk.current",
+ sdk_version: "current",
+ stl: "none",
+ system_shared_libs: [],
+ }
+
+ cc_library {
+ name: "libm.ndk.current",
+ sdk_version: "current",
+ stl: "none",
+ system_shared_libs: [],
+ }
+
+ cc_library {
+ name: "libdl.ndk.current",
+ sdk_version: "current",
+ stl: "none",
+ system_shared_libs: [],
+ }
+
+ ndk_prebuilt_object {
+ name: "ndk_crtbegin_so.27",
+ sdk_version: "27",
+ }
+
+ ndk_prebuilt_object {
+ name: "ndk_crtend_so.27",
+ sdk_version: "27",
+ }
+
+ ndk_prebuilt_shared_stl {
+ name: "ndk_libc++_shared",
+ }
+ `
+
if os == android.Fuchsia {
ret += `
cc_library {
@@ -275,6 +355,18 @@
return ret
}
+func GatherRequiredFilesForTest(fs map[string][]byte) {
+ fs["prebuilts/ndk/current/sources/cxx-stl/llvm-libc++/libs/arm64-v8a/libc++_shared.so"] = nil
+ fs["prebuilts/ndk/current/platforms/android-27/arch-arm/usr/lib/crtbegin_so.o"] = nil
+ fs["prebuilts/ndk/current/platforms/android-27/arch-arm/usr/lib/crtend_so.o"] = nil
+ fs["prebuilts/ndk/current/platforms/android-27/arch-arm64/usr/lib/crtbegin_so.o"] = nil
+ fs["prebuilts/ndk/current/platforms/android-27/arch-arm64/usr/lib/crtend_so.o"] = nil
+ fs["prebuilts/ndk/current/platforms/android-27/arch-x86/usr/lib/crtbegin_so.o"] = nil
+ fs["prebuilts/ndk/current/platforms/android-27/arch-x86/usr/lib/crtend_so.o"] = nil
+ fs["prebuilts/ndk/current/platforms/android-27/arch-x86_64/usr/lib64/crtbegin_so.o"] = nil
+ fs["prebuilts/ndk/current/platforms/android-27/arch-x86_64/usr/lib64/crtend_so.o"] = nil
+}
+
func TestConfig(buildDir string, os android.OsType, env map[string]string,
bp string, fs map[string][]byte) android.Config {
@@ -295,6 +387,8 @@
"liba.so": nil,
}
+ GatherRequiredFilesForTest(mockFS)
+
for k, v := range fs {
mockFS[k] = v
}
diff --git a/java/app.go b/java/app.go
index 71bad68..bcf08a7 100755
--- a/java/app.go
+++ b/java/app.go
@@ -79,6 +79,10 @@
// list of native libraries that will be provided in or alongside the resulting jar
Jni_libs []string `android:"arch_variant"`
+ // if true, allow JNI libraries that link against platform APIs even if this module sets
+ // sdk_version.
+ Jni_uses_platform_apis *bool
+
// STL library to use for JNI libraries.
Stl *string `android:"arch_variant"`
diff --git a/java/app_test.go b/java/app_test.go
index 6d94160..dfd8571 100644
--- a/java/app_test.go
+++ b/java/app_test.go
@@ -1859,42 +1859,6 @@
func TestStl(t *testing.T) {
ctx, _ := testJava(t, cc.GatherRequiredDepsForTest(android.Android)+`
cc_library {
- name: "ndk_libunwind",
- sdk_version: "current",
- stl: "none",
- system_shared_libs: [],
- }
-
- cc_library {
- name: "libc.ndk.current",
- sdk_version: "current",
- stl: "none",
- system_shared_libs: [],
- }
-
- cc_library {
- name: "libm.ndk.current",
- sdk_version: "current",
- stl: "none",
- system_shared_libs: [],
- }
-
- cc_library {
- name: "libdl.ndk.current",
- sdk_version: "current",
- stl: "none",
- system_shared_libs: [],
- }
-
- cc_object {
- name: "ndk_crtbegin_so.27",
- }
-
- cc_object {
- name: "ndk_crtend_so.27",
- }
-
- cc_library {
name: "libjni",
sdk_version: "current",
stl: "c++_shared",
@@ -1914,10 +1878,6 @@
compile_multilib: "both",
sdk_version: "current",
}
-
- ndk_prebuilt_shared_stl {
- name: "ndk_libc++_shared",
- }
`)
testCases := []struct {
diff --git a/java/hiddenapi_singleton.go b/java/hiddenapi_singleton.go
index 3243e43..7850193 100644
--- a/java/hiddenapi_singleton.go
+++ b/java/hiddenapi_singleton.go
@@ -294,9 +294,8 @@
rule.Command().
BuiltTool(ctx, "merge_csv").
- Inputs(metadataCSV).
- Text(">").
- Output(outputPath)
+ FlagWithOutput("--output=", outputPath).
+ Inputs(metadataCSV)
rule.Build(pctx, ctx, "hiddenAPIGreylistMetadataFile", "hiddenapi greylist metadata")
diff --git a/java/java_test.go b/java/java_test.go
index 7c06699..6d972be 100644
--- a/java/java_test.go
+++ b/java/java_test.go
@@ -92,7 +92,6 @@
// Register module types and mutators from cc needed for JNI testing
cc.RegisterRequiredBuildComponentsForTest(ctx)
- ctx.RegisterModuleType("ndk_prebuilt_shared_stl", cc.NdkPrebuiltSharedStlFactory)
dexpreopt.RegisterToolModulesForTest(ctx)
diff --git a/java/testing.go b/java/testing.go
index 3111109..5b6a39b 100644
--- a/java/testing.go
+++ b/java/testing.go
@@ -18,6 +18,7 @@
"fmt"
"android/soong/android"
+ "android/soong/cc"
)
func TestConfig(buildDir string, env map[string]string, bp string, fs map[string][]byte) android.Config {
@@ -52,8 +53,6 @@
"assets_a/a": nil,
"assets_b/b": nil,
- "prebuilts/ndk/current/sources/cxx-stl/llvm-libc++/libs/arm64-v8a/libc++_shared.so": nil,
-
"prebuilts/sdk/14/public/android.jar": nil,
"prebuilts/sdk/14/public/framework.aidl": nil,
"prebuilts/sdk/14/system/android.jar": nil,
@@ -122,6 +121,8 @@
"stubs/sources/foo/Foo.java": nil,
}
+ cc.GatherRequiredFilesForTest(mockFS)
+
for k, v := range fs {
mockFS[k] = v
}
diff --git a/python/tests/py-cmd_test.py b/python/tests/py-cmd_test.py
new file mode 100644
index 0000000..acda2d7
--- /dev/null
+++ b/python/tests/py-cmd_test.py
@@ -0,0 +1,78 @@
+# Copyright 2020 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.
+
+import os
+import site
+import sys
+
+# This file checks the visible python state against expected values when run
+# using a prebuilt python.
+
+failed = False
+def assert_equal(what, a, b):
+ global failed
+ if a != b:
+ print("Expected %s('%s') == '%s'" % (what, a, b))
+ failed = True
+
+assert_equal("__name__", __name__, "__main__")
+assert_equal("os.path.basename(__file__)", os.path.basename(__file__), "py-cmd_test.py")
+
+if os.getenv('ARGTEST', False):
+ assert_equal("len(sys.argv)", len(sys.argv), 3)
+ assert_equal("sys.argv[1]", sys.argv[1], "arg1")
+ assert_equal("sys.argv[2]", sys.argv[2], "arg2")
+elif os.getenv('ARGTEST2', False):
+ assert_equal("len(sys.argv)", len(sys.argv), 3)
+ assert_equal("sys.argv[1]", sys.argv[1], "--arg1")
+ assert_equal("sys.argv[2]", sys.argv[2], "arg2")
+else:
+ assert_equal("len(sys.argv)", len(sys.argv), 1)
+
+if os.getenv('ARGTEST_ONLY', False):
+ if failed:
+ sys.exit(1)
+ sys.exit(0)
+
+assert_equal("__package__", __package__, None)
+assert_equal("sys.argv[0]", sys.argv[0], 'py-cmd_test.py')
+if sys.version_info[0] == 2:
+ assert_equal("basename(sys.executable)", os.path.basename(sys.executable), 'py2-cmd')
+else:
+ assert_equal("basename(sys.executable)", os.path.basename(sys.executable), 'py3-cmd')
+assert_equal("sys.exec_prefix", sys.exec_prefix, sys.executable)
+assert_equal("sys.prefix", sys.prefix, sys.executable)
+assert_equal("site.ENABLE_USER_SITE", site.ENABLE_USER_SITE, None)
+
+if sys.version_info[0] == 2:
+ assert_equal("len(sys.path)", len(sys.path), 4)
+ assert_equal("sys.path[0]", sys.path[0], os.path.dirname(__file__))
+ assert_equal("sys.path[1]", sys.path[1], "/extra")
+ assert_equal("sys.path[2]", sys.path[2], os.path.join(sys.executable, "internal"))
+ assert_equal("sys.path[3]", sys.path[3], os.path.join(sys.executable, "internal", "stdlib"))
+else:
+ assert_equal("len(sys.path)", len(sys.path), 8)
+ assert_equal("sys.path[0]", sys.path[0], os.path.abspath(os.path.dirname(__file__)))
+ assert_equal("sys.path[1]", sys.path[1], "/extra")
+ assert_equal("sys.path[2]", sys.path[2], os.path.join(sys.executable, 'lib', 'python' + str(sys.version_info[0]) + str(sys.version_info[1]) + '.zip'))
+ assert_equal("sys.path[3]", sys.path[3], os.path.join(sys.executable, 'lib', 'python' + str(sys.version_info[0]) + '.' + str(sys.version_info[1]), '..'))
+ assert_equal("sys.path[4]", sys.path[4], os.path.join(sys.executable, 'lib', 'python' + str(sys.version_info[0]) + '.' + str(sys.version_info[1])))
+ assert_equal("sys.path[5]", sys.path[5], os.path.join(sys.executable, 'lib', 'python' + str(sys.version_info[0]) + '.' + str(sys.version_info[1]), 'lib-dynload'))
+ assert_equal("sys.path[6]", sys.path[6], os.path.join(sys.executable, "internal"))
+ assert_equal("sys.path[7]", sys.path[7], os.path.join(sys.executable, "internal", "stdlib"))
+
+if failed:
+ sys.exit(1)
+
+import testpkg.pycmd_test
diff --git a/python/tests/runtest.sh b/python/tests/runtest.sh
index 21187ed..35941dc 100755
--- a/python/tests/runtest.sh
+++ b/python/tests/runtest.sh
@@ -23,8 +23,11 @@
exit 1
fi
-if [[ ( ! -f $ANDROID_HOST_OUT/nativetest64/par_test/par_test ) || ( ! -f $ANDROID_HOST_OUT/nativetest64/par_test3/par_test3 ) ]]; then
- echo "Run 'm par_test par_test3' first"
+if [[ ( ! -f $ANDROID_HOST_OUT/nativetest64/par_test/par_test ) ||
+ ( ! -f $ANDROID_HOST_OUT/nativetest64/par_test3/par_test3 ) ||
+ ( ! -f $ANDROID_HOST_OUT/bin/py2-cmd ) ||
+ ( ! -f $ANDROID_HOST_OUT/bin/py3-cmd )]]; then
+ echo "Run 'm par_test par_test3 py2-cmd py3-cmd' first"
exit 1
fi
@@ -44,4 +47,15 @@
ARGTEST=true $ANDROID_HOST_OUT/nativetest64/par_test3/par_test3 --arg1 arg2
+cd $(dirname ${BASH_SOURCE[0]})
+
+PYTHONPATH=/extra $ANDROID_HOST_OUT/bin/py2-cmd py-cmd_test.py
+PYTHONPATH=/extra $ANDROID_HOST_OUT/bin/py3-cmd py-cmd_test.py
+
+ARGTEST=true PYTHONPATH=/extra $ANDROID_HOST_OUT/bin/py2-cmd py-cmd_test.py arg1 arg2
+ARGTEST2=true PYTHONPATH=/extra $ANDROID_HOST_OUT/bin/py2-cmd py-cmd_test.py --arg1 arg2
+
+ARGTEST=true PYTHONPATH=/extra $ANDROID_HOST_OUT/bin/py3-cmd py-cmd_test.py arg1 arg2
+ARGTEST2=true PYTHONPATH=/extra $ANDROID_HOST_OUT/bin/py3-cmd py-cmd_test.py --arg1 arg2
+
echo "Passed!"
diff --git a/python/tests/testpkg/__init__.py b/python/tests/testpkg/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/python/tests/testpkg/__init__.py
diff --git a/python/tests/testpkg/pycmd_test.py b/python/tests/testpkg/pycmd_test.py
new file mode 100644
index 0000000..6b8a263
--- /dev/null
+++ b/python/tests/testpkg/pycmd_test.py
@@ -0,0 +1,33 @@
+# 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.
+
+import os
+import sys
+
+# This file checks the visible python state against expected values when run
+# via the py*-cmd prebuilts
+
+failed = False
+def assert_equal(what, a, b):
+ global failed
+ if a != b:
+ print("Expected %s('%s') == '%s'" % (what, a, b))
+ failed = True
+
+assert_equal("__name__", __name__, "testpkg.pycmd_test")
+assert_equal("basename(__file__)", os.path.basename(__file__), "pycmd_test.py")
+assert_equal("__package__", __package__, "testpkg")
+
+if failed:
+ sys.exit(1)
diff --git a/rust/config/whitelist.go b/rust/config/whitelist.go
index 7dfb002..a339050 100644
--- a/rust/config/whitelist.go
+++ b/rust/config/whitelist.go
@@ -2,6 +2,7 @@
var (
RustAllowedPaths = []string{
+ "external/minijail",
"external/rust",
"external/crosvm",
"external/adhd",
diff --git a/rust/rust_test.go b/rust/rust_test.go
index afe530a..020581d 100644
--- a/rust/rust_test.go
+++ b/rust/rust_test.go
@@ -22,6 +22,7 @@
"testing"
"android/soong/android"
+ "android/soong/cc"
)
var (
@@ -61,6 +62,8 @@
"libz.so": nil,
}
+ cc.GatherRequiredFilesForTest(fs)
+
return android.TestArchConfig(buildDir, nil, bp, fs)
}
diff --git a/scripts/Android.bp b/scripts/Android.bp
index 4aaff9a..e848b50 100644
--- a/scripts/Android.bp
+++ b/scripts/Android.bp
@@ -3,7 +3,6 @@
main: "manifest_fixer.py",
srcs: [
"manifest_fixer.py",
- "manifest.py",
],
version: {
py2: {
@@ -13,6 +12,9 @@
enabled: false,
},
},
+ libs: [
+ "manifest_utils",
+ ],
}
python_test_host {
@@ -21,6 +23,24 @@
srcs: [
"manifest_fixer_test.py",
"manifest_fixer.py",
+ ],
+ version: {
+ py2: {
+ enabled: true,
+ },
+ py3: {
+ enabled: false,
+ },
+ },
+ libs: [
+ "manifest_utils",
+ ],
+ test_suites: ["general-tests"],
+}
+
+python_library_host {
+ name: "manifest_utils",
+ srcs: [
"manifest.py",
],
version: {
@@ -31,7 +51,6 @@
enabled: false,
},
},
- test_suites: ["general-tests"],
}
python_binary_host {
@@ -39,7 +58,6 @@
main: "manifest_check.py",
srcs: [
"manifest_check.py",
- "manifest.py",
],
version: {
py2: {
@@ -49,6 +67,9 @@
enabled: false,
},
},
+ libs: [
+ "manifest_utils",
+ ],
}
python_test_host {
@@ -57,7 +78,6 @@
srcs: [
"manifest_check_test.py",
"manifest_check.py",
- "manifest.py",
],
version: {
py2: {
@@ -67,6 +87,9 @@
enabled: false,
},
},
+ libs: [
+ "manifest_utils",
+ ],
test_suites: ["general-tests"],
}
@@ -91,7 +114,6 @@
main: "test_config_fixer.py",
srcs: [
"test_config_fixer.py",
- "manifest.py",
],
version: {
py2: {
@@ -101,6 +123,9 @@
enabled: false,
},
},
+ libs: [
+ "manifest_utils",
+ ],
}
python_test_host {
@@ -109,7 +134,6 @@
srcs: [
"test_config_fixer_test.py",
"test_config_fixer.py",
- "manifest.py",
],
version: {
py2: {
@@ -119,5 +143,8 @@
enabled: false,
},
},
+ libs: [
+ "manifest_utils",
+ ],
test_suites: ["general-tests"],
-}
\ No newline at end of file
+}
diff --git a/sdk/cc_sdk_test.go b/sdk/cc_sdk_test.go
index 8c32d8c..4d7f943 100644
--- a/sdk/cc_sdk_test.go
+++ b/sdk/cc_sdk_test.go
@@ -75,6 +75,7 @@
cc_library_shared {
name: "sdkmember",
+ system_shared_libs: [],
}
sdk_snapshot {
@@ -748,3 +749,94 @@
`),
)
}
+
+func TestHostSnapshotWithMultiLib64(t *testing.T) {
+ // b/145598135 - Generating host snapshots for anything other than linux is not supported.
+ SkipIfNotLinux(t)
+
+ result := testSdkWithCc(t, `
+ module_exports {
+ name: "myexports",
+ device_supported: false,
+ host_supported: true,
+ target: {
+ host: {
+ compile_multilib: "64",
+ },
+ },
+ native_static_libs: ["mynativelib"],
+ }
+
+ cc_library_static {
+ name: "mynativelib",
+ device_supported: false,
+ host_supported: true,
+ srcs: [
+ "Test.cpp",
+ "aidl/foo/bar/Test.aidl",
+ ],
+ export_include_dirs: ["include"],
+ aidl: {
+ export_aidl_headers: true,
+ },
+ system_shared_libs: [],
+ stl: "none",
+ }
+ `)
+
+ result.CheckSnapshot("myexports", "linux_glibc_common", "",
+ checkAndroidBpContents(`
+// This is auto-generated. DO NOT EDIT.
+
+cc_prebuilt_library_static {
+ name: "myexports_mynativelib@current",
+ sdk_member_name: "mynativelib",
+ device_supported: false,
+ host_supported: true,
+ export_include_dirs: ["include/include"],
+ arch: {
+ x86_64: {
+ srcs: ["x86_64/lib/mynativelib.a"],
+ export_include_dirs: ["x86_64/include_gen/mynativelib"],
+ },
+ },
+ stl: "none",
+ system_shared_libs: [],
+}
+
+cc_prebuilt_library_static {
+ name: "mynativelib",
+ prefer: false,
+ device_supported: false,
+ host_supported: true,
+ export_include_dirs: ["include/include"],
+ arch: {
+ x86_64: {
+ srcs: ["x86_64/lib/mynativelib.a"],
+ export_include_dirs: ["x86_64/include_gen/mynativelib"],
+ },
+ },
+ stl: "none",
+ system_shared_libs: [],
+}
+
+module_exports_snapshot {
+ name: "myexports@current",
+ device_supported: false,
+ host_supported: true,
+ target: {
+ host: {
+ compile_multilib: "64",
+ },
+ },
+ native_static_libs: ["myexports_mynativelib@current"],
+}`),
+ checkAllCopyRules(`
+include/Test.h -> include/include/Test.h
+.intermediates/mynativelib/linux_glibc_x86_64_static/mynativelib.a -> x86_64/lib/mynativelib.a
+.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/Test.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/Test.h
+.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BnTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BnTest.h
+.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BpTest.h -> x86_64/include_gen/mynativelib/aidl/foo/bar/BpTest.h
+`),
+ )
+}
diff --git a/sdk/sdk.go b/sdk/sdk.go
index dbe9ce2..4976dc0 100644
--- a/sdk/sdk.go
+++ b/sdk/sdk.go
@@ -320,10 +320,12 @@
// Step 1: create dependencies from an SDK module to its members.
func memberMutator(mctx android.BottomUpMutatorContext) {
if s, ok := mctx.Module().(*sdk); ok {
- for _, memberListProperty := range s.memberListProperties() {
- names := memberListProperty.getter(s.dynamicMemberTypeListProperties)
- tag := memberListProperty.dependencyTag
- memberListProperty.memberType.AddDependencies(mctx, tag, names)
+ if s.Enabled() {
+ for _, memberListProperty := range s.memberListProperties() {
+ names := memberListProperty.getter(s.dynamicMemberTypeListProperties)
+ tag := memberListProperty.dependencyTag
+ memberListProperty.memberType.AddDependencies(mctx, tag, names)
+ }
}
}
}
diff --git a/sdk/sdk_test.go b/sdk/sdk_test.go
index d376e59..934bdae 100644
--- a/sdk/sdk_test.go
+++ b/sdk/sdk_test.go
@@ -111,8 +111,14 @@
sdk_version: "none",
}
+ java_defaults {
+ name: "java-defaults",
+ visibility: ["//other/bar"],
+ }
+
java_library {
name: "mypublicjavalib",
+ defaults: ["java-defaults"],
visibility: ["//visibility:public"],
srcs: ["Test.java"],
system_modules: "none",
diff --git a/sdk/testing.go b/sdk/testing.go
index 6102441..ae0620d 100644
--- a/sdk/testing.go
+++ b/sdk/testing.go
@@ -53,6 +53,8 @@
"myapex.pk8": nil,
}
+ cc.GatherRequiredFilesForTest(mockFS)
+
for k, v := range fs {
mockFS[k] = v
}
diff --git a/sdk/update.go b/sdk/update.go
index ff567be..c64995f 100644
--- a/sdk/update.go
+++ b/sdk/update.go
@@ -107,10 +107,15 @@
// The members are first grouped by type and then grouped by name. The order of
// the types is the order they are referenced in android.SdkMemberTypesRegistry.
// The names are in the order in which the dependencies were added.
-func (s *sdk) collectMembers(ctx android.ModuleContext) []*sdkMember {
+//
+// Returns the members as well as the multilib setting to use.
+func (s *sdk) collectMembers(ctx android.ModuleContext) ([]*sdkMember, string) {
byType := make(map[android.SdkMemberType][]*sdkMember)
byName := make(map[string]*sdkMember)
+ lib32 := false // True if any of the members have 32 bit version.
+ lib64 := false // True if any of the members have 64 bit version.
+
ctx.WalkDeps(func(child android.Module, parent android.Module) bool {
tag := ctx.OtherModuleDependencyTag(child)
if memberTag, ok := tag.(android.SdkMemberTypeDependencyTag); ok {
@@ -122,7 +127,6 @@
}
name := ctx.OtherModuleName(child)
-
member := byName[name]
if member == nil {
member = &sdkMember{memberType: memberType, name: name}
@@ -130,6 +134,13 @@
byType[memberType] = append(byType[memberType], member)
}
+ multilib := child.Target().Arch.ArchType.Multilib
+ if multilib == "lib32" {
+ lib32 = true
+ } else if multilib == "lib64" {
+ lib64 = true
+ }
+
// Only append new variants to the list. This is needed because a member can be both
// exported by the sdk and also be a transitive sdk member.
member.variants = appendUniqueVariants(member.variants, child.(android.SdkAware))
@@ -148,7 +159,17 @@
members = append(members, membersOfType...)
}
- return members
+ // Compute the setting of multilib.
+ var multilib string
+ if lib32 && lib64 {
+ multilib = "both"
+ } else if lib32 {
+ multilib = "32"
+ } else if lib64 {
+ multilib = "64"
+ }
+
+ return members, multilib
}
func appendUniqueVariants(variants []android.SdkAware, newVariant android.SdkAware) []android.SdkAware {
@@ -207,7 +228,8 @@
}
s.builderForTests = builder
- for _, member := range s.collectMembers(ctx) {
+ members, multilib := s.collectMembers(ctx)
+ for _, member := range members {
member.memberType.BuildSnapshot(ctx, builder, member)
}
@@ -249,6 +271,16 @@
}
addHostDeviceSupportedProperties(&s.ModuleBase, snapshotModule)
+
+ // Compile_multilib defaults to both and must always be set to both on the
+ // device and so only needs to be set when targeted at the host and is neither
+ // unspecified or both.
+ if s.HostSupported() && multilib != "" && multilib != "both" {
+ targetSet := snapshotModule.AddPropertySet("target")
+ hostSet := targetSet.AddPropertySet("host")
+ hostSet.AddProperty("compile_multilib", multilib)
+ }
+
for _, memberListProperty := range s.memberListProperties() {
names := memberListProperty.getter(s.dynamicMemberTypeListProperties)
if len(names) > 0 {