diff options
author | 2023-08-22 19:24:07 +0000 | |
---|---|---|
committer | 2023-08-24 19:21:10 +0000 | |
commit | cb847638af5a56969929ddeae57d407fc8ad98c0 (patch) | |
tree | 6cc1e21dfecbabf6818fb3634f6dfae8c9c0b67c /python/python.go | |
parent | 4ed3d120c94833898b257920de3ff655d14faab5 (diff) |
Translate python_libray.pkg_path to proto.import_prefix
If a python_library uses a pkg_path foo/bar, then the proto srcs in
that libray need to import the dep .proto as foo/bar/proto.proto.
This behavior is restricted to python modules. To implement this is in
bp2build, this CL creates a new interface with a single method
`PkgPath`. Only python module structs implement this interface, and
this method is only available during bp2build
Test: Added a bp2build unit test
Test: TH
Change-Id: If8d207c0b321f75337a053795826b283a5eaaf46
Diffstat (limited to 'python/python.go')
-rw-r--r-- | python/python.go | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/python/python.go b/python/python.go index 6c837a888..7d77ca772 100644 --- a/python/python.go +++ b/python/python.go @@ -197,6 +197,14 @@ func (p *PythonLibraryModule) getPkgPath() string { return String(p.properties.Pkg_path) } +// PkgPath is the "public" version of `getPkgPath` that is only available during bp2build +func (p *PythonLibraryModule) PkgPath(ctx android.BazelConversionContext) *string { + if ctx.Config().BuildMode != android.Bp2build { + ctx.ModuleErrorf("PkgPath is only supported in bp2build mode") + } + return p.properties.Pkg_path +} + func (p *PythonLibraryModule) getBaseProperties() *BaseProperties { return &p.properties } |