Merge changes from topic "ndk_libandroid_support_late_static_libs" am: 9fb2d1fb62
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1736360 Change-Id: I5d987d66b27b1d2c434c8e99d91b95e2e50a9c0c
This commit is contained in:
14
cc/cc.go
14
cc/cc.go
@@ -2193,13 +2193,6 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
|
|||||||
}, depTag, RewriteSnapshotLib(staticUnwinder(actx), GetSnapshot(c, &snapshotInfo, actx).StaticLibs))
|
}, depTag, RewriteSnapshotLib(staticUnwinder(actx), GetSnapshot(c, &snapshotInfo, actx).StaticLibs))
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, lib := range deps.LateStaticLibs {
|
|
||||||
depTag := libraryDependencyTag{Kind: staticLibraryDependency, Order: lateLibraryDependency}
|
|
||||||
actx.AddVariationDependencies([]blueprint.Variation{
|
|
||||||
{Mutator: "link", Variation: "static"},
|
|
||||||
}, depTag, RewriteSnapshotLib(lib, GetSnapshot(c, &snapshotInfo, actx).StaticLibs))
|
|
||||||
}
|
|
||||||
|
|
||||||
// shared lib names without the #version suffix
|
// shared lib names without the #version suffix
|
||||||
var sharedLibNames []string
|
var sharedLibNames []string
|
||||||
|
|
||||||
@@ -2225,6 +2218,13 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
|
|||||||
AddSharedLibDependenciesWithVersions(ctx, c, variations, depTag, name, version, false)
|
AddSharedLibDependenciesWithVersions(ctx, c, variations, depTag, name, version, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for _, lib := range deps.LateStaticLibs {
|
||||||
|
depTag := libraryDependencyTag{Kind: staticLibraryDependency, Order: lateLibraryDependency}
|
||||||
|
actx.AddVariationDependencies([]blueprint.Variation{
|
||||||
|
{Mutator: "link", Variation: "static"},
|
||||||
|
}, depTag, RewriteSnapshotLib(lib, GetSnapshot(c, &snapshotInfo, actx).StaticLibs))
|
||||||
|
}
|
||||||
|
|
||||||
for _, lib := range deps.LateSharedLibs {
|
for _, lib := range deps.LateSharedLibs {
|
||||||
if inList(lib, sharedLibNames) {
|
if inList(lib, sharedLibNames) {
|
||||||
// This is to handle the case that some of the late shared libs (libc, libdl, libm, ...)
|
// This is to handle the case that some of the late shared libs (libc, libdl, libm, ...)
|
||||||
|
149
cc/cc_test.go
149
cc/cc_test.go
@@ -4231,3 +4231,152 @@ func TestIncludeDirsExporting(t *testing.T) {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestIncludeDirectoryOrdering(t *testing.T) {
|
||||||
|
bp := `
|
||||||
|
cc_library {
|
||||||
|
name: "libfoo",
|
||||||
|
srcs: ["foo.c"],
|
||||||
|
local_include_dirs: ["local_include_dirs"],
|
||||||
|
export_include_dirs: ["export_include_dirs"],
|
||||||
|
export_system_include_dirs: ["export_system_include_dirs"],
|
||||||
|
static_libs: ["libstatic1", "libstatic2"],
|
||||||
|
whole_static_libs: ["libwhole1", "libwhole2"],
|
||||||
|
shared_libs: ["libshared1", "libshared2"],
|
||||||
|
header_libs: ["libheader1", "libheader2"],
|
||||||
|
target: {
|
||||||
|
android: {
|
||||||
|
shared_libs: ["libandroid"],
|
||||||
|
local_include_dirs: ["android_local_include_dirs"],
|
||||||
|
export_include_dirs: ["android_export_include_dirs"],
|
||||||
|
},
|
||||||
|
android_arm: {
|
||||||
|
shared_libs: ["libandroid_arm"],
|
||||||
|
local_include_dirs: ["android_arm_local_include_dirs"],
|
||||||
|
export_include_dirs: ["android_arm_export_include_dirs"],
|
||||||
|
},
|
||||||
|
linux: {
|
||||||
|
shared_libs: ["liblinux"],
|
||||||
|
local_include_dirs: ["linux_local_include_dirs"],
|
||||||
|
export_include_dirs: ["linux_export_include_dirs"],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
multilib: {
|
||||||
|
lib32: {
|
||||||
|
shared_libs: ["lib32"],
|
||||||
|
local_include_dirs: ["lib32_local_include_dirs"],
|
||||||
|
export_include_dirs: ["lib32_export_include_dirs"],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
arch: {
|
||||||
|
arm: {
|
||||||
|
shared_libs: ["libarm"],
|
||||||
|
local_include_dirs: ["arm_local_include_dirs"],
|
||||||
|
export_include_dirs: ["arm_export_include_dirs"],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
stl: "libc++",
|
||||||
|
sdk_version: "20",
|
||||||
|
}
|
||||||
|
|
||||||
|
cc_library_headers {
|
||||||
|
name: "libheader1",
|
||||||
|
export_include_dirs: ["libheader1"],
|
||||||
|
sdk_version: "20",
|
||||||
|
stl: "none",
|
||||||
|
}
|
||||||
|
|
||||||
|
cc_library_headers {
|
||||||
|
name: "libheader2",
|
||||||
|
export_include_dirs: ["libheader2"],
|
||||||
|
sdk_version: "20",
|
||||||
|
stl: "none",
|
||||||
|
}
|
||||||
|
`
|
||||||
|
|
||||||
|
libs := []string{
|
||||||
|
"libstatic1",
|
||||||
|
"libstatic2",
|
||||||
|
"libwhole1",
|
||||||
|
"libwhole2",
|
||||||
|
"libshared1",
|
||||||
|
"libshared2",
|
||||||
|
"libandroid",
|
||||||
|
"libandroid_arm",
|
||||||
|
"liblinux",
|
||||||
|
"lib32",
|
||||||
|
"libarm",
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, lib := range libs {
|
||||||
|
bp += fmt.Sprintf(`
|
||||||
|
cc_library {
|
||||||
|
name: "%s",
|
||||||
|
export_include_dirs: ["%s"],
|
||||||
|
sdk_version: "20",
|
||||||
|
stl: "none",
|
||||||
|
}
|
||||||
|
`, lib, lib)
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx := PrepareForIntegrationTestWithCc.RunTestWithBp(t, bp)
|
||||||
|
// Use the arm variant instead of the arm64 variant so that it gets headers from
|
||||||
|
// ndk_libandroid_support to test LateStaticLibs.
|
||||||
|
cflags := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_sdk_static").Output("obj/foo.o").Args["cFlags"]
|
||||||
|
|
||||||
|
var includes []string
|
||||||
|
flags := strings.Split(cflags, " ")
|
||||||
|
for i, flag := range flags {
|
||||||
|
if strings.Contains(flag, "Cflags") {
|
||||||
|
includes = append(includes, flag)
|
||||||
|
} else if strings.HasPrefix(flag, "-I") {
|
||||||
|
includes = append(includes, strings.TrimPrefix(flag, "-I"))
|
||||||
|
} else if flag == "-isystem" {
|
||||||
|
includes = append(includes, flags[i+1])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
want := []string{
|
||||||
|
"${config.ArmClangThumbCflags}",
|
||||||
|
"${config.ArmClangCflags}",
|
||||||
|
"${config.CommonClangGlobalCflags}",
|
||||||
|
"${config.DeviceClangGlobalCflags}",
|
||||||
|
"${config.ClangExternalCflags}",
|
||||||
|
"${config.ArmToolchainClangCflags}",
|
||||||
|
"${config.ArmClangArmv7ANeonCflags}",
|
||||||
|
"${config.ArmClangGenericCflags}",
|
||||||
|
"export_include_dirs",
|
||||||
|
"linux_export_include_dirs",
|
||||||
|
"android_export_include_dirs",
|
||||||
|
"arm_export_include_dirs",
|
||||||
|
"lib32_export_include_dirs",
|
||||||
|
"android_arm_export_include_dirs",
|
||||||
|
"android_arm_local_include_dirs",
|
||||||
|
"lib32_local_include_dirs",
|
||||||
|
"arm_local_include_dirs",
|
||||||
|
"android_local_include_dirs",
|
||||||
|
"linux_local_include_dirs",
|
||||||
|
"local_include_dirs",
|
||||||
|
".",
|
||||||
|
"libheader1",
|
||||||
|
"libheader2",
|
||||||
|
"libwhole1",
|
||||||
|
"libwhole2",
|
||||||
|
"libstatic1",
|
||||||
|
"libstatic2",
|
||||||
|
"libshared1",
|
||||||
|
"libshared2",
|
||||||
|
"liblinux",
|
||||||
|
"libandroid",
|
||||||
|
"libarm",
|
||||||
|
"lib32",
|
||||||
|
"libandroid_arm",
|
||||||
|
"defaults/cc/common/ndk_libc++_shared",
|
||||||
|
"defaults/cc/common/ndk_libandroid_support",
|
||||||
|
"out/soong/ndk/sysroot/usr/include",
|
||||||
|
"out/soong/ndk/sysroot/usr/include/arm-linux-androideabi",
|
||||||
|
"${config.NoOverrideClangGlobalCflags}",
|
||||||
|
}
|
||||||
|
|
||||||
|
android.AssertArrayString(t, "includes", want, includes)
|
||||||
|
}
|
||||||
|
@@ -199,7 +199,9 @@ func (stl *stl) deps(ctx BaseModuleContext, deps Deps) Deps {
|
|||||||
deps.StaticLibs = append(deps.StaticLibs, stl.Properties.SelectedStl, "ndk_libc++abi")
|
deps.StaticLibs = append(deps.StaticLibs, stl.Properties.SelectedStl, "ndk_libc++abi")
|
||||||
}
|
}
|
||||||
if needsLibAndroidSupport(ctx) {
|
if needsLibAndroidSupport(ctx) {
|
||||||
deps.StaticLibs = append(deps.StaticLibs, "ndk_libandroid_support")
|
// Use LateStaticLibs for ndk_libandroid_support so that its include directories
|
||||||
|
// come after ndk_libc++_static or ndk_libc++_shared.
|
||||||
|
deps.LateStaticLibs = append(deps.LateStaticLibs, "ndk_libandroid_support")
|
||||||
}
|
}
|
||||||
deps.StaticLibs = append(deps.StaticLibs, "ndk_libunwind")
|
deps.StaticLibs = append(deps.StaticLibs, "ndk_libunwind")
|
||||||
default:
|
default:
|
||||||
|
@@ -34,6 +34,7 @@ func RegisterRequiredBuildComponentsForTest(ctx android.RegistrationContext) {
|
|||||||
ctx.RegisterModuleType("cc_object", ObjectFactory)
|
ctx.RegisterModuleType("cc_object", ObjectFactory)
|
||||||
ctx.RegisterModuleType("cc_genrule", genRuleFactory)
|
ctx.RegisterModuleType("cc_genrule", genRuleFactory)
|
||||||
ctx.RegisterModuleType("ndk_prebuilt_shared_stl", NdkPrebuiltSharedStlFactory)
|
ctx.RegisterModuleType("ndk_prebuilt_shared_stl", NdkPrebuiltSharedStlFactory)
|
||||||
|
ctx.RegisterModuleType("ndk_prebuilt_static_stl", NdkPrebuiltStaticStlFactory)
|
||||||
ctx.RegisterModuleType("ndk_prebuilt_object", NdkPrebuiltObjectFactory)
|
ctx.RegisterModuleType("ndk_prebuilt_object", NdkPrebuiltObjectFactory)
|
||||||
ctx.RegisterModuleType("ndk_library", NdkLibraryFactory)
|
ctx.RegisterModuleType("ndk_library", NdkLibraryFactory)
|
||||||
}
|
}
|
||||||
@@ -403,7 +404,7 @@ func commonDefaultModules() string {
|
|||||||
|
|
||||||
cc_library {
|
cc_library {
|
||||||
name: "ndk_libunwind",
|
name: "ndk_libunwind",
|
||||||
sdk_version: "current",
|
sdk_version: "minimum",
|
||||||
stl: "none",
|
stl: "none",
|
||||||
system_shared_libs: [],
|
system_shared_libs: [],
|
||||||
}
|
}
|
||||||
@@ -428,6 +429,12 @@ func commonDefaultModules() string {
|
|||||||
|
|
||||||
ndk_prebuilt_shared_stl {
|
ndk_prebuilt_shared_stl {
|
||||||
name: "ndk_libc++_shared",
|
name: "ndk_libc++_shared",
|
||||||
|
export_include_dirs: ["ndk_libc++_shared"],
|
||||||
|
}
|
||||||
|
|
||||||
|
ndk_prebuilt_static_stl {
|
||||||
|
name: "ndk_libandroid_support",
|
||||||
|
export_include_dirs: ["ndk_libandroid_support"],
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_library_static {
|
cc_library_static {
|
||||||
@@ -578,9 +585,11 @@ var PrepareForTestWithCcDefaultModules = android.GroupFixturePreparers(
|
|||||||
|
|
||||||
// Additional files needed in tests that disallow non-existent source.
|
// Additional files needed in tests that disallow non-existent source.
|
||||||
android.MockFS{
|
android.MockFS{
|
||||||
"defaults/cc/common/libc.map.txt": nil,
|
"defaults/cc/common/libc.map.txt": nil,
|
||||||
"defaults/cc/common/libdl.map.txt": nil,
|
"defaults/cc/common/libdl.map.txt": nil,
|
||||||
"defaults/cc/common/libm.map.txt": nil,
|
"defaults/cc/common/libm.map.txt": nil,
|
||||||
|
"defaults/cc/common/ndk_libandroid_support": nil,
|
||||||
|
"defaults/cc/common/ndk_libc++_shared": nil,
|
||||||
}.AddToFixture(),
|
}.AddToFixture(),
|
||||||
|
|
||||||
// Place the default cc test modules that are common to all platforms in a location that will not
|
// Place the default cc test modules that are common to all platforms in a location that will not
|
||||||
|
Reference in New Issue
Block a user