|
@@ -308,6 +308,75 @@ cc_library {
|
|
|
android.AssertPathsRelativeToTopEquals(t, "deps", []string{"outputbase/execroot/__main__/foo.h"}, flagExporter.Deps)
|
|
|
}
|
|
|
|
|
|
+func TestCcLibraryWithBazelValidations(t *testing.T) {
|
|
|
+ t.Parallel()
|
|
|
+ bp := `
|
|
|
+cc_library {
|
|
|
+ name: "foo",
|
|
|
+ srcs: ["foo.cc"],
|
|
|
+ bazel_module: { label: "//foo/bar:bar" },
|
|
|
+ tidy: true,
|
|
|
+}`
|
|
|
+ config := TestConfig(t.TempDir(), android.Android, nil, bp, nil)
|
|
|
+ config.BazelContext = android.MockBazelContext{
|
|
|
+ OutputBaseDir: "outputbase",
|
|
|
+ LabelToCcInfo: map[string]cquery.CcInfo{
|
|
|
+ "//foo/bar:bar": cquery.CcInfo{
|
|
|
+ CcObjectFiles: []string{"foo.o"},
|
|
|
+ Includes: []string{"include"},
|
|
|
+ SystemIncludes: []string{"system_include"},
|
|
|
+ Headers: []string{"foo.h"},
|
|
|
+ RootDynamicLibraries: []string{"foo.so"},
|
|
|
+ UnstrippedOutput: "foo_unstripped.so",
|
|
|
+ },
|
|
|
+ "//foo/bar:bar_bp2build_cc_library_static": cquery.CcInfo{
|
|
|
+ CcObjectFiles: []string{"foo.o"},
|
|
|
+ Includes: []string{"include"},
|
|
|
+ SystemIncludes: []string{"system_include"},
|
|
|
+ Headers: []string{"foo.h"},
|
|
|
+ RootStaticArchives: []string{"foo.a"},
|
|
|
+ TidyFiles: []string{"foo.c.tidy"},
|
|
|
+ },
|
|
|
+ },
|
|
|
+ }
|
|
|
+ ctx := android.GroupFixturePreparers(
|
|
|
+ prepareForCcTest,
|
|
|
+ android.FixtureMergeEnv(map[string]string{
|
|
|
+ "ALLOW_LOCAL_TIDY_TRUE": "1",
|
|
|
+ }),
|
|
|
+ ).RunTestWithConfig(t, config).TestContext
|
|
|
+
|
|
|
+ staticFoo := ctx.ModuleForTests("foo", "android_arm_armv7-a-neon_static").Module()
|
|
|
+ outputFiles, err := staticFoo.(android.OutputFileProducer).OutputFiles("")
|
|
|
+ if err != nil {
|
|
|
+ t.Errorf("Unexpected error getting cc_object outputfiles %s", err)
|
|
|
+ }
|
|
|
+
|
|
|
+ expectedOutputFiles := []string{"out/soong/.intermediates/foo/android_arm_armv7-a-neon_static/validated/foo.a"}
|
|
|
+ android.AssertPathsRelativeToTopEquals(t, "output files", expectedOutputFiles, outputFiles)
|
|
|
+
|
|
|
+ flagExporter := ctx.ModuleProvider(staticFoo, FlagExporterInfoProvider).(FlagExporterInfo)
|
|
|
+ android.AssertPathsRelativeToTopEquals(t, "exported include dirs", []string{"outputbase/execroot/__main__/include"}, flagExporter.IncludeDirs)
|
|
|
+ android.AssertPathsRelativeToTopEquals(t, "exported system include dirs", []string{"outputbase/execroot/__main__/system_include"}, flagExporter.SystemIncludeDirs)
|
|
|
+ android.AssertPathsRelativeToTopEquals(t, "exported headers", []string{"outputbase/execroot/__main__/foo.h"}, flagExporter.GeneratedHeaders)
|
|
|
+ android.AssertPathsRelativeToTopEquals(t, "deps", []string{"outputbase/execroot/__main__/foo.h"}, flagExporter.Deps)
|
|
|
+
|
|
|
+ sharedFoo := ctx.ModuleForTests("foo", "android_arm_armv7-a-neon_shared").Module()
|
|
|
+ outputFiles, err = sharedFoo.(android.OutputFileProducer).OutputFiles("")
|
|
|
+ if err != nil {
|
|
|
+ t.Errorf("Unexpected error getting cc_library outputfiles %s", err)
|
|
|
+ }
|
|
|
+ expectedOutputFiles = []string{"outputbase/execroot/__main__/foo.so"}
|
|
|
+ android.AssertDeepEquals(t, "output files", expectedOutputFiles, outputFiles.Strings())
|
|
|
+
|
|
|
+ android.AssertStringEquals(t, "unstripped shared library", "outputbase/execroot/__main__/foo_unstripped.so", sharedFoo.(*Module).linker.unstrippedOutputFilePath().String())
|
|
|
+ flagExporter = ctx.ModuleProvider(sharedFoo, FlagExporterInfoProvider).(FlagExporterInfo)
|
|
|
+ android.AssertPathsRelativeToTopEquals(t, "exported include dirs", []string{"outputbase/execroot/__main__/include"}, flagExporter.IncludeDirs)
|
|
|
+ android.AssertPathsRelativeToTopEquals(t, "exported system include dirs", []string{"outputbase/execroot/__main__/system_include"}, flagExporter.SystemIncludeDirs)
|
|
|
+ android.AssertPathsRelativeToTopEquals(t, "exported headers", []string{"outputbase/execroot/__main__/foo.h"}, flagExporter.GeneratedHeaders)
|
|
|
+ android.AssertPathsRelativeToTopEquals(t, "deps", []string{"outputbase/execroot/__main__/foo.h"}, flagExporter.Deps)
|
|
|
+}
|
|
|
+
|
|
|
func TestLibraryVersionScript(t *testing.T) {
|
|
|
t.Parallel()
|
|
|
result := PrepareForIntegrationTestWithCc.RunTestWithBp(t, `
|
|
@@ -344,6 +413,59 @@ func TestLibraryDynamicList(t *testing.T) {
|
|
|
|
|
|
}
|
|
|
|
|
|
+func TestCcLibrarySharedWithBazelValidations(t *testing.T) {
|
|
|
+ t.Parallel()
|
|
|
+ bp := `
|
|
|
+cc_library_shared {
|
|
|
+ name: "foo",
|
|
|
+ srcs: ["foo.cc"],
|
|
|
+ bazel_module: { label: "//foo/bar:bar" },
|
|
|
+ tidy: true,
|
|
|
+}`
|
|
|
+ config := TestConfig(t.TempDir(), android.Android, nil, bp, nil)
|
|
|
+ config.BazelContext = android.MockBazelContext{
|
|
|
+ OutputBaseDir: "outputbase",
|
|
|
+ LabelToCcInfo: map[string]cquery.CcInfo{
|
|
|
+ "//foo/bar:bar": cquery.CcInfo{
|
|
|
+ CcObjectFiles: []string{"foo.o"},
|
|
|
+ Includes: []string{"include"},
|
|
|
+ SystemIncludes: []string{"system_include"},
|
|
|
+ RootDynamicLibraries: []string{"foo.so"},
|
|
|
+ TocFile: "foo.so.toc",
|
|
|
+ TidyFiles: []string{"foo.c.tidy"},
|
|
|
+ },
|
|
|
+ },
|
|
|
+ }
|
|
|
+ ctx := android.GroupFixturePreparers(
|
|
|
+ prepareForCcTest,
|
|
|
+ android.FixtureMergeEnv(map[string]string{
|
|
|
+ "ALLOW_LOCAL_TIDY_TRUE": "1",
|
|
|
+ }),
|
|
|
+ ).RunTestWithConfig(t, config).TestContext
|
|
|
+
|
|
|
+ sharedFoo := ctx.ModuleForTests("foo", "android_arm_armv7-a-neon_shared").Module()
|
|
|
+ producer := sharedFoo.(android.OutputFileProducer)
|
|
|
+ outputFiles, err := producer.OutputFiles("")
|
|
|
+ if err != nil {
|
|
|
+ t.Errorf("Unexpected error getting cc_object outputfiles %s", err)
|
|
|
+ }
|
|
|
+ expectedOutputFiles := []string{"out/soong/.intermediates/foo/android_arm_armv7-a-neon_shared/validated/foo.so"}
|
|
|
+ android.AssertPathsRelativeToTopEquals(t, "output files", expectedOutputFiles, outputFiles)
|
|
|
+
|
|
|
+ tocFilePath := sharedFoo.(*Module).Toc()
|
|
|
+ if !tocFilePath.Valid() {
|
|
|
+ t.Errorf("Invalid tocFilePath: %s", tocFilePath)
|
|
|
+ }
|
|
|
+ tocFile := tocFilePath.Path()
|
|
|
+ expectedToc := "outputbase/execroot/__main__/foo.so.toc"
|
|
|
+ android.AssertStringEquals(t, "toc file", expectedToc, tocFile.String())
|
|
|
+
|
|
|
+ entries := android.AndroidMkEntriesForTest(t, ctx, sharedFoo)[0]
|
|
|
+ expectedFlags := []string{"-Ioutputbase/execroot/__main__/include", "-isystem outputbase/execroot/__main__/system_include"}
|
|
|
+ gotFlags := entries.EntryMap["LOCAL_EXPORT_CFLAGS"]
|
|
|
+ android.AssertDeepEquals(t, "androidmk exported cflags", expectedFlags, gotFlags)
|
|
|
+}
|
|
|
+
|
|
|
func TestCcLibrarySharedWithBazel(t *testing.T) {
|
|
|
t.Parallel()
|
|
|
bp := `
|