summaryrefslogtreecommitdiff
path: root/python/binary.go
diff options
context:
space:
mode:
author Wei Li <weiwli@google.com> 2022-10-11 14:38:16 -0700
committer Wei Li <weiwli@google.com> 2022-10-12 17:43:20 -0700
commit7d8f6182f9fb6cab1e292ea767dd2410726ac7dd (patch)
tree4131804475e4fc6e1b00b17f0506d6579d38d1bf /python/binary.go
parent922875d1870ce4fbab6b01394960d2ab4e285f6f (diff)
Fix some issues in bp2build converter for python_binary_host.
1) Bp2build convert python_binary_host main attribute as LabelAttribute. Currently "main" attribute in python_binary_host is handled as string but for some modules (e.g certify_bootimg) the "main" attribute points to a file in its subpackage like "subpackage/file.py" and should be converted to "//.../subpackage:file.py". 2) Filter out duplicated labels in the merged list of "required" attributes of python_binary_host and its defaults. Test: b build //system/tools/mkbootimg:certify_bootimg Test: b build //build/make/tools/releasetools:check_target_files_signatures Bug: 253081249 Bug: 253101186 Change-Id: Ic2cb4cadec2c1348da70af9f0730da9914d3a8ca
Diffstat (limited to 'python/binary.go')
-rw-r--r--python/binary.go26
1 files changed, 13 insertions, 13 deletions
diff --git a/python/binary.go b/python/binary.go
index e6324a3b5..1c2b5552a 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",