Merge "Gen a header library when genrules export includes" into main
This commit is contained in:
@@ -1003,6 +1003,38 @@ cc_library_static {
|
||||
})
|
||||
}
|
||||
|
||||
func TestCcLibraryStaticGeneratedHeadersMultipleExports(t *testing.T) {
|
||||
runCcLibraryStaticTestCase(t, Bp2buildTestCase{
|
||||
Blueprint: soongCcLibraryStaticPreamble + `
|
||||
genrule {
|
||||
name: "generated_hdr",
|
||||
cmd: "nothing to see here",
|
||||
export_include_dirs: ["foo", "bar"],
|
||||
bazel_module: { bp2build_available: false },
|
||||
}
|
||||
|
||||
genrule {
|
||||
name: "export_generated_hdr",
|
||||
cmd: "nothing to see here",
|
||||
export_include_dirs: ["a", "b"],
|
||||
bazel_module: { bp2build_available: false },
|
||||
}
|
||||
|
||||
cc_library_static {
|
||||
name: "foo_static",
|
||||
generated_headers: ["generated_hdr", "export_generated_hdr"],
|
||||
export_generated_headers: ["export_generated_hdr"],
|
||||
include_build_directory: false,
|
||||
}`,
|
||||
ExpectedBazelTargets: []string{
|
||||
MakeBazelTarget("cc_library_static", "foo_static", AttrNameToString{
|
||||
"deps": `[":export_generated_hdr__header_library"]`,
|
||||
"implementation_deps": `[":generated_hdr__header_library"]`,
|
||||
}),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
// generated_headers has "variant_prepend" tag. In bp2build output,
|
||||
// variant info(select) should go before general info.
|
||||
func TestCcLibraryStaticArchSrcsExcludeSrcsGeneratedFiles(t *testing.T) {
|
||||
|
||||
@@ -16,6 +16,7 @@ package bp2build
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"android/soong/android"
|
||||
@@ -695,3 +696,79 @@ func TestCcGenruleArchAndExcludeSrcs(t *testing.T) {
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
func TestGenruleWithExportIncludeDirs(t *testing.T) {
|
||||
testCases := []struct {
|
||||
moduleType string
|
||||
factory android.ModuleFactory
|
||||
hod android.HostOrDeviceSupported
|
||||
}{
|
||||
{
|
||||
moduleType: "genrule",
|
||||
factory: genrule.GenRuleFactory,
|
||||
},
|
||||
{
|
||||
moduleType: "cc_genrule",
|
||||
factory: cc.GenRuleFactory,
|
||||
hod: android.DeviceSupported,
|
||||
},
|
||||
{
|
||||
moduleType: "java_genrule",
|
||||
factory: java.GenRuleFactory,
|
||||
hod: android.DeviceSupported,
|
||||
},
|
||||
{
|
||||
moduleType: "java_genrule_host",
|
||||
factory: java.GenRuleFactoryHost,
|
||||
hod: android.HostSupported,
|
||||
},
|
||||
}
|
||||
|
||||
dir := "baz"
|
||||
|
||||
bp := `%s {
|
||||
name: "foo",
|
||||
out: ["foo.out.h"],
|
||||
srcs: ["foo.in"],
|
||||
cmd: "cp $(in) $(out)",
|
||||
export_include_dirs: ["foo", "bar", "."],
|
||||
bazel_module: { bp2build_available: true },
|
||||
}`
|
||||
|
||||
for _, tc := range testCases {
|
||||
moduleAttrs := AttrNameToString{
|
||||
"cmd": `"cp $(SRCS) $(OUTS)"`,
|
||||
"outs": `["foo.out.h"]`,
|
||||
"srcs": `["foo.in"]`,
|
||||
}
|
||||
|
||||
expectedBazelTargets := []string{
|
||||
makeBazelTargetHostOrDevice("genrule", "foo", moduleAttrs, tc.hod),
|
||||
makeBazelTargetHostOrDevice("cc_library_headers", "foo__header_library", AttrNameToString{
|
||||
"hdrs": `[":foo"]`,
|
||||
"export_includes": `[
|
||||
"foo",
|
||||
"baz/foo",
|
||||
"bar",
|
||||
"baz/bar",
|
||||
".",
|
||||
"baz",
|
||||
]`,
|
||||
},
|
||||
tc.hod),
|
||||
}
|
||||
|
||||
t.Run(tc.moduleType, func(t *testing.T) {
|
||||
RunBp2BuildTestCase(t, func(ctx android.RegistrationContext) {},
|
||||
Bp2buildTestCase{
|
||||
ModuleTypeUnderTest: tc.moduleType,
|
||||
ModuleTypeUnderTestFactory: tc.factory,
|
||||
Filesystem: map[string]string{
|
||||
filepath.Join(dir, "Android.bp"): fmt.Sprintf(bp, tc.moduleType),
|
||||
},
|
||||
Dir: dir,
|
||||
ExpectedBazelTargets: expectedBazelTargets,
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user