From 370f13c3bd64c888d14dbdc81497f665b43b0e79 Mon Sep 17 00:00:00 2001 From: Spandan Das Date: Wed, 31 May 2023 22:03:33 +0000 Subject: bp2build for java libraries using xsd_config srcs In Soong, java libraries can use src files generated from xsd_config. In Bazel, instead of providing srcs, java_xsd_config_library will provide a jar. Update bp2build so that all src references to xsd_config modules in srcs get routed to deps and exports attributes This CL creates an interface in build/soong/android to get around a circular dependency issue. The bp2build logic needs to exist in soong-java, but soong-java does have soong-xsdc in its package path. Use the interface and type assertions to special case xsd_config references Bug: 211678537 Test: bp2build test in sibling CL in system/tools/xsdc Change-Id: Ida924bb20b1fd7eb8beeef950b070d37a9c6f3b5 --- java/java.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'java/java.go') diff --git a/java/java.go b/java/java.go index aa9f936d0..d5ddbbe45 100644 --- a/java/java.go +++ b/java/java.go @@ -2798,6 +2798,14 @@ type bp2BuildJavaInfo struct { hasKotlin bool } +// Replaces //a/b/my_xsd_config with //a/b/my_xsd_config-java +func xsdConfigJavaTarget(ctx android.BazelConversionPathContext, mod blueprint.Module) string { + callback := func(xsd android.XsdConfigBp2buildTargets) string { + return xsd.JavaBp2buildTargetName() + } + return android.XsdConfigBp2buildTarget(ctx, mod, callback) +} + // convertLibraryAttrsBp2Build returns a javaCommonAttributes struct with // converted attributes shared across java_* modules and a bp2BuildJavaInfo struct // which has other non-attribute information needed for bp2build conversion @@ -2812,8 +2820,15 @@ func (m *Library) convertLibraryAttrsBp2Build(ctx android.TopDownMutatorContext) for axis, configToProps := range archVariantProps { for config, _props := range configToProps { if archProps, ok := _props.(*CommonProperties); ok { - archSrcs := android.BazelLabelForModuleSrcExcludes(ctx, archProps.Srcs, archProps.Exclude_srcs) + srcsNonXsd, srcsXsd := android.PartitionXsdSrcs(ctx, archProps.Srcs) + excludeSrcsNonXsd, _ := android.PartitionXsdSrcs(ctx, archProps.Exclude_srcs) + archSrcs := android.BazelLabelForModuleSrcExcludes(ctx, srcsNonXsd, excludeSrcsNonXsd) srcs.SetSelectValue(axis, config, archSrcs) + + // Add to static deps + xsdJavaConfigLibraryLabels := android.BazelLabelForModuleDepsWithFn(ctx, srcsXsd, xsdConfigJavaTarget) + staticDeps.Append(xsdJavaConfigLibraryLabels) + } } } -- cgit v1.2.3-59-g8ed1b