Merge "bp2build: Handle export_generated_header property"
This commit is contained in:
@@ -17,6 +17,7 @@ package bp2build
|
|||||||
import (
|
import (
|
||||||
"android/soong/android"
|
"android/soong/android"
|
||||||
"android/soong/cc"
|
"android/soong/cc"
|
||||||
|
"android/soong/genrule"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
@@ -32,6 +33,7 @@ func registerCcBinaryModuleTypes(ctx android.RegistrationContext) {
|
|||||||
ctx.RegisterModuleType("filegroup", android.FileGroupFactory)
|
ctx.RegisterModuleType("filegroup", android.FileGroupFactory)
|
||||||
ctx.RegisterModuleType("cc_library_static", cc.LibraryStaticFactory)
|
ctx.RegisterModuleType("cc_library_static", cc.LibraryStaticFactory)
|
||||||
ctx.RegisterModuleType("cc_library", cc.LibraryFactory)
|
ctx.RegisterModuleType("cc_library", cc.LibraryFactory)
|
||||||
|
ctx.RegisterModuleType("genrule", genrule.GenRuleFactory)
|
||||||
}
|
}
|
||||||
|
|
||||||
var binaryReplacer = strings.NewReplacer(ccBinaryTypePlaceHolder, "cc_binary", compatibleWithPlaceHolder, "")
|
var binaryReplacer = strings.NewReplacer(ccBinaryTypePlaceHolder, "cc_binary", compatibleWithPlaceHolder, "")
|
||||||
@@ -220,14 +222,27 @@ func TestCcBinaryDoNotDistinguishBetweenDepsAndImplementationDeps(t *testing.T)
|
|||||||
runCcBinaryTestCase(t, bp2buildTestCase{
|
runCcBinaryTestCase(t, bp2buildTestCase{
|
||||||
description: "no implementation deps",
|
description: "no implementation deps",
|
||||||
blueprint: `
|
blueprint: `
|
||||||
|
genrule {
|
||||||
|
name: "generated_hdr",
|
||||||
|
cmd: "nothing to see here",
|
||||||
|
}
|
||||||
|
|
||||||
|
genrule {
|
||||||
|
name: "export_generated_hdr",
|
||||||
|
cmd: "nothing to see here",
|
||||||
|
}
|
||||||
|
|
||||||
{rule_name} {
|
{rule_name} {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
|
srcs: ["foo.cpp"],
|
||||||
shared_libs: ["implementation_shared_dep", "shared_dep"],
|
shared_libs: ["implementation_shared_dep", "shared_dep"],
|
||||||
export_shared_lib_headers: ["shared_dep"],
|
export_shared_lib_headers: ["shared_dep"],
|
||||||
static_libs: ["implementation_static_dep", "static_dep"],
|
static_libs: ["implementation_static_dep", "static_dep"],
|
||||||
export_static_lib_headers: ["static_dep", "whole_static_dep"],
|
export_static_lib_headers: ["static_dep", "whole_static_dep"],
|
||||||
whole_static_libs: ["not_explicitly_exported_whole_static_dep", "whole_static_dep"],
|
whole_static_libs: ["not_explicitly_exported_whole_static_dep", "whole_static_dep"],
|
||||||
include_build_directory: false,
|
include_build_directory: false,
|
||||||
|
generated_headers: ["generated_hdr", "export_generated_hdr"],
|
||||||
|
export_generated_headers: ["export_generated_hdr"],
|
||||||
}
|
}
|
||||||
` +
|
` +
|
||||||
simpleModuleDoNotConvertBp2build("cc_library_static", "static_dep") +
|
simpleModuleDoNotConvertBp2build("cc_library_static", "static_dep") +
|
||||||
@@ -245,6 +260,11 @@ func TestCcBinaryDoNotDistinguishBetweenDepsAndImplementationDeps(t *testing.T)
|
|||||||
dynamic_deps = [
|
dynamic_deps = [
|
||||||
":implementation_shared_dep",
|
":implementation_shared_dep",
|
||||||
":shared_dep",
|
":shared_dep",
|
||||||
|
],
|
||||||
|
srcs = [
|
||||||
|
"foo.cpp",
|
||||||
|
":generated_hdr",
|
||||||
|
":export_generated_hdr",
|
||||||
],{target_compatible_with}
|
],{target_compatible_with}
|
||||||
whole_archive_deps = [
|
whole_archive_deps = [
|
||||||
":not_explicitly_exported_whole_static_dep",
|
":not_explicitly_exported_whole_static_dep",
|
||||||
|
@@ -997,14 +997,21 @@ genrule {
|
|||||||
cmd: "nothing to see here",
|
cmd: "nothing to see here",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
genrule {
|
||||||
|
name: "export_generated_hdr",
|
||||||
|
cmd: "nothing to see here",
|
||||||
|
}
|
||||||
|
|
||||||
cc_library_static {
|
cc_library_static {
|
||||||
name: "foo_static",
|
name: "foo_static",
|
||||||
srcs: ["cpp_src.cpp", "as_src.S", "c_src.c"],
|
srcs: ["cpp_src.cpp", "as_src.S", "c_src.c"],
|
||||||
generated_headers: ["generated_hdr"],
|
generated_headers: ["generated_hdr", "export_generated_hdr"],
|
||||||
|
export_generated_headers: ["export_generated_hdr"],
|
||||||
include_build_directory: false,
|
include_build_directory: false,
|
||||||
}`,
|
}`,
|
||||||
expectedBazelTargets: []string{`cc_library_static(
|
expectedBazelTargets: []string{`cc_library_static(
|
||||||
name = "foo_static",
|
name = "foo_static",
|
||||||
|
hdrs = [":export_generated_hdr"],
|
||||||
srcs = [
|
srcs = [
|
||||||
"cpp_src.cpp",
|
"cpp_src.cpp",
|
||||||
":generated_hdr",
|
":generated_hdr",
|
||||||
|
55
cc/binary.go
55
cc/binary.go
@@ -577,47 +577,46 @@ func binaryBp2build(ctx android.TopDownMutatorContext, typ string) {
|
|||||||
compatibleWith.SetSelectValue(bazel.OsConfigurationAxis, bazel.ConditionsDefaultConfigKey, []string{})
|
compatibleWith.SetSelectValue(bazel.OsConfigurationAxis, bazel.ConditionsDefaultConfigKey, []string{})
|
||||||
}
|
}
|
||||||
|
|
||||||
compilerAttrs := bp2BuildParseCompilerProps(ctx, m)
|
baseAttrs := bp2BuildParseBaseProps(ctx, m)
|
||||||
linkerAttrs := bp2BuildParseLinkerProps(ctx, m)
|
|
||||||
|
|
||||||
attrs := &binaryAttributes{
|
attrs := &binaryAttributes{
|
||||||
binaryLinkerAttrs: bp2buildBinaryLinkerProps(ctx, m),
|
binaryLinkerAttrs: bp2buildBinaryLinkerProps(ctx, m),
|
||||||
|
|
||||||
Srcs: compilerAttrs.srcs,
|
Srcs: baseAttrs.srcs,
|
||||||
Srcs_c: compilerAttrs.cSrcs,
|
Srcs_c: baseAttrs.cSrcs,
|
||||||
Srcs_as: compilerAttrs.asSrcs,
|
Srcs_as: baseAttrs.asSrcs,
|
||||||
|
|
||||||
Copts: compilerAttrs.copts,
|
Copts: baseAttrs.copts,
|
||||||
Cppflags: compilerAttrs.cppFlags,
|
Cppflags: baseAttrs.cppFlags,
|
||||||
Conlyflags: compilerAttrs.conlyFlags,
|
Conlyflags: baseAttrs.conlyFlags,
|
||||||
Asflags: compilerAttrs.asFlags,
|
Asflags: baseAttrs.asFlags,
|
||||||
|
|
||||||
Deps: linkerAttrs.implementationDeps,
|
Deps: baseAttrs.implementationDeps,
|
||||||
Dynamic_deps: linkerAttrs.implementationDynamicDeps,
|
Dynamic_deps: baseAttrs.implementationDynamicDeps,
|
||||||
Whole_archive_deps: linkerAttrs.wholeArchiveDeps,
|
Whole_archive_deps: baseAttrs.wholeArchiveDeps,
|
||||||
System_deps: linkerAttrs.systemDynamicDeps,
|
System_deps: baseAttrs.systemDynamicDeps,
|
||||||
|
|
||||||
Local_includes: compilerAttrs.localIncludes,
|
Local_includes: baseAttrs.localIncludes,
|
||||||
Absolute_includes: compilerAttrs.absoluteIncludes,
|
Absolute_includes: baseAttrs.absoluteIncludes,
|
||||||
Linkopts: linkerAttrs.linkopts,
|
Linkopts: baseAttrs.linkopts,
|
||||||
Link_crt: linkerAttrs.linkCrt,
|
Link_crt: baseAttrs.linkCrt,
|
||||||
Use_libcrt: linkerAttrs.useLibcrt,
|
Use_libcrt: baseAttrs.useLibcrt,
|
||||||
Rtti: compilerAttrs.rtti,
|
Rtti: baseAttrs.rtti,
|
||||||
Stl: compilerAttrs.stl,
|
Stl: baseAttrs.stl,
|
||||||
Cpp_std: compilerAttrs.cppStd,
|
Cpp_std: baseAttrs.cppStd,
|
||||||
|
|
||||||
Additional_linker_inputs: linkerAttrs.additionalLinkerInputs,
|
Additional_linker_inputs: baseAttrs.additionalLinkerInputs,
|
||||||
|
|
||||||
Strip: stripAttributes{
|
Strip: stripAttributes{
|
||||||
Keep_symbols: linkerAttrs.stripKeepSymbols,
|
Keep_symbols: baseAttrs.stripKeepSymbols,
|
||||||
Keep_symbols_and_debug_frame: linkerAttrs.stripKeepSymbolsAndDebugFrame,
|
Keep_symbols_and_debug_frame: baseAttrs.stripKeepSymbolsAndDebugFrame,
|
||||||
Keep_symbols_list: linkerAttrs.stripKeepSymbolsList,
|
Keep_symbols_list: baseAttrs.stripKeepSymbolsList,
|
||||||
All: linkerAttrs.stripAll,
|
All: baseAttrs.stripAll,
|
||||||
None: linkerAttrs.stripNone,
|
None: baseAttrs.stripNone,
|
||||||
},
|
},
|
||||||
|
|
||||||
Target_compatible_with: compatibleWith,
|
Target_compatible_with: compatibleWith,
|
||||||
Features: linkerAttrs.features,
|
Features: baseAttrs.features,
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.CreateBazelTargetModule(bazel.BazelTargetModuleProperties{
|
ctx.CreateBazelTargetModule(bazel.BazelTargetModuleProperties{
|
||||||
|
441
cc/bp2build.go
441
cc/bp2build.go
@@ -38,6 +38,7 @@ type staticOrSharedAttributes struct {
|
|||||||
Srcs bazel.LabelListAttribute
|
Srcs bazel.LabelListAttribute
|
||||||
Srcs_c bazel.LabelListAttribute
|
Srcs_c bazel.LabelListAttribute
|
||||||
Srcs_as bazel.LabelListAttribute
|
Srcs_as bazel.LabelListAttribute
|
||||||
|
Hdrs bazel.LabelListAttribute
|
||||||
Copts bazel.StringListAttribute
|
Copts bazel.StringListAttribute
|
||||||
|
|
||||||
Deps bazel.LabelListAttribute
|
Deps bazel.LabelListAttribute
|
||||||
@@ -226,6 +227,11 @@ func Bp2BuildParsePrebuiltLibraryProps(ctx android.TopDownMutatorContext, module
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type baseAttributes struct {
|
||||||
|
compilerAttributes
|
||||||
|
linkerAttributes
|
||||||
|
}
|
||||||
|
|
||||||
// Convenience struct to hold all attributes parsed from compiler properties.
|
// Convenience struct to hold all attributes parsed from compiler properties.
|
||||||
type compilerAttributes struct {
|
type compilerAttributes struct {
|
||||||
// Options for all languages
|
// Options for all languages
|
||||||
@@ -240,6 +246,8 @@ type compilerAttributes struct {
|
|||||||
cppFlags bazel.StringListAttribute
|
cppFlags bazel.StringListAttribute
|
||||||
srcs bazel.LabelListAttribute
|
srcs bazel.LabelListAttribute
|
||||||
|
|
||||||
|
hdrs bazel.LabelListAttribute
|
||||||
|
|
||||||
rtti bazel.BoolAttribute
|
rtti bazel.BoolAttribute
|
||||||
|
|
||||||
// Not affected by arch variants
|
// Not affected by arch variants
|
||||||
@@ -250,21 +258,7 @@ type compilerAttributes struct {
|
|||||||
absoluteIncludes bazel.StringListAttribute
|
absoluteIncludes bazel.StringListAttribute
|
||||||
}
|
}
|
||||||
|
|
||||||
// bp2BuildParseCompilerProps returns copts, srcs and hdrs and other attributes.
|
func parseCommandLineFlags(soongFlags []string) []string {
|
||||||
func bp2BuildParseCompilerProps(ctx android.TopDownMutatorContext, module *Module) compilerAttributes {
|
|
||||||
var srcs bazel.LabelListAttribute
|
|
||||||
var implementationHdrs bazel.LabelListAttribute
|
|
||||||
var copts bazel.StringListAttribute
|
|
||||||
var asFlags bazel.StringListAttribute
|
|
||||||
var conlyFlags bazel.StringListAttribute
|
|
||||||
var cppFlags bazel.StringListAttribute
|
|
||||||
var rtti bazel.BoolAttribute
|
|
||||||
var localIncludes bazel.StringListAttribute
|
|
||||||
var absoluteIncludes bazel.StringListAttribute
|
|
||||||
var stl *string = nil
|
|
||||||
var cppStd *string = nil
|
|
||||||
|
|
||||||
parseCommandLineFlags := func(soongFlags []string) []string {
|
|
||||||
var result []string
|
var result []string
|
||||||
for _, flag := range soongFlags {
|
for _, flag := range soongFlags {
|
||||||
// Soong's cflags can contain spaces, like `-include header.h`. For
|
// Soong's cflags can contain spaces, like `-include header.h`. For
|
||||||
@@ -273,10 +267,95 @@ func bp2BuildParseCompilerProps(ctx android.TopDownMutatorContext, module *Modul
|
|||||||
result = append(result, strings.Split(flag, " ")...)
|
result = append(result, strings.Split(flag, " ")...)
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ca *compilerAttributes) bp2buildForAxisAndConfig(ctx android.TopDownMutatorContext, axis bazel.ConfigurationAxis, config string, props *BaseCompilerProperties) {
|
||||||
|
// If there's arch specific srcs or exclude_srcs, generate a select entry for it.
|
||||||
|
// TODO(b/186153868): do this for OS specific srcs and exclude_srcs too.
|
||||||
|
if srcsList, ok := parseSrcs(ctx, props); ok {
|
||||||
|
ca.srcs.SetSelectValue(axis, config, srcsList)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse srcs from an arch or OS's props value.
|
localIncludeDirs := props.Local_include_dirs
|
||||||
parseSrcs := func(props *BaseCompilerProperties) (bazel.LabelList, bool) {
|
if axis == bazel.NoConfigAxis {
|
||||||
|
ca.cppStd = bp2buildResolveCppStdValue(props.Cpp_std, props.Gnu_extensions)
|
||||||
|
|
||||||
|
if includeBuildDirectory(props.Include_build_directory) {
|
||||||
|
localIncludeDirs = append(localIncludeDirs, ".")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ca.absoluteIncludes.SetSelectValue(axis, config, props.Include_dirs)
|
||||||
|
ca.localIncludes.SetSelectValue(axis, config, localIncludeDirs)
|
||||||
|
|
||||||
|
ca.copts.SetSelectValue(axis, config, parseCommandLineFlags(props.Cflags))
|
||||||
|
ca.asFlags.SetSelectValue(axis, config, parseCommandLineFlags(props.Asflags))
|
||||||
|
ca.conlyFlags.SetSelectValue(axis, config, parseCommandLineFlags(props.Conlyflags))
|
||||||
|
ca.cppFlags.SetSelectValue(axis, config, parseCommandLineFlags(props.Cppflags))
|
||||||
|
ca.rtti.SetSelectValue(axis, config, props.Rtti)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ca *compilerAttributes) convertStlProps(ctx android.TopDownMutatorContext, module *Module) {
|
||||||
|
stlPropsByArch := module.GetArchVariantProperties(ctx, &StlProperties{})
|
||||||
|
for _, configToProps := range stlPropsByArch {
|
||||||
|
for _, props := range configToProps {
|
||||||
|
if stlProps, ok := props.(*StlProperties); ok {
|
||||||
|
if stlProps.Stl == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if ca.stl == nil {
|
||||||
|
ca.stl = stlProps.Stl
|
||||||
|
} else if ca.stl != stlProps.Stl {
|
||||||
|
ctx.ModuleErrorf("Unsupported conversion: module with different stl for different variants: %s and %s", *ca.stl, stlProps.Stl)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ca *compilerAttributes) convertProductVariables(ctx android.TopDownMutatorContext, productVariableProps android.ProductConfigProperties) {
|
||||||
|
productVarPropNameToAttribute := map[string]*bazel.StringListAttribute{
|
||||||
|
"Cflags": &ca.copts,
|
||||||
|
"Asflags": &ca.asFlags,
|
||||||
|
"CppFlags": &ca.cppFlags,
|
||||||
|
}
|
||||||
|
for propName, attr := range productVarPropNameToAttribute {
|
||||||
|
if props, exists := productVariableProps[propName]; exists {
|
||||||
|
for _, prop := range props {
|
||||||
|
flags, ok := prop.Property.([]string)
|
||||||
|
if !ok {
|
||||||
|
ctx.ModuleErrorf("Could not convert product variable %s property", proptools.PropertyNameForField(propName))
|
||||||
|
}
|
||||||
|
newFlags, _ := bazel.TryVariableSubstitutions(flags, prop.ProductConfigVariable)
|
||||||
|
attr.SetSelectValue(bazel.ProductVariableConfigurationAxis(prop.FullConfig), prop.FullConfig, newFlags)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ca *compilerAttributes) finalize(ctx android.TopDownMutatorContext, implementationHdrs bazel.LabelListAttribute) {
|
||||||
|
ca.srcs.ResolveExcludes()
|
||||||
|
partitionedSrcs := groupSrcsByExtension(ctx, ca.srcs)
|
||||||
|
|
||||||
|
for p, lla := range partitionedSrcs {
|
||||||
|
// if there are no sources, there is no need for headers
|
||||||
|
if lla.IsEmpty() {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
lla.Append(implementationHdrs)
|
||||||
|
partitionedSrcs[p] = lla
|
||||||
|
}
|
||||||
|
|
||||||
|
ca.srcs = partitionedSrcs[cppSrcPartition]
|
||||||
|
ca.cSrcs = partitionedSrcs[cSrcPartition]
|
||||||
|
ca.asSrcs = partitionedSrcs[asSrcPartition]
|
||||||
|
|
||||||
|
ca.absoluteIncludes.DeduplicateAxesFromBase()
|
||||||
|
ca.localIncludes.DeduplicateAxesFromBase()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Parse srcs from an arch or OS's props value.
|
||||||
|
func parseSrcs(ctx android.TopDownMutatorContext, props *BaseCompilerProperties) (bazel.LabelList, bool) {
|
||||||
anySrcs := false
|
anySrcs := false
|
||||||
// Add srcs-like dependencies such as generated files.
|
// Add srcs-like dependencies such as generated files.
|
||||||
// First create a LabelList containing these dependencies, then merge the values with srcs.
|
// First create a LabelList containing these dependencies, then merge the values with srcs.
|
||||||
@@ -290,128 +369,88 @@ func bp2BuildParseCompilerProps(ctx android.TopDownMutatorContext, module *Modul
|
|||||||
anySrcs = true
|
anySrcs = true
|
||||||
}
|
}
|
||||||
return bazel.AppendBazelLabelLists(allSrcsLabelList, generatedSrcsLabelList), anySrcs
|
return bazel.AppendBazelLabelLists(allSrcsLabelList, generatedSrcsLabelList), anySrcs
|
||||||
}
|
}
|
||||||
|
|
||||||
archVariantCompilerProps := module.GetArchVariantProperties(ctx, &BaseCompilerProperties{})
|
func bp2buildResolveCppStdValue(cpp_std *string, gnu_extensions *bool) *string {
|
||||||
for axis, configToProps := range archVariantCompilerProps {
|
var cppStd *string
|
||||||
for config, props := range configToProps {
|
|
||||||
if baseCompilerProps, ok := props.(*BaseCompilerProperties); ok {
|
|
||||||
// If there's arch specific srcs or exclude_srcs, generate a select entry for it.
|
|
||||||
// TODO(b/186153868): do this for OS specific srcs and exclude_srcs too.
|
|
||||||
if srcsList, ok := parseSrcs(baseCompilerProps); ok {
|
|
||||||
srcs.SetSelectValue(axis, config, srcsList)
|
|
||||||
}
|
|
||||||
if len(baseCompilerProps.Generated_headers) > 0 {
|
|
||||||
implementationHdrs.SetSelectValue(axis, config, android.BazelLabelForModuleDeps(ctx, baseCompilerProps.Generated_headers))
|
|
||||||
}
|
|
||||||
|
|
||||||
if axis == bazel.NoConfigAxis {
|
|
||||||
// If cpp_std is not specified, don't generate it in the
|
// If cpp_std is not specified, don't generate it in the
|
||||||
// BUILD file. For readability purposes, cpp_std and gnu_extensions are
|
// BUILD file. For readability purposes, cpp_std and gnu_extensions are
|
||||||
// combined into a single -std=<version> copt, except in the
|
// combined into a single -std=<version> copt, except in the
|
||||||
// default case where cpp_std is nil and gnu_extensions is true or unspecified,
|
// default case where cpp_std is nil and gnu_extensions is true or unspecified,
|
||||||
// then the toolchain's default "gnu++17" will be used.
|
// then the toolchain's default "gnu++17" will be used.
|
||||||
if baseCompilerProps.Cpp_std != nil {
|
if cpp_std != nil {
|
||||||
// TODO(b/202491296): Handle C_std.
|
// TODO(b/202491296): Handle C_std.
|
||||||
// These transformations are shared with compiler.go.
|
// These transformations are shared with compiler.go.
|
||||||
cppStdVal := parseCppStd(baseCompilerProps.Cpp_std)
|
cppStdVal := parseCppStd(cpp_std)
|
||||||
_, cppStdVal = maybeReplaceGnuToC(baseCompilerProps.Gnu_extensions, "", cppStdVal)
|
_, cppStdVal = maybeReplaceGnuToC(gnu_extensions, "", cppStdVal)
|
||||||
cppStd = &cppStdVal
|
cppStd = &cppStdVal
|
||||||
} else if baseCompilerProps.Gnu_extensions != nil && !*baseCompilerProps.Gnu_extensions {
|
} else if gnu_extensions != nil && !*gnu_extensions {
|
||||||
cppStdVal := "c++17"
|
cppStdVal := "c++17"
|
||||||
cppStd = &cppStdVal
|
cppStd = &cppStdVal
|
||||||
}
|
}
|
||||||
|
return cppStd
|
||||||
|
}
|
||||||
|
|
||||||
|
// bp2BuildParseCompilerProps returns copts, srcs and hdrs and other attributes.
|
||||||
|
func bp2BuildParseBaseProps(ctx android.TopDownMutatorContext, module *Module) baseAttributes {
|
||||||
|
archVariantCompilerProps := module.GetArchVariantProperties(ctx, &BaseCompilerProperties{})
|
||||||
|
archVariantLinkerProps := module.GetArchVariantProperties(ctx, &BaseLinkerProperties{})
|
||||||
|
|
||||||
|
var implementationHdrs bazel.LabelListAttribute
|
||||||
|
|
||||||
|
axisToConfigs := map[bazel.ConfigurationAxis]map[string]bool{}
|
||||||
|
allAxesAndConfigs := func(cp android.ConfigurationAxisToArchVariantProperties) {
|
||||||
|
for axis, configMap := range cp {
|
||||||
|
if _, ok := axisToConfigs[axis]; !ok {
|
||||||
|
axisToConfigs[axis] = map[string]bool{}
|
||||||
}
|
}
|
||||||
|
for config, _ := range configMap {
|
||||||
var archVariantCopts []string
|
axisToConfigs[axis][config] = true
|
||||||
archVariantCopts = append(archVariantCopts, parseCommandLineFlags(baseCompilerProps.Cflags)...)
|
|
||||||
archVariantAsflags := parseCommandLineFlags(baseCompilerProps.Asflags)
|
|
||||||
|
|
||||||
localIncludeDirs := baseCompilerProps.Local_include_dirs
|
|
||||||
if axis == bazel.NoConfigAxis && includeBuildDirectory(baseCompilerProps.Include_build_directory) {
|
|
||||||
localIncludeDirs = append(localIncludeDirs, ".")
|
|
||||||
}
|
|
||||||
|
|
||||||
absoluteIncludes.SetSelectValue(axis, config, baseCompilerProps.Include_dirs)
|
|
||||||
localIncludes.SetSelectValue(axis, config, localIncludeDirs)
|
|
||||||
|
|
||||||
copts.SetSelectValue(axis, config, archVariantCopts)
|
|
||||||
asFlags.SetSelectValue(axis, config, archVariantAsflags)
|
|
||||||
conlyFlags.SetSelectValue(axis, config, parseCommandLineFlags(baseCompilerProps.Conlyflags))
|
|
||||||
cppFlags.SetSelectValue(axis, config, parseCommandLineFlags(baseCompilerProps.Cppflags))
|
|
||||||
rtti.SetSelectValue(axis, config, baseCompilerProps.Rtti)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
allAxesAndConfigs(archVariantCompilerProps)
|
||||||
|
allAxesAndConfigs(archVariantLinkerProps)
|
||||||
|
|
||||||
srcs.ResolveExcludes()
|
compilerAttrs := compilerAttributes{}
|
||||||
partitionedSrcs := groupSrcsByExtension(ctx, srcs)
|
linkerAttrs := linkerAttributes{}
|
||||||
|
|
||||||
for p, lla := range partitionedSrcs {
|
for axis, configs := range axisToConfigs {
|
||||||
// if there are no sources, there is no need for headers
|
for config, _ := range configs {
|
||||||
if lla.IsEmpty() {
|
var allHdrs []string
|
||||||
continue
|
if baseCompilerProps, ok := archVariantCompilerProps[axis][config].(*BaseCompilerProperties); ok {
|
||||||
}
|
allHdrs = baseCompilerProps.Generated_headers
|
||||||
lla.Append(implementationHdrs)
|
|
||||||
partitionedSrcs[p] = lla
|
(&compilerAttrs).bp2buildForAxisAndConfig(ctx, axis, config, baseCompilerProps)
|
||||||
}
|
}
|
||||||
|
|
||||||
srcs = partitionedSrcs[cppSrcPartition]
|
var exportHdrs []string
|
||||||
cSrcs := partitionedSrcs[cSrcPartition]
|
|
||||||
asSrcs := partitionedSrcs[asSrcPartition]
|
|
||||||
|
|
||||||
absoluteIncludes.DeduplicateAxesFromBase()
|
if baseLinkerProps, ok := archVariantLinkerProps[axis][config].(*BaseLinkerProperties); ok {
|
||||||
localIncludes.DeduplicateAxesFromBase()
|
exportHdrs = baseLinkerProps.Export_generated_headers
|
||||||
|
|
||||||
productVarPropNameToAttribute := map[string]*bazel.StringListAttribute{
|
(&linkerAttrs).bp2buildForAxisAndConfig(ctx, module.Binary(), axis, config, baseLinkerProps)
|
||||||
"Cflags": &copts,
|
|
||||||
"Asflags": &asFlags,
|
|
||||||
"CppFlags": &cppFlags,
|
|
||||||
}
|
}
|
||||||
|
headers := maybePartitionExportedAndImplementationsDeps(ctx, !module.Binary(), allHdrs, exportHdrs, android.BazelLabelForModuleDeps)
|
||||||
|
implementationHdrs.SetSelectValue(axis, config, headers.implementation)
|
||||||
|
compilerAttrs.hdrs.SetSelectValue(axis, config, headers.export)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
compilerAttrs.convertStlProps(ctx, module)
|
||||||
|
(&linkerAttrs).convertStripProps(ctx, module)
|
||||||
|
|
||||||
productVariableProps := android.ProductVariableProperties(ctx)
|
productVariableProps := android.ProductVariableProperties(ctx)
|
||||||
for propName, attr := range productVarPropNameToAttribute {
|
|
||||||
if props, exists := productVariableProps[propName]; exists {
|
|
||||||
for _, prop := range props {
|
|
||||||
flags, ok := prop.Property.([]string)
|
|
||||||
if !ok {
|
|
||||||
ctx.ModuleErrorf("Could not convert product variable %s property", proptools.PropertyNameForField(propName))
|
|
||||||
}
|
|
||||||
newFlags, _ := bazel.TryVariableSubstitutions(flags, prop.ProductConfigVariable)
|
|
||||||
attr.SetSelectValue(bazel.ProductVariableConfigurationAxis(prop.FullConfig), prop.FullConfig, newFlags)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stlPropsByArch := module.GetArchVariantProperties(ctx, &StlProperties{})
|
(&compilerAttrs).convertProductVariables(ctx, productVariableProps)
|
||||||
for _, configToProps := range stlPropsByArch {
|
(&linkerAttrs).convertProductVariables(ctx, productVariableProps)
|
||||||
for _, props := range configToProps {
|
|
||||||
if stlProps, ok := props.(*StlProperties); ok {
|
|
||||||
if stlProps.Stl != nil {
|
|
||||||
if stl == nil {
|
|
||||||
stl = stlProps.Stl
|
|
||||||
} else {
|
|
||||||
if stl != stlProps.Stl {
|
|
||||||
ctx.ModuleErrorf("Unsupported conversion: module with different stl for different variants: %s and %s", *stl, stlProps.Stl)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return compilerAttributes{
|
(&compilerAttrs).finalize(ctx, implementationHdrs)
|
||||||
copts: copts,
|
(&linkerAttrs).finalize()
|
||||||
srcs: srcs,
|
|
||||||
asFlags: asFlags,
|
return baseAttributes{
|
||||||
asSrcs: asSrcs,
|
compilerAttrs,
|
||||||
cSrcs: cSrcs,
|
linkerAttrs,
|
||||||
conlyFlags: conlyFlags,
|
|
||||||
cppFlags: cppFlags,
|
|
||||||
rtti: rtti,
|
|
||||||
stl: stl,
|
|
||||||
cppStd: cppStd,
|
|
||||||
localIncludes: localIncludes,
|
|
||||||
absoluteIncludes: absoluteIncludes,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -436,126 +475,94 @@ type linkerAttributes struct {
|
|||||||
features bazel.StringListAttribute
|
features bazel.StringListAttribute
|
||||||
}
|
}
|
||||||
|
|
||||||
// bp2BuildParseLinkerProps parses the linker properties of a module, including
|
func (la *linkerAttributes) bp2buildForAxisAndConfig(ctx android.TopDownMutatorContext, isBinary bool, axis bazel.ConfigurationAxis, config string, props *BaseLinkerProperties) {
|
||||||
// configurable attribute values.
|
|
||||||
func bp2BuildParseLinkerProps(ctx android.TopDownMutatorContext, module *Module) linkerAttributes {
|
|
||||||
|
|
||||||
var headerDeps bazel.LabelListAttribute
|
|
||||||
var implementationHeaderDeps bazel.LabelListAttribute
|
|
||||||
var deps bazel.LabelListAttribute
|
|
||||||
var implementationDeps bazel.LabelListAttribute
|
|
||||||
var dynamicDeps bazel.LabelListAttribute
|
|
||||||
var implementationDynamicDeps bazel.LabelListAttribute
|
|
||||||
var wholeArchiveDeps bazel.LabelListAttribute
|
|
||||||
systemSharedDeps := bazel.LabelListAttribute{ForceSpecifyEmptyList: true}
|
|
||||||
|
|
||||||
var linkopts bazel.StringListAttribute
|
|
||||||
var linkCrt bazel.BoolAttribute
|
|
||||||
var additionalLinkerInputs bazel.LabelListAttribute
|
|
||||||
var useLibcrt bazel.BoolAttribute
|
|
||||||
|
|
||||||
var stripKeepSymbols bazel.BoolAttribute
|
|
||||||
var stripKeepSymbolsAndDebugFrame bazel.BoolAttribute
|
|
||||||
var stripKeepSymbolsList bazel.StringListAttribute
|
|
||||||
var stripAll bazel.BoolAttribute
|
|
||||||
var stripNone bazel.BoolAttribute
|
|
||||||
|
|
||||||
var features bazel.StringListAttribute
|
|
||||||
|
|
||||||
for axis, configToProps := range module.GetArchVariantProperties(ctx, &StripProperties{}) {
|
|
||||||
for config, props := range configToProps {
|
|
||||||
if stripProperties, ok := props.(*StripProperties); ok {
|
|
||||||
stripKeepSymbols.SetSelectValue(axis, config, stripProperties.Strip.Keep_symbols)
|
|
||||||
stripKeepSymbolsList.SetSelectValue(axis, config, stripProperties.Strip.Keep_symbols_list)
|
|
||||||
stripKeepSymbolsAndDebugFrame.SetSelectValue(axis, config, stripProperties.Strip.Keep_symbols_and_debug_frame)
|
|
||||||
stripAll.SetSelectValue(axis, config, stripProperties.Strip.All)
|
|
||||||
stripNone.SetSelectValue(axis, config, stripProperties.Strip.None)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Use a single variable to capture usage of nocrt in arch variants, so there's only 1 error message for this module
|
// Use a single variable to capture usage of nocrt in arch variants, so there's only 1 error message for this module
|
||||||
var disallowedArchVariantCrt bool
|
|
||||||
isBinary := module.Binary()
|
|
||||||
|
|
||||||
for axis, configToProps := range module.GetArchVariantProperties(ctx, &BaseLinkerProperties{}) {
|
|
||||||
for config, props := range configToProps {
|
|
||||||
if baseLinkerProps, ok := props.(*BaseLinkerProperties); ok {
|
|
||||||
var axisFeatures []string
|
var axisFeatures []string
|
||||||
|
|
||||||
// Excludes to parallel Soong:
|
// Excludes to parallel Soong:
|
||||||
// https://cs.android.com/android/platform/superproject/+/master:build/soong/cc/linker.go;l=247-249;drc=088b53577dde6e40085ffd737a1ae96ad82fc4b0
|
// https://cs.android.com/android/platform/superproject/+/master:build/soong/cc/linker.go;l=247-249;drc=088b53577dde6e40085ffd737a1ae96ad82fc4b0
|
||||||
staticLibs := android.FirstUniqueStrings(baseLinkerProps.Static_libs)
|
staticLibs := android.FirstUniqueStrings(props.Static_libs)
|
||||||
staticDeps := maybePartitionExportedAndImplementationsDepsExcludes(ctx, !isBinary, staticLibs, baseLinkerProps.Exclude_static_libs, baseLinkerProps.Export_static_lib_headers, bazelLabelForStaticDepsExcludes)
|
staticDeps := maybePartitionExportedAndImplementationsDepsExcludes(ctx, !isBinary, staticLibs, props.Exclude_static_libs, props.Export_static_lib_headers, bazelLabelForStaticDepsExcludes)
|
||||||
deps.SetSelectValue(axis, config, staticDeps.export)
|
|
||||||
implementationDeps.SetSelectValue(axis, config, staticDeps.implementation)
|
|
||||||
|
|
||||||
wholeStaticLibs := android.FirstUniqueStrings(baseLinkerProps.Whole_static_libs)
|
headerLibs := android.FirstUniqueStrings(props.Header_libs)
|
||||||
wholeArchiveDeps.SetSelectValue(axis, config, bazelLabelForWholeDepsExcludes(ctx, wholeStaticLibs, baseLinkerProps.Exclude_static_libs))
|
hDeps := maybePartitionExportedAndImplementationsDeps(ctx, !isBinary, headerLibs, props.Export_header_lib_headers, bazelLabelForHeaderDeps)
|
||||||
|
|
||||||
systemSharedLibs := baseLinkerProps.System_shared_libs
|
(&hDeps.export).Append(staticDeps.export)
|
||||||
|
la.deps.SetSelectValue(axis, config, hDeps.export)
|
||||||
|
|
||||||
|
(&hDeps.implementation).Append(staticDeps.implementation)
|
||||||
|
la.implementationDeps.SetSelectValue(axis, config, hDeps.implementation)
|
||||||
|
|
||||||
|
wholeStaticLibs := android.FirstUniqueStrings(props.Whole_static_libs)
|
||||||
|
la.wholeArchiveDeps.SetSelectValue(axis, config, bazelLabelForWholeDepsExcludes(ctx, wholeStaticLibs, props.Exclude_static_libs))
|
||||||
|
|
||||||
|
systemSharedLibs := props.System_shared_libs
|
||||||
// systemSharedLibs distinguishes between nil/empty list behavior:
|
// systemSharedLibs distinguishes between nil/empty list behavior:
|
||||||
// nil -> use default values
|
// nil -> use default values
|
||||||
// empty list -> no values specified
|
// empty list -> no values specified
|
||||||
if len(systemSharedLibs) > 0 {
|
if len(systemSharedLibs) > 0 {
|
||||||
systemSharedLibs = android.FirstUniqueStrings(systemSharedLibs)
|
systemSharedLibs = android.FirstUniqueStrings(systemSharedLibs)
|
||||||
}
|
}
|
||||||
systemSharedDeps.SetSelectValue(axis, config, bazelLabelForSharedDeps(ctx, systemSharedLibs))
|
la.systemDynamicDeps.SetSelectValue(axis, config, bazelLabelForSharedDeps(ctx, systemSharedLibs))
|
||||||
|
|
||||||
sharedLibs := android.FirstUniqueStrings(baseLinkerProps.Shared_libs)
|
sharedLibs := android.FirstUniqueStrings(props.Shared_libs)
|
||||||
sharedDeps := maybePartitionExportedAndImplementationsDepsExcludes(ctx, !isBinary, sharedLibs, baseLinkerProps.Exclude_shared_libs, baseLinkerProps.Export_shared_lib_headers, bazelLabelForSharedDepsExcludes)
|
sharedDeps := maybePartitionExportedAndImplementationsDepsExcludes(ctx, !isBinary, sharedLibs, props.Exclude_shared_libs, props.Export_shared_lib_headers, bazelLabelForSharedDepsExcludes)
|
||||||
dynamicDeps.SetSelectValue(axis, config, sharedDeps.export)
|
la.dynamicDeps.SetSelectValue(axis, config, sharedDeps.export)
|
||||||
implementationDynamicDeps.SetSelectValue(axis, config, sharedDeps.implementation)
|
la.implementationDynamicDeps.SetSelectValue(axis, config, sharedDeps.implementation)
|
||||||
|
|
||||||
headerLibs := android.FirstUniqueStrings(baseLinkerProps.Header_libs)
|
if !BoolDefault(props.Pack_relocations, packRelocationsDefault) {
|
||||||
hDeps := maybePartitionExportedAndImplementationsDeps(ctx, !isBinary, headerLibs, baseLinkerProps.Export_header_lib_headers, bazelLabelForHeaderDeps)
|
|
||||||
|
|
||||||
headerDeps.SetSelectValue(axis, config, hDeps.export)
|
|
||||||
implementationHeaderDeps.SetSelectValue(axis, config, hDeps.implementation)
|
|
||||||
|
|
||||||
if !BoolDefault(baseLinkerProps.Pack_relocations, packRelocationsDefault) {
|
|
||||||
axisFeatures = append(axisFeatures, "disable_pack_relocations")
|
axisFeatures = append(axisFeatures, "disable_pack_relocations")
|
||||||
}
|
}
|
||||||
|
|
||||||
if Bool(baseLinkerProps.Allow_undefined_symbols) {
|
if Bool(props.Allow_undefined_symbols) {
|
||||||
axisFeatures = append(axisFeatures, "-no_undefined_symbols")
|
axisFeatures = append(axisFeatures, "-no_undefined_symbols")
|
||||||
}
|
}
|
||||||
|
|
||||||
var linkerFlags []string
|
var linkerFlags []string
|
||||||
if len(baseLinkerProps.Ldflags) > 0 {
|
if len(props.Ldflags) > 0 {
|
||||||
linkerFlags = append(linkerFlags, baseLinkerProps.Ldflags...)
|
linkerFlags = append(linkerFlags, props.Ldflags...)
|
||||||
// binaries remove static flag if -shared is in the linker flags
|
// binaries remove static flag if -shared is in the linker flags
|
||||||
if module.Binary() && android.InList("-shared", linkerFlags) {
|
if isBinary && android.InList("-shared", linkerFlags) {
|
||||||
axisFeatures = append(axisFeatures, "-static_flag")
|
axisFeatures = append(axisFeatures, "-static_flag")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if baseLinkerProps.Version_script != nil {
|
if props.Version_script != nil {
|
||||||
label := android.BazelLabelForModuleSrcSingle(ctx, *baseLinkerProps.Version_script)
|
label := android.BazelLabelForModuleSrcSingle(ctx, *props.Version_script)
|
||||||
additionalLinkerInputs.SetSelectValue(axis, config, bazel.LabelList{Includes: []bazel.Label{label}})
|
la.additionalLinkerInputs.SetSelectValue(axis, config, bazel.LabelList{Includes: []bazel.Label{label}})
|
||||||
linkerFlags = append(linkerFlags, fmt.Sprintf("-Wl,--version-script,$(location %s)", label.Label))
|
linkerFlags = append(linkerFlags, fmt.Sprintf("-Wl,--version-script,$(location %s)", label.Label))
|
||||||
}
|
}
|
||||||
linkopts.SetSelectValue(axis, config, linkerFlags)
|
la.linkopts.SetSelectValue(axis, config, linkerFlags)
|
||||||
useLibcrt.SetSelectValue(axis, config, baseLinkerProps.libCrt())
|
la.useLibcrt.SetSelectValue(axis, config, props.libCrt())
|
||||||
|
|
||||||
// it's very unlikely for nocrt to be arch variant, so bp2build doesn't support it.
|
// it's very unlikely for nocrt to be arch variant, so bp2build doesn't support it.
|
||||||
if baseLinkerProps.crt() != nil {
|
if props.crt() != nil {
|
||||||
if axis == bazel.NoConfigAxis {
|
if axis == bazel.NoConfigAxis {
|
||||||
linkCrt.SetSelectValue(axis, config, baseLinkerProps.crt())
|
la.linkCrt.SetSelectValue(axis, config, props.crt())
|
||||||
} else if axis == bazel.ArchConfigurationAxis {
|
} else if axis == bazel.ArchConfigurationAxis {
|
||||||
disallowedArchVariantCrt = true
|
ctx.ModuleErrorf("nocrt is not supported for arch variants")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if axisFeatures != nil {
|
if axisFeatures != nil {
|
||||||
features.SetSelectValue(axis, config, axisFeatures)
|
la.features.SetSelectValue(axis, config, axisFeatures)
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if disallowedArchVariantCrt {
|
func (la *linkerAttributes) convertStripProps(ctx android.TopDownMutatorContext, module *Module) {
|
||||||
ctx.ModuleErrorf("nocrt is not supported for arch variants")
|
for axis, configToProps := range module.GetArchVariantProperties(ctx, &StripProperties{}) {
|
||||||
|
for config, props := range configToProps {
|
||||||
|
if stripProperties, ok := props.(*StripProperties); ok {
|
||||||
|
la.stripKeepSymbols.SetSelectValue(axis, config, stripProperties.Strip.Keep_symbols)
|
||||||
|
la.stripKeepSymbolsList.SetSelectValue(axis, config, stripProperties.Strip.Keep_symbols_list)
|
||||||
|
la.stripKeepSymbolsAndDebugFrame.SetSelectValue(axis, config, stripProperties.Strip.Keep_symbols_and_debug_frame)
|
||||||
|
la.stripAll.SetSelectValue(axis, config, stripProperties.Strip.All)
|
||||||
|
la.stripNone.SetSelectValue(axis, config, stripProperties.Strip.None)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (la *linkerAttributes) convertProductVariables(ctx android.TopDownMutatorContext, productVariableProps android.ProductConfigProperties) {
|
||||||
|
|
||||||
type productVarDep struct {
|
type productVarDep struct {
|
||||||
// the name of the corresponding excludes field, if one exists
|
// the name of the corresponding excludes field, if one exists
|
||||||
@@ -568,12 +575,11 @@ func bp2BuildParseLinkerProps(ctx android.TopDownMutatorContext, module *Module)
|
|||||||
|
|
||||||
productVarToDepFields := map[string]productVarDep{
|
productVarToDepFields := map[string]productVarDep{
|
||||||
// product variables do not support exclude_shared_libs
|
// product variables do not support exclude_shared_libs
|
||||||
"Shared_libs": productVarDep{attribute: &implementationDynamicDeps, depResolutionFunc: bazelLabelForSharedDepsExcludes},
|
"Shared_libs": productVarDep{attribute: &la.implementationDynamicDeps, depResolutionFunc: bazelLabelForSharedDepsExcludes},
|
||||||
"Static_libs": productVarDep{"Exclude_static_libs", &implementationDeps, bazelLabelForStaticDepsExcludes},
|
"Static_libs": productVarDep{"Exclude_static_libs", &la.implementationDeps, bazelLabelForStaticDepsExcludes},
|
||||||
"Whole_static_libs": productVarDep{"Exclude_static_libs", &wholeArchiveDeps, bazelLabelForWholeDepsExcludes},
|
"Whole_static_libs": productVarDep{"Exclude_static_libs", &la.wholeArchiveDeps, bazelLabelForWholeDepsExcludes},
|
||||||
}
|
}
|
||||||
|
|
||||||
productVariableProps := android.ProductVariableProperties(ctx)
|
|
||||||
for name, dep := range productVarToDepFields {
|
for name, dep := range productVarToDepFields {
|
||||||
props, exists := productVariableProps[name]
|
props, exists := productVariableProps[name]
|
||||||
excludeProps, excludesExists := productVariableProps[dep.excludesField]
|
excludeProps, excludesExists := productVariableProps[dep.excludesField]
|
||||||
@@ -608,38 +614,15 @@ func bp2BuildParseLinkerProps(ctx android.TopDownMutatorContext, module *Module)
|
|||||||
dep.attribute.SetSelectValue(bazel.ProductVariableConfigurationAxis(config), config, dep.depResolutionFunc(ctx, android.FirstUniqueStrings(includes), excludes))
|
dep.attribute.SetSelectValue(bazel.ProductVariableConfigurationAxis(config), config, dep.depResolutionFunc(ctx, android.FirstUniqueStrings(includes), excludes))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
headerDeps.Append(deps)
|
func (la *linkerAttributes) finalize() {
|
||||||
implementationHeaderDeps.Append(implementationDeps)
|
la.deps.ResolveExcludes()
|
||||||
|
la.implementationDeps.ResolveExcludes()
|
||||||
headerDeps.ResolveExcludes()
|
la.dynamicDeps.ResolveExcludes()
|
||||||
implementationHeaderDeps.ResolveExcludes()
|
la.implementationDynamicDeps.ResolveExcludes()
|
||||||
dynamicDeps.ResolveExcludes()
|
la.wholeArchiveDeps.ResolveExcludes()
|
||||||
implementationDynamicDeps.ResolveExcludes()
|
la.systemDynamicDeps.ForceSpecifyEmptyList = true
|
||||||
wholeArchiveDeps.ResolveExcludes()
|
|
||||||
|
|
||||||
return linkerAttributes{
|
|
||||||
deps: headerDeps,
|
|
||||||
implementationDeps: implementationHeaderDeps,
|
|
||||||
dynamicDeps: dynamicDeps,
|
|
||||||
implementationDynamicDeps: implementationDynamicDeps,
|
|
||||||
wholeArchiveDeps: wholeArchiveDeps,
|
|
||||||
systemDynamicDeps: systemSharedDeps,
|
|
||||||
|
|
||||||
linkCrt: linkCrt,
|
|
||||||
linkopts: linkopts,
|
|
||||||
useLibcrt: useLibcrt,
|
|
||||||
additionalLinkerInputs: additionalLinkerInputs,
|
|
||||||
|
|
||||||
// Strip properties
|
|
||||||
stripKeepSymbols: stripKeepSymbols,
|
|
||||||
stripKeepSymbolsAndDebugFrame: stripKeepSymbolsAndDebugFrame,
|
|
||||||
stripKeepSymbolsList: stripKeepSymbolsList,
|
|
||||||
stripAll: stripAll,
|
|
||||||
stripNone: stripNone,
|
|
||||||
|
|
||||||
features: features,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Relativize a list of root-relative paths with respect to the module's
|
// Relativize a list of root-relative paths with respect to the module's
|
||||||
|
@@ -293,8 +293,9 @@ func CcLibraryBp2Build(ctx android.TopDownMutatorContext) {
|
|||||||
|
|
||||||
sharedAttrs := bp2BuildParseSharedProps(ctx, m)
|
sharedAttrs := bp2BuildParseSharedProps(ctx, m)
|
||||||
staticAttrs := bp2BuildParseStaticProps(ctx, m)
|
staticAttrs := bp2BuildParseStaticProps(ctx, m)
|
||||||
compilerAttrs := bp2BuildParseCompilerProps(ctx, m)
|
baseAttributes := bp2BuildParseBaseProps(ctx, m)
|
||||||
linkerAttrs := bp2BuildParseLinkerProps(ctx, m)
|
compilerAttrs := baseAttributes.compilerAttributes
|
||||||
|
linkerAttrs := baseAttributes.linkerAttributes
|
||||||
exportedIncludes := bp2BuildParseExportedIncludes(ctx, m)
|
exportedIncludes := bp2BuildParseExportedIncludes(ctx, m)
|
||||||
|
|
||||||
srcs := compilerAttrs.srcs
|
srcs := compilerAttrs.srcs
|
||||||
@@ -309,6 +310,7 @@ func CcLibraryBp2Build(ctx android.TopDownMutatorContext) {
|
|||||||
Srcs: srcs,
|
Srcs: srcs,
|
||||||
Srcs_c: compilerAttrs.cSrcs,
|
Srcs_c: compilerAttrs.cSrcs,
|
||||||
Srcs_as: compilerAttrs.asSrcs,
|
Srcs_as: compilerAttrs.asSrcs,
|
||||||
|
Hdrs: compilerAttrs.hdrs,
|
||||||
|
|
||||||
Copts: compilerAttrs.copts,
|
Copts: compilerAttrs.copts,
|
||||||
Cppflags: compilerAttrs.cppFlags,
|
Cppflags: compilerAttrs.cppFlags,
|
||||||
@@ -2357,8 +2359,10 @@ func ccSharedOrStaticBp2BuildMutatorInternal(ctx android.TopDownMutatorContext,
|
|||||||
}
|
}
|
||||||
isStatic := modType == "cc_library_static"
|
isStatic := modType == "cc_library_static"
|
||||||
|
|
||||||
compilerAttrs := bp2BuildParseCompilerProps(ctx, module)
|
baseAttributes := bp2BuildParseBaseProps(ctx, module)
|
||||||
linkerAttrs := bp2BuildParseLinkerProps(ctx, module)
|
compilerAttrs := baseAttributes.compilerAttributes
|
||||||
|
linkerAttrs := baseAttributes.linkerAttributes
|
||||||
|
|
||||||
exportedIncludes := bp2BuildParseExportedIncludes(ctx, module)
|
exportedIncludes := bp2BuildParseExportedIncludes(ctx, module)
|
||||||
|
|
||||||
// Append shared/static{} stanza properties. These won't be specified on
|
// Append shared/static{} stanza properties. These won't be specified on
|
||||||
@@ -2388,6 +2392,7 @@ func ccSharedOrStaticBp2BuildMutatorInternal(ctx android.TopDownMutatorContext,
|
|||||||
Srcs_c: compilerAttrs.cSrcs,
|
Srcs_c: compilerAttrs.cSrcs,
|
||||||
Srcs_as: compilerAttrs.asSrcs,
|
Srcs_as: compilerAttrs.asSrcs,
|
||||||
Copts: compilerAttrs.copts,
|
Copts: compilerAttrs.copts,
|
||||||
|
Hdrs: compilerAttrs.hdrs,
|
||||||
|
|
||||||
Deps: linkerAttrs.deps,
|
Deps: linkerAttrs.deps,
|
||||||
Implementation_deps: linkerAttrs.implementationDeps,
|
Implementation_deps: linkerAttrs.implementationDeps,
|
||||||
|
@@ -132,7 +132,8 @@ func CcLibraryHeadersBp2Build(ctx android.TopDownMutatorContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
exportedIncludes := bp2BuildParseExportedIncludes(ctx, module)
|
exportedIncludes := bp2BuildParseExportedIncludes(ctx, module)
|
||||||
linkerAttrs := bp2BuildParseLinkerProps(ctx, module)
|
baseAttributes := bp2BuildParseBaseProps(ctx, module)
|
||||||
|
linkerAttrs := baseAttributes.linkerAttributes
|
||||||
|
|
||||||
attrs := &bazelCcLibraryHeadersAttributes{
|
attrs := &bazelCcLibraryHeadersAttributes{
|
||||||
Export_includes: exportedIncludes.Includes,
|
Export_includes: exportedIncludes.Includes,
|
||||||
@@ -140,6 +141,7 @@ func CcLibraryHeadersBp2Build(ctx android.TopDownMutatorContext) {
|
|||||||
Implementation_deps: linkerAttrs.implementationDeps,
|
Implementation_deps: linkerAttrs.implementationDeps,
|
||||||
Deps: linkerAttrs.deps,
|
Deps: linkerAttrs.deps,
|
||||||
System_dynamic_deps: linkerAttrs.systemDynamicDeps,
|
System_dynamic_deps: linkerAttrs.systemDynamicDeps,
|
||||||
|
Hdrs: baseAttributes.hdrs,
|
||||||
}
|
}
|
||||||
|
|
||||||
props := bazel.BazelTargetModuleProperties{
|
props := bazel.BazelTargetModuleProperties{
|
||||||
|
@@ -154,7 +154,8 @@ func ObjectBp2Build(ctx android.TopDownMutatorContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set arch-specific configurable attributes
|
// Set arch-specific configurable attributes
|
||||||
compilerAttrs := bp2BuildParseCompilerProps(ctx, m)
|
baseAttributes := bp2BuildParseBaseProps(ctx, m)
|
||||||
|
compilerAttrs := baseAttributes.compilerAttributes
|
||||||
var deps bazel.LabelListAttribute
|
var deps bazel.LabelListAttribute
|
||||||
systemDynamicDeps := bazel.LabelListAttribute{ForceSpecifyEmptyList: true}
|
systemDynamicDeps := bazel.LabelListAttribute{ForceSpecifyEmptyList: true}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user