Merge "Seperate asflags and cflags" am: ace3b7f0a2
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1764626 Change-Id: I633ff94b7155be285175f5b1d380f74ff0255644
This commit is contained in:
commit
7e8be02166
8 changed files with 78 additions and 30 deletions
|
@ -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
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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"],
|
||||
)`},
|
||||
})
|
||||
}
|
||||
|
|
|
@ -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": [],
|
||||
}),
|
||||
)`,
|
||||
|
|
|
@ -90,8 +90,11 @@ func depsBp2BuildMutator(ctx android.BottomUpMutatorContext) {
|
|||
|
||||
// TODO(b/186024507, b/186489250): Temporarily exclude adding
|
||||
// system_shared_libs deps until libc and libm builds.
|
||||
// allDeps = append(allDeps, lib.SharedProperties.Shared.System_shared_libs...)
|
||||
// allDeps = append(allDeps, lib.StaticProperties.Static.System_shared_libs...)
|
||||
if lib.static() {
|
||||
allDeps = append(allDeps, lib.StaticProperties.Static.System_shared_libs...)
|
||||
} else if lib.shared() {
|
||||
allDeps = append(allDeps, lib.SharedProperties.Shared.System_shared_libs...)
|
||||
}
|
||||
|
||||
// Deps in the target/arch nested static: { .. } and shared: { .. } props of a cc_library.
|
||||
// target: { <target>: shared: { ... } }
|
||||
|
@ -253,7 +256,7 @@ func bp2buildParseStaticOrSharedProps(ctx android.TopDownMutatorContext, module
|
|||
Copts: bazel.StringListAttribute{Value: props.Cflags},
|
||||
Srcs: bazel.MakeLabelListAttribute(android.BazelLabelForModuleSrc(ctx, props.Srcs)),
|
||||
Static_deps: bazel.MakeLabelListAttribute(android.BazelLabelForModuleDeps(ctx, props.Static_libs)),
|
||||
Dynamic_deps: bazel.MakeLabelListAttribute(android.BazelLabelForModuleDeps(ctx, props.Shared_libs)),
|
||||
Dynamic_deps: bazel.MakeLabelListAttribute(android.BazelLabelForModuleDeps(ctx, append(props.Shared_libs, props.System_shared_libs...))),
|
||||
Whole_archive_deps: bazel.MakeLabelListAttribute(android.BazelLabelForModuleWholeDeps(ctx, props.Whole_static_libs)),
|
||||
}
|
||||
|
||||
|
@ -385,16 +388,6 @@ func bp2BuildParseCompilerProps(ctx android.TopDownMutatorContext, module *Modul
|
|||
return result
|
||||
}
|
||||
|
||||
// Parse the list of copts.
|
||||
parseCopts := func(baseCompilerProps *BaseCompilerProperties) []string {
|
||||
var copts []string
|
||||
copts = append(copts, parseCommandLineFlags(baseCompilerProps.Cflags)...)
|
||||
for _, dir := range parseLocalIncludeDirs(baseCompilerProps) {
|
||||
copts = append(copts, includeFlags(dir)...)
|
||||
}
|
||||
return copts
|
||||
}
|
||||
|
||||
// Parse srcs from an arch or OS's props value.
|
||||
parseSrcs := func(baseCompilerProps *BaseCompilerProperties) bazel.LabelList {
|
||||
// Add srcs-like dependencies such as generated files.
|
||||
|
@ -410,11 +403,15 @@ func bp2BuildParseCompilerProps(ctx android.TopDownMutatorContext, module *Modul
|
|||
for _, props := range module.compiler.compilerProps() {
|
||||
if baseCompilerProps, ok := props.(*BaseCompilerProperties); ok {
|
||||
srcs.SetValue(parseSrcs(baseCompilerProps))
|
||||
copts.Value = parseCopts(baseCompilerProps)
|
||||
copts.Value = parseCommandLineFlags(baseCompilerProps.Cflags)
|
||||
asFlags.Value = parseCommandLineFlags(baseCompilerProps.Asflags)
|
||||
conlyFlags.Value = parseCommandLineFlags(baseCompilerProps.Conlyflags)
|
||||
cppFlags.Value = parseCommandLineFlags(baseCompilerProps.Cppflags)
|
||||
|
||||
for _, dir := range parseLocalIncludeDirs(baseCompilerProps) {
|
||||
copts.Value = append(copts.Value, includeFlags(dir)...)
|
||||
asFlags.Value = append(asFlags.Value, includeFlags(dir)...)
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
@ -424,8 +421,10 @@ func bp2BuildParseCompilerProps(ctx android.TopDownMutatorContext, module *Modul
|
|||
// "-I<module-dir>" in its copts.
|
||||
if c, ok := module.compiler.(*baseCompiler); ok && c.includeBuildDirectory() {
|
||||
copts.Value = append(copts.Value, includeFlags(".")...)
|
||||
asFlags.Value = append(asFlags.Value, includeFlags(".")...)
|
||||
} else if c, ok := module.compiler.(*libraryDecorator); ok && c.includeBuildDirectory() {
|
||||
copts.Value = append(copts.Value, includeFlags(".")...)
|
||||
asFlags.Value = append(asFlags.Value, includeFlags(".")...)
|
||||
}
|
||||
|
||||
archVariantCompilerProps := module.GetArchVariantProperties(ctx, &BaseCompilerProperties{})
|
||||
|
@ -440,8 +439,15 @@ func bp2BuildParseCompilerProps(ctx android.TopDownMutatorContext, module *Modul
|
|||
srcs.SetSelectValue(axis, config, srcsList)
|
||||
}
|
||||
|
||||
copts.SetSelectValue(axis, config, parseCopts(baseCompilerProps))
|
||||
asFlags.SetSelectValue(axis, config, parseCommandLineFlags(baseCompilerProps.Asflags))
|
||||
archVariantCopts := parseCommandLineFlags(baseCompilerProps.Cflags)
|
||||
archVariantAsflags := parseCommandLineFlags(baseCompilerProps.Asflags)
|
||||
for _, dir := range parseLocalIncludeDirs(baseCompilerProps) {
|
||||
archVariantCopts = append(archVariantCopts, includeFlags(dir)...)
|
||||
archVariantAsflags = append(archVariantAsflags, includeFlags(dir)...)
|
||||
}
|
||||
|
||||
copts.SetSelectValue(axis, config, archVariantCopts)
|
||||
asFlags.SetSelectValue(axis, config, archVariantAsflags)
|
||||
conlyFlags.SetSelectValue(axis, config, parseCommandLineFlags(baseCompilerProps.Conlyflags))
|
||||
cppFlags.SetSelectValue(axis, config, parseCommandLineFlags(baseCompilerProps.Cppflags))
|
||||
}
|
||||
|
@ -554,7 +560,9 @@ func bp2BuildParseLinkerProps(ctx android.TopDownMutatorContext, module *Module)
|
|||
staticDeps.Value = android.BazelLabelForModuleDepsExcludes(ctx, staticLibs, baseLinkerProps.Exclude_static_libs)
|
||||
wholeArchiveLibs := android.FirstUniqueStrings(baseLinkerProps.Whole_static_libs)
|
||||
wholeArchiveDeps = bazel.MakeLabelListAttribute(android.BazelLabelForModuleWholeDepsExcludes(ctx, wholeArchiveLibs, baseLinkerProps.Exclude_static_libs))
|
||||
sharedLibs := android.FirstUniqueStrings(baseLinkerProps.Shared_libs)
|
||||
// TODO(b/186024507): Handle system_shared_libs as its own attribute, so that the appropriate default
|
||||
// may be supported.
|
||||
sharedLibs := android.FirstUniqueStrings(append(baseLinkerProps.Shared_libs, baseLinkerProps.System_shared_libs...))
|
||||
dynamicDeps = bazel.MakeLabelListAttribute(android.BazelLabelForModuleDepsExcludes(ctx, sharedLibs, baseLinkerProps.Exclude_shared_libs))
|
||||
|
||||
headerLibs := android.FirstUniqueStrings(baseLinkerProps.Header_libs)
|
||||
|
@ -581,7 +589,7 @@ func bp2BuildParseLinkerProps(ctx android.TopDownMutatorContext, module *Module)
|
|||
staticDeps.SetSelectValue(axis, config, android.BazelLabelForModuleDepsExcludes(ctx, staticLibs, baseLinkerProps.Exclude_static_libs))
|
||||
wholeArchiveLibs := android.FirstUniqueStrings(baseLinkerProps.Whole_static_libs)
|
||||
wholeArchiveDeps.SetSelectValue(axis, config, android.BazelLabelForModuleWholeDepsExcludes(ctx, wholeArchiveLibs, baseLinkerProps.Exclude_static_libs))
|
||||
sharedLibs := android.FirstUniqueStrings(baseLinkerProps.Shared_libs)
|
||||
sharedLibs := android.FirstUniqueStrings(append(baseLinkerProps.Shared_libs, baseLinkerProps.System_shared_libs...))
|
||||
dynamicDeps.SetSelectValue(axis, config, android.BazelLabelForModuleDepsExcludes(ctx, sharedLibs, baseLinkerProps.Exclude_shared_libs))
|
||||
|
||||
headerLibs := android.FirstUniqueStrings(baseLinkerProps.Header_libs)
|
||||
|
|
|
@ -300,6 +300,12 @@ func CcLibraryBp2Build(ctx android.TopDownMutatorContext) {
|
|||
|
||||
srcs := compilerAttrs.srcs
|
||||
|
||||
asFlags := compilerAttrs.asFlags
|
||||
if compilerAttrs.asSrcs.IsEmpty() && sharedAttrs.Srcs_as.IsEmpty() && staticAttrs.Srcs_as.IsEmpty() {
|
||||
// Skip asflags for BUILD file simplicity if there are no assembly sources.
|
||||
asFlags = bazel.MakeStringListAttribute(nil)
|
||||
}
|
||||
|
||||
attrs := &bazelCcLibraryAttributes{
|
||||
Srcs: srcs,
|
||||
Srcs_c: compilerAttrs.cSrcs,
|
||||
|
@ -308,7 +314,7 @@ func CcLibraryBp2Build(ctx android.TopDownMutatorContext) {
|
|||
Copts: compilerAttrs.copts,
|
||||
Cppflags: compilerAttrs.cppFlags,
|
||||
Conlyflags: compilerAttrs.conlyFlags,
|
||||
Asflags: compilerAttrs.asFlags,
|
||||
Asflags: asFlags,
|
||||
|
||||
Implementation_deps: linkerAttrs.deps,
|
||||
Deps: linkerAttrs.exportedDeps,
|
||||
|
@ -2370,6 +2376,12 @@ func ccLibraryStaticBp2BuildInternal(ctx android.TopDownMutatorContext, module *
|
|||
linkerAttrs := bp2BuildParseLinkerProps(ctx, module)
|
||||
exportedIncludes := bp2BuildParseExportedIncludes(ctx, module)
|
||||
|
||||
asFlags := compilerAttrs.asFlags
|
||||
if compilerAttrs.asSrcs.IsEmpty() {
|
||||
// Skip asflags for BUILD file simplicity if there are no assembly sources.
|
||||
asFlags = bazel.MakeStringListAttribute(nil)
|
||||
}
|
||||
|
||||
attrs := &bazelCcLibraryStaticAttributes{
|
||||
Copts: compilerAttrs.copts,
|
||||
Srcs: compilerAttrs.srcs,
|
||||
|
@ -2386,7 +2398,7 @@ func ccLibraryStaticBp2BuildInternal(ctx android.TopDownMutatorContext, module *
|
|||
Srcs_c: compilerAttrs.cSrcs,
|
||||
Conlyflags: compilerAttrs.conlyFlags,
|
||||
Srcs_as: compilerAttrs.asSrcs,
|
||||
Asflags: compilerAttrs.asFlags,
|
||||
Asflags: asFlags,
|
||||
}
|
||||
|
||||
props := bazel.BazelTargetModuleProperties{
|
||||
|
|
11
cc/object.go
11
cc/object.go
|
@ -123,6 +123,7 @@ func ObjectFactory() android.Module {
|
|||
// For bp2build conversion.
|
||||
type bazelObjectAttributes struct {
|
||||
Srcs bazel.LabelListAttribute
|
||||
Srcs_as bazel.LabelListAttribute
|
||||
Hdrs bazel.LabelListAttribute
|
||||
Deps bazel.LabelListAttribute
|
||||
Copts bazel.StringListAttribute
|
||||
|
@ -179,13 +180,19 @@ func ObjectBp2Build(ctx android.TopDownMutatorContext) {
|
|||
// and this isn't typically done for cc_object.
|
||||
srcs := compilerAttrs.srcs
|
||||
srcs.Append(compilerAttrs.cSrcs)
|
||||
srcs.Append(compilerAttrs.asSrcs)
|
||||
|
||||
asFlags := compilerAttrs.asFlags
|
||||
if compilerAttrs.asSrcs.IsEmpty() {
|
||||
// Skip asflags for BUILD file simplicity if there are no assembly sources.
|
||||
asFlags = bazel.MakeStringListAttribute(nil)
|
||||
}
|
||||
|
||||
attrs := &bazelObjectAttributes{
|
||||
Srcs: srcs,
|
||||
Srcs_as: compilerAttrs.asSrcs,
|
||||
Deps: deps,
|
||||
Copts: compilerAttrs.copts,
|
||||
Asflags: compilerAttrs.asFlags,
|
||||
Asflags: asFlags,
|
||||
}
|
||||
|
||||
props := bazel.BazelTargetModuleProperties{
|
||||
|
|
Loading…
Reference in a new issue