c63677b3c9
This CL adds support to bp2build/Soong to dump a BUILD file under out/soong/soong_injection/targets containing alias targets to their real targets for every converted Soong module, regardless of whether they are handcrafted or generated. Test: TH Change-Id: Ic1816fda5d019c395301618134fac68b3057d752
31 lines
1 KiB
Go
31 lines
1 KiB
Go
package bp2build
|
|
|
|
import (
|
|
"android/soong/bazel"
|
|
"fmt"
|
|
)
|
|
|
|
// Data from the code generation process that is used to improve compatibility
|
|
// between build systems.
|
|
type CodegenCompatLayer struct {
|
|
// A map from the original module name to the generated/handcrafted Bazel
|
|
// label for legacy build systems to be able to build a fully-qualified
|
|
// Bazel target from an unique module name.
|
|
NameToLabelMap map[string]string
|
|
}
|
|
|
|
// Log an entry of module name -> Bazel target label.
|
|
func (compatLayer CodegenCompatLayer) AddNameToLabelEntry(name, label string) {
|
|
// The module name may be prefixed with bazel.BazelTargetModuleNamePrefix if
|
|
// generated from bp2build.
|
|
name = bazel.StripNamePrefix(name)
|
|
if existingLabel, ok := compatLayer.NameToLabelMap[name]; ok {
|
|
panic(fmt.Errorf(
|
|
"Module '%s' maps to more than one Bazel target label: %s, %s. "+
|
|
"This shouldn't happen. It probably indicates a bug with the bp2build internals.",
|
|
name,
|
|
existingLabel,
|
|
label))
|
|
}
|
|
compatLayer.NameToLabelMap[name] = label
|
|
}
|