bp2build: Handle export_generated_header property
The generated_header property resides in BaseCompilerProperties, while
export_generated_header resides in BaseLinkerProperties. Previously
bp2build handled these property structs separately; however, these two
related properties residing in separate structs requires restructuring
the code to allow access to both BaseCompilerProperties and
BaseLinkerProperties for a single axis/configuration combination to
resolve which generated headers are exported/not for the
axis/configuration..
Test: go test soong tests
Test: build/bazel/ci/bp2build.sh
Change-Id: Id150003637fd19d87e8dc5d6941e9f36dc4031dd
diff --git a/bp2build/cc_binary_conversion_test.go b/bp2build/cc_binary_conversion_test.go
index 3a07128..0b71d89 100644
--- a/bp2build/cc_binary_conversion_test.go
+++ b/bp2build/cc_binary_conversion_test.go
@@ -17,6 +17,7 @@
import (
"android/soong/android"
"android/soong/cc"
+ "android/soong/genrule"
"fmt"
"strings"
"testing"
@@ -32,6 +33,7 @@
ctx.RegisterModuleType("filegroup", android.FileGroupFactory)
ctx.RegisterModuleType("cc_library_static", cc.LibraryStaticFactory)
ctx.RegisterModuleType("cc_library", cc.LibraryFactory)
+ ctx.RegisterModuleType("genrule", genrule.GenRuleFactory)
}
var binaryReplacer = strings.NewReplacer(ccBinaryTypePlaceHolder, "cc_binary", compatibleWithPlaceHolder, "")
@@ -220,14 +222,27 @@
runCcBinaryTestCase(t, bp2buildTestCase{
description: "no implementation deps",
blueprint: `
+genrule {
+ name: "generated_hdr",
+ cmd: "nothing to see here",
+}
+
+genrule {
+ name: "export_generated_hdr",
+ cmd: "nothing to see here",
+}
+
{rule_name} {
name: "foo",
+ srcs: ["foo.cpp"],
shared_libs: ["implementation_shared_dep", "shared_dep"],
export_shared_lib_headers: ["shared_dep"],
static_libs: ["implementation_static_dep", "static_dep"],
export_static_lib_headers: ["static_dep", "whole_static_dep"],
whole_static_libs: ["not_explicitly_exported_whole_static_dep", "whole_static_dep"],
include_build_directory: false,
+ generated_headers: ["generated_hdr", "export_generated_hdr"],
+ export_generated_headers: ["export_generated_hdr"],
}
` +
simpleModuleDoNotConvertBp2build("cc_library_static", "static_dep") +
@@ -245,6 +260,11 @@
dynamic_deps = [
":implementation_shared_dep",
":shared_dep",
+ ],
+ srcs = [
+ "foo.cpp",
+ ":generated_hdr",
+ ":export_generated_hdr",
],{target_compatible_with}
whole_archive_deps = [
":not_explicitly_exported_whole_static_dep",