bp2build: refactor/standardize cc_* bp2build converters
This CL refactors the cc* bp2build converters to use the common
attribute extractors in cc/bp2build.go.
This also adds include_build_directory to be handled by the compiler
attr extractor to generate recursive headers as inputs.
This also turns include_dirs and local_include_dirs into the
execroot-relative -I flags.
e.g. if a module in bionic/libc has "private" in local_include_dirs,
the "-Ibionic/libc/private" copt is generated for it.
Fixes: 185139955
Test: TH
Test: Forrest for mixed_clean-droid
Change-Id: Ib67056482227e62068fbbea0455035bdf5d56319
diff --git a/bp2build/cc_library_conversion_test.go b/bp2build/cc_library_conversion_test.go
index 783af2e..4b6e888 100644
--- a/bp2build/cc_library_conversion_test.go
+++ b/bp2build/cc_library_conversion_test.go
@@ -109,10 +109,22 @@
`,
expectedBazelTargets: []string{`cc_library(
name = "foo-lib",
- copts = ["-Wall"],
+ copts = [
+ "-Wall",
+ "-I.",
+ ],
deps = [":some-headers"],
- hdrs = [
+ hdrs = ["foo-dir/a.h"],
+ includes = ["foo-dir"],
+ linkopts = ["-Wl,--exclude-libs=bar.a"] + select({
+ "//build/bazel/platforms/arch:x86": ["-Wl,--exclude-libs=baz.a"],
+ "//build/bazel/platforms/arch:x86_64": ["-Wl,--exclude-libs=qux.a"],
+ "//conditions:default": [],
+ }),
+ srcs = [
+ "impl.cpp",
"header.h",
+ "foo-dir/a.h",
"header.hh",
"header.hpp",
"header.hxx",
@@ -121,15 +133,7 @@
"header.inc",
"header.ipp",
"header.h.generic",
- "foo-dir/a.h",
- ],
- includes = ["foo-dir"],
- linkopts = ["-Wl,--exclude-libs=bar.a"] + select({
- "//build/bazel/platforms/arch:x86": ["-Wl,--exclude-libs=baz.a"],
- "//build/bazel/platforms/arch:x86_64": ["-Wl,--exclude-libs=qux.a"],
- "//conditions:default": [],
- }),
- srcs = ["impl.cpp"] + select({
+ ] + select({
"//build/bazel/platforms/arch:x86": ["x86.cpp"],
"//build/bazel/platforms/arch:x86_64": ["x86_64.cpp"],
"//conditions:default": [],
@@ -190,14 +194,9 @@
"-Wextra",
"-Wunused",
"-Werror",
+ "-I.",
],
deps = [":libc_headers"],
- hdrs = [
- "linked_list.h",
- "linker.h",
- "linker_block_allocator.h",
- "linker_cfi.h",
- ],
linkopts = [
"-Wl,--exclude-libs=libgcc.a",
"-Wl,--exclude-libs=libgcc_stripped.a",
@@ -210,7 +209,13 @@
"//build/bazel/platforms/arch:x86_64": ["-Wl,--exclude-libs=libgcc_eh.a"],
"//conditions:default": [],
}),
- srcs = ["ld_android.cpp"],
+ srcs = [
+ "ld_android.cpp",
+ "linked_list.h",
+ "linker.h",
+ "linker_block_allocator.h",
+ "linker_cfi.h",
+ ],
)`},
},
}