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
This commit is contained in:
23
cc/binary.go
23
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)
|
||||
|
Reference in New Issue
Block a user