Merge "Cleanup bp2build tests to reduce repetition"
This commit is contained in:
@@ -25,18 +25,18 @@ const (
|
||||
// See cc/testing.go for more context
|
||||
soongCcLibraryPreamble = `
|
||||
cc_defaults {
|
||||
name: "linux_bionic_supported",
|
||||
name: "linux_bionic_supported",
|
||||
}
|
||||
|
||||
toolchain_library {
|
||||
name: "libclang_rt.builtins-x86_64-android",
|
||||
defaults: ["linux_bionic_supported"],
|
||||
vendor_available: true,
|
||||
vendor_ramdisk_available: true,
|
||||
product_available: true,
|
||||
recovery_available: true,
|
||||
native_bridge_supported: true,
|
||||
src: "",
|
||||
name: "libclang_rt.builtins-x86_64-android",
|
||||
defaults: ["linux_bionic_supported"],
|
||||
vendor_available: true,
|
||||
vendor_ramdisk_available: true,
|
||||
product_available: true,
|
||||
recovery_available: true,
|
||||
native_bridge_supported: true,
|
||||
src: "",
|
||||
}`
|
||||
)
|
||||
|
||||
@@ -113,15 +113,12 @@ cc_library {
|
||||
srcs: ["bionic.cpp"]
|
||||
},
|
||||
},
|
||||
include_build_directory: false,
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{`cc_library(
|
||||
name = "foo-lib",
|
||||
copts = [
|
||||
"-Wall",
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
],
|
||||
copts = ["-Wall"],
|
||||
export_includes = ["foo-dir"],
|
||||
implementation_deps = [":some-headers"],
|
||||
linkopts = ["-Wl,--exclude-libs=bar.a"] + select({
|
||||
@@ -186,6 +183,7 @@ cc_library {
|
||||
ldflags: ["-Wl,--exclude-libs=libgcc_eh.a"],
|
||||
},
|
||||
},
|
||||
include_build_directory: false,
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{`cc_library(
|
||||
@@ -195,8 +193,6 @@ cc_library {
|
||||
"-Wextra",
|
||||
"-Wunused",
|
||||
"-Werror",
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
],
|
||||
implementation_deps = [":libc_headers"],
|
||||
linkopts = [
|
||||
@@ -277,12 +273,12 @@ func TestCcLibrarySharedStaticProps(t *testing.T) {
|
||||
moduleTypeUnderTest: "cc_library",
|
||||
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
||||
moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryBp2Build,
|
||||
dir: "foo/bar",
|
||||
filesystem: map[string]string{
|
||||
"foo/bar/both.cpp": "",
|
||||
"foo/bar/sharedonly.cpp": "",
|
||||
"foo/bar/staticonly.cpp": "",
|
||||
"foo/bar/Android.bp": `
|
||||
"both.cpp": "",
|
||||
"sharedonly.cpp": "",
|
||||
"staticonly.cpp": "",
|
||||
},
|
||||
blueprint: soongCcLibraryPreamble + `
|
||||
cc_library {
|
||||
name: "a",
|
||||
srcs: ["both.cpp"],
|
||||
@@ -304,36 +300,57 @@ cc_library {
|
||||
static_libs: ["static_dep_for_shared"],
|
||||
whole_static_libs: ["whole_static_lib_for_shared"],
|
||||
},
|
||||
bazel_module: { bp2build_available: true },
|
||||
include_build_directory: false,
|
||||
}
|
||||
|
||||
cc_library_static { name: "static_dep_for_shared" }
|
||||
cc_library_static {
|
||||
name: "static_dep_for_shared",
|
||||
bazel_module: { bp2build_available: false },
|
||||
}
|
||||
|
||||
cc_library_static { name: "static_dep_for_static" }
|
||||
cc_library_static {
|
||||
name: "static_dep_for_static",
|
||||
bazel_module: { bp2build_available: false },
|
||||
}
|
||||
|
||||
cc_library_static { name: "static_dep_for_both" }
|
||||
cc_library_static {
|
||||
name: "static_dep_for_both",
|
||||
bazel_module: { bp2build_available: false },
|
||||
}
|
||||
|
||||
cc_library_static { name: "whole_static_lib_for_shared" }
|
||||
cc_library_static {
|
||||
name: "whole_static_lib_for_shared",
|
||||
bazel_module: { bp2build_available: false },
|
||||
}
|
||||
|
||||
cc_library_static { name: "whole_static_lib_for_static" }
|
||||
cc_library_static {
|
||||
name: "whole_static_lib_for_static",
|
||||
bazel_module: { bp2build_available: false },
|
||||
}
|
||||
|
||||
cc_library_static { name: "whole_static_lib_for_both" }
|
||||
cc_library_static {
|
||||
name: "whole_static_lib_for_both",
|
||||
bazel_module: { bp2build_available: false },
|
||||
}
|
||||
|
||||
cc_library { name: "shared_dep_for_shared" }
|
||||
cc_library {
|
||||
name: "shared_dep_for_shared",
|
||||
bazel_module: { bp2build_available: false },
|
||||
}
|
||||
|
||||
cc_library { name: "shared_dep_for_static" }
|
||||
cc_library {
|
||||
name: "shared_dep_for_static",
|
||||
bazel_module: { bp2build_available: false },
|
||||
}
|
||||
|
||||
cc_library { name: "shared_dep_for_both" }
|
||||
cc_library {
|
||||
name: "shared_dep_for_both",
|
||||
bazel_module: { bp2build_available: false },
|
||||
}
|
||||
`,
|
||||
},
|
||||
blueprint: soongCcLibraryPreamble,
|
||||
expectedBazelTargets: []string{`cc_library(
|
||||
name = "a",
|
||||
copts = [
|
||||
"bothflag",
|
||||
"-Ifoo/bar",
|
||||
"-I$(BINDIR)/foo/bar",
|
||||
],
|
||||
copts = ["bothflag"],
|
||||
dynamic_deps = [":shared_dep_for_both"],
|
||||
implementation_deps = [":static_dep_for_both"],
|
||||
shared = {
|
||||
@@ -374,6 +391,7 @@ cc_library {
|
||||
whole_static_libs: ["whole_static_lib_for_shared"],
|
||||
},
|
||||
bazel_module: { bp2build_available: true },
|
||||
include_build_directory: false,
|
||||
}
|
||||
|
||||
cc_prebuilt_library_static { name: "whole_static_lib_for_shared" }
|
||||
@@ -386,10 +404,6 @@ cc_prebuilt_library_static { name: "whole_static_lib_for_both" }
|
||||
blueprint: soongCcLibraryPreamble,
|
||||
expectedBazelTargets: []string{`cc_library(
|
||||
name = "a",
|
||||
copts = [
|
||||
"-Ifoo/bar",
|
||||
"-I$(BINDIR)/foo/bar",
|
||||
],
|
||||
shared = {
|
||||
"whole_archive_deps": [":whole_static_lib_for_shared_alwayslink"],
|
||||
},
|
||||
@@ -574,24 +588,24 @@ cc_library {
|
||||
":both_filegroup",
|
||||
],
|
||||
static: {
|
||||
srcs: [
|
||||
"static_source.cpp",
|
||||
"static_source.cc",
|
||||
"static_source.c",
|
||||
"static_source.s",
|
||||
"static_source.S",
|
||||
":static_filegroup",
|
||||
],
|
||||
srcs: [
|
||||
"static_source.cpp",
|
||||
"static_source.cc",
|
||||
"static_source.c",
|
||||
"static_source.s",
|
||||
"static_source.S",
|
||||
":static_filegroup",
|
||||
],
|
||||
},
|
||||
shared: {
|
||||
srcs: [
|
||||
"shared_source.cpp",
|
||||
"shared_source.cc",
|
||||
"shared_source.c",
|
||||
"shared_source.s",
|
||||
"shared_source.S",
|
||||
":shared_filegroup",
|
||||
],
|
||||
srcs: [
|
||||
"shared_source.cpp",
|
||||
"shared_source.cc",
|
||||
"shared_source.c",
|
||||
"shared_source.s",
|
||||
"shared_source.S",
|
||||
":shared_filegroup",
|
||||
],
|
||||
},
|
||||
bazel_module: { bp2build_available: true },
|
||||
}
|
||||
@@ -693,16 +707,13 @@ cc_library {
|
||||
srcs: ["a.cpp"],
|
||||
version_script: "v.map",
|
||||
bazel_module: { bp2build_available: true },
|
||||
include_build_directory: false,
|
||||
}
|
||||
`,
|
||||
},
|
||||
blueprint: soongCcLibraryPreamble,
|
||||
expectedBazelTargets: []string{`cc_library(
|
||||
name = "a",
|
||||
copts = [
|
||||
"-Ifoo/bar",
|
||||
"-I$(BINDIR)/foo/bar",
|
||||
],
|
||||
srcs = ["a.cpp"],
|
||||
version_script = "v.map",
|
||||
)`},
|
||||
@@ -718,29 +729,26 @@ func TestCcLibraryConfiguredVersionScript(t *testing.T) {
|
||||
dir: "foo/bar",
|
||||
filesystem: map[string]string{
|
||||
"foo/bar/Android.bp": `
|
||||
cc_library {
|
||||
name: "a",
|
||||
srcs: ["a.cpp"],
|
||||
arch: {
|
||||
arm: {
|
||||
version_script: "arm.map",
|
||||
},
|
||||
arm64: {
|
||||
version_script: "arm64.map",
|
||||
},
|
||||
},
|
||||
cc_library {
|
||||
name: "a",
|
||||
srcs: ["a.cpp"],
|
||||
arch: {
|
||||
arm: {
|
||||
version_script: "arm.map",
|
||||
},
|
||||
arm64: {
|
||||
version_script: "arm64.map",
|
||||
},
|
||||
},
|
||||
|
||||
bazel_module: { bp2build_available: true },
|
||||
}
|
||||
bazel_module: { bp2build_available: true },
|
||||
include_build_directory: false,
|
||||
}
|
||||
`,
|
||||
},
|
||||
blueprint: soongCcLibraryPreamble,
|
||||
expectedBazelTargets: []string{`cc_library(
|
||||
name = "a",
|
||||
copts = [
|
||||
"-Ifoo/bar",
|
||||
"-I$(BINDIR)/foo/bar",
|
||||
],
|
||||
srcs = ["a.cpp"],
|
||||
version_script = select({
|
||||
"//build/bazel/platforms/arch:arm": "arm.map",
|
||||
@@ -757,35 +765,21 @@ func TestCcLibrarySharedLibs(t *testing.T) {
|
||||
moduleTypeUnderTest: "cc_library",
|
||||
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
||||
moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryBp2Build,
|
||||
dir: "foo/bar",
|
||||
filesystem: map[string]string{
|
||||
"foo/bar/Android.bp": `
|
||||
blueprint: soongCcLibraryPreamble + `
|
||||
cc_library {
|
||||
name: "mylib",
|
||||
bazel_module: { bp2build_available: true },
|
||||
bazel_module: { bp2build_available: false },
|
||||
}
|
||||
|
||||
cc_library {
|
||||
name: "a",
|
||||
shared_libs: ["mylib",],
|
||||
bazel_module: { bp2build_available: true },
|
||||
include_build_directory: false,
|
||||
}
|
||||
`,
|
||||
},
|
||||
blueprint: soongCcLibraryPreamble,
|
||||
expectedBazelTargets: []string{`cc_library(
|
||||
name = "a",
|
||||
copts = [
|
||||
"-Ifoo/bar",
|
||||
"-I$(BINDIR)/foo/bar",
|
||||
],
|
||||
dynamic_deps = [":mylib"],
|
||||
)`, `cc_library(
|
||||
name = "mylib",
|
||||
copts = [
|
||||
"-Ifoo/bar",
|
||||
"-I$(BINDIR)/foo/bar",
|
||||
],
|
||||
)`},
|
||||
})
|
||||
}
|
||||
@@ -796,14 +790,12 @@ func TestCcLibraryPackRelocations(t *testing.T) {
|
||||
moduleTypeUnderTest: "cc_library",
|
||||
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
||||
moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryBp2Build,
|
||||
dir: "foo/bar",
|
||||
filesystem: map[string]string{
|
||||
"foo/bar/Android.bp": `
|
||||
blueprint: soongCcLibraryPreamble + `
|
||||
cc_library {
|
||||
name: "a",
|
||||
srcs: ["a.cpp"],
|
||||
pack_relocations: false,
|
||||
bazel_module: { bp2build_available: true },
|
||||
include_build_directory: false,
|
||||
}
|
||||
|
||||
cc_library {
|
||||
@@ -811,10 +803,10 @@ cc_library {
|
||||
srcs: ["b.cpp"],
|
||||
arch: {
|
||||
x86_64: {
|
||||
pack_relocations: false,
|
||||
},
|
||||
pack_relocations: false,
|
||||
},
|
||||
},
|
||||
bazel_module: { bp2build_available: true },
|
||||
include_build_directory: false,
|
||||
}
|
||||
|
||||
cc_library {
|
||||
@@ -822,27 +814,17 @@ cc_library {
|
||||
srcs: ["c.cpp"],
|
||||
target: {
|
||||
darwin: {
|
||||
pack_relocations: false,
|
||||
},
|
||||
pack_relocations: false,
|
||||
},
|
||||
},
|
||||
bazel_module: { bp2build_available: true },
|
||||
include_build_directory: false,
|
||||
}`,
|
||||
},
|
||||
blueprint: soongCcLibraryPreamble,
|
||||
expectedBazelTargets: []string{`cc_library(
|
||||
name = "a",
|
||||
copts = [
|
||||
"-Ifoo/bar",
|
||||
"-I$(BINDIR)/foo/bar",
|
||||
],
|
||||
linkopts = ["-Wl,--pack-dyn-relocs=none"],
|
||||
srcs = ["a.cpp"],
|
||||
)`, `cc_library(
|
||||
name = "b",
|
||||
copts = [
|
||||
"-Ifoo/bar",
|
||||
"-I$(BINDIR)/foo/bar",
|
||||
],
|
||||
linkopts = select({
|
||||
"//build/bazel/platforms/arch:x86_64": ["-Wl,--pack-dyn-relocs=none"],
|
||||
"//conditions:default": [],
|
||||
@@ -850,10 +832,6 @@ cc_library {
|
||||
srcs = ["b.cpp"],
|
||||
)`, `cc_library(
|
||||
name = "c",
|
||||
copts = [
|
||||
"-Ifoo/bar",
|
||||
"-I$(BINDIR)/foo/bar",
|
||||
],
|
||||
linkopts = select({
|
||||
"//build/bazel/platforms/os:darwin": ["-Wl,--pack-dyn-relocs=none"],
|
||||
"//conditions:default": [],
|
||||
@@ -869,24 +847,18 @@ func TestCcLibrarySpacesInCopts(t *testing.T) {
|
||||
moduleTypeUnderTest: "cc_library",
|
||||
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
||||
moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryBp2Build,
|
||||
dir: "foo/bar",
|
||||
filesystem: map[string]string{
|
||||
"foo/bar/Android.bp": `
|
||||
blueprint: soongCcLibraryPreamble + `
|
||||
cc_library {
|
||||
name: "a",
|
||||
cflags: ["-include header.h",],
|
||||
bazel_module: { bp2build_available: true },
|
||||
include_build_directory: false,
|
||||
}
|
||||
`,
|
||||
},
|
||||
blueprint: soongCcLibraryPreamble,
|
||||
expectedBazelTargets: []string{`cc_library(
|
||||
name = "a",
|
||||
copts = [
|
||||
"-include",
|
||||
"header.h",
|
||||
"-Ifoo/bar",
|
||||
"-I$(BINDIR)/foo/bar",
|
||||
],
|
||||
)`},
|
||||
})
|
||||
@@ -898,40 +870,30 @@ func TestCcLibraryCppFlagsGoesIntoCopts(t *testing.T) {
|
||||
moduleTypeUnderTest: "cc_library",
|
||||
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
||||
moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryBp2Build,
|
||||
dir: "foo/bar",
|
||||
filesystem: map[string]string{
|
||||
"foo/bar/Android.bp": `cc_library {
|
||||
blueprint: soongCcLibraryPreamble + `cc_library {
|
||||
name: "a",
|
||||
srcs: ["a.cpp"],
|
||||
cflags: [
|
||||
"-Wall",
|
||||
],
|
||||
cflags: ["-Wall"],
|
||||
cppflags: [
|
||||
"-fsigned-char",
|
||||
"-pedantic",
|
||||
],
|
||||
],
|
||||
arch: {
|
||||
arm64: {
|
||||
cppflags: ["-DARM64=1"],
|
||||
},
|
||||
},
|
||||
},
|
||||
target: {
|
||||
android: {
|
||||
cppflags: ["-DANDROID=1"],
|
||||
},
|
||||
},
|
||||
},
|
||||
bazel_module: { bp2build_available: true },
|
||||
include_build_directory: false,
|
||||
}
|
||||
`,
|
||||
},
|
||||
blueprint: soongCcLibraryPreamble,
|
||||
expectedBazelTargets: []string{`cc_library(
|
||||
name = "a",
|
||||
copts = [
|
||||
"-Wall",
|
||||
"-Ifoo/bar",
|
||||
"-I$(BINDIR)/foo/bar",
|
||||
],
|
||||
copts = ["-Wall"],
|
||||
cppflags = [
|
||||
"-fsigned-char",
|
||||
"-pedantic",
|
||||
@@ -953,32 +915,23 @@ func TestCcLibraryLabelAttributeGetTargetProperties(t *testing.T) {
|
||||
moduleTypeUnderTest: "cc_library",
|
||||
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
||||
moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryBp2Build,
|
||||
dir: "foo/bar",
|
||||
filesystem: map[string]string{
|
||||
"foo/bar/Android.bp": `
|
||||
cc_library {
|
||||
name: "a",
|
||||
srcs: ["a.cpp"],
|
||||
target: {
|
||||
android_arm: {
|
||||
version_script: "android_arm.map",
|
||||
},
|
||||
linux_bionic_arm64: {
|
||||
version_script: "linux_bionic_arm64.map",
|
||||
},
|
||||
},
|
||||
|
||||
bazel_module: { bp2build_available: true },
|
||||
}
|
||||
blueprint: soongCcLibraryPreamble + `
|
||||
cc_library {
|
||||
name: "a",
|
||||
srcs: ["a.cpp"],
|
||||
target: {
|
||||
android_arm: {
|
||||
version_script: "android_arm.map",
|
||||
},
|
||||
linux_bionic_arm64: {
|
||||
version_script: "linux_bionic_arm64.map",
|
||||
},
|
||||
},
|
||||
include_build_directory: false,
|
||||
}
|
||||
`,
|
||||
},
|
||||
blueprint: soongCcLibraryPreamble,
|
||||
expectedBazelTargets: []string{`cc_library(
|
||||
name = "a",
|
||||
copts = [
|
||||
"-Ifoo/bar",
|
||||
"-I$(BINDIR)/foo/bar",
|
||||
],
|
||||
srcs = ["a.cpp"],
|
||||
version_script = select({
|
||||
"//build/bazel/platforms/os_arch:android_arm": "android_arm.map",
|
||||
@@ -1031,6 +984,7 @@ cc_library {
|
||||
],
|
||||
},
|
||||
},
|
||||
include_build_directory: false,
|
||||
}
|
||||
|
||||
cc_library {
|
||||
@@ -1071,10 +1025,6 @@ cc_library {
|
||||
expectedBazelTargets: []string{
|
||||
`cc_library(
|
||||
name = "foo_static",
|
||||
copts = [
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
],
|
||||
dynamic_deps = select({
|
||||
"//build/bazel/platforms/arch:arm": [],
|
||||
"//conditions:default": [":arm_shared_lib_excludes"],
|
||||
@@ -1117,14 +1067,11 @@ cc_library {
|
||||
name: "foo-lib",
|
||||
srcs: ["impl.cpp"],
|
||||
no_libcrt: true,
|
||||
include_build_directory: false,
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{`cc_library(
|
||||
name = "foo-lib",
|
||||
copts = [
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
],
|
||||
srcs = ["impl.cpp"],
|
||||
use_libcrt = False,
|
||||
)`}})
|
||||
@@ -1144,14 +1091,11 @@ cc_library {
|
||||
name: "foo-lib",
|
||||
srcs: ["impl.cpp"],
|
||||
no_libcrt: false,
|
||||
include_build_directory: false,
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{`cc_library(
|
||||
name = "foo-lib",
|
||||
copts = [
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
],
|
||||
srcs = ["impl.cpp"],
|
||||
use_libcrt = True,
|
||||
)`}})
|
||||
@@ -1166,7 +1110,6 @@ func TestCCLibraryNoCrtArchVariant(t *testing.T) {
|
||||
"impl.cpp": "",
|
||||
},
|
||||
blueprint: soongCcLibraryPreamble + `
|
||||
cc_library_headers { name: "some-headers" }
|
||||
cc_library {
|
||||
name: "foo-lib",
|
||||
srcs: ["impl.cpp"],
|
||||
@@ -1178,14 +1121,11 @@ cc_library {
|
||||
no_libcrt: true,
|
||||
},
|
||||
},
|
||||
include_build_directory: false,
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{`cc_library(
|
||||
name = "foo-lib",
|
||||
copts = [
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
],
|
||||
srcs = ["impl.cpp"],
|
||||
use_libcrt = select({
|
||||
"//build/bazel/platforms/arch:arm": False,
|
||||
@@ -1204,7 +1144,6 @@ func TestCCLibraryNoCrtArchVariantWithDefault(t *testing.T) {
|
||||
"impl.cpp": "",
|
||||
},
|
||||
blueprint: soongCcLibraryPreamble + `
|
||||
cc_library_headers { name: "some-headers" }
|
||||
cc_library {
|
||||
name: "foo-lib",
|
||||
srcs: ["impl.cpp"],
|
||||
@@ -1217,14 +1156,11 @@ cc_library {
|
||||
no_libcrt: true,
|
||||
},
|
||||
},
|
||||
include_build_directory: false,
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{`cc_library(
|
||||
name = "foo-lib",
|
||||
copts = [
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
],
|
||||
srcs = ["impl.cpp"],
|
||||
use_libcrt = select({
|
||||
"//build/bazel/platforms/arch:arm": False,
|
||||
@@ -1240,102 +1176,74 @@ func TestCcLibraryStrip(t *testing.T) {
|
||||
moduleTypeUnderTest: "cc_library",
|
||||
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
||||
moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryBp2Build,
|
||||
dir: "foo/bar",
|
||||
filesystem: map[string]string{
|
||||
"foo/bar/Android.bp": `
|
||||
blueprint: soongCcLibraryPreamble + `
|
||||
cc_library {
|
||||
name: "nothing",
|
||||
bazel_module: { bp2build_available: true },
|
||||
include_build_directory: false,
|
||||
}
|
||||
cc_library {
|
||||
name: "keep_symbols",
|
||||
bazel_module: { bp2build_available: true },
|
||||
strip: {
|
||||
keep_symbols: true,
|
||||
}
|
||||
keep_symbols: true,
|
||||
},
|
||||
include_build_directory: false,
|
||||
}
|
||||
cc_library {
|
||||
name: "keep_symbols_and_debug_frame",
|
||||
bazel_module: { bp2build_available: true },
|
||||
strip: {
|
||||
keep_symbols_and_debug_frame: true,
|
||||
}
|
||||
keep_symbols_and_debug_frame: true,
|
||||
},
|
||||
include_build_directory: false,
|
||||
}
|
||||
cc_library {
|
||||
name: "none",
|
||||
bazel_module: { bp2build_available: true },
|
||||
strip: {
|
||||
none: true,
|
||||
}
|
||||
none: true,
|
||||
},
|
||||
include_build_directory: false,
|
||||
}
|
||||
cc_library {
|
||||
name: "keep_symbols_list",
|
||||
bazel_module: { bp2build_available: true },
|
||||
strip: {
|
||||
keep_symbols_list: ["symbol"],
|
||||
}
|
||||
keep_symbols_list: ["symbol"],
|
||||
},
|
||||
include_build_directory: false,
|
||||
}
|
||||
cc_library {
|
||||
name: "all",
|
||||
bazel_module: { bp2build_available: true },
|
||||
strip: {
|
||||
all: true,
|
||||
}
|
||||
all: true,
|
||||
},
|
||||
include_build_directory: false,
|
||||
}
|
||||
`,
|
||||
},
|
||||
blueprint: soongCcLibraryPreamble,
|
||||
expectedBazelTargets: []string{`cc_library(
|
||||
name = "all",
|
||||
copts = [
|
||||
"-Ifoo/bar",
|
||||
"-I$(BINDIR)/foo/bar",
|
||||
],
|
||||
strip = {
|
||||
"all": True,
|
||||
},
|
||||
)`, `cc_library(
|
||||
name = "keep_symbols",
|
||||
copts = [
|
||||
"-Ifoo/bar",
|
||||
"-I$(BINDIR)/foo/bar",
|
||||
],
|
||||
strip = {
|
||||
"keep_symbols": True,
|
||||
},
|
||||
)`, `cc_library(
|
||||
name = "keep_symbols_and_debug_frame",
|
||||
copts = [
|
||||
"-Ifoo/bar",
|
||||
"-I$(BINDIR)/foo/bar",
|
||||
],
|
||||
strip = {
|
||||
"keep_symbols_and_debug_frame": True,
|
||||
},
|
||||
)`, `cc_library(
|
||||
name = "keep_symbols_list",
|
||||
copts = [
|
||||
"-Ifoo/bar",
|
||||
"-I$(BINDIR)/foo/bar",
|
||||
],
|
||||
strip = {
|
||||
"keep_symbols_list": ["symbol"],
|
||||
},
|
||||
)`, `cc_library(
|
||||
name = "none",
|
||||
copts = [
|
||||
"-Ifoo/bar",
|
||||
"-I$(BINDIR)/foo/bar",
|
||||
],
|
||||
strip = {
|
||||
"none": True,
|
||||
},
|
||||
)`, `cc_library(
|
||||
name = "nothing",
|
||||
copts = [
|
||||
"-Ifoo/bar",
|
||||
"-I$(BINDIR)/foo/bar",
|
||||
],
|
||||
)`},
|
||||
})
|
||||
}
|
||||
@@ -1346,12 +1254,9 @@ func TestCcLibraryStripWithArch(t *testing.T) {
|
||||
moduleTypeUnderTest: "cc_library",
|
||||
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
||||
moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryBp2Build,
|
||||
dir: "foo/bar",
|
||||
filesystem: map[string]string{
|
||||
"foo/bar/Android.bp": `
|
||||
blueprint: soongCcLibraryPreamble + `
|
||||
cc_library {
|
||||
name: "multi-arch",
|
||||
bazel_module: { bp2build_available: true },
|
||||
target: {
|
||||
darwin: {
|
||||
strip: {
|
||||
@@ -1370,17 +1275,12 @@ cc_library {
|
||||
keep_symbols: true,
|
||||
},
|
||||
},
|
||||
}
|
||||
},
|
||||
include_build_directory: false,
|
||||
}
|
||||
`,
|
||||
},
|
||||
blueprint: soongCcLibraryPreamble,
|
||||
expectedBazelTargets: []string{`cc_library(
|
||||
name = "multi-arch",
|
||||
copts = [
|
||||
"-Ifoo/bar",
|
||||
"-I$(BINDIR)/foo/bar",
|
||||
],
|
||||
strip = {
|
||||
"keep_symbols": select({
|
||||
"//build/bazel/platforms/arch:arm64": True,
|
||||
@@ -1411,15 +1311,12 @@ func TestCcLibrary_SystemSharedLibsRootEmpty(t *testing.T) {
|
||||
blueprint: soongCcLibraryPreamble + `
|
||||
cc_library {
|
||||
name: "root_empty",
|
||||
system_shared_libs: [],
|
||||
system_shared_libs: [],
|
||||
include_build_directory: false,
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{`cc_library(
|
||||
name = "root_empty",
|
||||
copts = [
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
],
|
||||
system_dynamic_deps = [],
|
||||
)`},
|
||||
})
|
||||
@@ -1435,16 +1332,13 @@ func TestCcLibrary_SystemSharedLibsStaticEmpty(t *testing.T) {
|
||||
cc_library {
|
||||
name: "static_empty",
|
||||
static: {
|
||||
system_shared_libs: [],
|
||||
},
|
||||
system_shared_libs: [],
|
||||
},
|
||||
include_build_directory: false,
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{`cc_library(
|
||||
name = "static_empty",
|
||||
copts = [
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
],
|
||||
static = {
|
||||
"system_dynamic_deps": [],
|
||||
},
|
||||
@@ -1462,16 +1356,13 @@ func TestCcLibrary_SystemSharedLibsSharedEmpty(t *testing.T) {
|
||||
cc_library {
|
||||
name: "shared_empty",
|
||||
shared: {
|
||||
system_shared_libs: [],
|
||||
},
|
||||
system_shared_libs: [],
|
||||
},
|
||||
include_build_directory: false,
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{`cc_library(
|
||||
name = "shared_empty",
|
||||
copts = [
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
],
|
||||
shared = {
|
||||
"system_dynamic_deps": [],
|
||||
},
|
||||
@@ -1494,15 +1385,12 @@ cc_library {
|
||||
system_shared_libs: [],
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
include_build_directory: false,
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{`cc_library(
|
||||
name = "shared_empty",
|
||||
copts = [
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
],
|
||||
shared = {
|
||||
"system_dynamic_deps": [],
|
||||
},
|
||||
@@ -1528,14 +1416,11 @@ cc_library {
|
||||
system_shared_libs: [],
|
||||
},
|
||||
},
|
||||
include_build_directory: false,
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{`cc_library(
|
||||
name = "target_linux_bionic_empty",
|
||||
copts = [
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
],
|
||||
system_dynamic_deps = [],
|
||||
)`},
|
||||
})
|
||||
@@ -1555,14 +1440,11 @@ cc_library {
|
||||
system_shared_libs: [],
|
||||
},
|
||||
},
|
||||
include_build_directory: false,
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{`cc_library(
|
||||
name = "target_bionic_empty",
|
||||
copts = [
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
],
|
||||
system_dynamic_deps = [],
|
||||
)`},
|
||||
})
|
||||
@@ -1575,39 +1457,30 @@ func TestCcLibrary_SystemSharedLibsSharedAndRoot(t *testing.T) {
|
||||
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
||||
moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryBp2Build,
|
||||
blueprint: soongCcLibraryPreamble + `
|
||||
cc_library {name: "libc"}
|
||||
cc_library {name: "libm"}
|
||||
cc_library {
|
||||
name: "libc",
|
||||
bazel_module: { bp2build_available: false },
|
||||
}
|
||||
cc_library {
|
||||
name: "libm",
|
||||
bazel_module: { bp2build_available: false },
|
||||
}
|
||||
|
||||
cc_library {
|
||||
name: "foo",
|
||||
system_shared_libs: ["libc"],
|
||||
shared: {
|
||||
system_shared_libs: ["libm"],
|
||||
system_shared_libs: ["libm"],
|
||||
},
|
||||
include_build_directory: false,
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{`cc_library(
|
||||
name = "foo",
|
||||
copts = [
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
],
|
||||
shared = {
|
||||
"system_dynamic_deps": [":libm"],
|
||||
},
|
||||
system_dynamic_deps = [":libc"],
|
||||
)`, `cc_library(
|
||||
name = "libc",
|
||||
copts = [
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
],
|
||||
)`, `cc_library(
|
||||
name = "libm",
|
||||
copts = [
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
],
|
||||
)`},
|
||||
})
|
||||
}
|
||||
|
@@ -25,18 +25,18 @@ const (
|
||||
// See cc/testing.go for more context
|
||||
soongCcLibraryHeadersPreamble = `
|
||||
cc_defaults {
|
||||
name: "linux_bionic_supported",
|
||||
name: "linux_bionic_supported",
|
||||
}
|
||||
|
||||
toolchain_library {
|
||||
name: "libclang_rt.builtins-x86_64-android",
|
||||
defaults: ["linux_bionic_supported"],
|
||||
vendor_available: true,
|
||||
vendor_ramdisk_available: true,
|
||||
product_available: true,
|
||||
recovery_available: true,
|
||||
native_bridge_supported: true,
|
||||
src: "",
|
||||
name: "libclang_rt.builtins-x86_64-android",
|
||||
defaults: ["linux_bionic_supported"],
|
||||
vendor_available: true,
|
||||
vendor_ramdisk_available: true,
|
||||
product_available: true,
|
||||
recovery_available: true,
|
||||
native_bridge_supported: true,
|
||||
src: "",
|
||||
}`
|
||||
)
|
||||
|
||||
@@ -99,11 +99,13 @@ func TestCcLibraryHeadersSimple(t *testing.T) {
|
||||
cc_library_headers {
|
||||
name: "lib-1",
|
||||
export_include_dirs: ["lib-1"],
|
||||
bazel_module: { bp2build_available: false },
|
||||
}
|
||||
|
||||
cc_library_headers {
|
||||
name: "lib-2",
|
||||
export_include_dirs: ["lib-2"],
|
||||
bazel_module: { bp2build_available: false },
|
||||
}
|
||||
|
||||
cc_library_headers {
|
||||
@@ -113,7 +115,7 @@ cc_library_headers {
|
||||
|
||||
arch: {
|
||||
arm64: {
|
||||
// We expect dir-1 headers to be dropped, because dir-1 is already in export_include_dirs
|
||||
// We expect dir-1 headers to be dropped, because dir-1 is already in export_include_dirs
|
||||
export_include_dirs: ["arch_arm64_exported_include_dir", "dir-1"],
|
||||
},
|
||||
x86: {
|
||||
@@ -145,25 +147,11 @@ cc_library_headers {
|
||||
":lib-1",
|
||||
":lib-2",
|
||||
],
|
||||
)`, `cc_library_headers(
|
||||
name = "lib-1",
|
||||
copts = [
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
],
|
||||
export_includes = ["lib-1"],
|
||||
)`, `cc_library_headers(
|
||||
name = "lib-2",
|
||||
copts = [
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
],
|
||||
export_includes = ["lib-2"],
|
||||
)`},
|
||||
})
|
||||
}
|
||||
|
||||
func TestCcLibraryHeadersOSSpecificHeader(t *testing.T) {
|
||||
func TestCcLibraryHeadersOsSpecificHeader(t *testing.T) {
|
||||
runCcLibraryHeadersTestCase(t, bp2buildTestCase{
|
||||
description: "cc_library_headers test with os-specific header_libs props",
|
||||
moduleTypeUnderTest: "cc_library_headers",
|
||||
@@ -171,12 +159,30 @@ func TestCcLibraryHeadersOSSpecificHeader(t *testing.T) {
|
||||
moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryHeadersBp2Build,
|
||||
filesystem: map[string]string{},
|
||||
blueprint: soongCcLibraryPreamble + `
|
||||
cc_library_headers { name: "android-lib" }
|
||||
cc_library_headers { name: "base-lib" }
|
||||
cc_library_headers { name: "darwin-lib" }
|
||||
cc_library_headers { name: "linux-lib" }
|
||||
cc_library_headers { name: "linux_bionic-lib" }
|
||||
cc_library_headers { name: "windows-lib" }
|
||||
cc_library_headers {
|
||||
name: "android-lib",
|
||||
bazel_module: { bp2build_available: false },
|
||||
}
|
||||
cc_library_headers {
|
||||
name: "base-lib",
|
||||
bazel_module: { bp2build_available: false },
|
||||
}
|
||||
cc_library_headers {
|
||||
name: "darwin-lib",
|
||||
bazel_module: { bp2build_available: false },
|
||||
}
|
||||
cc_library_headers {
|
||||
name: "linux-lib",
|
||||
bazel_module: { bp2build_available: false },
|
||||
}
|
||||
cc_library_headers {
|
||||
name: "linux_bionic-lib",
|
||||
bazel_module: { bp2build_available: false },
|
||||
}
|
||||
cc_library_headers {
|
||||
name: "windows-lib",
|
||||
bazel_module: { bp2build_available: false },
|
||||
}
|
||||
cc_library_headers {
|
||||
name: "foo_headers",
|
||||
header_libs: ["base-lib"],
|
||||
@@ -187,32 +193,10 @@ cc_library_headers {
|
||||
linux_glibc: { header_libs: ["linux-lib"] },
|
||||
windows: { header_libs: ["windows-lib"] },
|
||||
},
|
||||
bazel_module: { bp2build_available: true },
|
||||
include_build_directory: false,
|
||||
}`,
|
||||
expectedBazelTargets: []string{`cc_library_headers(
|
||||
name = "android-lib",
|
||||
copts = [
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
],
|
||||
)`, `cc_library_headers(
|
||||
name = "base-lib",
|
||||
copts = [
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
],
|
||||
)`, `cc_library_headers(
|
||||
name = "darwin-lib",
|
||||
copts = [
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
],
|
||||
)`, `cc_library_headers(
|
||||
name = "foo_headers",
|
||||
copts = [
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
],
|
||||
implementation_deps = [":base-lib"] + select({
|
||||
"//build/bazel/platforms/os:android": [":android-lib"],
|
||||
"//build/bazel/platforms/os:darwin": [":darwin-lib"],
|
||||
@@ -221,24 +205,6 @@ cc_library_headers {
|
||||
"//build/bazel/platforms/os:windows": [":windows-lib"],
|
||||
"//conditions:default": [],
|
||||
}),
|
||||
)`, `cc_library_headers(
|
||||
name = "linux-lib",
|
||||
copts = [
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
],
|
||||
)`, `cc_library_headers(
|
||||
name = "linux_bionic-lib",
|
||||
copts = [
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
],
|
||||
)`, `cc_library_headers(
|
||||
name = "windows-lib",
|
||||
copts = [
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
],
|
||||
)`},
|
||||
})
|
||||
}
|
||||
@@ -251,32 +217,23 @@ func TestCcLibraryHeadersOsSpecficHeaderLibsExportHeaderLibHeaders(t *testing.T)
|
||||
moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryHeadersBp2Build,
|
||||
filesystem: map[string]string{},
|
||||
blueprint: soongCcLibraryPreamble + `
|
||||
cc_library_headers { name: "android-lib" }
|
||||
cc_library_headers { name: "exported-lib" }
|
||||
cc_library_headers {
|
||||
name: "android-lib",
|
||||
bazel_module: { bp2build_available: false },
|
||||
}
|
||||
cc_library_headers {
|
||||
name: "exported-lib",
|
||||
bazel_module: { bp2build_available: false },
|
||||
}
|
||||
cc_library_headers {
|
||||
name: "foo_headers",
|
||||
target: {
|
||||
android: { header_libs: ["android-lib"], export_header_lib_headers: ["exported-lib"] },
|
||||
},
|
||||
include_build_directory: false,
|
||||
}`,
|
||||
expectedBazelTargets: []string{`cc_library_headers(
|
||||
name = "android-lib",
|
||||
copts = [
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
],
|
||||
)`, `cc_library_headers(
|
||||
name = "exported-lib",
|
||||
copts = [
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
],
|
||||
)`, `cc_library_headers(
|
||||
name = "foo_headers",
|
||||
copts = [
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
],
|
||||
deps = select({
|
||||
"//build/bazel/platforms/os:android": [":exported-lib"],
|
||||
"//conditions:default": [],
|
||||
@@ -299,14 +256,14 @@ func TestCcLibraryHeadersArchAndTargetExportSystemIncludes(t *testing.T) {
|
||||
blueprint: soongCcLibraryPreamble + `cc_library_headers {
|
||||
name: "foo_headers",
|
||||
export_system_include_dirs: [
|
||||
"shared_include_dir",
|
||||
"shared_include_dir",
|
||||
],
|
||||
target: {
|
||||
android: {
|
||||
export_system_include_dirs: [
|
||||
"android_include_dir",
|
||||
android: {
|
||||
export_system_include_dirs: [
|
||||
"android_include_dir",
|
||||
],
|
||||
},
|
||||
},
|
||||
linux_glibc: {
|
||||
export_system_include_dirs: [
|
||||
"linux_include_dir",
|
||||
@@ -320,23 +277,20 @@ func TestCcLibraryHeadersArchAndTargetExportSystemIncludes(t *testing.T) {
|
||||
},
|
||||
arch: {
|
||||
arm: {
|
||||
export_system_include_dirs: [
|
||||
"arm_include_dir",
|
||||
export_system_include_dirs: [
|
||||
"arm_include_dir",
|
||||
],
|
||||
},
|
||||
},
|
||||
x86_64: {
|
||||
export_system_include_dirs: [
|
||||
"x86_64_include_dir",
|
||||
],
|
||||
},
|
||||
},
|
||||
include_build_directory: false,
|
||||
}`,
|
||||
expectedBazelTargets: []string{`cc_library_headers(
|
||||
name = "foo_headers",
|
||||
copts = [
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
],
|
||||
export_system_includes = ["shared_include_dir"] + select({
|
||||
"//build/bazel/platforms/arch:arm": ["arm_include_dir"],
|
||||
"//build/bazel/platforms/arch:x86_64": ["x86_64_include_dir"],
|
||||
@@ -375,13 +329,10 @@ cc_library_headers {
|
||||
name: "lib-1",
|
||||
export_include_dirs: ["lib-1"],
|
||||
no_libcrt: true,
|
||||
include_build_directory: false,
|
||||
}`,
|
||||
expectedBazelTargets: []string{`cc_library_headers(
|
||||
name = "lib-1",
|
||||
copts = [
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
],
|
||||
export_includes = ["lib-1"],
|
||||
)`},
|
||||
})
|
||||
|
@@ -26,18 +26,18 @@ const (
|
||||
// See cc/testing.go for more context
|
||||
soongCcLibraryStaticPreamble = `
|
||||
cc_defaults {
|
||||
name: "linux_bionic_supported",
|
||||
name: "linux_bionic_supported",
|
||||
}
|
||||
|
||||
toolchain_library {
|
||||
name: "libclang_rt.builtins-x86_64-android",
|
||||
defaults: ["linux_bionic_supported"],
|
||||
vendor_available: true,
|
||||
vendor_ramdisk_available: true,
|
||||
product_available: true,
|
||||
recovery_available: true,
|
||||
native_bridge_supported: true,
|
||||
src: "",
|
||||
name: "libclang_rt.builtins-x86_64-android",
|
||||
defaults: ["linux_bionic_supported"],
|
||||
vendor_available: true,
|
||||
vendor_ramdisk_available: true,
|
||||
product_available: true,
|
||||
recovery_available: true,
|
||||
native_bridge_supported: true,
|
||||
src: "",
|
||||
}`
|
||||
)
|
||||
|
||||
@@ -112,31 +112,37 @@ func TestCcLibraryStaticSimple(t *testing.T) {
|
||||
cc_library_headers {
|
||||
name: "header_lib_1",
|
||||
export_include_dirs: ["header_lib_1"],
|
||||
bazel_module: { bp2build_available: false },
|
||||
}
|
||||
|
||||
cc_library_headers {
|
||||
name: "header_lib_2",
|
||||
export_include_dirs: ["header_lib_2"],
|
||||
bazel_module: { bp2build_available: false },
|
||||
}
|
||||
|
||||
cc_library_static {
|
||||
name: "static_lib_1",
|
||||
srcs: ["static_lib_1.cc"],
|
||||
bazel_module: { bp2build_available: false },
|
||||
}
|
||||
|
||||
cc_library_static {
|
||||
name: "static_lib_2",
|
||||
srcs: ["static_lib_2.cc"],
|
||||
bazel_module: { bp2build_available: false },
|
||||
}
|
||||
|
||||
cc_library_static {
|
||||
name: "whole_static_lib_1",
|
||||
srcs: ["whole_static_lib_1.cc"],
|
||||
bazel_module: { bp2build_available: false },
|
||||
}
|
||||
|
||||
cc_library_static {
|
||||
name: "whole_static_lib_2",
|
||||
srcs: ["whole_static_lib_2.cc"],
|
||||
bazel_module: { bp2build_available: false },
|
||||
}
|
||||
|
||||
cc_library_static {
|
||||
@@ -211,38 +217,6 @@ cc_library_static {
|
||||
":whole_static_lib_1",
|
||||
":whole_static_lib_2",
|
||||
],
|
||||
)`, `cc_library_static(
|
||||
name = "static_lib_1",
|
||||
copts = [
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
],
|
||||
linkstatic = True,
|
||||
srcs = ["static_lib_1.cc"],
|
||||
)`, `cc_library_static(
|
||||
name = "static_lib_2",
|
||||
copts = [
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
],
|
||||
linkstatic = True,
|
||||
srcs = ["static_lib_2.cc"],
|
||||
)`, `cc_library_static(
|
||||
name = "whole_static_lib_1",
|
||||
copts = [
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
],
|
||||
linkstatic = True,
|
||||
srcs = ["whole_static_lib_1.cc"],
|
||||
)`, `cc_library_static(
|
||||
name = "whole_static_lib_2",
|
||||
copts = [
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
],
|
||||
linkstatic = True,
|
||||
srcs = ["whole_static_lib_2.cc"],
|
||||
)`},
|
||||
})
|
||||
}
|
||||
@@ -273,7 +247,7 @@ cc_library_static {
|
||||
srcs: [
|
||||
],
|
||||
include_dirs: [
|
||||
"subpackage",
|
||||
"subpackage",
|
||||
],
|
||||
}`,
|
||||
expectedBazelTargets: []string{`cc_library_static(
|
||||
@@ -305,13 +279,10 @@ func TestCcLibraryStaticExportIncludeDir(t *testing.T) {
|
||||
cc_library_static {
|
||||
name: "foo_static",
|
||||
export_include_dirs: ["subpackage"],
|
||||
include_build_directory: false,
|
||||
}`,
|
||||
expectedBazelTargets: []string{`cc_library_static(
|
||||
name = "foo_static",
|
||||
copts = [
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
],
|
||||
export_includes = ["subpackage"],
|
||||
linkstatic = True,
|
||||
)`},
|
||||
@@ -334,13 +305,10 @@ func TestCcLibraryStaticExportSystemIncludeDir(t *testing.T) {
|
||||
cc_library_static {
|
||||
name: "foo_static",
|
||||
export_system_include_dirs: ["subpackage"],
|
||||
include_build_directory: false,
|
||||
}`,
|
||||
expectedBazelTargets: []string{`cc_library_static(
|
||||
name = "foo_static",
|
||||
copts = [
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
],
|
||||
export_system_includes = ["subpackage"],
|
||||
linkstatic = True,
|
||||
)`},
|
||||
@@ -473,18 +441,21 @@ func TestCcLibraryStaticArchSpecificStaticLib(t *testing.T) {
|
||||
moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryStaticBp2Build,
|
||||
filesystem: map[string]string{},
|
||||
blueprint: soongCcLibraryStaticPreamble + `
|
||||
cc_library_static { name: "static_dep" }
|
||||
cc_library_static { name: "static_dep2" }
|
||||
cc_library_static {
|
||||
name: "static_dep",
|
||||
bazel_module: { bp2build_available: false },
|
||||
}
|
||||
cc_library_static {
|
||||
name: "static_dep2",
|
||||
bazel_module: { bp2build_available: false },
|
||||
}
|
||||
cc_library_static {
|
||||
name: "foo_static",
|
||||
arch: { arm64: { static_libs: ["static_dep"], whole_static_libs: ["static_dep2"] } },
|
||||
include_build_directory: false,
|
||||
}`,
|
||||
expectedBazelTargets: []string{`cc_library_static(
|
||||
name = "foo_static",
|
||||
copts = [
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
],
|
||||
implementation_deps = select({
|
||||
"//build/bazel/platforms/arch:arm64": [":static_dep"],
|
||||
"//conditions:default": [],
|
||||
@@ -494,20 +465,6 @@ cc_library_static {
|
||||
"//build/bazel/platforms/arch:arm64": [":static_dep2"],
|
||||
"//conditions:default": [],
|
||||
}),
|
||||
)`, `cc_library_static(
|
||||
name = "static_dep",
|
||||
copts = [
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
],
|
||||
linkstatic = True,
|
||||
)`, `cc_library_static(
|
||||
name = "static_dep2",
|
||||
copts = [
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
],
|
||||
linkstatic = True,
|
||||
)`},
|
||||
})
|
||||
}
|
||||
@@ -520,18 +477,21 @@ func TestCcLibraryStaticOsSpecificStaticLib(t *testing.T) {
|
||||
moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryStaticBp2Build,
|
||||
filesystem: map[string]string{},
|
||||
blueprint: soongCcLibraryStaticPreamble + `
|
||||
cc_library_static { name: "static_dep" }
|
||||
cc_library_static { name: "static_dep2" }
|
||||
cc_library_static {
|
||||
name: "static_dep",
|
||||
bazel_module: { bp2build_available: false },
|
||||
}
|
||||
cc_library_static {
|
||||
name: "static_dep2",
|
||||
bazel_module: { bp2build_available: false },
|
||||
}
|
||||
cc_library_static {
|
||||
name: "foo_static",
|
||||
target: { android: { static_libs: ["static_dep"], whole_static_libs: ["static_dep2"] } },
|
||||
include_build_directory: false,
|
||||
}`,
|
||||
expectedBazelTargets: []string{`cc_library_static(
|
||||
name = "foo_static",
|
||||
copts = [
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
],
|
||||
implementation_deps = select({
|
||||
"//build/bazel/platforms/os:android": [":static_dep"],
|
||||
"//conditions:default": [],
|
||||
@@ -541,20 +501,6 @@ cc_library_static {
|
||||
"//build/bazel/platforms/os:android": [":static_dep2"],
|
||||
"//conditions:default": [],
|
||||
}),
|
||||
)`, `cc_library_static(
|
||||
name = "static_dep",
|
||||
copts = [
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
],
|
||||
linkstatic = True,
|
||||
)`, `cc_library_static(
|
||||
name = "static_dep2",
|
||||
copts = [
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
],
|
||||
linkstatic = True,
|
||||
)`},
|
||||
})
|
||||
}
|
||||
@@ -567,23 +513,32 @@ func TestCcLibraryStaticBaseArchOsSpecificStaticLib(t *testing.T) {
|
||||
moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryStaticBp2Build,
|
||||
filesystem: map[string]string{},
|
||||
blueprint: soongCcLibraryStaticPreamble + `
|
||||
cc_library_static { name: "static_dep" }
|
||||
cc_library_static { name: "static_dep2" }
|
||||
cc_library_static { name: "static_dep3" }
|
||||
cc_library_static { name: "static_dep4" }
|
||||
cc_library_static {
|
||||
name: "static_dep",
|
||||
bazel_module: { bp2build_available: false },
|
||||
}
|
||||
cc_library_static {
|
||||
name: "static_dep2",
|
||||
bazel_module: { bp2build_available: false },
|
||||
}
|
||||
cc_library_static {
|
||||
name: "static_dep3",
|
||||
bazel_module: { bp2build_available: false },
|
||||
}
|
||||
cc_library_static {
|
||||
name: "static_dep4",
|
||||
bazel_module: { bp2build_available: false },
|
||||
}
|
||||
cc_library_static {
|
||||
name: "foo_static",
|
||||
static_libs: ["static_dep"],
|
||||
whole_static_libs: ["static_dep2"],
|
||||
target: { android: { static_libs: ["static_dep3"] } },
|
||||
arch: { arm64: { static_libs: ["static_dep4"] } },
|
||||
include_build_directory: false,
|
||||
}`,
|
||||
expectedBazelTargets: []string{`cc_library_static(
|
||||
name = "foo_static",
|
||||
copts = [
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
],
|
||||
implementation_deps = [":static_dep"] + select({
|
||||
"//build/bazel/platforms/arch:arm64": [":static_dep4"],
|
||||
"//conditions:default": [],
|
||||
@@ -593,34 +548,6 @@ cc_library_static {
|
||||
}),
|
||||
linkstatic = True,
|
||||
whole_archive_deps = [":static_dep2"],
|
||||
)`, `cc_library_static(
|
||||
name = "static_dep",
|
||||
copts = [
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
],
|
||||
linkstatic = True,
|
||||
)`, `cc_library_static(
|
||||
name = "static_dep2",
|
||||
copts = [
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
],
|
||||
linkstatic = True,
|
||||
)`, `cc_library_static(
|
||||
name = "static_dep3",
|
||||
copts = [
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
],
|
||||
linkstatic = True,
|
||||
)`, `cc_library_static(
|
||||
name = "static_dep4",
|
||||
copts = [
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
],
|
||||
linkstatic = True,
|
||||
)`},
|
||||
})
|
||||
}
|
||||
@@ -641,13 +568,10 @@ cc_library_static {
|
||||
name: "foo_static",
|
||||
srcs: ["common.c", "foo-*.c"],
|
||||
exclude_srcs: ["foo-excluded.c"],
|
||||
include_build_directory: false,
|
||||
}`,
|
||||
expectedBazelTargets: []string{`cc_library_static(
|
||||
name = "foo_static",
|
||||
copts = [
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
],
|
||||
linkstatic = True,
|
||||
srcs_c = [
|
||||
"common.c",
|
||||
@@ -671,14 +595,11 @@ func TestCcLibraryStaticOneArchSrcs(t *testing.T) {
|
||||
cc_library_static {
|
||||
name: "foo_static",
|
||||
srcs: ["common.c"],
|
||||
arch: { arm: { srcs: ["foo-arm.c"] } }
|
||||
arch: { arm: { srcs: ["foo-arm.c"] } },
|
||||
include_build_directory: false,
|
||||
}`,
|
||||
expectedBazelTargets: []string{`cc_library_static(
|
||||
name = "foo_static",
|
||||
copts = [
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
],
|
||||
linkstatic = True,
|
||||
srcs_c = ["common.c"] + select({
|
||||
"//build/bazel/platforms/arch:arm": ["foo-arm.c"],
|
||||
@@ -708,13 +629,10 @@ cc_library_static {
|
||||
arch: {
|
||||
arm: { srcs: ["for-arm.c"], exclude_srcs: ["not-for-arm.c"] },
|
||||
},
|
||||
include_build_directory: false,
|
||||
}`,
|
||||
expectedBazelTargets: []string{`cc_library_static(
|
||||
name = "foo_static",
|
||||
copts = [
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
],
|
||||
linkstatic = True,
|
||||
srcs_c = ["common.c"] + select({
|
||||
"//build/bazel/platforms/arch:arm": ["for-arm.c"],
|
||||
@@ -746,13 +664,10 @@ cc_library_static {
|
||||
arm: { srcs: ["for-arm.c"], exclude_srcs: ["not-for-arm.c"] },
|
||||
x86: { srcs: ["for-x86.c"], exclude_srcs: ["not-for-x86.c"] },
|
||||
},
|
||||
include_build_directory: false,
|
||||
} `,
|
||||
expectedBazelTargets: []string{`cc_library_static(
|
||||
name = "foo_static",
|
||||
copts = [
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
],
|
||||
linkstatic = True,
|
||||
srcs_c = ["common.c"] + select({
|
||||
"//build/bazel/platforms/arch:arm": [
|
||||
@@ -799,14 +714,11 @@ cc_library_static {
|
||||
arm64: { srcs: ["for-arm64.c"], exclude_srcs: ["not-for-arm64.c"] },
|
||||
x86: { srcs: ["for-x86.c"], exclude_srcs: ["not-for-x86.c"] },
|
||||
x86_64: { srcs: ["for-x86_64.c"], exclude_srcs: ["not-for-x86_64.c"] },
|
||||
},
|
||||
},
|
||||
include_build_directory: false,
|
||||
} `,
|
||||
expectedBazelTargets: []string{`cc_library_static(
|
||||
name = "foo_static",
|
||||
copts = [
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
],
|
||||
linkstatic = True,
|
||||
srcs_c = ["common.c"] + select({
|
||||
"//build/bazel/platforms/arch:arm": [
|
||||
@@ -863,13 +775,10 @@ cc_library_static {
|
||||
arch: {
|
||||
arm: { exclude_srcs: ["foo-no-arm.cc"] },
|
||||
},
|
||||
include_build_directory: false,
|
||||
}`,
|
||||
expectedBazelTargets: []string{`cc_library_static(
|
||||
name = "foo_static",
|
||||
copts = [
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
],
|
||||
linkstatic = True,
|
||||
srcs = ["common.cc"] + select({
|
||||
"//build/bazel/platforms/arch:arm": [],
|
||||
@@ -900,13 +809,10 @@ cc_library_static {
|
||||
arm: { exclude_srcs: ["foo-no-arm.cc"] },
|
||||
x86: { srcs: ["x86-only.cc"] },
|
||||
},
|
||||
include_build_directory: false,
|
||||
}`,
|
||||
expectedBazelTargets: []string{`cc_library_static(
|
||||
name = "foo_static",
|
||||
copts = [
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
],
|
||||
linkstatic = True,
|
||||
srcs = ["common.cc"] + select({
|
||||
"//build/bazel/platforms/arch:arm": [],
|
||||
@@ -928,26 +834,19 @@ func TestCcLibraryStaticMultipleDepSameName(t *testing.T) {
|
||||
moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryStaticBp2Build,
|
||||
filesystem: map[string]string{},
|
||||
blueprint: soongCcLibraryStaticPreamble + `
|
||||
cc_library_static { name: "static_dep" }
|
||||
cc_library_static {
|
||||
name: "static_dep",
|
||||
bazel_module: { bp2build_available: false },
|
||||
}
|
||||
cc_library_static {
|
||||
name: "foo_static",
|
||||
static_libs: ["static_dep", "static_dep"],
|
||||
include_build_directory: false,
|
||||
}`,
|
||||
expectedBazelTargets: []string{`cc_library_static(
|
||||
name = "foo_static",
|
||||
copts = [
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
],
|
||||
implementation_deps = [":static_dep"],
|
||||
linkstatic = True,
|
||||
)`, `cc_library_static(
|
||||
name = "static_dep",
|
||||
copts = [
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
],
|
||||
linkstatic = True,
|
||||
)`},
|
||||
})
|
||||
}
|
||||
@@ -970,13 +869,10 @@ cc_library_static {
|
||||
multilib: {
|
||||
lib32: { srcs: ["for-lib32.c"], exclude_srcs: ["not-for-lib32.c"] },
|
||||
},
|
||||
include_build_directory: false,
|
||||
} `,
|
||||
expectedBazelTargets: []string{`cc_library_static(
|
||||
name = "foo_static",
|
||||
copts = [
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
],
|
||||
linkstatic = True,
|
||||
srcs_c = ["common.c"] + select({
|
||||
"//build/bazel/platforms/arch:arm": ["for-lib32.c"],
|
||||
@@ -1008,13 +904,10 @@ cc_library_static {
|
||||
lib32: { srcs: ["for-lib32.c"], exclude_srcs: ["not-for-lib32.c"] },
|
||||
lib64: { srcs: ["for-lib64.c"], exclude_srcs: ["not-for-lib64.c"] },
|
||||
},
|
||||
include_build_directory: false,
|
||||
} `,
|
||||
expectedBazelTargets: []string{`cc_library_static(
|
||||
name = "foo_static2",
|
||||
copts = [
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
],
|
||||
linkstatic = True,
|
||||
srcs_c = ["common.c"] + select({
|
||||
"//build/bazel/platforms/arch:arm": [
|
||||
@@ -1079,13 +972,10 @@ cc_library_static {
|
||||
lib32: { srcs: ["for-lib32.c"], exclude_srcs: ["not-for-lib32.c"] },
|
||||
lib64: { srcs: ["for-lib64.c"], exclude_srcs: ["not-for-lib64.c"] },
|
||||
},
|
||||
include_build_directory: false,
|
||||
}`,
|
||||
expectedBazelTargets: []string{`cc_library_static(
|
||||
name = "foo_static3",
|
||||
copts = [
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
],
|
||||
linkstatic = True,
|
||||
srcs_c = ["common.c"] + select({
|
||||
"//build/bazel/platforms/arch:arm": [
|
||||
@@ -1146,21 +1036,21 @@ func TestCcLibraryStaticArchSrcsExcludeSrcsGeneratedFiles(t *testing.T) {
|
||||
"not-for-everything.cpp": "",
|
||||
"dep/Android.bp": `
|
||||
genrule {
|
||||
name: "generated_src_other_pkg",
|
||||
out: ["generated_src_other_pkg.cpp"],
|
||||
cmd: "nothing to see here",
|
||||
name: "generated_src_other_pkg",
|
||||
out: ["generated_src_other_pkg.cpp"],
|
||||
cmd: "nothing to see here",
|
||||
}
|
||||
|
||||
genrule {
|
||||
name: "generated_hdr_other_pkg",
|
||||
out: ["generated_hdr_other_pkg.cpp"],
|
||||
cmd: "nothing to see here",
|
||||
name: "generated_hdr_other_pkg",
|
||||
out: ["generated_hdr_other_pkg.cpp"],
|
||||
cmd: "nothing to see here",
|
||||
}
|
||||
|
||||
genrule {
|
||||
name: "generated_hdr_other_pkg_x86",
|
||||
out: ["generated_hdr_other_pkg_x86.cpp"],
|
||||
cmd: "nothing to see here",
|
||||
name: "generated_hdr_other_pkg_x86",
|
||||
out: ["generated_hdr_other_pkg_x86.cpp"],
|
||||
cmd: "nothing to see here",
|
||||
}`,
|
||||
},
|
||||
blueprint: soongCcLibraryStaticPreamble + `
|
||||
@@ -1196,14 +1086,11 @@ cc_library_static {
|
||||
generated_headers: ["generated_hdr_other_pkg_x86"],
|
||||
},
|
||||
},
|
||||
include_build_directory: false,
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{`cc_library_static(
|
||||
name = "foo_static3",
|
||||
copts = [
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
],
|
||||
linkstatic = True,
|
||||
srcs = [
|
||||
"//dep:generated_hdr_other_pkg",
|
||||
@@ -1256,13 +1143,10 @@ cc_library_static {
|
||||
srcs: ["linux_bionic_x86_64_src.c"],
|
||||
},
|
||||
},
|
||||
include_build_directory: false,
|
||||
}`,
|
||||
expectedBazelTargets: []string{`cc_library_static(
|
||||
name = "foo_static",
|
||||
copts = [
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
],
|
||||
linkstatic = True,
|
||||
srcs_c = select({
|
||||
"//build/bazel/platforms/os:android": ["android_src.c"],
|
||||
@@ -1301,13 +1185,11 @@ cc_library_static {
|
||||
cflags: ["-Wbinder32bit"],
|
||||
},
|
||||
},
|
||||
include_build_directory: false,
|
||||
} `,
|
||||
expectedBazelTargets: []string{`cc_library_static(
|
||||
name = "foo_static",
|
||||
copts = [
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
] + select({
|
||||
copts = select({
|
||||
"//build/bazel/product_variables:binder32bit": ["-Wbinder32bit"],
|
||||
"//conditions:default": [],
|
||||
}) + select({
|
||||
@@ -1339,40 +1221,38 @@ cc_library_static {
|
||||
cflags: ["-Wmalloc_not_svelte"],
|
||||
},
|
||||
},
|
||||
arch: {
|
||||
arm64: {
|
||||
product_variables: {
|
||||
malloc_not_svelte: {
|
||||
cflags: ["-Warm64_malloc_not_svelte"],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
multilib: {
|
||||
lib32: {
|
||||
product_variables: {
|
||||
malloc_not_svelte: {
|
||||
cflags: ["-Wlib32_malloc_not_svelte"],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
target: {
|
||||
android: {
|
||||
product_variables: {
|
||||
malloc_not_svelte: {
|
||||
cflags: ["-Wandroid_malloc_not_svelte"],
|
||||
},
|
||||
},
|
||||
}
|
||||
},
|
||||
arch: {
|
||||
arm64: {
|
||||
product_variables: {
|
||||
malloc_not_svelte: {
|
||||
cflags: ["-Warm64_malloc_not_svelte"],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
multilib: {
|
||||
lib32: {
|
||||
product_variables: {
|
||||
malloc_not_svelte: {
|
||||
cflags: ["-Wlib32_malloc_not_svelte"],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
target: {
|
||||
android: {
|
||||
product_variables: {
|
||||
malloc_not_svelte: {
|
||||
cflags: ["-Wandroid_malloc_not_svelte"],
|
||||
},
|
||||
},
|
||||
}
|
||||
},
|
||||
include_build_directory: false,
|
||||
} `,
|
||||
expectedBazelTargets: []string{`cc_library_static(
|
||||
name = "foo_static",
|
||||
copts = [
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
] + select({
|
||||
copts = select({
|
||||
"//build/bazel/product_variables:malloc_not_svelte": ["-Wmalloc_not_svelte"],
|
||||
"//conditions:default": [],
|
||||
}) + select({
|
||||
@@ -1410,20 +1290,14 @@ cc_library_static {
|
||||
asflags: ["-DPLATFORM_SDK_VERSION=%d"],
|
||||
},
|
||||
},
|
||||
include_build_directory: false,
|
||||
} `,
|
||||
expectedBazelTargets: []string{`cc_library_static(
|
||||
name = "foo_static",
|
||||
asflags = [
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
] + select({
|
||||
asflags = select({
|
||||
"//build/bazel/product_variables:platform_sdk_version": ["-DPLATFORM_SDK_VERSION=$(Platform_sdk_version)"],
|
||||
"//conditions:default": [],
|
||||
}),
|
||||
copts = [
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
],
|
||||
linkstatic = True,
|
||||
srcs_as = ["common.S"],
|
||||
)`},
|
||||
@@ -1439,15 +1313,12 @@ func TestStaticLibrary_SystemSharedLibsRootEmpty(t *testing.T) {
|
||||
blueprint: soongCcLibraryStaticPreamble + `
|
||||
cc_library_static {
|
||||
name: "root_empty",
|
||||
system_shared_libs: [],
|
||||
system_shared_libs: [],
|
||||
include_build_directory: false,
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{`cc_library_static(
|
||||
name = "root_empty",
|
||||
copts = [
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
],
|
||||
linkstatic = True,
|
||||
system_dynamic_deps = [],
|
||||
)`},
|
||||
@@ -1464,20 +1335,17 @@ func TestStaticLibrary_SystemSharedLibsStaticEmpty(t *testing.T) {
|
||||
cc_defaults {
|
||||
name: "static_empty_defaults",
|
||||
static: {
|
||||
system_shared_libs: [],
|
||||
},
|
||||
system_shared_libs: [],
|
||||
},
|
||||
include_build_directory: false,
|
||||
}
|
||||
cc_library_static {
|
||||
name: "static_empty",
|
||||
defaults: ["static_empty_defaults"],
|
||||
defaults: ["static_empty_defaults"],
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{`cc_library_static(
|
||||
name = "static_empty",
|
||||
copts = [
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
],
|
||||
linkstatic = True,
|
||||
system_dynamic_deps = [],
|
||||
)`},
|
||||
@@ -1498,14 +1366,11 @@ cc_library_static {
|
||||
system_shared_libs: [],
|
||||
},
|
||||
},
|
||||
include_build_directory: false,
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{`cc_library_static(
|
||||
name = "target_bionic_empty",
|
||||
copts = [
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
],
|
||||
linkstatic = True,
|
||||
system_dynamic_deps = [],
|
||||
)`},
|
||||
@@ -1530,14 +1395,11 @@ cc_library_static {
|
||||
system_shared_libs: [],
|
||||
},
|
||||
},
|
||||
include_build_directory: false,
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{`cc_library_static(
|
||||
name = "target_linux_bionic_empty",
|
||||
copts = [
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
],
|
||||
linkstatic = True,
|
||||
system_dynamic_deps = [],
|
||||
)`},
|
||||
@@ -1560,14 +1422,11 @@ cc_library_static {
|
||||
system_shared_libs: ["libc"],
|
||||
},
|
||||
},
|
||||
include_build_directory: false,
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{`cc_library_static(
|
||||
name = "target_bionic",
|
||||
copts = [
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
],
|
||||
linkstatic = True,
|
||||
system_dynamic_deps = select({
|
||||
"//build/bazel/platforms/os:bionic": [":libc"],
|
||||
@@ -1589,20 +1448,17 @@ cc_library{name: "libm"}
|
||||
|
||||
cc_library_static {
|
||||
name: "target_linux_bionic",
|
||||
system_shared_libs: ["libc"],
|
||||
system_shared_libs: ["libc"],
|
||||
target: {
|
||||
linux_bionic: {
|
||||
system_shared_libs: ["libm"],
|
||||
},
|
||||
},
|
||||
include_build_directory: false,
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{`cc_library_static(
|
||||
name = "target_linux_bionic",
|
||||
copts = [
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
],
|
||||
linkstatic = True,
|
||||
system_dynamic_deps = [":libc"] + select({
|
||||
"//build/bazel/platforms/os:linux_bionic": [":libm"],
|
||||
|
@@ -78,14 +78,12 @@ func TestCcObjectSimple(t *testing.T) {
|
||||
|
||||
func TestCcObjectDefaults(t *testing.T) {
|
||||
runCcObjectTestCase(t, bp2buildTestCase{
|
||||
description: "simple cc_object with defaults",
|
||||
moduleTypeUnderTest: "cc_object",
|
||||
moduleTypeUnderTestFactory: cc.ObjectFactory,
|
||||
moduleTypeUnderTestBp2BuildMutator: cc.ObjectBp2Build,
|
||||
blueprint: `cc_object {
|
||||
name: "foo",
|
||||
system_shared_libs: [],
|
||||
local_include_dirs: ["include"],
|
||||
srcs: [
|
||||
"a/b/*.h",
|
||||
"a/b/c.c"
|
||||
@@ -115,8 +113,6 @@ cc_defaults {
|
||||
"-Wall",
|
||||
"-Werror",
|
||||
"-fno-addrsig",
|
||||
"-Iinclude",
|
||||
"-I$(BINDIR)/include",
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
],
|
||||
@@ -140,29 +136,23 @@ func TestCcObjectCcObjetDepsInObjs(t *testing.T) {
|
||||
system_shared_libs: [],
|
||||
srcs: ["a/b/c.c"],
|
||||
objs: ["bar"],
|
||||
include_build_directory: false,
|
||||
}
|
||||
|
||||
cc_object {
|
||||
name: "bar",
|
||||
system_shared_libs: [],
|
||||
srcs: ["x/y/z.c"],
|
||||
include_build_directory: false,
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{`cc_object(
|
||||
name = "bar",
|
||||
copts = [
|
||||
"-fno-addrsig",
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
],
|
||||
copts = ["-fno-addrsig"],
|
||||
srcs = ["x/y/z.c"],
|
||||
)`, `cc_object(
|
||||
name = "foo",
|
||||
copts = [
|
||||
"-fno-addrsig",
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
],
|
||||
copts = ["-fno-addrsig"],
|
||||
deps = [":bar"],
|
||||
srcs = ["a/b/c.c"],
|
||||
)`,
|
||||
@@ -245,16 +235,13 @@ func TestCcObjectCflagsOneArch(t *testing.T) {
|
||||
srcs: ["arch/arm/file.cpp"], // label list
|
||||
},
|
||||
},
|
||||
include_build_directory: false,
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{
|
||||
`cc_object(
|
||||
name = "foo",
|
||||
copts = [
|
||||
"-fno-addrsig",
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
] + select({
|
||||
copts = ["-fno-addrsig"] + select({
|
||||
"//build/bazel/platforms/arch:x86": ["-fPIC"],
|
||||
"//conditions:default": [],
|
||||
}),
|
||||
@@ -295,16 +282,13 @@ func TestCcObjectCflagsFourArch(t *testing.T) {
|
||||
cflags: ["-Wall"],
|
||||
},
|
||||
},
|
||||
include_build_directory: false,
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{
|
||||
`cc_object(
|
||||
name = "foo",
|
||||
copts = [
|
||||
"-fno-addrsig",
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
] + select({
|
||||
copts = ["-fno-addrsig"] + select({
|
||||
"//build/bazel/platforms/arch:arm": ["-Wall"],
|
||||
"//build/bazel/platforms/arch:arm64": ["-Wall"],
|
||||
"//build/bazel/platforms/arch:x86": ["-fPIC"],
|
||||
@@ -344,16 +328,13 @@ func TestCcObjectCflagsMultiOs(t *testing.T) {
|
||||
cflags: ["-Wall"],
|
||||
},
|
||||
},
|
||||
include_build_directory: false,
|
||||
}
|
||||
`,
|
||||
expectedBazelTargets: []string{
|
||||
`cc_object(
|
||||
name = "foo",
|
||||
copts = [
|
||||
"-fno-addrsig",
|
||||
"-I.",
|
||||
"-I$(BINDIR)/.",
|
||||
] + select({
|
||||
copts = ["-fno-addrsig"] + select({
|
||||
"//build/bazel/platforms/os:android": ["-fPIC"],
|
||||
"//build/bazel/platforms/os:darwin": ["-Wall"],
|
||||
"//build/bazel/platforms/os:windows": ["-fPIC"],
|
||||
|
Reference in New Issue
Block a user