Merge "bp2build: support generated sources and hdrs" am: 72a13e8d40
am: a15ba2556f
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1705758 Change-Id: Id18c0d70af4b27b153656eb79958f722ae079bae
This commit is contained in:
committed by
Automerger Merge Worker
commit
b17dc508e4
@@ -160,12 +160,6 @@ var (
|
|||||||
// Per-module denylist to always opt modules out of both bp2build and mixed builds.
|
// Per-module denylist to always opt modules out of both bp2build and mixed builds.
|
||||||
bp2buildModuleDoNotConvertList = []string{
|
bp2buildModuleDoNotConvertList = []string{
|
||||||
// Things that transitively depend on unconverted libc_* modules.
|
// Things that transitively depend on unconverted libc_* modules.
|
||||||
"libc_nopthread", // http://b/186821550, cc_library_static, depends on //bionic/libc:libc_bionic_ndk (http://b/186822256)
|
|
||||||
// also depends on //bionic/libc:libc_tzcode (http://b/186822591)
|
|
||||||
// also depends on //bionic/libc:libstdc++ (http://b/186822597)
|
|
||||||
"libc_common", // http://b/186821517, cc_library_static, depends on //bionic/libc:libc_nopthread (http://b/186821550)
|
|
||||||
"libc_common_static", // http://b/186824119, cc_library_static, depends on //bionic/libc:libc_common (http://b/186821517)
|
|
||||||
"libc_common_shared", // http://b/186824118, cc_library_static, depends on //bionic/libc:libc_common (http://b/186821517)
|
|
||||||
"libc_nomalloc", // http://b/186825031, cc_library_static, depends on //bionic/libc:libc_common (http://b/186821517)
|
"libc_nomalloc", // http://b/186825031, cc_library_static, depends on //bionic/libc:libc_common (http://b/186821517)
|
||||||
|
|
||||||
"libbionic_spawn_benchmark", // http://b/186824595, cc_library_static, depends on //external/google-benchmark (http://b/186822740)
|
"libbionic_spawn_benchmark", // http://b/186824595, cc_library_static, depends on //external/google-benchmark (http://b/186822740)
|
||||||
@@ -189,7 +183,6 @@ var (
|
|||||||
"libc_jemalloc_wrapper", // http://b/187012490, cc_library_static, depends on //external/jemalloc_new:libjemalloc5 (http://b/186828626)
|
"libc_jemalloc_wrapper", // http://b/187012490, cc_library_static, depends on //external/jemalloc_new:libjemalloc5 (http://b/186828626)
|
||||||
"libc_ndk", // http://b/187013218, cc_library_static, depends on //bionic/libm:libm (http://b/183064661)
|
"libc_ndk", // http://b/187013218, cc_library_static, depends on //bionic/libm:libm (http://b/183064661)
|
||||||
"libc", // http://b/183064430, cc_library, depends on //external/jemalloc_new:libjemalloc5 (http://b/186828626)
|
"libc", // http://b/183064430, cc_library, depends on //external/jemalloc_new:libjemalloc5 (http://b/186828626)
|
||||||
"libc_bionic_ndk", // http://b/186822256, cc_library_static, fatal error: 'generated_android_ids.h' file not found
|
|
||||||
"libc_malloc_hooks", // http://b/187016307, cc_library, ld.lld: error: undefined symbol: __malloc_hook
|
"libc_malloc_hooks", // http://b/187016307, cc_library, ld.lld: error: undefined symbol: __malloc_hook
|
||||||
"libm", // http://b/183064661, cc_library, math.h:25:16: error: unexpected token in argument list
|
"libm", // http://b/183064661, cc_library, math.h:25:16: error: unexpected token in argument list
|
||||||
|
|
||||||
@@ -230,7 +223,12 @@ var (
|
|||||||
// Per-module denylist to opt modules out of mixed builds. Such modules will
|
// Per-module denylist to opt modules out of mixed builds. Such modules will
|
||||||
// still be generated via bp2build.
|
// still be generated via bp2build.
|
||||||
mixedBuildsDisabledList = []string{
|
mixedBuildsDisabledList = []string{
|
||||||
|
"libc_bionic_ndk", // cparsons@, http://b/183213331, Handle generated headers in mixed builds.
|
||||||
|
"libc_common", // cparsons@ cc_library_static, depends on //bionic/libc:libc_nopthread
|
||||||
|
"libc_common_static", // cparsons@ cc_library_static, depends on //bionic/libc:libc_common
|
||||||
|
"libc_common_shared", // cparsons@ cc_library_static, depends on //bionic/libc:libc_common
|
||||||
"libc_netbsd", // lberki@, cc_library_static, version script assignment of 'LIBC_PRIVATE' to symbol 'SHA1Final' failed: symbol not defined
|
"libc_netbsd", // lberki@, cc_library_static, version script assignment of 'LIBC_PRIVATE' to symbol 'SHA1Final' failed: symbol not defined
|
||||||
|
"libc_nopthread", // cparsons@ cc_library_static, depends on //bionic/libc:libc_bionic_ndk
|
||||||
"libc_openbsd", // ruperts@, cc_library_static, OK for bp2build but error: duplicate symbol: strcpy for mixed builds
|
"libc_openbsd", // ruperts@, cc_library_static, OK for bp2build but error: duplicate symbol: strcpy for mixed builds
|
||||||
"libsystemproperties", // cparsons@, cc_library_static, wrong include paths
|
"libsystemproperties", // cparsons@, cc_library_static, wrong include paths
|
||||||
"libpropertyinfoparser", // cparsons@, cc_library_static, wrong include paths
|
"libpropertyinfoparser", // cparsons@, cc_library_static, wrong include paths
|
||||||
|
@@ -160,6 +160,14 @@ func SubtractBazelLabels(haystack []Label, needle []Label) []Label {
|
|||||||
return labels
|
return labels
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Appends two LabelLists, returning the combined list.
|
||||||
|
func AppendBazelLabelLists(a LabelList, b LabelList) LabelList {
|
||||||
|
var result LabelList
|
||||||
|
result.Includes = append(a.Includes, b.Includes...)
|
||||||
|
result.Excludes = append(a.Excludes, b.Excludes...)
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
// Subtract needle from haystack
|
// Subtract needle from haystack
|
||||||
func SubtractBazelLabelList(haystack LabelList, needle LabelList) LabelList {
|
func SubtractBazelLabelList(haystack LabelList, needle LabelList) LabelList {
|
||||||
var result LabelList
|
var result LabelList
|
||||||
|
@@ -113,6 +113,7 @@ cc_library {
|
|||||||
copts = [
|
copts = [
|
||||||
"-Wall",
|
"-Wall",
|
||||||
"-I.",
|
"-I.",
|
||||||
|
"-I$(BINDIR)/.",
|
||||||
],
|
],
|
||||||
deps = [":some-headers"],
|
deps = [":some-headers"],
|
||||||
includes = ["foo-dir"],
|
includes = ["foo-dir"],
|
||||||
@@ -183,6 +184,7 @@ cc_library {
|
|||||||
"-Wunused",
|
"-Wunused",
|
||||||
"-Werror",
|
"-Werror",
|
||||||
"-I.",
|
"-I.",
|
||||||
|
"-I$(BINDIR)/.",
|
||||||
],
|
],
|
||||||
deps = [":libc_headers"],
|
deps = [":libc_headers"],
|
||||||
linkopts = [
|
linkopts = [
|
||||||
@@ -242,7 +244,10 @@ cc_library {
|
|||||||
bp: soongCcLibraryPreamble,
|
bp: soongCcLibraryPreamble,
|
||||||
expectedBazelTargets: []string{`cc_library(
|
expectedBazelTargets: []string{`cc_library(
|
||||||
name = "fake-libarm-optimized-routines-math",
|
name = "fake-libarm-optimized-routines-math",
|
||||||
copts = ["-Iexternal"] + select({
|
copts = [
|
||||||
|
"-Iexternal",
|
||||||
|
"-I$(BINDIR)/external",
|
||||||
|
] + select({
|
||||||
"//build/bazel/platforms/arch:arm64": ["-DHAVE_FAST_FMA=1"],
|
"//build/bazel/platforms/arch:arm64": ["-DHAVE_FAST_FMA=1"],
|
||||||
"//conditions:default": [],
|
"//conditions:default": [],
|
||||||
}),
|
}),
|
||||||
@@ -310,6 +315,7 @@ cc_library { name: "shared_dep_for_both" }
|
|||||||
copts = [
|
copts = [
|
||||||
"bothflag",
|
"bothflag",
|
||||||
"-Ifoo/bar",
|
"-Ifoo/bar",
|
||||||
|
"-I$(BINDIR)/foo/bar",
|
||||||
],
|
],
|
||||||
deps = [":static_dep_for_both"],
|
deps = [":static_dep_for_both"],
|
||||||
dynamic_deps = [":shared_dep_for_both"],
|
dynamic_deps = [":shared_dep_for_both"],
|
||||||
@@ -347,7 +353,10 @@ cc_library {
|
|||||||
bp: soongCcLibraryPreamble,
|
bp: soongCcLibraryPreamble,
|
||||||
expectedBazelTargets: []string{`cc_library(
|
expectedBazelTargets: []string{`cc_library(
|
||||||
name = "a",
|
name = "a",
|
||||||
copts = ["-Ifoo/bar"],
|
copts = [
|
||||||
|
"-Ifoo/bar",
|
||||||
|
"-I$(BINDIR)/foo/bar",
|
||||||
|
],
|
||||||
srcs = ["a.cpp"],
|
srcs = ["a.cpp"],
|
||||||
version_script = "v.map",
|
version_script = "v.map",
|
||||||
)`},
|
)`},
|
||||||
@@ -380,7 +389,10 @@ cc_library {
|
|||||||
bp: soongCcLibraryPreamble,
|
bp: soongCcLibraryPreamble,
|
||||||
expectedBazelTargets: []string{`cc_library(
|
expectedBazelTargets: []string{`cc_library(
|
||||||
name = "a",
|
name = "a",
|
||||||
copts = ["-Ifoo/bar"],
|
copts = [
|
||||||
|
"-Ifoo/bar",
|
||||||
|
"-I$(BINDIR)/foo/bar",
|
||||||
|
],
|
||||||
srcs = ["a.cpp"],
|
srcs = ["a.cpp"],
|
||||||
version_script = select({
|
version_script = select({
|
||||||
"//build/bazel/platforms/arch:arm": "arm.map",
|
"//build/bazel/platforms/arch:arm": "arm.map",
|
||||||
@@ -413,11 +425,17 @@ cc_library {
|
|||||||
bp: soongCcLibraryPreamble,
|
bp: soongCcLibraryPreamble,
|
||||||
expectedBazelTargets: []string{`cc_library(
|
expectedBazelTargets: []string{`cc_library(
|
||||||
name = "a",
|
name = "a",
|
||||||
copts = ["-Ifoo/bar"],
|
copts = [
|
||||||
|
"-Ifoo/bar",
|
||||||
|
"-I$(BINDIR)/foo/bar",
|
||||||
|
],
|
||||||
dynamic_deps = [":mylib"],
|
dynamic_deps = [":mylib"],
|
||||||
)`, `cc_library(
|
)`, `cc_library(
|
||||||
name = "mylib",
|
name = "mylib",
|
||||||
copts = ["-Ifoo/bar"],
|
copts = [
|
||||||
|
"-Ifoo/bar",
|
||||||
|
"-I$(BINDIR)/foo/bar",
|
||||||
|
],
|
||||||
)`},
|
)`},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -461,12 +479,18 @@ cc_library {
|
|||||||
bp: soongCcLibraryPreamble,
|
bp: soongCcLibraryPreamble,
|
||||||
expectedBazelTargets: []string{`cc_library(
|
expectedBazelTargets: []string{`cc_library(
|
||||||
name = "a",
|
name = "a",
|
||||||
copts = ["-Ifoo/bar"],
|
copts = [
|
||||||
|
"-Ifoo/bar",
|
||||||
|
"-I$(BINDIR)/foo/bar",
|
||||||
|
],
|
||||||
linkopts = ["-Wl,--pack-dyn-relocs=none"],
|
linkopts = ["-Wl,--pack-dyn-relocs=none"],
|
||||||
srcs = ["a.cpp"],
|
srcs = ["a.cpp"],
|
||||||
)`, `cc_library(
|
)`, `cc_library(
|
||||||
name = "b",
|
name = "b",
|
||||||
copts = ["-Ifoo/bar"],
|
copts = [
|
||||||
|
"-Ifoo/bar",
|
||||||
|
"-I$(BINDIR)/foo/bar",
|
||||||
|
],
|
||||||
linkopts = select({
|
linkopts = select({
|
||||||
"//build/bazel/platforms/arch:x86_64": ["-Wl,--pack-dyn-relocs=none"],
|
"//build/bazel/platforms/arch:x86_64": ["-Wl,--pack-dyn-relocs=none"],
|
||||||
"//conditions:default": [],
|
"//conditions:default": [],
|
||||||
@@ -474,7 +498,10 @@ cc_library {
|
|||||||
srcs = ["b.cpp"],
|
srcs = ["b.cpp"],
|
||||||
)`, `cc_library(
|
)`, `cc_library(
|
||||||
name = "c",
|
name = "c",
|
||||||
copts = ["-Ifoo/bar"],
|
copts = [
|
||||||
|
"-Ifoo/bar",
|
||||||
|
"-I$(BINDIR)/foo/bar",
|
||||||
|
],
|
||||||
linkopts = select({
|
linkopts = select({
|
||||||
"//build/bazel/platforms/os:darwin": ["-Wl,--pack-dyn-relocs=none"],
|
"//build/bazel/platforms/os:darwin": ["-Wl,--pack-dyn-relocs=none"],
|
||||||
"//conditions:default": [],
|
"//conditions:default": [],
|
||||||
@@ -505,6 +532,7 @@ cc_library {
|
|||||||
"-include",
|
"-include",
|
||||||
"header.h",
|
"header.h",
|
||||||
"-Ifoo/bar",
|
"-Ifoo/bar",
|
||||||
|
"-I$(BINDIR)/foo/bar",
|
||||||
],
|
],
|
||||||
)`},
|
)`},
|
||||||
},
|
},
|
||||||
@@ -548,6 +576,7 @@ cc_library {
|
|||||||
"-fsigned-char",
|
"-fsigned-char",
|
||||||
"-pedantic",
|
"-pedantic",
|
||||||
"-Ifoo/bar",
|
"-Ifoo/bar",
|
||||||
|
"-I$(BINDIR)/foo/bar",
|
||||||
] + select({
|
] + select({
|
||||||
"//build/bazel/platforms/arch:arm64": ["-DARM64=1"],
|
"//build/bazel/platforms/arch:arm64": ["-DARM64=1"],
|
||||||
"//conditions:default": [],
|
"//conditions:default": [],
|
||||||
|
@@ -131,7 +131,10 @@ cc_library_headers {
|
|||||||
}`,
|
}`,
|
||||||
expectedBazelTargets: []string{`cc_library_headers(
|
expectedBazelTargets: []string{`cc_library_headers(
|
||||||
name = "foo_headers",
|
name = "foo_headers",
|
||||||
copts = ["-I."],
|
copts = [
|
||||||
|
"-I.",
|
||||||
|
"-I$(BINDIR)/.",
|
||||||
|
],
|
||||||
deps = [
|
deps = [
|
||||||
":lib-1",
|
":lib-1",
|
||||||
":lib-2",
|
":lib-2",
|
||||||
@@ -147,11 +150,17 @@ cc_library_headers {
|
|||||||
}),
|
}),
|
||||||
)`, `cc_library_headers(
|
)`, `cc_library_headers(
|
||||||
name = "lib-1",
|
name = "lib-1",
|
||||||
copts = ["-I."],
|
copts = [
|
||||||
|
"-I.",
|
||||||
|
"-I$(BINDIR)/.",
|
||||||
|
],
|
||||||
includes = ["lib-1"],
|
includes = ["lib-1"],
|
||||||
)`, `cc_library_headers(
|
)`, `cc_library_headers(
|
||||||
name = "lib-2",
|
name = "lib-2",
|
||||||
copts = ["-I."],
|
copts = [
|
||||||
|
"-I.",
|
||||||
|
"-I$(BINDIR)/.",
|
||||||
|
],
|
||||||
includes = ["lib-2"],
|
includes = ["lib-2"],
|
||||||
)`},
|
)`},
|
||||||
},
|
},
|
||||||
@@ -185,16 +194,28 @@ cc_library_headers {
|
|||||||
}`,
|
}`,
|
||||||
expectedBazelTargets: []string{`cc_library_headers(
|
expectedBazelTargets: []string{`cc_library_headers(
|
||||||
name = "android-lib",
|
name = "android-lib",
|
||||||
copts = ["-I."],
|
copts = [
|
||||||
|
"-I.",
|
||||||
|
"-I$(BINDIR)/.",
|
||||||
|
],
|
||||||
)`, `cc_library_headers(
|
)`, `cc_library_headers(
|
||||||
name = "base-lib",
|
name = "base-lib",
|
||||||
copts = ["-I."],
|
copts = [
|
||||||
|
"-I.",
|
||||||
|
"-I$(BINDIR)/.",
|
||||||
|
],
|
||||||
)`, `cc_library_headers(
|
)`, `cc_library_headers(
|
||||||
name = "darwin-lib",
|
name = "darwin-lib",
|
||||||
copts = ["-I."],
|
copts = [
|
||||||
|
"-I.",
|
||||||
|
"-I$(BINDIR)/.",
|
||||||
|
],
|
||||||
)`, `cc_library_headers(
|
)`, `cc_library_headers(
|
||||||
name = "foo_headers",
|
name = "foo_headers",
|
||||||
copts = ["-I."],
|
copts = [
|
||||||
|
"-I.",
|
||||||
|
"-I$(BINDIR)/.",
|
||||||
|
],
|
||||||
deps = [":base-lib"] + select({
|
deps = [":base-lib"] + select({
|
||||||
"//build/bazel/platforms/os:android": [":android-lib"],
|
"//build/bazel/platforms/os:android": [":android-lib"],
|
||||||
"//build/bazel/platforms/os:darwin": [":darwin-lib"],
|
"//build/bazel/platforms/os:darwin": [":darwin-lib"],
|
||||||
@@ -206,16 +227,28 @@ cc_library_headers {
|
|||||||
}),
|
}),
|
||||||
)`, `cc_library_headers(
|
)`, `cc_library_headers(
|
||||||
name = "fuchsia-lib",
|
name = "fuchsia-lib",
|
||||||
copts = ["-I."],
|
copts = [
|
||||||
|
"-I.",
|
||||||
|
"-I$(BINDIR)/.",
|
||||||
|
],
|
||||||
)`, `cc_library_headers(
|
)`, `cc_library_headers(
|
||||||
name = "linux-lib",
|
name = "linux-lib",
|
||||||
copts = ["-I."],
|
copts = [
|
||||||
|
"-I.",
|
||||||
|
"-I$(BINDIR)/.",
|
||||||
|
],
|
||||||
)`, `cc_library_headers(
|
)`, `cc_library_headers(
|
||||||
name = "linux_bionic-lib",
|
name = "linux_bionic-lib",
|
||||||
copts = ["-I."],
|
copts = [
|
||||||
|
"-I.",
|
||||||
|
"-I$(BINDIR)/.",
|
||||||
|
],
|
||||||
)`, `cc_library_headers(
|
)`, `cc_library_headers(
|
||||||
name = "windows-lib",
|
name = "windows-lib",
|
||||||
copts = ["-I."],
|
copts = [
|
||||||
|
"-I.",
|
||||||
|
"-I$(BINDIR)/.",
|
||||||
|
],
|
||||||
)`},
|
)`},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -236,13 +269,22 @@ cc_library_headers {
|
|||||||
}`,
|
}`,
|
||||||
expectedBazelTargets: []string{`cc_library_headers(
|
expectedBazelTargets: []string{`cc_library_headers(
|
||||||
name = "android-lib",
|
name = "android-lib",
|
||||||
copts = ["-I."],
|
copts = [
|
||||||
|
"-I.",
|
||||||
|
"-I$(BINDIR)/.",
|
||||||
|
],
|
||||||
)`, `cc_library_headers(
|
)`, `cc_library_headers(
|
||||||
name = "exported-lib",
|
name = "exported-lib",
|
||||||
copts = ["-I."],
|
copts = [
|
||||||
|
"-I.",
|
||||||
|
"-I$(BINDIR)/.",
|
||||||
|
],
|
||||||
)`, `cc_library_headers(
|
)`, `cc_library_headers(
|
||||||
name = "foo_headers",
|
name = "foo_headers",
|
||||||
copts = ["-I."],
|
copts = [
|
||||||
|
"-I.",
|
||||||
|
"-I$(BINDIR)/.",
|
||||||
|
],
|
||||||
deps = select({
|
deps = select({
|
||||||
"//build/bazel/platforms/os:android": [
|
"//build/bazel/platforms/os:android": [
|
||||||
":android-lib",
|
":android-lib",
|
||||||
@@ -296,7 +338,10 @@ cc_library_headers {
|
|||||||
}`,
|
}`,
|
||||||
expectedBazelTargets: []string{`cc_library_headers(
|
expectedBazelTargets: []string{`cc_library_headers(
|
||||||
name = "foo_headers",
|
name = "foo_headers",
|
||||||
copts = ["-I."],
|
copts = [
|
||||||
|
"-I.",
|
||||||
|
"-I$(BINDIR)/.",
|
||||||
|
],
|
||||||
includes = ["shared_include_dir"] + select({
|
includes = ["shared_include_dir"] + select({
|
||||||
"//build/bazel/platforms/arch:arm": ["arm_include_dir"],
|
"//build/bazel/platforms/arch:arm": ["arm_include_dir"],
|
||||||
"//build/bazel/platforms/arch:x86_64": ["x86_64_include_dir"],
|
"//build/bazel/platforms/arch:x86_64": ["x86_64_include_dir"],
|
||||||
|
@@ -17,6 +17,8 @@ package bp2build
|
|||||||
import (
|
import (
|
||||||
"android/soong/android"
|
"android/soong/android"
|
||||||
"android/soong/cc"
|
"android/soong/cc"
|
||||||
|
"android/soong/genrule"
|
||||||
|
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
@@ -179,10 +181,15 @@ cc_library_static {
|
|||||||
"-Dflag1",
|
"-Dflag1",
|
||||||
"-Dflag2",
|
"-Dflag2",
|
||||||
"-Iinclude_dir_1",
|
"-Iinclude_dir_1",
|
||||||
|
"-I$(BINDIR)/include_dir_1",
|
||||||
"-Iinclude_dir_2",
|
"-Iinclude_dir_2",
|
||||||
|
"-I$(BINDIR)/include_dir_2",
|
||||||
"-Ilocal_include_dir_1",
|
"-Ilocal_include_dir_1",
|
||||||
|
"-I$(BINDIR)/local_include_dir_1",
|
||||||
"-Ilocal_include_dir_2",
|
"-Ilocal_include_dir_2",
|
||||||
|
"-I$(BINDIR)/local_include_dir_2",
|
||||||
"-I.",
|
"-I.",
|
||||||
|
"-I$(BINDIR)/.",
|
||||||
],
|
],
|
||||||
deps = [
|
deps = [
|
||||||
":header_lib_1",
|
":header_lib_1",
|
||||||
@@ -205,22 +212,34 @@ cc_library_static {
|
|||||||
],
|
],
|
||||||
)`, `cc_library_static(
|
)`, `cc_library_static(
|
||||||
name = "static_lib_1",
|
name = "static_lib_1",
|
||||||
copts = ["-I."],
|
copts = [
|
||||||
|
"-I.",
|
||||||
|
"-I$(BINDIR)/.",
|
||||||
|
],
|
||||||
linkstatic = True,
|
linkstatic = True,
|
||||||
srcs = ["static_lib_1.cc"],
|
srcs = ["static_lib_1.cc"],
|
||||||
)`, `cc_library_static(
|
)`, `cc_library_static(
|
||||||
name = "static_lib_2",
|
name = "static_lib_2",
|
||||||
copts = ["-I."],
|
copts = [
|
||||||
|
"-I.",
|
||||||
|
"-I$(BINDIR)/.",
|
||||||
|
],
|
||||||
linkstatic = True,
|
linkstatic = True,
|
||||||
srcs = ["static_lib_2.cc"],
|
srcs = ["static_lib_2.cc"],
|
||||||
)`, `cc_library_static(
|
)`, `cc_library_static(
|
||||||
name = "whole_static_lib_1",
|
name = "whole_static_lib_1",
|
||||||
copts = ["-I."],
|
copts = [
|
||||||
|
"-I.",
|
||||||
|
"-I$(BINDIR)/.",
|
||||||
|
],
|
||||||
linkstatic = True,
|
linkstatic = True,
|
||||||
srcs = ["whole_static_lib_1.cc"],
|
srcs = ["whole_static_lib_1.cc"],
|
||||||
)`, `cc_library_static(
|
)`, `cc_library_static(
|
||||||
name = "whole_static_lib_2",
|
name = "whole_static_lib_2",
|
||||||
copts = ["-I."],
|
copts = [
|
||||||
|
"-I.",
|
||||||
|
"-I$(BINDIR)/.",
|
||||||
|
],
|
||||||
linkstatic = True,
|
linkstatic = True,
|
||||||
srcs = ["whole_static_lib_2.cc"],
|
srcs = ["whole_static_lib_2.cc"],
|
||||||
)`},
|
)`},
|
||||||
@@ -257,7 +276,9 @@ cc_library_static {
|
|||||||
name = "foo_static",
|
name = "foo_static",
|
||||||
copts = [
|
copts = [
|
||||||
"-Isubpackage",
|
"-Isubpackage",
|
||||||
|
"-I$(BINDIR)/subpackage",
|
||||||
"-I.",
|
"-I.",
|
||||||
|
"-I$(BINDIR)/.",
|
||||||
],
|
],
|
||||||
linkstatic = True,
|
linkstatic = True,
|
||||||
)`},
|
)`},
|
||||||
@@ -280,7 +301,10 @@ cc_library_static {
|
|||||||
}`,
|
}`,
|
||||||
expectedBazelTargets: []string{`cc_library_static(
|
expectedBazelTargets: []string{`cc_library_static(
|
||||||
name = "foo_static",
|
name = "foo_static",
|
||||||
copts = ["-I."],
|
copts = [
|
||||||
|
"-I.",
|
||||||
|
"-I$(BINDIR)/.",
|
||||||
|
],
|
||||||
includes = ["subpackage"],
|
includes = ["subpackage"],
|
||||||
linkstatic = True,
|
linkstatic = True,
|
||||||
)`},
|
)`},
|
||||||
@@ -303,7 +327,10 @@ cc_library_static {
|
|||||||
}`,
|
}`,
|
||||||
expectedBazelTargets: []string{`cc_library_static(
|
expectedBazelTargets: []string{`cc_library_static(
|
||||||
name = "foo_static",
|
name = "foo_static",
|
||||||
copts = ["-I."],
|
copts = [
|
||||||
|
"-I.",
|
||||||
|
"-I$(BINDIR)/.",
|
||||||
|
],
|
||||||
includes = ["subpackage"],
|
includes = ["subpackage"],
|
||||||
linkstatic = True,
|
linkstatic = True,
|
||||||
)`},
|
)`},
|
||||||
@@ -341,10 +368,15 @@ cc_library_static {
|
|||||||
name = "foo_static",
|
name = "foo_static",
|
||||||
copts = [
|
copts = [
|
||||||
"-Isubpackage/subsubpackage",
|
"-Isubpackage/subsubpackage",
|
||||||
|
"-I$(BINDIR)/subpackage/subsubpackage",
|
||||||
"-Isubpackage2",
|
"-Isubpackage2",
|
||||||
|
"-I$(BINDIR)/subpackage2",
|
||||||
"-Isubpackage3/subsubpackage",
|
"-Isubpackage3/subsubpackage",
|
||||||
|
"-I$(BINDIR)/subpackage3/subsubpackage",
|
||||||
"-Isubpackage/subsubpackage2",
|
"-Isubpackage/subsubpackage2",
|
||||||
|
"-I$(BINDIR)/subpackage/subsubpackage2",
|
||||||
"-Isubpackage",
|
"-Isubpackage",
|
||||||
|
"-I$(BINDIR)/subpackage",
|
||||||
],
|
],
|
||||||
includes = ["./exported_subsubpackage"],
|
includes = ["./exported_subsubpackage"],
|
||||||
linkstatic = True,
|
linkstatic = True,
|
||||||
@@ -372,7 +404,9 @@ cc_library_static {
|
|||||||
name = "foo_static",
|
name = "foo_static",
|
||||||
copts = [
|
copts = [
|
||||||
"-Isubpackage",
|
"-Isubpackage",
|
||||||
|
"-I$(BINDIR)/subpackage",
|
||||||
"-Isubpackage2",
|
"-Isubpackage2",
|
||||||
|
"-I$(BINDIR)/subpackage2",
|
||||||
],
|
],
|
||||||
linkstatic = True,
|
linkstatic = True,
|
||||||
)`},
|
)`},
|
||||||
@@ -401,8 +435,11 @@ cc_library_static {
|
|||||||
name = "foo_static",
|
name = "foo_static",
|
||||||
copts = [
|
copts = [
|
||||||
"-Isubpackage",
|
"-Isubpackage",
|
||||||
|
"-I$(BINDIR)/subpackage",
|
||||||
"-Isubpackage2",
|
"-Isubpackage2",
|
||||||
|
"-I$(BINDIR)/subpackage2",
|
||||||
"-I.",
|
"-I.",
|
||||||
|
"-I$(BINDIR)/.",
|
||||||
],
|
],
|
||||||
linkstatic = True,
|
linkstatic = True,
|
||||||
)`},
|
)`},
|
||||||
@@ -423,7 +460,10 @@ cc_library_static {
|
|||||||
}`,
|
}`,
|
||||||
expectedBazelTargets: []string{`cc_library_static(
|
expectedBazelTargets: []string{`cc_library_static(
|
||||||
name = "foo_static",
|
name = "foo_static",
|
||||||
copts = ["-I."],
|
copts = [
|
||||||
|
"-I.",
|
||||||
|
"-I$(BINDIR)/.",
|
||||||
|
],
|
||||||
deps = select({
|
deps = select({
|
||||||
"//build/bazel/platforms/arch:arm64": [":static_dep"],
|
"//build/bazel/platforms/arch:arm64": [":static_dep"],
|
||||||
"//conditions:default": [],
|
"//conditions:default": [],
|
||||||
@@ -435,11 +475,17 @@ cc_library_static {
|
|||||||
}),
|
}),
|
||||||
)`, `cc_library_static(
|
)`, `cc_library_static(
|
||||||
name = "static_dep",
|
name = "static_dep",
|
||||||
copts = ["-I."],
|
copts = [
|
||||||
|
"-I.",
|
||||||
|
"-I$(BINDIR)/.",
|
||||||
|
],
|
||||||
linkstatic = True,
|
linkstatic = True,
|
||||||
)`, `cc_library_static(
|
)`, `cc_library_static(
|
||||||
name = "static_dep2",
|
name = "static_dep2",
|
||||||
copts = ["-I."],
|
copts = [
|
||||||
|
"-I.",
|
||||||
|
"-I$(BINDIR)/.",
|
||||||
|
],
|
||||||
linkstatic = True,
|
linkstatic = True,
|
||||||
)`},
|
)`},
|
||||||
},
|
},
|
||||||
@@ -459,7 +505,10 @@ cc_library_static {
|
|||||||
}`,
|
}`,
|
||||||
expectedBazelTargets: []string{`cc_library_static(
|
expectedBazelTargets: []string{`cc_library_static(
|
||||||
name = "foo_static",
|
name = "foo_static",
|
||||||
copts = ["-I."],
|
copts = [
|
||||||
|
"-I.",
|
||||||
|
"-I$(BINDIR)/.",
|
||||||
|
],
|
||||||
deps = select({
|
deps = select({
|
||||||
"//build/bazel/platforms/os:android": [":static_dep"],
|
"//build/bazel/platforms/os:android": [":static_dep"],
|
||||||
"//conditions:default": [],
|
"//conditions:default": [],
|
||||||
@@ -471,11 +520,17 @@ cc_library_static {
|
|||||||
}),
|
}),
|
||||||
)`, `cc_library_static(
|
)`, `cc_library_static(
|
||||||
name = "static_dep",
|
name = "static_dep",
|
||||||
copts = ["-I."],
|
copts = [
|
||||||
|
"-I.",
|
||||||
|
"-I$(BINDIR)/.",
|
||||||
|
],
|
||||||
linkstatic = True,
|
linkstatic = True,
|
||||||
)`, `cc_library_static(
|
)`, `cc_library_static(
|
||||||
name = "static_dep2",
|
name = "static_dep2",
|
||||||
copts = ["-I."],
|
copts = [
|
||||||
|
"-I.",
|
||||||
|
"-I$(BINDIR)/.",
|
||||||
|
],
|
||||||
linkstatic = True,
|
linkstatic = True,
|
||||||
)`},
|
)`},
|
||||||
},
|
},
|
||||||
@@ -500,7 +555,10 @@ cc_library_static {
|
|||||||
}`,
|
}`,
|
||||||
expectedBazelTargets: []string{`cc_library_static(
|
expectedBazelTargets: []string{`cc_library_static(
|
||||||
name = "foo_static",
|
name = "foo_static",
|
||||||
copts = ["-I."],
|
copts = [
|
||||||
|
"-I.",
|
||||||
|
"-I$(BINDIR)/.",
|
||||||
|
],
|
||||||
deps = [":static_dep"] + select({
|
deps = [":static_dep"] + select({
|
||||||
"//build/bazel/platforms/arch:arm64": [":static_dep4"],
|
"//build/bazel/platforms/arch:arm64": [":static_dep4"],
|
||||||
"//conditions:default": [],
|
"//conditions:default": [],
|
||||||
@@ -512,19 +570,31 @@ cc_library_static {
|
|||||||
whole_archive_deps = [":static_dep2"],
|
whole_archive_deps = [":static_dep2"],
|
||||||
)`, `cc_library_static(
|
)`, `cc_library_static(
|
||||||
name = "static_dep",
|
name = "static_dep",
|
||||||
copts = ["-I."],
|
copts = [
|
||||||
|
"-I.",
|
||||||
|
"-I$(BINDIR)/.",
|
||||||
|
],
|
||||||
linkstatic = True,
|
linkstatic = True,
|
||||||
)`, `cc_library_static(
|
)`, `cc_library_static(
|
||||||
name = "static_dep2",
|
name = "static_dep2",
|
||||||
copts = ["-I."],
|
copts = [
|
||||||
|
"-I.",
|
||||||
|
"-I$(BINDIR)/.",
|
||||||
|
],
|
||||||
linkstatic = True,
|
linkstatic = True,
|
||||||
)`, `cc_library_static(
|
)`, `cc_library_static(
|
||||||
name = "static_dep3",
|
name = "static_dep3",
|
||||||
copts = ["-I."],
|
copts = [
|
||||||
|
"-I.",
|
||||||
|
"-I$(BINDIR)/.",
|
||||||
|
],
|
||||||
linkstatic = True,
|
linkstatic = True,
|
||||||
)`, `cc_library_static(
|
)`, `cc_library_static(
|
||||||
name = "static_dep4",
|
name = "static_dep4",
|
||||||
copts = ["-I."],
|
copts = [
|
||||||
|
"-I.",
|
||||||
|
"-I$(BINDIR)/.",
|
||||||
|
],
|
||||||
linkstatic = True,
|
linkstatic = True,
|
||||||
)`},
|
)`},
|
||||||
},
|
},
|
||||||
@@ -547,7 +617,10 @@ cc_library_static {
|
|||||||
}`,
|
}`,
|
||||||
expectedBazelTargets: []string{`cc_library_static(
|
expectedBazelTargets: []string{`cc_library_static(
|
||||||
name = "foo_static",
|
name = "foo_static",
|
||||||
copts = ["-I."],
|
copts = [
|
||||||
|
"-I.",
|
||||||
|
"-I$(BINDIR)/.",
|
||||||
|
],
|
||||||
linkstatic = True,
|
linkstatic = True,
|
||||||
srcs = [
|
srcs = [
|
||||||
"common.c",
|
"common.c",
|
||||||
@@ -573,7 +646,10 @@ cc_library_static {
|
|||||||
}`,
|
}`,
|
||||||
expectedBazelTargets: []string{`cc_library_static(
|
expectedBazelTargets: []string{`cc_library_static(
|
||||||
name = "foo_static",
|
name = "foo_static",
|
||||||
copts = ["-I."],
|
copts = [
|
||||||
|
"-I.",
|
||||||
|
"-I$(BINDIR)/.",
|
||||||
|
],
|
||||||
linkstatic = True,
|
linkstatic = True,
|
||||||
srcs = ["common.c"] + select({
|
srcs = ["common.c"] + select({
|
||||||
"//build/bazel/platforms/arch:arm": ["foo-arm.c"],
|
"//build/bazel/platforms/arch:arm": ["foo-arm.c"],
|
||||||
@@ -604,7 +680,10 @@ cc_library_static {
|
|||||||
}`,
|
}`,
|
||||||
expectedBazelTargets: []string{`cc_library_static(
|
expectedBazelTargets: []string{`cc_library_static(
|
||||||
name = "foo_static",
|
name = "foo_static",
|
||||||
copts = ["-I."],
|
copts = [
|
||||||
|
"-I.",
|
||||||
|
"-I$(BINDIR)/.",
|
||||||
|
],
|
||||||
linkstatic = True,
|
linkstatic = True,
|
||||||
srcs = ["common.c"] + select({
|
srcs = ["common.c"] + select({
|
||||||
"//build/bazel/platforms/arch:arm": ["for-arm.c"],
|
"//build/bazel/platforms/arch:arm": ["for-arm.c"],
|
||||||
@@ -637,7 +716,10 @@ cc_library_static {
|
|||||||
} `,
|
} `,
|
||||||
expectedBazelTargets: []string{`cc_library_static(
|
expectedBazelTargets: []string{`cc_library_static(
|
||||||
name = "foo_static",
|
name = "foo_static",
|
||||||
copts = ["-I."],
|
copts = [
|
||||||
|
"-I.",
|
||||||
|
"-I$(BINDIR)/.",
|
||||||
|
],
|
||||||
linkstatic = True,
|
linkstatic = True,
|
||||||
srcs = ["common.c"] + select({
|
srcs = ["common.c"] + select({
|
||||||
"//build/bazel/platforms/arch:arm": [
|
"//build/bazel/platforms/arch:arm": [
|
||||||
@@ -687,7 +769,10 @@ cc_library_static {
|
|||||||
} `,
|
} `,
|
||||||
expectedBazelTargets: []string{`cc_library_static(
|
expectedBazelTargets: []string{`cc_library_static(
|
||||||
name = "foo_static",
|
name = "foo_static",
|
||||||
copts = ["-I."],
|
copts = [
|
||||||
|
"-I.",
|
||||||
|
"-I$(BINDIR)/.",
|
||||||
|
],
|
||||||
linkstatic = True,
|
linkstatic = True,
|
||||||
srcs = ["common.c"] + select({
|
srcs = ["common.c"] + select({
|
||||||
"//build/bazel/platforms/arch:arm": [
|
"//build/bazel/platforms/arch:arm": [
|
||||||
@@ -738,12 +823,18 @@ cc_library_static {
|
|||||||
}`,
|
}`,
|
||||||
expectedBazelTargets: []string{`cc_library_static(
|
expectedBazelTargets: []string{`cc_library_static(
|
||||||
name = "foo_static",
|
name = "foo_static",
|
||||||
copts = ["-I."],
|
copts = [
|
||||||
|
"-I.",
|
||||||
|
"-I$(BINDIR)/.",
|
||||||
|
],
|
||||||
deps = [":static_dep"],
|
deps = [":static_dep"],
|
||||||
linkstatic = True,
|
linkstatic = True,
|
||||||
)`, `cc_library_static(
|
)`, `cc_library_static(
|
||||||
name = "static_dep",
|
name = "static_dep",
|
||||||
copts = ["-I."],
|
copts = [
|
||||||
|
"-I.",
|
||||||
|
"-I$(BINDIR)/.",
|
||||||
|
],
|
||||||
linkstatic = True,
|
linkstatic = True,
|
||||||
)`},
|
)`},
|
||||||
},
|
},
|
||||||
@@ -768,7 +859,10 @@ cc_library_static {
|
|||||||
} `,
|
} `,
|
||||||
expectedBazelTargets: []string{`cc_library_static(
|
expectedBazelTargets: []string{`cc_library_static(
|
||||||
name = "foo_static",
|
name = "foo_static",
|
||||||
copts = ["-I."],
|
copts = [
|
||||||
|
"-I.",
|
||||||
|
"-I$(BINDIR)/.",
|
||||||
|
],
|
||||||
linkstatic = True,
|
linkstatic = True,
|
||||||
srcs = ["common.c"] + select({
|
srcs = ["common.c"] + select({
|
||||||
"//build/bazel/platforms/arch:arm": ["for-lib32.c"],
|
"//build/bazel/platforms/arch:arm": ["for-lib32.c"],
|
||||||
@@ -801,7 +895,10 @@ cc_library_static {
|
|||||||
} `,
|
} `,
|
||||||
expectedBazelTargets: []string{`cc_library_static(
|
expectedBazelTargets: []string{`cc_library_static(
|
||||||
name = "foo_static2",
|
name = "foo_static2",
|
||||||
copts = ["-I."],
|
copts = [
|
||||||
|
"-I.",
|
||||||
|
"-I$(BINDIR)/.",
|
||||||
|
],
|
||||||
linkstatic = True,
|
linkstatic = True,
|
||||||
srcs = ["common.c"] + select({
|
srcs = ["common.c"] + select({
|
||||||
"//build/bazel/platforms/arch:arm": [
|
"//build/bazel/platforms/arch:arm": [
|
||||||
@@ -867,7 +964,10 @@ cc_library_static {
|
|||||||
}`,
|
}`,
|
||||||
expectedBazelTargets: []string{`cc_library_static(
|
expectedBazelTargets: []string{`cc_library_static(
|
||||||
name = "foo_static3",
|
name = "foo_static3",
|
||||||
copts = ["-I."],
|
copts = [
|
||||||
|
"-I.",
|
||||||
|
"-I$(BINDIR)/.",
|
||||||
|
],
|
||||||
linkstatic = True,
|
linkstatic = True,
|
||||||
srcs = ["common.c"] + select({
|
srcs = ["common.c"] + select({
|
||||||
"//build/bazel/platforms/arch:arm": [
|
"//build/bazel/platforms/arch:arm": [
|
||||||
@@ -911,6 +1011,94 @@ cc_library_static {
|
|||||||
"not-for-x86_64.c",
|
"not-for-x86_64.c",
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
|
)`},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
description: "cc_library_static arch srcs/exclude_srcs with generated files",
|
||||||
|
moduleTypeUnderTest: "cc_library_static",
|
||||||
|
moduleTypeUnderTestFactory: cc.LibraryStaticFactory,
|
||||||
|
moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryStaticBp2Build,
|
||||||
|
depsMutators: []android.RegisterMutatorFunc{cc.RegisterDepsBp2Build},
|
||||||
|
filesystem: map[string]string{
|
||||||
|
"common.c": "",
|
||||||
|
"for-x86.c": "",
|
||||||
|
"not-for-x86.c": "",
|
||||||
|
"not-for-everything.c": "",
|
||||||
|
"dep/Android.bp": `
|
||||||
|
genrule {
|
||||||
|
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",
|
||||||
|
}
|
||||||
|
|
||||||
|
genrule {
|
||||||
|
name: "generated_hdr_other_pkg_x86",
|
||||||
|
out: ["generated_hdr_other_pkg_x86.cpp"],
|
||||||
|
cmd: "nothing to see here",
|
||||||
|
}`,
|
||||||
|
},
|
||||||
|
bp: soongCcLibraryStaticPreamble + `
|
||||||
|
genrule {
|
||||||
|
name: "generated_src",
|
||||||
|
out: ["generated_src.cpp"],
|
||||||
|
cmd: "nothing to see here",
|
||||||
|
}
|
||||||
|
|
||||||
|
genrule {
|
||||||
|
name: "generated_src_x86",
|
||||||
|
out: ["generated_src_x86.cpp"],
|
||||||
|
cmd: "nothing to see here",
|
||||||
|
}
|
||||||
|
|
||||||
|
genrule {
|
||||||
|
name: "generated_hdr",
|
||||||
|
out: ["generated_hdr.h"],
|
||||||
|
cmd: "nothing to see here",
|
||||||
|
}
|
||||||
|
|
||||||
|
cc_library_static {
|
||||||
|
name: "foo_static3",
|
||||||
|
srcs: ["common.c", "not-for-*.c"],
|
||||||
|
exclude_srcs: ["not-for-everything.c"],
|
||||||
|
generated_sources: ["generated_src", "generated_src_other_pkg"],
|
||||||
|
generated_headers: ["generated_hdr", "generated_hdr_other_pkg"],
|
||||||
|
arch: {
|
||||||
|
x86: {
|
||||||
|
srcs: ["for-x86.c"],
|
||||||
|
exclude_srcs: ["not-for-x86.c"],
|
||||||
|
generated_sources: ["generated_src_x86"],
|
||||||
|
generated_headers: ["generated_hdr_other_pkg_x86"],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
expectedBazelTargets: []string{`cc_library_static(
|
||||||
|
name = "foo_static3",
|
||||||
|
copts = [
|
||||||
|
"-I.",
|
||||||
|
"-I$(BINDIR)/.",
|
||||||
|
],
|
||||||
|
linkstatic = True,
|
||||||
|
srcs = [
|
||||||
|
"//dep:generated_hdr_other_pkg",
|
||||||
|
"//dep:generated_src_other_pkg",
|
||||||
|
":generated_hdr",
|
||||||
|
":generated_src",
|
||||||
|
"common.c",
|
||||||
|
] + select({
|
||||||
|
"//build/bazel/platforms/arch:x86": [
|
||||||
|
"//dep:generated_hdr_other_pkg_x86",
|
||||||
|
":generated_src_x86",
|
||||||
|
"for-x86.c",
|
||||||
|
],
|
||||||
|
"//conditions:default": ["not-for-x86.c"],
|
||||||
|
}),
|
||||||
)`},
|
)`},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -933,6 +1121,7 @@ cc_library_static {
|
|||||||
cc.RegisterCCBuildComponents(ctx)
|
cc.RegisterCCBuildComponents(ctx)
|
||||||
ctx.RegisterModuleType("toolchain_library", cc.ToolchainLibraryFactory)
|
ctx.RegisterModuleType("toolchain_library", cc.ToolchainLibraryFactory)
|
||||||
ctx.RegisterModuleType("cc_library_headers", cc.LibraryHeaderFactory)
|
ctx.RegisterModuleType("cc_library_headers", cc.LibraryHeaderFactory)
|
||||||
|
ctx.RegisterModuleType("genrule", genrule.GenRuleFactory)
|
||||||
|
|
||||||
ctx.RegisterModuleType(testCase.moduleTypeUnderTest, testCase.moduleTypeUnderTestFactory)
|
ctx.RegisterModuleType(testCase.moduleTypeUnderTest, testCase.moduleTypeUnderTestFactory)
|
||||||
for _, m := range testCase.depsMutators {
|
for _, m := range testCase.depsMutators {
|
||||||
|
@@ -65,7 +65,9 @@ func TestCcObjectBp2Build(t *testing.T) {
|
|||||||
"-Wall",
|
"-Wall",
|
||||||
"-Werror",
|
"-Werror",
|
||||||
"-Iinclude",
|
"-Iinclude",
|
||||||
|
"-I$(BINDIR)/include",
|
||||||
"-I.",
|
"-I.",
|
||||||
|
"-I$(BINDIR)/.",
|
||||||
],
|
],
|
||||||
srcs = ["a/b/c.c"],
|
srcs = ["a/b/c.c"],
|
||||||
)`,
|
)`,
|
||||||
@@ -109,7 +111,9 @@ cc_defaults {
|
|||||||
"-Werror",
|
"-Werror",
|
||||||
"-fno-addrsig",
|
"-fno-addrsig",
|
||||||
"-Iinclude",
|
"-Iinclude",
|
||||||
|
"-I$(BINDIR)/include",
|
||||||
"-I.",
|
"-I.",
|
||||||
|
"-I$(BINDIR)/.",
|
||||||
],
|
],
|
||||||
srcs = ["a/b/c.c"],
|
srcs = ["a/b/c.c"],
|
||||||
)`,
|
)`,
|
||||||
@@ -140,6 +144,7 @@ cc_object {
|
|||||||
copts = [
|
copts = [
|
||||||
"-fno-addrsig",
|
"-fno-addrsig",
|
||||||
"-I.",
|
"-I.",
|
||||||
|
"-I$(BINDIR)/.",
|
||||||
],
|
],
|
||||||
srcs = ["x/y/z.c"],
|
srcs = ["x/y/z.c"],
|
||||||
)`, `cc_object(
|
)`, `cc_object(
|
||||||
@@ -147,6 +152,7 @@ cc_object {
|
|||||||
copts = [
|
copts = [
|
||||||
"-fno-addrsig",
|
"-fno-addrsig",
|
||||||
"-I.",
|
"-I.",
|
||||||
|
"-I$(BINDIR)/.",
|
||||||
],
|
],
|
||||||
deps = [":bar"],
|
deps = [":bar"],
|
||||||
srcs = ["a/b/c.c"],
|
srcs = ["a/b/c.c"],
|
||||||
@@ -284,6 +290,7 @@ func TestCcObjectConfigurableAttributesBp2Build(t *testing.T) {
|
|||||||
copts = [
|
copts = [
|
||||||
"-fno-addrsig",
|
"-fno-addrsig",
|
||||||
"-I.",
|
"-I.",
|
||||||
|
"-I$(BINDIR)/.",
|
||||||
] + select({
|
] + select({
|
||||||
"//build/bazel/platforms/arch:x86": ["-fPIC"],
|
"//build/bazel/platforms/arch:x86": ["-fPIC"],
|
||||||
"//conditions:default": [],
|
"//conditions:default": [],
|
||||||
@@ -329,6 +336,7 @@ func TestCcObjectConfigurableAttributesBp2Build(t *testing.T) {
|
|||||||
copts = [
|
copts = [
|
||||||
"-fno-addrsig",
|
"-fno-addrsig",
|
||||||
"-I.",
|
"-I.",
|
||||||
|
"-I$(BINDIR)/.",
|
||||||
] + select({
|
] + select({
|
||||||
"//build/bazel/platforms/arch:arm": ["-Wall"],
|
"//build/bazel/platforms/arch:arm": ["-Wall"],
|
||||||
"//build/bazel/platforms/arch:arm64": ["-Wall"],
|
"//build/bazel/platforms/arch:arm64": ["-Wall"],
|
||||||
@@ -373,6 +381,7 @@ func TestCcObjectConfigurableAttributesBp2Build(t *testing.T) {
|
|||||||
copts = [
|
copts = [
|
||||||
"-fno-addrsig",
|
"-fno-addrsig",
|
||||||
"-I.",
|
"-I.",
|
||||||
|
"-I$(BINDIR)/.",
|
||||||
] + select({
|
] + select({
|
||||||
"//build/bazel/platforms/os:android": ["-fPIC"],
|
"//build/bazel/platforms/os:android": ["-fPIC"],
|
||||||
"//build/bazel/platforms/os:darwin": ["-Wall"],
|
"//build/bazel/platforms/os:darwin": ["-Wall"],
|
||||||
|
@@ -14,10 +14,11 @@
|
|||||||
package cc
|
package cc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"android/soong/android"
|
|
||||||
"android/soong/bazel"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"android/soong/android"
|
||||||
|
"android/soong/bazel"
|
||||||
)
|
)
|
||||||
|
|
||||||
// bp2build functions and helpers for converting cc_* modules to Bazel.
|
// bp2build functions and helpers for converting cc_* modules to Bazel.
|
||||||
@@ -49,6 +50,22 @@ func depsBp2BuildMutator(ctx android.BottomUpMutatorContext) {
|
|||||||
|
|
||||||
var allDeps []string
|
var allDeps []string
|
||||||
|
|
||||||
|
for _, p := range module.GetTargetProperties(ctx, &BaseCompilerProperties{}) {
|
||||||
|
// base compiler props
|
||||||
|
if baseCompilerProps, ok := p.(*BaseCompilerProperties); ok {
|
||||||
|
allDeps = append(allDeps, baseCompilerProps.Generated_headers...)
|
||||||
|
allDeps = append(allDeps, baseCompilerProps.Generated_sources...)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, p := range module.GetArchProperties(ctx, &BaseCompilerProperties{}) {
|
||||||
|
// arch specific compiler props
|
||||||
|
if baseCompilerProps, ok := p.(*BaseCompilerProperties); ok {
|
||||||
|
allDeps = append(allDeps, baseCompilerProps.Generated_headers...)
|
||||||
|
allDeps = append(allDeps, baseCompilerProps.Generated_sources...)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for _, p := range module.GetTargetProperties(ctx, &BaseLinkerProperties{}) {
|
for _, p := range module.GetTargetProperties(ctx, &BaseLinkerProperties{}) {
|
||||||
// arch specific linker props
|
// arch specific linker props
|
||||||
if baseLinkerProps, ok := p.(*BaseLinkerProperties); ok {
|
if baseLinkerProps, ok := p.(*BaseLinkerProperties); ok {
|
||||||
@@ -173,11 +190,19 @@ func bp2BuildParseCompilerProps(ctx android.TopDownMutatorContext, module *Modul
|
|||||||
var srcs bazel.LabelListAttribute
|
var srcs bazel.LabelListAttribute
|
||||||
var copts bazel.StringListAttribute
|
var copts bazel.StringListAttribute
|
||||||
|
|
||||||
// Creates the -I flag for a directory, while making the directory relative
|
// Creates the -I flags for a directory, while making the directory relative
|
||||||
// to the exec root for Bazel to work.
|
// to the exec root for Bazel to work.
|
||||||
includeFlag := func(dir string) string {
|
includeFlags := func(dir string) []string {
|
||||||
// filepath.Join canonicalizes the path, i.e. it takes care of . or .. elements.
|
// filepath.Join canonicalizes the path, i.e. it takes care of . or .. elements.
|
||||||
return "-I" + filepath.Join(ctx.ModuleDir(), dir)
|
moduleDirRootedPath := filepath.Join(ctx.ModuleDir(), dir)
|
||||||
|
return []string{
|
||||||
|
"-I" + moduleDirRootedPath,
|
||||||
|
// Include the bindir-rooted path (using make variable substitution). This most
|
||||||
|
// closely matches Bazel's native include path handling, which allows for dependency
|
||||||
|
// on generated headers in these directories.
|
||||||
|
// TODO(b/188084383): Handle local include directories in Bazel.
|
||||||
|
"-I$(BINDIR)/" + moduleDirRootedPath,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse the list of module-relative include directories (-I).
|
// Parse the list of module-relative include directories (-I).
|
||||||
@@ -197,7 +222,7 @@ func bp2BuildParseCompilerProps(ctx android.TopDownMutatorContext, module *Modul
|
|||||||
copts = append(copts, strings.Split(flag, " ")...)
|
copts = append(copts, strings.Split(flag, " ")...)
|
||||||
}
|
}
|
||||||
for _, dir := range parseLocalIncludeDirs(baseCompilerProps) {
|
for _, dir := range parseLocalIncludeDirs(baseCompilerProps) {
|
||||||
copts = append(copts, includeFlag(dir))
|
copts = append(copts, includeFlags(dir)...)
|
||||||
}
|
}
|
||||||
return copts
|
return copts
|
||||||
}
|
}
|
||||||
@@ -215,9 +240,17 @@ func bp2BuildParseCompilerProps(ctx android.TopDownMutatorContext, module *Modul
|
|||||||
parseSrcs := func(baseCompilerProps *BaseCompilerProperties) bazel.LabelList {
|
parseSrcs := func(baseCompilerProps *BaseCompilerProperties) bazel.LabelList {
|
||||||
// Combine the base srcs and arch-specific srcs
|
// Combine the base srcs and arch-specific srcs
|
||||||
allSrcs := append(baseSrcs, baseCompilerProps.Srcs...)
|
allSrcs := append(baseSrcs, baseCompilerProps.Srcs...)
|
||||||
|
// Add srcs-like dependencies such as generated files.
|
||||||
|
// First create a LabelList containing these dependencies, then merge the values with srcs.
|
||||||
|
generatedHdrsAndSrcs := baseCompilerProps.Generated_headers
|
||||||
|
generatedHdrsAndSrcs = append(generatedHdrsAndSrcs, baseCompilerProps.Generated_sources...)
|
||||||
|
|
||||||
|
generatedHdrsAndSrcsLabelList := android.BazelLabelForModuleDeps(ctx, generatedHdrsAndSrcs)
|
||||||
|
|
||||||
// Combine the base exclude_srcs and configuration-specific exclude_srcs
|
// Combine the base exclude_srcs and configuration-specific exclude_srcs
|
||||||
allExcludeSrcs := append(baseExcludeSrcs, baseCompilerProps.Exclude_srcs...)
|
allExcludeSrcs := append(baseExcludeSrcs, baseCompilerProps.Exclude_srcs...)
|
||||||
return android.BazelLabelForModuleSrcExcludes(ctx, allSrcs, allExcludeSrcs)
|
allSrcsLabelList := android.BazelLabelForModuleSrcExcludes(ctx, allSrcs, allExcludeSrcs)
|
||||||
|
return bazel.AppendBazelLabelLists(allSrcsLabelList, generatedHdrsAndSrcsLabelList)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, props := range module.compiler.compilerProps() {
|
for _, props := range module.compiler.compilerProps() {
|
||||||
@@ -227,8 +260,8 @@ func bp2BuildParseCompilerProps(ctx android.TopDownMutatorContext, module *Modul
|
|||||||
|
|
||||||
// Used for arch-specific srcs later.
|
// Used for arch-specific srcs later.
|
||||||
baseSrcs = baseCompilerProps.Srcs
|
baseSrcs = baseCompilerProps.Srcs
|
||||||
baseExcludeSrcs = baseCompilerProps.Exclude_srcs
|
|
||||||
baseSrcsLabelList = parseSrcs(baseCompilerProps)
|
baseSrcsLabelList = parseSrcs(baseCompilerProps)
|
||||||
|
baseExcludeSrcs = baseCompilerProps.Exclude_srcs
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -237,9 +270,9 @@ func bp2BuildParseCompilerProps(ctx android.TopDownMutatorContext, module *Modul
|
|||||||
// target has access to all headers recursively in the package, and has
|
// target has access to all headers recursively in the package, and has
|
||||||
// "-I<module-dir>" in its copts.
|
// "-I<module-dir>" in its copts.
|
||||||
if c, ok := module.compiler.(*baseCompiler); ok && c.includeBuildDirectory() {
|
if c, ok := module.compiler.(*baseCompiler); ok && c.includeBuildDirectory() {
|
||||||
copts.Value = append(copts.Value, includeFlag("."))
|
copts.Value = append(copts.Value, includeFlags(".")...)
|
||||||
} else if c, ok := module.compiler.(*libraryDecorator); ok && c.includeBuildDirectory() {
|
} else if c, ok := module.compiler.(*libraryDecorator); ok && c.includeBuildDirectory() {
|
||||||
copts.Value = append(copts.Value, includeFlag("."))
|
copts.Value = append(copts.Value, includeFlags(".")...)
|
||||||
}
|
}
|
||||||
|
|
||||||
for arch, props := range module.GetArchProperties(ctx, &BaseCompilerProperties{}) {
|
for arch, props := range module.GetArchProperties(ctx, &BaseCompilerProperties{}) {
|
||||||
|
Reference in New Issue
Block a user