Merge "mixed builds: add cc_test bazel handler, and add adbd_test to staging allowlist." am: 597894279d
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2337087 Change-Id: I4da1986a5b8db6bb8b359e850707ca9b097d8279 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -1373,5 +1373,6 @@ var (
|
|||||||
// also be built - do not add them to this list.
|
// also be built - do not add them to this list.
|
||||||
StagingMixedBuildsEnabledList = []string{
|
StagingMixedBuildsEnabledList = []string{
|
||||||
"com.android.adbd",
|
"com.android.adbd",
|
||||||
|
"adbd_test",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@@ -667,10 +667,12 @@ load(":main.bzl", "config_node", "mixed_build_root", "phony_root")
|
|||||||
|
|
||||||
mixed_build_root(name = "buildroot",
|
mixed_build_root(name = "buildroot",
|
||||||
deps = [%s],
|
deps = [%s],
|
||||||
|
testonly = True, # Unblocks testonly deps.
|
||||||
)
|
)
|
||||||
|
|
||||||
phony_root(name = "phonyroot",
|
phony_root(name = "phonyroot",
|
||||||
deps = [":buildroot"],
|
deps = [":buildroot"],
|
||||||
|
testonly = True, # Unblocks testonly deps.
|
||||||
)
|
)
|
||||||
`
|
`
|
||||||
configNodeFormatString := `
|
configNodeFormatString := `
|
||||||
@@ -678,6 +680,7 @@ config_node(name = "%s",
|
|||||||
arch = "%s",
|
arch = "%s",
|
||||||
os = "%s",
|
os = "%s",
|
||||||
deps = [%s],
|
deps = [%s],
|
||||||
|
testonly = True, # Unblocks testonly deps.
|
||||||
)
|
)
|
||||||
`
|
`
|
||||||
|
|
||||||
|
@@ -11,7 +11,7 @@ var (
|
|||||||
GetPythonBinary = &getPythonBinaryRequestType{}
|
GetPythonBinary = &getPythonBinaryRequestType{}
|
||||||
GetCcInfo = &getCcInfoType{}
|
GetCcInfo = &getCcInfoType{}
|
||||||
GetApexInfo = &getApexInfoType{}
|
GetApexInfo = &getApexInfoType{}
|
||||||
GetCcUnstrippedInfo = &getCcUnstippedInfoType{}
|
GetCcUnstrippedInfo = &getCcUnstrippedInfoType{}
|
||||||
)
|
)
|
||||||
|
|
||||||
type CcInfo struct {
|
type CcInfo struct {
|
||||||
@@ -275,13 +275,13 @@ func (g getApexInfoType) ParseResult(rawString string) (ApexInfo, error) {
|
|||||||
// getCcUnstrippedInfoType implements cqueryRequest interface. It handles the
|
// getCcUnstrippedInfoType implements cqueryRequest interface. It handles the
|
||||||
// interaction with `bazel cquery` to retrieve CcUnstrippedInfo provided
|
// interaction with `bazel cquery` to retrieve CcUnstrippedInfo provided
|
||||||
// by the` cc_binary` and `cc_shared_library` rules.
|
// by the` cc_binary` and `cc_shared_library` rules.
|
||||||
type getCcUnstippedInfoType struct{}
|
type getCcUnstrippedInfoType struct{}
|
||||||
|
|
||||||
func (g getCcUnstippedInfoType) Name() string {
|
func (g getCcUnstrippedInfoType) Name() string {
|
||||||
return "getCcUnstrippedInfo"
|
return "getCcUnstrippedInfo"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g getCcUnstippedInfoType) StarlarkFunctionBody() string {
|
func (g getCcUnstrippedInfoType) StarlarkFunctionBody() string {
|
||||||
return `unstripped_tag = "//build/bazel/rules/cc:stripped_cc_common.bzl%CcUnstrippedInfo"
|
return `unstripped_tag = "//build/bazel/rules/cc:stripped_cc_common.bzl%CcUnstrippedInfo"
|
||||||
p = providers(target)
|
p = providers(target)
|
||||||
output_path = target.files.to_list()[0].path
|
output_path = target.files.to_list()[0].path
|
||||||
@@ -298,7 +298,7 @@ return json_encode({
|
|||||||
// ParseResult returns a value obtained by parsing the result of the request's Starlark function.
|
// ParseResult returns a value obtained by parsing the result of the request's Starlark function.
|
||||||
// The given rawString must correspond to the string output which was created by evaluating the
|
// The given rawString must correspond to the string output which was created by evaluating the
|
||||||
// Starlark given in StarlarkFunctionBody.
|
// Starlark given in StarlarkFunctionBody.
|
||||||
func (g getCcUnstippedInfoType) ParseResult(rawString string) (CcUnstrippedInfo, error) {
|
func (g getCcUnstrippedInfoType) ParseResult(rawString string) (CcUnstrippedInfo, error) {
|
||||||
var info CcUnstrippedInfo
|
var info CcUnstrippedInfo
|
||||||
err := parseJson(rawString, &info)
|
err := parseJson(rawString, &info)
|
||||||
return info, err
|
return info, err
|
||||||
|
20
cc/cc.go
20
cc/cc.go
@@ -1858,7 +1858,22 @@ func (c *Module) QueueBazelCall(ctx android.BaseModuleContext) {
|
|||||||
c.bazelHandler.QueueBazelCall(ctx, c.getBazelModuleLabel(ctx))
|
c.bazelHandler.QueueBazelCall(ctx, c.getBazelModuleLabel(ctx))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
mixedBuildSupportedCcTest = []string{
|
||||||
|
"adbd_test",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
// IsMixedBuildSupported returns true if the module should be analyzed by Bazel
|
||||||
|
// in any of the --bazel-mode(s). This filters at the module level and takes
|
||||||
|
// precedence over the allowlists in allowlists/allowlists.go.
|
||||||
func (c *Module) IsMixedBuildSupported(ctx android.BaseModuleContext) bool {
|
func (c *Module) IsMixedBuildSupported(ctx android.BaseModuleContext) bool {
|
||||||
|
if c.testBinary() && !android.InList(c.Name(), mixedBuildSupportedCcTest) {
|
||||||
|
// Per-module rollout of mixed-builds for cc_test modules.
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// Enable mixed builds as long as the cc_* module type has a bazel handler.
|
||||||
return c.bazelHandler != nil
|
return c.bazelHandler != nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1888,6 +1903,8 @@ func (c *Module) ProcessBazelQueryResponse(ctx android.ModuleContext) {
|
|||||||
}
|
}
|
||||||
mctx.ctx = mctx
|
mctx.ctx = mctx
|
||||||
|
|
||||||
|
// TODO(b/244432500): Get the tradefed config from the bazel target instead
|
||||||
|
// of generating it with Soong.
|
||||||
c.maybeInstall(mctx, apexInfo)
|
c.maybeInstall(mctx, apexInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2038,6 +2055,9 @@ func (c *Module) maybeUnhideFromMake() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// maybeInstall is called at the end of both GenerateAndroidBuildActions and
|
||||||
|
// ProcessBazelQueryResponse to run the install hooks for installable modules,
|
||||||
|
// like binaries and tests.
|
||||||
func (c *Module) maybeInstall(ctx ModuleContext, apexInfo android.ApexInfo) {
|
func (c *Module) maybeInstall(ctx ModuleContext, apexInfo android.ApexInfo) {
|
||||||
if !proptools.BoolDefault(c.Installable(), true) {
|
if !proptools.BoolDefault(c.Installable(), true) {
|
||||||
// If the module has been specifically configure to not be installed then
|
// If the module has been specifically configure to not be installed then
|
||||||
|
27
cc/test.go
27
cc/test.go
@@ -23,6 +23,7 @@ import (
|
|||||||
|
|
||||||
"android/soong/android"
|
"android/soong/android"
|
||||||
"android/soong/bazel"
|
"android/soong/bazel"
|
||||||
|
"android/soong/bazel/cquery"
|
||||||
"android/soong/tradefed"
|
"android/soong/tradefed"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -135,6 +136,7 @@ func init() {
|
|||||||
// static_libs dependency on libgtests unless the gtest flag is set to false.
|
// static_libs dependency on libgtests unless the gtest flag is set to false.
|
||||||
func TestFactory() android.Module {
|
func TestFactory() android.Module {
|
||||||
module := NewTest(android.HostAndDeviceSupported, true)
|
module := NewTest(android.HostAndDeviceSupported, true)
|
||||||
|
module.bazelHandler = &ccTestBazelHandler{module: module}
|
||||||
return module.Init()
|
return module.Init()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -500,6 +502,7 @@ func getTradefedConfigOptions(ctx android.EarlyModuleContext, properties *TestBi
|
|||||||
|
|
||||||
func NewTest(hod android.HostOrDeviceSupported, bazelable bool) *Module {
|
func NewTest(hod android.HostOrDeviceSupported, bazelable bool) *Module {
|
||||||
module, binary := newBinary(hod, bazelable)
|
module, binary := newBinary(hod, bazelable)
|
||||||
|
module.bazelable = bazelable
|
||||||
module.multilib = android.MultilibBoth
|
module.multilib = android.MultilibBoth
|
||||||
binary.baseInstaller = NewTestInstaller()
|
binary.baseInstaller = NewTestInstaller()
|
||||||
|
|
||||||
@@ -663,6 +666,30 @@ func NewBenchmark(hod android.HostOrDeviceSupported) *Module {
|
|||||||
return 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
|
// binaryAttributes contains Bazel attributes corresponding to a cc test
|
||||||
type testBinaryAttributes struct {
|
type testBinaryAttributes struct {
|
||||||
binaryAttributes
|
binaryAttributes
|
||||||
|
Reference in New Issue
Block a user