Merge "mixed builds: add cc_test bazel handler, and add adbd_test to staging allowlist."

This commit is contained in:
Treehugger Robot
2022-12-20 03:12:53 +00:00
committed by Gerrit Code Review
5 changed files with 56 additions and 5 deletions

View File

@@ -23,6 +23,7 @@ import (
"android/soong/android"
"android/soong/bazel"
"android/soong/bazel/cquery"
"android/soong/tradefed"
)
@@ -135,6 +136,7 @@ func init() {
// static_libs dependency on libgtests unless the gtest flag is set to false.
func TestFactory() android.Module {
module := NewTest(android.HostAndDeviceSupported, true)
module.bazelHandler = &ccTestBazelHandler{module: module}
return module.Init()
}
@@ -500,6 +502,7 @@ func getTradefedConfigOptions(ctx android.EarlyModuleContext, properties *TestBi
func NewTest(hod android.HostOrDeviceSupported, bazelable bool) *Module {
module, binary := newBinary(hod, bazelable)
module.bazelable = bazelable
module.multilib = android.MultilibBoth
binary.baseInstaller = NewTestInstaller()
@@ -663,6 +666,30 @@ func NewBenchmark(hod android.HostOrDeviceSupported) *Module {
return module
}
type ccTestBazelHandler struct {
module *Module
}
var _ BazelHandler = (*ccTestBazelHandler)(nil)
func (handler *ccTestBazelHandler) QueueBazelCall(ctx android.BaseModuleContext, label string) {
bazelCtx := ctx.Config().BazelContext
bazelCtx.QueueBazelRequest(label, cquery.GetCcUnstrippedInfo, android.GetConfigKey(ctx))
}
func (handler *ccTestBazelHandler) ProcessBazelQueryResponse(ctx android.ModuleContext, label string) {
bazelCtx := ctx.Config().BazelContext
info, err := bazelCtx.GetCcUnstrippedInfo(label, android.GetConfigKey(ctx))
if err != nil {
ctx.ModuleErrorf(err.Error())
return
}
outputFilePath := android.PathForBazelOut(ctx, info.OutputFile)
handler.module.outputFile = android.OptionalPathForPath(outputFilePath)
handler.module.linker.(*testBinary).unstrippedOutputFile = android.PathForBazelOut(ctx, info.UnstrippedOutput)
}
// binaryAttributes contains Bazel attributes corresponding to a cc test
type testBinaryAttributes struct {
binaryAttributes