diff options
author | 2022-10-13 03:35:38 +0000 | |
---|---|---|
committer | 2022-10-13 03:35:38 +0000 | |
commit | f18404f331e5e552d65283e307c865a9a2d44a90 (patch) | |
tree | eb586ba3b68cfe12637cf59be5983c027b9032a5 /python | |
parent | 49a9bfd8fd239c421b45d883801d63d196f5b850 (diff) | |
parent | 7d8f6182f9fb6cab1e292ea767dd2410726ac7dd (diff) |
Merge "Fix some issues in bp2build converter for python_binary_host."
Diffstat (limited to 'python')
-rw-r--r-- | python/binary.go | 26 | ||||
-rw-r--r-- | python/defaults.go | 4 |
2 files changed, 15 insertions, 15 deletions
diff --git a/python/binary.go b/python/binary.go index f4ad626b8..1f49a5476 100644 --- a/python/binary.go +++ b/python/binary.go @@ -34,7 +34,7 @@ func registerPythonBinaryComponents(ctx android.RegistrationContext) { } type bazelPythonBinaryAttributes struct { - Main *string + Main *bazel.Label Srcs bazel.LabelListAttribute Deps bazel.LabelListAttribute Python_version *string @@ -42,17 +42,6 @@ type bazelPythonBinaryAttributes struct { } func pythonBinaryBp2Build(ctx android.TopDownMutatorContext, m *Module) { - var main *string - for _, propIntf := range m.GetProperties() { - if props, ok := propIntf.(*BinaryProperties); ok { - // main is optional. - if props.Main != nil { - main = props.Main - break - } - } - } - // TODO(b/182306917): this doesn't fully handle all nested props versioned // by the python version, which would have been handled by the version split // mutator. This is sufficient for very simple python_binary_host modules @@ -72,13 +61,24 @@ func pythonBinaryBp2Build(ctx android.TopDownMutatorContext, m *Module) { baseAttrs := m.makeArchVariantBaseAttributes(ctx) attrs := &bazelPythonBinaryAttributes{ - Main: main, + Main: nil, Srcs: baseAttrs.Srcs, Deps: baseAttrs.Deps, Python_version: python_version, Imports: baseAttrs.Imports, } + for _, propIntf := range m.GetProperties() { + if props, ok := propIntf.(*BinaryProperties); ok { + // main is optional. + if props.Main != nil { + main := android.BazelLabelForModuleSrcSingle(ctx, *props.Main) + attrs.Main = &main + break + } + } + } + props := bazel.BazelTargetModuleProperties{ // Use the native py_binary rule. Rule_class: "py_binary", diff --git a/python/defaults.go b/python/defaults.go index c54e7d059..3dc5bc4d2 100644 --- a/python/defaults.go +++ b/python/defaults.go @@ -19,7 +19,7 @@ import ( ) func init() { - android.RegisterModuleType("python_defaults", defaultsFactory) + android.RegisterModuleType("python_defaults", DefaultsFactory) } type Defaults struct { @@ -30,7 +30,7 @@ type Defaults struct { func (d *Defaults) GenerateAndroidBuildActions(ctx android.ModuleContext) { } -func defaultsFactory() android.Module { +func DefaultsFactory() android.Module { module := &Defaults{} module.AddProperties( |