Loading android/proto.go +12 −0 Original line number Diff line number Diff line Loading @@ -281,6 +281,13 @@ func Bp2buildProtoProperties(ctx Bp2buildMutatorContext, m *ModuleBase, srcs baz } } if p, ok := m.module.(PkgPathInterface); ok && p.PkgPath(ctx) != nil { // python_library with pkg_path // proto_library for this module should have the pkg_path as the import_prefix attrs.Import_prefix = p.PkgPath(ctx) attrs.Strip_import_prefix = proptools.StringPtr("") } tags := ApexAvailableTagsWithoutTestApexes(ctx.(TopDownMutatorContext), ctx.Module()) moduleDir := ctx.ModuleDir() Loading Loading @@ -333,6 +340,11 @@ func Bp2buildProtoProperties(ctx Bp2buildMutatorContext, m *ModuleBase, srcs baz return info, true } // PkgPathInterface is used as a type assertion in bp2build to get pkg_path property of python_library_host type PkgPathInterface interface { PkgPath(ctx BazelConversionContext) *string } var ( protoIncludeDirGeneratedSuffix = ".include_dir_bp2build_generated_proto" protoIncludeDirsBp2buildKey = NewOnceKey("protoIncludeDirsBp2build") Loading bp2build/python_library_conversion_test.go +40 −0 Original line number Diff line number Diff line Loading @@ -348,3 +348,43 @@ func TestPythonLibraryWithProtobufs(t *testing.T) { }, }) } func TestPythonLibraryWithProtobufsAndPkgPath(t *testing.T) { t.Parallel() runBp2BuildTestCaseWithPythonLibraries(t, Bp2buildTestCase{ Description: "test python_library protobuf with pkg_path", Filesystem: map[string]string{ "dir/foo.proto": "", "dir/bar.proto": "", // bar contains "import dir/foo.proto" "dir/Android.bp": ` python_library { name: "foo", pkg_path: "dir", srcs: [ "foo.proto", "bar.proto", ], bazel_module: {bp2build_available: true}, }`, }, Dir: "dir", ExpectedBazelTargets: []string{ MakeBazelTarget("proto_library", "foo_proto", AttrNameToString{ "import_prefix": `"dir"`, "strip_import_prefix": `""`, "srcs": `[ "foo.proto", "bar.proto", ]`, }), MakeBazelTarget("py_proto_library", "foo_py_proto", AttrNameToString{ "deps": `[":foo_proto"]`, }), MakeBazelTarget("py_library", "foo", AttrNameToString{ "srcs_version": `"PY3"`, "imports": `[".."]`, "deps": `[":foo_py_proto"]`, }), }, }) } java/proto.go +12 −5 Original line number Diff line number Diff line Loading @@ -144,6 +144,13 @@ func protoFlags(ctx android.ModuleContext, j *CommonProperties, p *android.Proto type protoAttributes struct { Deps bazel.LabelListAttribute // A list of proto_library targets that the proto_library in `deps` depends on // This list is overestimation. // Overestimation is necessary since Soong includes other protos via proto.include_dirs and not // a specific .proto file module explicitly. Transitive_deps bazel.LabelListAttribute Sdk_version bazel.StringAttribute Java_version bazel.StringAttribute } Loading Loading @@ -176,9 +183,9 @@ func bp2buildProto(ctx android.Bp2buildMutatorContext, m *Module, protoSrcs baze ctx.PropertyErrorf("proto.type", "cannot handle conversion at this time: %q", typ) } protoLabel := bazel.Label{Label: ":" + m.Name() + "_proto"} protoAttrs := &protoAttributes{ Deps: bazel.MakeSingleLabelListAttribute(protoLabel), Deps: bazel.MakeLabelListAttribute(protoInfo.Proto_libs), Transitive_deps: bazel.MakeLabelListAttribute(protoInfo.Transitive_proto_libs), Java_version: bazel.StringAttribute{Value: m.properties.Java_version}, Sdk_version: bazel.StringAttribute{Value: m.deviceProperties.Sdk_version}, } Loading python/python.go +8 −0 Original line number Diff line number Diff line Loading @@ -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 } Loading Loading
android/proto.go +12 −0 Original line number Diff line number Diff line Loading @@ -281,6 +281,13 @@ func Bp2buildProtoProperties(ctx Bp2buildMutatorContext, m *ModuleBase, srcs baz } } if p, ok := m.module.(PkgPathInterface); ok && p.PkgPath(ctx) != nil { // python_library with pkg_path // proto_library for this module should have the pkg_path as the import_prefix attrs.Import_prefix = p.PkgPath(ctx) attrs.Strip_import_prefix = proptools.StringPtr("") } tags := ApexAvailableTagsWithoutTestApexes(ctx.(TopDownMutatorContext), ctx.Module()) moduleDir := ctx.ModuleDir() Loading Loading @@ -333,6 +340,11 @@ func Bp2buildProtoProperties(ctx Bp2buildMutatorContext, m *ModuleBase, srcs baz return info, true } // PkgPathInterface is used as a type assertion in bp2build to get pkg_path property of python_library_host type PkgPathInterface interface { PkgPath(ctx BazelConversionContext) *string } var ( protoIncludeDirGeneratedSuffix = ".include_dir_bp2build_generated_proto" protoIncludeDirsBp2buildKey = NewOnceKey("protoIncludeDirsBp2build") Loading
bp2build/python_library_conversion_test.go +40 −0 Original line number Diff line number Diff line Loading @@ -348,3 +348,43 @@ func TestPythonLibraryWithProtobufs(t *testing.T) { }, }) } func TestPythonLibraryWithProtobufsAndPkgPath(t *testing.T) { t.Parallel() runBp2BuildTestCaseWithPythonLibraries(t, Bp2buildTestCase{ Description: "test python_library protobuf with pkg_path", Filesystem: map[string]string{ "dir/foo.proto": "", "dir/bar.proto": "", // bar contains "import dir/foo.proto" "dir/Android.bp": ` python_library { name: "foo", pkg_path: "dir", srcs: [ "foo.proto", "bar.proto", ], bazel_module: {bp2build_available: true}, }`, }, Dir: "dir", ExpectedBazelTargets: []string{ MakeBazelTarget("proto_library", "foo_proto", AttrNameToString{ "import_prefix": `"dir"`, "strip_import_prefix": `""`, "srcs": `[ "foo.proto", "bar.proto", ]`, }), MakeBazelTarget("py_proto_library", "foo_py_proto", AttrNameToString{ "deps": `[":foo_proto"]`, }), MakeBazelTarget("py_library", "foo", AttrNameToString{ "srcs_version": `"PY3"`, "imports": `[".."]`, "deps": `[":foo_py_proto"]`, }), }, }) }
java/proto.go +12 −5 Original line number Diff line number Diff line Loading @@ -144,6 +144,13 @@ func protoFlags(ctx android.ModuleContext, j *CommonProperties, p *android.Proto type protoAttributes struct { Deps bazel.LabelListAttribute // A list of proto_library targets that the proto_library in `deps` depends on // This list is overestimation. // Overestimation is necessary since Soong includes other protos via proto.include_dirs and not // a specific .proto file module explicitly. Transitive_deps bazel.LabelListAttribute Sdk_version bazel.StringAttribute Java_version bazel.StringAttribute } Loading Loading @@ -176,9 +183,9 @@ func bp2buildProto(ctx android.Bp2buildMutatorContext, m *Module, protoSrcs baze ctx.PropertyErrorf("proto.type", "cannot handle conversion at this time: %q", typ) } protoLabel := bazel.Label{Label: ":" + m.Name() + "_proto"} protoAttrs := &protoAttributes{ Deps: bazel.MakeSingleLabelListAttribute(protoLabel), Deps: bazel.MakeLabelListAttribute(protoInfo.Proto_libs), Transitive_deps: bazel.MakeLabelListAttribute(protoInfo.Transitive_proto_libs), Java_version: bazel.StringAttribute{Value: m.properties.Java_version}, Sdk_version: bazel.StringAttribute{Value: m.deviceProperties.Sdk_version}, } Loading
python/python.go +8 −0 Original line number Diff line number Diff line Loading @@ -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 } Loading