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

Commit 69fa9f9e authored by Chris Parsons's avatar Chris Parsons
Browse files

Seperate asflags and cflags

This fixes a bug which was a misunderstanding of soong properties:
Soong's cflags pertain only to C and C++ language, whereas bazel's copts
pertain to all three languages. This change ensures that asflags are
added as specifically asflags, and the 'copts' for the static library
macro pertains only to C and C++ languages.

This requires a somewhat hacky workaround for asflags, however: Since
assembly sources also need includepath-related flags, this duplicates
these flags between copts and asflags. To reduce verbosity of
bp2build-generated targets, this also ensures that asflags are omitted
in cases where there are no assembly sources.

Test: Mixed build droid CI
Change-Id: Ic0babed1f90d6dc82e5788638681ce5b995043f8
parent 73c7755a
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -180,7 +180,6 @@ var (
		//                                                       also depends on //system/logging/liblog:liblog (http://b/186822772)
		"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
		"libm",              // http://b/183064661, cc_library, math.h:25:16: error: unexpected token in argument list

		// http://b/186823769: Needs C++ STL support, includes from unconverted standard libraries in //external/libcxx
		// c++_static
@@ -189,7 +188,7 @@ var (
		"libBionicBenchmarksUtils", // cc_library_static, fatal error: 'map' file not found, from libcxx
		"fmtlib",                   // cc_library_static, fatal error: 'cassert' file not found, from libcxx
		"fmtlib_ndk",               // cc_library_static, fatal error: 'cassert' file not found
		"libbase",                  // http://b/186826479, cc_library, fatal error: 'memory' file not found, from libcxx
		"libbase",                  // Requires liblog. http://b/186826479, cc_library, fatal error: 'memory' file not found, from libcxx.

		// http://b/186024507: Includes errors because of the system_shared_libs default value.
		// Missing -isystem bionic/libc/include through the libc/libm/libdl
+13 −0
Original line number Diff line number Diff line
@@ -558,6 +558,19 @@ func (lla LabelListAttribute) HasConfigurableValues() bool {
	return len(lla.ConfigurableValues) > 0
}

// IsEmpty returns true if the attribute has no values under any configuration.
func (lla LabelListAttribute) IsEmpty() bool {
	if len(lla.Value.Includes) > 0 {
		return false
	}
	for axis, _ := range lla.ConfigurableValues {
		if lla.ConfigurableValues[axis].HasConfigurableValues() {
			return false
		}
	}
	return true
}

// ResolveExcludes handles excludes across the various axes, ensuring that items are removed from
// the base value and included in default values as appropriate.
func (lla *LabelListAttribute) ResolveExcludes() {
+4 −0
Original line number Diff line number Diff line
@@ -674,6 +674,10 @@ filegroup {
		blueprint: soongCcLibraryPreamble,
		expectedBazelTargets: []string{`cc_library(
    name = "a",
    asflags = [
        "-Ifoo/bar",
        "-I$(BINDIR)/foo/bar",
    ],
    copts = [
        "-Ifoo/bar",
        "-I$(BINDIR)/foo/bar",
+7 −4
Original line number Diff line number Diff line
@@ -1413,7 +1413,7 @@ cc_library_static {

func TestCcLibraryStaticProductVariableStringReplacement(t *testing.T) {
	runCcLibraryStaticTestCase(t, bp2buildTestCase{
		description:                        "cc_library_static product variable selects",
		description:                        "cc_library_static product variable string replacement",
		moduleTypeUnderTest:                "cc_library_static",
		moduleTypeUnderTestFactory:         cc.LibraryStaticFactory,
		moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryStaticBp2Build,
@@ -1422,7 +1422,7 @@ func TestCcLibraryStaticProductVariableStringReplacement(t *testing.T) {
		blueprint: soongCcLibraryStaticPreamble + `
cc_library_static {
    name: "foo_static",
    srcs: ["common.c"],
    srcs: ["common.S"],
    product_variables: {
      platform_sdk_version: {
          asflags: ["-DPLATFORM_SDK_VERSION=%d"],
@@ -1431,7 +1431,10 @@ cc_library_static {
} `,
		expectedBazelTargets: []string{`cc_library_static(
    name = "foo_static",
    asflags = select({
    asflags = [
        "-I.",
        "-I$(BINDIR)/.",
    ] + select({
        "//build/bazel/product_variables:platform_sdk_version": ["-DPLATFORM_SDK_VERSION=$(Platform_sdk_version)"],
        "//conditions:default": [],
    }),
@@ -1440,7 +1443,7 @@ cc_library_static {
        "-I$(BINDIR)/.",
    ],
    linkstatic = True,
    srcs_c = ["common.c"],
    srcs_as = ["common.S"],
)`},
	})
}
+4 −2
Original line number Diff line number Diff line
@@ -211,6 +211,7 @@ func TestCcObjectProductVariable(t *testing.T) {
            asflags: ["-DPLATFORM_SDK_VERSION=%d"],
        },
    },
    srcs: ["src.S"],
}
`,
		expectedBazelTargets: []string{`cc_object(
@@ -220,6 +221,7 @@ func TestCcObjectProductVariable(t *testing.T) {
        "//conditions:default": [],
    }),
    copts = ["-fno-addrsig"],
    srcs_as = ["src.S"],
)`,
		},
	})
@@ -240,7 +242,7 @@ func TestCcObjectCflagsOneArch(t *testing.T) {
            cflags: ["-fPIC"], // string list
        },
        arm: {
            srcs: ["arch/arm/file.S"], // label list
            srcs: ["arch/arm/file.cpp"], // label list
        },
    },
}
@@ -257,7 +259,7 @@ func TestCcObjectCflagsOneArch(t *testing.T) {
        "//conditions:default": [],
    }),
    srcs = ["a.cpp"] + select({
        "//build/bazel/platforms/arch:arm": ["arch/arm/file.S"],
        "//build/bazel/platforms/arch:arm": ["arch/arm/file.cpp"],
        "//conditions:default": [],
    }),
)`,
Loading