Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6244df2a authored by Liz Kammer's avatar Liz Kammer Committed by Gerrit Code Review
Browse files

Merge "bp2build: Add support for export_.*headers props"

parents f3c6843b 7a210ac2
Loading
Loading
Loading
Loading
+0 −7
Original line number Diff line number Diff line
@@ -218,13 +218,6 @@ var (
		"libc_ndk",          // http://b/187013218, cc_library_static, depends on //bionic/libm:libm (http://b/183064661)
		"libc_malloc_hooks", // http://b/187016307, cc_library, ld.lld: error: undefined symbol: __malloc_hook

		// There are unexported symbols that don't surface on a shared library build,
		// from the source static archive
		// e.g. _Unwind_{GetRegionStart,GetLanguageSpecificData,GetIP,Set{IP,GR},Resume,{Raise,Delete}Exception}, pthread_atfork
		// ... from: cxa_{personality,exception}.o, system_error.o, wrappers_c_bionic.o
		// cf. http://b/198403271
		"libc++",

		// http://b/186823769: Needs C++ STL support, includes from unconverted standard libraries in //external/libcxx
		// c++_static
		"libbase_ndk", // http://b/186826477, cc_library, no such target '//build/bazel/platforms/os:darwin' when --platforms //build/bazel/platforms:android_x86 is added
+1 −0
Original line number Diff line number Diff line
@@ -635,6 +635,7 @@ func extractStructProperties(structValue reflect.Value, indent int) map[string]s
			// Ignore zero-valued fields
			continue
		}

		// if the struct is embedded (anonymous), flatten the properties into the containing struct
		if field.Anonymous {
			if field.Type.Kind() == reflect.Ptr {
+124 −25
Original line number Diff line number Diff line
@@ -349,21 +349,21 @@ cc_library {
		expectedBazelTargets: []string{`cc_library(
    name = "a",
    copts = ["bothflag"],
    dynamic_deps = [":shared_dep_for_both"],
    implementation_deps = [":static_dep_for_both"],
    implementation_dynamic_deps = [":shared_dep_for_both"],
    shared = {
        "copts": ["sharedflag"],
        "dynamic_deps": [":shared_dep_for_shared"],
        "implementation_deps": [":static_dep_for_shared"],
        "implementation_dynamic_deps": [":shared_dep_for_shared"],
        "srcs": ["sharedonly.cpp"],
        "static_deps": [":static_dep_for_shared"],
        "whole_archive_deps": [":whole_static_lib_for_shared"],
    },
    srcs = ["both.cpp"],
    static = {
        "copts": ["staticflag"],
        "dynamic_deps": [":shared_dep_for_static"],
        "implementation_deps": [":static_dep_for_static"],
        "implementation_dynamic_deps": [":shared_dep_for_static"],
        "srcs": ["staticonly.cpp"],
        "static_deps": [":static_dep_for_static"],
        "whole_archive_deps": [":whole_static_lib_for_static"],
    },
    whole_archive_deps = [":whole_static_lib_for_both"],
@@ -371,6 +371,105 @@ cc_library {
	})
}

func TestCcLibraryDeps(t *testing.T) {
	runCcLibraryTestCase(t, bp2buildTestCase{
		description:                        "cc_library shared/static props",
		moduleTypeUnderTest:                "cc_library",
		moduleTypeUnderTestFactory:         cc.LibraryFactory,
		moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryBp2Build,
		filesystem: map[string]string{
			"both.cpp":       "",
			"sharedonly.cpp": "",
			"staticonly.cpp": "",
		},
		blueprint: soongCcLibraryPreamble + `
cc_library {
    name: "a",
    srcs: ["both.cpp"],
    cflags: ["bothflag"],
    shared_libs: ["implementation_shared_dep_for_both", "shared_dep_for_both"],
    export_shared_lib_headers: ["shared_dep_for_both"],
    static_libs: ["implementation_static_dep_for_both", "static_dep_for_both"],
    export_static_lib_headers: ["static_dep_for_both", "whole_static_dep_for_both"],
    whole_static_libs: ["not_explicitly_exported_whole_static_dep_for_both", "whole_static_dep_for_both"],
    static: {
        srcs: ["staticonly.cpp"],
        cflags: ["staticflag"],
        shared_libs: ["implementation_shared_dep_for_static", "shared_dep_for_static"],
        export_shared_lib_headers: ["shared_dep_for_static"],
        static_libs: ["implementation_static_dep_for_static", "static_dep_for_static"],
        export_static_lib_headers: ["static_dep_for_static", "whole_static_dep_for_static"],
        whole_static_libs: ["not_explicitly_exported_whole_static_dep_for_static", "whole_static_dep_for_static"],
    },
    shared: {
        srcs: ["sharedonly.cpp"],
        cflags: ["sharedflag"],
        shared_libs: ["implementation_shared_dep_for_shared", "shared_dep_for_shared"],
        export_shared_lib_headers: ["shared_dep_for_shared"],
        static_libs: ["implementation_static_dep_for_shared", "static_dep_for_shared"],
        export_static_lib_headers: ["static_dep_for_shared", "whole_static_dep_for_shared"],
        whole_static_libs: ["not_explicitly_exported_whole_static_dep_for_shared", "whole_static_dep_for_shared"],
    },
    include_build_directory: false,
}
` + simpleModuleDoNotConvertBp2build("cc_library_static", "static_dep_for_shared") +
			simpleModuleDoNotConvertBp2build("cc_library_static", "implementation_static_dep_for_shared") +
			simpleModuleDoNotConvertBp2build("cc_library_static", "static_dep_for_static") +
			simpleModuleDoNotConvertBp2build("cc_library_static", "implementation_static_dep_for_static") +
			simpleModuleDoNotConvertBp2build("cc_library_static", "static_dep_for_both") +
			simpleModuleDoNotConvertBp2build("cc_library_static", "implementation_static_dep_for_both") +
			simpleModuleDoNotConvertBp2build("cc_library_static", "whole_static_dep_for_shared") +
			simpleModuleDoNotConvertBp2build("cc_library_static", "not_explicitly_exported_whole_static_dep_for_shared") +
			simpleModuleDoNotConvertBp2build("cc_library_static", "whole_static_dep_for_static") +
			simpleModuleDoNotConvertBp2build("cc_library_static", "not_explicitly_exported_whole_static_dep_for_static") +
			simpleModuleDoNotConvertBp2build("cc_library_static", "whole_static_dep_for_both") +
			simpleModuleDoNotConvertBp2build("cc_library_static", "not_explicitly_exported_whole_static_dep_for_both") +
			simpleModuleDoNotConvertBp2build("cc_library", "shared_dep_for_shared") +
			simpleModuleDoNotConvertBp2build("cc_library", "implementation_shared_dep_for_shared") +
			simpleModuleDoNotConvertBp2build("cc_library", "shared_dep_for_static") +
			simpleModuleDoNotConvertBp2build("cc_library", "implementation_shared_dep_for_static") +
			simpleModuleDoNotConvertBp2build("cc_library", "shared_dep_for_both") +
			simpleModuleDoNotConvertBp2build("cc_library", "implementation_shared_dep_for_both"),
		expectedBazelTargets: []string{`cc_library(
    name = "a",
    copts = ["bothflag"],
    deps = [":static_dep_for_both"],
    dynamic_deps = [":shared_dep_for_both"],
    implementation_deps = [":implementation_static_dep_for_both"],
    implementation_dynamic_deps = [":implementation_shared_dep_for_both"],
    shared = {
        "copts": ["sharedflag"],
        "deps": [":static_dep_for_shared"],
        "dynamic_deps": [":shared_dep_for_shared"],
        "implementation_deps": [":implementation_static_dep_for_shared"],
        "implementation_dynamic_deps": [":implementation_shared_dep_for_shared"],
        "srcs": ["sharedonly.cpp"],
        "whole_archive_deps": [
            ":not_explicitly_exported_whole_static_dep_for_shared",
            ":whole_static_dep_for_shared",
        ],
    },
    srcs = ["both.cpp"],
    static = {
        "copts": ["staticflag"],
        "deps": [":static_dep_for_static"],
        "dynamic_deps": [":shared_dep_for_static"],
        "implementation_deps": [":implementation_static_dep_for_static"],
        "implementation_dynamic_deps": [":implementation_shared_dep_for_static"],
        "srcs": ["staticonly.cpp"],
        "whole_archive_deps": [
            ":not_explicitly_exported_whole_static_dep_for_static",
            ":whole_static_dep_for_static",
        ],
    },
    whole_archive_deps = [
        ":not_explicitly_exported_whole_static_dep_for_both",
        ":whole_static_dep_for_both",
    ],
)`},
	})
}

func TestCcLibraryWholeStaticLibsAlwaysLink(t *testing.T) {
	runCcLibraryTestCase(t, bp2buildTestCase{
		moduleTypeUnderTest:                "cc_library",
@@ -506,7 +605,14 @@ cc_library_static { name: "android_dep_for_shared" }
            "//build/bazel/platforms/os_arch:android_arm": ["-DANDROID_ARM_SHARED"],
            "//conditions:default": [],
        }),
        "dynamic_deps": select({
        "implementation_deps": [":static_dep_for_shared"] + select({
            "//build/bazel/platforms/arch:arm": [":arm_static_dep_for_shared"],
            "//conditions:default": [],
        }) + select({
            "//build/bazel/platforms/os:android": [":android_dep_for_shared"],
            "//conditions:default": [],
        }),
        "implementation_dynamic_deps": select({
            "//build/bazel/platforms/arch:arm": [":arm_shared_dep_for_shared"],
            "//conditions:default": [],
        }),
@@ -517,13 +623,6 @@ cc_library_static { name: "android_dep_for_shared" }
            "//build/bazel/platforms/os:android": ["android_shared.cpp"],
            "//conditions:default": [],
        }),
        "static_deps": [":static_dep_for_shared"] + select({
            "//build/bazel/platforms/arch:arm": [":arm_static_dep_for_shared"],
            "//conditions:default": [],
        }) + select({
            "//build/bazel/platforms/os:android": [":android_dep_for_shared"],
            "//conditions:default": [],
        }),
        "whole_archive_deps": select({
            "//build/bazel/platforms/arch:arm": [":arm_whole_static_dep_for_shared"],
            "//conditions:default": [],
@@ -535,12 +634,12 @@ cc_library_static { name: "android_dep_for_shared" }
            "//build/bazel/platforms/arch:x86": ["-DX86_STATIC"],
            "//conditions:default": [],
        }),
        "srcs": ["staticonly.cpp"] + select({
            "//build/bazel/platforms/arch:x86": ["x86_static.cpp"],
        "implementation_deps": [":static_dep_for_static"] + select({
            "//build/bazel/platforms/arch:x86": [":x86_dep_for_static"],
            "//conditions:default": [],
        }),
        "static_deps": [":static_dep_for_static"] + select({
            "//build/bazel/platforms/arch:x86": [":x86_dep_for_static"],
        "srcs": ["staticonly.cpp"] + select({
            "//build/bazel/platforms/arch:x86": ["x86_static.cpp"],
            "//conditions:default": [],
        }),
    },
@@ -767,7 +866,7 @@ cc_library {
`,
		expectedBazelTargets: []string{`cc_library(
    name = "a",
    dynamic_deps = [":mylib"],
    implementation_dynamic_deps = [":mylib"],
)`},
	})
}
@@ -1013,13 +1112,6 @@ cc_library {
		expectedBazelTargets: []string{
			`cc_library(
    name = "foo_static",
    dynamic_deps = select({
        "//build/bazel/platforms/arch:arm": [],
        "//conditions:default": [":arm_shared_lib_excludes"],
    }) + select({
        "//build/bazel/product_variables:malloc_not_svelte": [":malloc_not_svelte_shared_lib"],
        "//conditions:default": [],
    }),
    implementation_deps = select({
        "//build/bazel/platforms/arch:arm": [],
        "//conditions:default": [":arm_static_lib_excludes_bp2build_cc_library_static"],
@@ -1027,6 +1119,13 @@ cc_library {
        "//build/bazel/product_variables:malloc_not_svelte": [],
        "//conditions:default": [":malloc_not_svelte_static_lib_excludes_bp2build_cc_library_static"],
    }),
    implementation_dynamic_deps = select({
        "//build/bazel/platforms/arch:arm": [],
        "//conditions:default": [":arm_shared_lib_excludes"],
    }) + select({
        "//build/bazel/product_variables:malloc_not_svelte": [":malloc_not_svelte_shared_lib"],
        "//conditions:default": [],
    }),
    srcs_c = ["common.c"],
    whole_archive_deps = select({
        "//build/bazel/platforms/arch:arm": [],
+4 −1
Original line number Diff line number Diff line
@@ -224,7 +224,10 @@ cc_library_headers {
cc_library_headers {
    name: "foo_headers",
    target: {
        android: { header_libs: ["android-lib"], export_header_lib_headers: ["exported-lib"] },
        android: {
            header_libs: ["android-lib", "exported-lib"],
            export_header_lib_headers: ["exported-lib"]
        },
    },
    include_build_directory: false,
}`,
+7 −7
Original line number Diff line number Diff line
@@ -149,10 +149,6 @@ cc_library_shared {
        "-Dflag1",
        "-Dflag2",
    ],
    dynamic_deps = [
        ":shared_lib_1",
        ":shared_lib_2",
    ],
    export_includes = [
        "export_include_dir_1",
        "export_include_dir_2",
@@ -161,6 +157,10 @@ cc_library_shared {
        ":header_lib_1",
        ":header_lib_2",
    ],
    implementation_dynamic_deps = [
        ":shared_lib_1",
        ":shared_lib_2",
    ],
    local_includes = [
        "local_include_dir_1",
        "local_include_dir_2",
@@ -201,7 +201,7 @@ cc_library_shared {
}`,
		expectedBazelTargets: []string{`cc_library_shared(
    name = "foo_shared",
    dynamic_deps = select({
    implementation_dynamic_deps = select({
        "//build/bazel/platforms/arch:arm64": [":shared_dep"],
        "//conditions:default": [],
    }),
@@ -232,7 +232,7 @@ cc_library_shared {
}`,
		expectedBazelTargets: []string{`cc_library_shared(
    name = "foo_shared",
    dynamic_deps = select({
    implementation_dynamic_deps = select({
        "//build/bazel/platforms/os:android": [":shared_dep"],
        "//conditions:default": [],
    }),
@@ -269,7 +269,7 @@ cc_library_shared {
}`,
		expectedBazelTargets: []string{`cc_library_shared(
    name = "foo_shared",
    dynamic_deps = [":shared_dep"] + select({
    implementation_dynamic_deps = [":shared_dep"] + select({
        "//build/bazel/platforms/arch:arm64": [":shared_dep3"],
        "//conditions:default": [],
    }) + select({
Loading