summaryrefslogtreecommitdiff
path: root/cc/binary.go
diff options
context:
space:
mode:
author Yu Liu <yudiliu@google.com> 2022-02-08 14:15:12 -0800
committer Yu Liu <yudiliu@google.com> 2022-02-17 11:15:59 -0800
commit7f3605fee189e99cd50b03cd01f39d78da113f5d (patch)
treec444925e48b769219cf7da4186084397eca25dc9 /cc/binary.go
parentfc70d4d2be9364d693daeff953d16f318c3cfb6c (diff)
Enable cc_binary in mixed build.
Bug: 216114082 Test: Run mixed build on adbd apex and verify the pavkaged adbd binary; add unit test. Change-Id: Id11549a7952a7ce5ac02988b88b747bbfe8339ff Change-Id: If01efe076c223886278f466b65628602bff3a964
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)