diff options
Diffstat (limited to 'cc/binary.go')
-rw-r--r-- | cc/binary.go | 38 |
1 files changed, 9 insertions, 29 deletions
diff --git a/cc/binary.go b/cc/binary.go index e839122f4..50175d92f 100644 --- a/cc/binary.go +++ b/cc/binary.go @@ -69,13 +69,14 @@ func RegisterBinaryBuildComponents(ctx android.RegistrationContext) { // cc_binary produces a binary that is runnable on a device. func BinaryFactory() android.Module { - module, _ := NewBinary(android.HostAndDeviceSupported) + module, _ := newBinary(android.HostAndDeviceSupported, true) return module.Init() } // cc_binary_host produces a binary that is runnable on a host. func BinaryHostFactory() android.Module { - module, _ := NewBinary(android.HostSupported) + module, _ := newBinary(android.HostSupported, true) + module.bazelable = true return module.Init() } @@ -193,6 +194,10 @@ func (binary *binaryDecorator) linkerDeps(ctx DepsContext, deps Deps) Deps { // Individual module implementations which comprise a C++ binary should call this function, // set some fields on the result, and then call the Init function. func NewBinary(hod android.HostOrDeviceSupported) (*Module, *binaryDecorator) { + return newBinary(hod, true) +} + +func newBinary(hod android.HostOrDeviceSupported, bazelable bool) (*Module, *binaryDecorator) { module := newModule(hod, android.MultilibFirst) binary := &binaryDecorator{ baseLinker: NewBaseLinker(module.sanitize), @@ -201,6 +206,7 @@ func NewBinary(hod android.HostOrDeviceSupported) (*Module, *binaryDecorator) { module.compiler = NewBaseCompiler() module.linker = binary module.installer = binary + module.bazelable = bazelable // Allow module to be added as member of an sdk/module_exports. module.sdkMemberTypes = []android.SdkMemberType{ @@ -551,33 +557,7 @@ func (binary *binaryDecorator) verifyHostBionicLinker(ctx ModuleContext, in, lin }) } -func init() { - android.RegisterBp2BuildMutator("cc_binary", BinaryBp2build) - android.RegisterBp2BuildMutator("cc_binary_host", BinaryHostBp2build) -} - -func BinaryBp2build(ctx android.TopDownMutatorContext) { - binaryBp2build(ctx, "cc_binary") -} - -func BinaryHostBp2build(ctx android.TopDownMutatorContext) { - binaryBp2build(ctx, "cc_binary_host") -} - -func binaryBp2build(ctx android.TopDownMutatorContext, typ string) { - m, ok := ctx.Module().(*Module) - if !ok { - // Not a cc module - return - } - if !m.ConvertWithBp2build(ctx) { - return - } - - if ctx.ModuleType() != typ { - return - } - +func binaryBp2build(ctx android.TopDownMutatorContext, m *Module, typ string) { var compatibleWith bazel.StringListAttribute if typ == "cc_binary_host" { //incompatible with android OS |