summaryrefslogtreecommitdiff
path: root/cc/binary.go
diff options
context:
space:
mode:
Diffstat (limited to 'cc/binary.go')
-rw-r--r--cc/binary.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/cc/binary.go b/cc/binary.go
index 54fd339c2..6c7d581ec 100644
--- a/cc/binary.go
+++ b/cc/binary.go
@@ -70,6 +70,7 @@ func RegisterBinaryBuildComponents(ctx android.RegistrationContext) {
// cc_binary produces a binary that is runnable on a device.
func BinaryFactory() android.Module {
module, _ := newBinary(android.HostAndDeviceSupported, true)
+ module.bazelHandler = &ccBinaryBazelHandler{module: module}
return module.Init()
}
@@ -556,6 +557,28 @@ func (binary *binaryDecorator) verifyHostBionicLinker(ctx ModuleContext, in, lin
})
}
+type ccBinaryBazelHandler struct {
+ android.BazelHandler
+
+ module *Module
+}
+
+func (handler *ccBinaryBazelHandler) GenerateBazelBuildActions(ctx android.ModuleContext, label string) bool {
+ bazelCtx := ctx.Config().BazelContext
+ filePaths, ok := bazelCtx.GetOutputFiles(label, android.GetConfigKey(ctx))
+ if ok {
+ if len(filePaths) != 1 {
+ ctx.ModuleErrorf("expected exactly one output file for '%s', but got %s", label, filePaths)
+ return false
+ }
+ outputFilePath := android.PathForBazelOut(ctx, filePaths[0])
+ handler.module.outputFile = android.OptionalPathForPath(outputFilePath)
+ // TODO(b/220164721): We need to decide if we should return the stripped as the unstripped.
+ handler.module.linker.(*binaryDecorator).unstrippedOutputFile = outputFilePath
+ }
+ return ok
+}
+
func binaryBp2build(ctx android.TopDownMutatorContext, m *Module, typ string) {
baseAttrs := bp2BuildParseBaseProps(ctx, m)
binaryLinkerAttrs := bp2buildBinaryLinkerProps(ctx, m)