Merge changes Id3de4ede,Iae326016 am: fe57ecfdef

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2172556

Change-Id: I06844917d9ee27bbb3f5ab85d976c5231f6ff695
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Alexander Smundak 2022-08-04 03:01:53 +00:00 committed by Automerger Merge Worker
commit d3252715f2
3 changed files with 33 additions and 24 deletions

View file

@ -35,6 +35,20 @@ const (
Bp2BuildTopLevel = "."
)
type BazelConversionStatus struct {
// Information about _all_ bp2build targets generated by this module. Multiple targets are
// supported as Soong handles some things within a single target that we may choose to split into
// multiple targets, e.g. renderscript, protos, yacc within a cc module.
Bp2buildInfo []bp2buildInfo `blueprint:"mutated"`
// UnconvertedBp2buildDep stores the module names of direct dependency that were not converted to
// Bazel
UnconvertedDeps []string `blueprint:"mutated"`
// MissingBp2buildDep stores the module names of direct dependency that were not found
MissingDeps []string `blueprint:"mutated"`
}
type bazelModuleProperties struct {
// The label of the Bazel target replacing this Soong module. When run in conversion mode, this
// will import the handcrafted build target into the autogenerated file. Note: this may result in

View file

@ -909,17 +909,8 @@ type commonProperties struct {
// constants in image.go, but can also be set to a custom value by individual module types.
ImageVariation string `blueprint:"mutated"`
// Information about _all_ bp2build targets generated by this module. Multiple targets are
// supported as Soong handles some things within a single target that we may choose to split into
// multiple targets, e.g. renderscript, protos, yacc within a cc module.
Bp2buildInfo []bp2buildInfo `blueprint:"mutated"`
// UnconvertedBp2buildDep stores the module names of direct dependency that were not converted to
// Bazel
UnconvertedBp2buildDeps []string `blueprint:"mutated"`
// MissingBp2buildDep stores the module names of direct dependency that were not found
MissingBp2buildDeps []string `blueprint:"mutated"`
// Bazel conversion status
BazelConversionStatus BazelConversionStatus `blueprint:"mutated"`
}
// CommonAttributes represents the common Bazel attributes from which properties
@ -1489,40 +1480,40 @@ func (b bp2buildInfo) BazelAttributes() []interface{} {
}
func (m *ModuleBase) addBp2buildInfo(info bp2buildInfo) {
m.commonProperties.Bp2buildInfo = append(m.commonProperties.Bp2buildInfo, info)
m.commonProperties.BazelConversionStatus.Bp2buildInfo = append(m.commonProperties.BazelConversionStatus.Bp2buildInfo, info)
}
// IsConvertedByBp2build returns whether this module was converted via bp2build.
func (m *ModuleBase) IsConvertedByBp2build() bool {
return len(m.commonProperties.Bp2buildInfo) > 0
return len(m.commonProperties.BazelConversionStatus.Bp2buildInfo) > 0
}
// Bp2buildTargets returns the Bazel targets bp2build generated for this module.
func (m *ModuleBase) Bp2buildTargets() []bp2buildInfo {
return m.commonProperties.Bp2buildInfo
return m.commonProperties.BazelConversionStatus.Bp2buildInfo
}
// AddUnconvertedBp2buildDep stores module name of a dependency that was not converted to Bazel.
func (b *baseModuleContext) AddUnconvertedBp2buildDep(dep string) {
unconvertedDeps := &b.Module().base().commonProperties.UnconvertedBp2buildDeps
unconvertedDeps := &b.Module().base().commonProperties.BazelConversionStatus.UnconvertedDeps
*unconvertedDeps = append(*unconvertedDeps, dep)
}
// AddMissingBp2buildDep stores module name of a dependency that was not found in a Android.bp file.
func (b *baseModuleContext) AddMissingBp2buildDep(dep string) {
missingDeps := &b.Module().base().commonProperties.MissingBp2buildDeps
missingDeps := &b.Module().base().commonProperties.BazelConversionStatus.MissingDeps
*missingDeps = append(*missingDeps, dep)
}
// GetUnconvertedBp2buildDeps returns the list of module names of this module's direct dependencies that
// were not converted to Bazel.
func (m *ModuleBase) GetUnconvertedBp2buildDeps() []string {
return FirstUniqueStrings(m.commonProperties.UnconvertedBp2buildDeps)
return FirstUniqueStrings(m.commonProperties.BazelConversionStatus.UnconvertedDeps)
}
// GetMissingBp2buildDeps eturns the list of module names that were not found in Android.bp files.
func (m *ModuleBase) GetMissingBp2buildDeps() []string {
return FirstUniqueStrings(m.commonProperties.MissingBp2buildDeps)
return FirstUniqueStrings(m.commonProperties.BazelConversionStatus.MissingDeps)
}
func (m *ModuleBase) AddJSONData(d *map[string]interface{}) {

View file

@ -44,14 +44,18 @@ declare -r go_extractor=$(realpath prebuilts/build-tools/linux-x86/bin/go_extrac
declare -r go_root=$(realpath prebuilts/go/linux-x86)
declare -r source_root=$PWD
# TODO(asmundak): Until b/182183061 is fixed, default corpus has to be specified
# in the rules file. Generate this file on the fly with corpus value set from the
# environment variable.
for dir in blueprint soong; do
(cd "build/$dir";
# For the Go code, we invoke the extractor directly. The two caveats are that
# the extractor's rewrite rules are generated on the fly as they depend on the XREF_CORPUS
# value, and that the name of the kzip file is derived from the directory name
# by replacing '/' with '_'.
declare -ar go_modules=(build/blueprint build/soong
build/make/tools/canoninja build/make/tools/compliance build/make/tools/rbcrun)
for dir in "${go_modules[@]}"; do
(cd "$dir";
outfile=$(echo "$dir" | sed -r 's|/|_|g;s|(.*)|\1.go.kzip|');
KYTHE_ROOT_DIRECTORY="${source_root}" "$go_extractor" --goroot="$go_root" \
--rules=<(printf '[{"pattern": "(.*)","vname": {"path": "@1@", "corpus":"%s"}}]' "${XREF_CORPUS}") \
--canonicalize_package_corpus --output "${abspath_out}/soong/build_${dir}.go.kzip" ./...
--canonicalize_package_corpus --output "${abspath_out}/soong/$outfile" ./...
)
done