bp2build remove "-std" from cflags am: cac7f690eb
am: 547bdc5207
am: 7b901cb0fb
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1927501 Change-Id: I468f8accaaf37502c10e0392e217d56ce016c551
This commit is contained in:
@@ -364,8 +364,6 @@ var (
|
|||||||
|
|
||||||
// Per-module denylist to always opt modules out of both bp2build and mixed builds.
|
// Per-module denylist to always opt modules out of both bp2build and mixed builds.
|
||||||
bp2buildModuleDoNotConvertList = []string{
|
bp2buildModuleDoNotConvertList = []string{
|
||||||
"libnativehelper_compat_libc++", // Broken compile: implicit declaration of function 'strerror_r' is invalid in C99
|
|
||||||
|
|
||||||
"libandroid_runtime_lazy", // depends on unconverted modules: libbinder_headers
|
"libandroid_runtime_lazy", // depends on unconverted modules: libbinder_headers
|
||||||
"libcmd", // depends on unconverted modules: libbinder
|
"libcmd", // depends on unconverted modules: libbinder
|
||||||
|
|
||||||
|
@@ -1433,3 +1433,21 @@ func TestCcLibraryStaticUseVersionLib(t *testing.T) {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestCcLibraryStaticStdInFlags(t *testing.T) {
|
||||||
|
runCcLibraryStaticTestCase(t, bp2buildTestCase{
|
||||||
|
blueprint: soongCcProtoPreamble + `cc_library_static {
|
||||||
|
name: "foo",
|
||||||
|
cflags: ["-std=candcpp"],
|
||||||
|
conlyflags: ["-std=conly"],
|
||||||
|
cppflags: ["-std=cpp"],
|
||||||
|
include_build_directory: false,
|
||||||
|
}`,
|
||||||
|
expectedBazelTargets: []string{
|
||||||
|
makeBazelTarget("cc_library_static", "foo", attrNameToString{
|
||||||
|
"conlyflags": `["-std=conly"]`,
|
||||||
|
"cppflags": `["-std=cpp"]`,
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
@@ -162,7 +162,7 @@ func bp2buildParseStaticOrSharedProps(ctx android.BazelConversionPathContext, mo
|
|||||||
attrs := staticOrSharedAttributes{}
|
attrs := staticOrSharedAttributes{}
|
||||||
|
|
||||||
setAttrs := func(axis bazel.ConfigurationAxis, config string, props StaticOrSharedProperties) {
|
setAttrs := func(axis bazel.ConfigurationAxis, config string, props StaticOrSharedProperties) {
|
||||||
attrs.Copts.SetSelectValue(axis, config, props.Cflags)
|
attrs.Copts.SetSelectValue(axis, config, parseCommandLineFlags(props.Cflags, filterOutStdFlag))
|
||||||
attrs.Srcs.SetSelectValue(axis, config, android.BazelLabelForModuleSrc(ctx, props.Srcs))
|
attrs.Srcs.SetSelectValue(axis, config, android.BazelLabelForModuleSrc(ctx, props.Srcs))
|
||||||
attrs.System_dynamic_deps.SetSelectValue(axis, config, bazelLabelForSharedDeps(ctx, props.System_shared_libs))
|
attrs.System_dynamic_deps.SetSelectValue(axis, config, bazelLabelForSharedDeps(ctx, props.System_shared_libs))
|
||||||
|
|
||||||
@@ -279,9 +279,18 @@ type compilerAttributes struct {
|
|||||||
protoSrcs bazel.LabelListAttribute
|
protoSrcs bazel.LabelListAttribute
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseCommandLineFlags(soongFlags []string) []string {
|
type filterOutFn func(string) bool
|
||||||
|
|
||||||
|
func filterOutStdFlag(flag string) bool {
|
||||||
|
return strings.HasPrefix(flag, "-std=")
|
||||||
|
}
|
||||||
|
|
||||||
|
func parseCommandLineFlags(soongFlags []string, filterOut filterOutFn) []string {
|
||||||
var result []string
|
var result []string
|
||||||
for _, flag := range soongFlags {
|
for _, flag := range soongFlags {
|
||||||
|
if filterOut != nil && filterOut(flag) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
// Soong's cflags can contain spaces, like `-include header.h`. For
|
// Soong's cflags can contain spaces, like `-include header.h`. For
|
||||||
// Bazel's copts, split them up to be compatible with the
|
// Bazel's copts, split them up to be compatible with the
|
||||||
// no_copts_tokenization feature.
|
// no_copts_tokenization feature.
|
||||||
@@ -308,10 +317,14 @@ func (ca *compilerAttributes) bp2buildForAxisAndConfig(ctx android.BazelConversi
|
|||||||
ca.absoluteIncludes.SetSelectValue(axis, config, props.Include_dirs)
|
ca.absoluteIncludes.SetSelectValue(axis, config, props.Include_dirs)
|
||||||
ca.localIncludes.SetSelectValue(axis, config, localIncludeDirs)
|
ca.localIncludes.SetSelectValue(axis, config, localIncludeDirs)
|
||||||
|
|
||||||
ca.copts.SetSelectValue(axis, config, parseCommandLineFlags(props.Cflags))
|
// In Soong, cflags occur on the command line before -std=<val> flag, resulting in the value being
|
||||||
ca.asFlags.SetSelectValue(axis, config, parseCommandLineFlags(props.Asflags))
|
// overridden. In Bazel we always allow overriding, via flags; however, this can cause
|
||||||
ca.conlyFlags.SetSelectValue(axis, config, parseCommandLineFlags(props.Conlyflags))
|
// incompatibilities, so we remove "-std=" flags from Cflag properties while leaving it in other
|
||||||
ca.cppFlags.SetSelectValue(axis, config, parseCommandLineFlags(props.Cppflags))
|
// cases.
|
||||||
|
ca.copts.SetSelectValue(axis, config, parseCommandLineFlags(props.Cflags, filterOutStdFlag))
|
||||||
|
ca.asFlags.SetSelectValue(axis, config, parseCommandLineFlags(props.Asflags, nil))
|
||||||
|
ca.conlyFlags.SetSelectValue(axis, config, parseCommandLineFlags(props.Conlyflags, nil))
|
||||||
|
ca.cppFlags.SetSelectValue(axis, config, parseCommandLineFlags(props.Cppflags, nil))
|
||||||
ca.rtti.SetSelectValue(axis, config, props.Rtti)
|
ca.rtti.SetSelectValue(axis, config, props.Rtti)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user