Merge "Lift BazelHandler interface into android/"
This commit is contained in:
committed by
Gerrit Code Review
commit
ccb6a01324
@@ -57,6 +57,17 @@ type cqueryKey struct {
|
|||||||
archType ArchType
|
archType ArchType
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// bazelHandler is the interface for a helper object related to deferring to Bazel for
|
||||||
|
// processing a module (during Bazel mixed builds). Individual module types should define
|
||||||
|
// their own bazel handler if they support deferring to Bazel.
|
||||||
|
type BazelHandler interface {
|
||||||
|
// Issue query to Bazel to retrieve information about Bazel's view of the current module.
|
||||||
|
// If Bazel returns this information, set module properties on the current module to reflect
|
||||||
|
// the returned information.
|
||||||
|
// Returns true if information was available from Bazel, false if bazel invocation still needs to occur.
|
||||||
|
GenerateBazelBuildActions(ctx ModuleContext, label string) bool
|
||||||
|
}
|
||||||
|
|
||||||
type BazelContext interface {
|
type BazelContext interface {
|
||||||
// The below methods involve queuing cquery requests to be later invoked
|
// The below methods involve queuing cquery requests to be later invoked
|
||||||
// by bazel. If any of these methods return (_, false), then the request
|
// by bazel. If any of these methods return (_, false), then the request
|
||||||
|
@@ -15,8 +15,9 @@
|
|||||||
package android
|
package android
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"android/soong/bazel"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"android/soong/bazel"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@@ -108,7 +109,7 @@ func FileGroupFactory() Module {
|
|||||||
return module
|
return module
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fg *fileGroup) generateBazelBuildActions(ctx ModuleContext) bool {
|
func (fg *fileGroup) GenerateBazelBuildActions(ctx ModuleContext) bool {
|
||||||
if !fg.MixedBuildsEnabled(ctx) {
|
if !fg.MixedBuildsEnabled(ctx) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@@ -131,7 +132,7 @@ func (fg *fileGroup) generateBazelBuildActions(ctx ModuleContext) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (fg *fileGroup) GenerateAndroidBuildActions(ctx ModuleContext) {
|
func (fg *fileGroup) GenerateAndroidBuildActions(ctx ModuleContext) {
|
||||||
if fg.generateBazelBuildActions(ctx) {
|
if fg.GenerateBazelBuildActions(ctx) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
15
cc/cc.go
15
cc/cc.go
@@ -589,17 +589,6 @@ type installer interface {
|
|||||||
installInRoot() bool
|
installInRoot() bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// bazelHandler is the interface for a helper object related to deferring to Bazel for
|
|
||||||
// processing a module (during Bazel mixed builds). Individual module types should define
|
|
||||||
// their own bazel handler if they support deferring to Bazel.
|
|
||||||
type bazelHandler interface {
|
|
||||||
// Issue query to Bazel to retrieve information about Bazel's view of the current module.
|
|
||||||
// If Bazel returns this information, set module properties on the current module to reflect
|
|
||||||
// the returned information.
|
|
||||||
// Returns true if information was available from Bazel, false if bazel invocation still needs to occur.
|
|
||||||
generateBazelBuildActions(ctx android.ModuleContext, label string) bool
|
|
||||||
}
|
|
||||||
|
|
||||||
type xref interface {
|
type xref interface {
|
||||||
XrefCcFiles() android.Paths
|
XrefCcFiles() android.Paths
|
||||||
}
|
}
|
||||||
@@ -796,7 +785,7 @@ type Module struct {
|
|||||||
compiler compiler
|
compiler compiler
|
||||||
linker linker
|
linker linker
|
||||||
installer installer
|
installer installer
|
||||||
bazelHandler bazelHandler
|
bazelHandler android.BazelHandler
|
||||||
|
|
||||||
features []feature
|
features []feature
|
||||||
stl *stl
|
stl *stl
|
||||||
@@ -1696,7 +1685,7 @@ func (c *Module) maybeGenerateBazelActions(actx android.ModuleContext) bool {
|
|||||||
bazelModuleLabel := c.GetBazelLabel(actx, c)
|
bazelModuleLabel := c.GetBazelLabel(actx, c)
|
||||||
bazelActionsUsed := false
|
bazelActionsUsed := false
|
||||||
if c.MixedBuildsEnabled(actx) && c.bazelHandler != nil {
|
if c.MixedBuildsEnabled(actx) && c.bazelHandler != nil {
|
||||||
bazelActionsUsed = c.bazelHandler.generateBazelBuildActions(actx, bazelModuleLabel)
|
bazelActionsUsed = c.bazelHandler.GenerateBazelBuildActions(actx, bazelModuleLabel)
|
||||||
}
|
}
|
||||||
return bazelActionsUsed
|
return bazelActionsUsed
|
||||||
}
|
}
|
||||||
|
@@ -556,7 +556,7 @@ type libraryDecorator struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type ccLibraryBazelHandler struct {
|
type ccLibraryBazelHandler struct {
|
||||||
bazelHandler
|
android.BazelHandler
|
||||||
|
|
||||||
module *Module
|
module *Module
|
||||||
}
|
}
|
||||||
@@ -642,7 +642,7 @@ func getTocFile(ctx android.ModuleContext, label string, outputFiles []string) a
|
|||||||
return android.OptionalPathForPath(android.PathForBazelOut(ctx, tocFile))
|
return android.OptionalPathForPath(android.PathForBazelOut(ctx, tocFile))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (handler *ccLibraryBazelHandler) generateBazelBuildActions(ctx android.ModuleContext, label string) bool {
|
func (handler *ccLibraryBazelHandler) GenerateBazelBuildActions(ctx android.ModuleContext, label string) bool {
|
||||||
bazelCtx := ctx.Config().BazelContext
|
bazelCtx := ctx.Config().BazelContext
|
||||||
ccInfo, ok, err := bazelCtx.GetCcInfo(label, ctx.Arch().ArchType)
|
ccInfo, ok, err := bazelCtx.GetCcInfo(label, ctx.Arch().ArchType)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@@ -44,13 +44,13 @@ func RegisterLibraryHeadersBuildComponents(ctx android.RegistrationContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type libraryHeaderBazelHander struct {
|
type libraryHeaderBazelHander struct {
|
||||||
bazelHandler
|
android.BazelHandler
|
||||||
|
|
||||||
module *Module
|
module *Module
|
||||||
library *libraryDecorator
|
library *libraryDecorator
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *libraryHeaderBazelHander) generateBazelBuildActions(ctx android.ModuleContext, label string) bool {
|
func (h *libraryHeaderBazelHander) GenerateBazelBuildActions(ctx android.ModuleContext, label string) bool {
|
||||||
bazelCtx := ctx.Config().BazelContext
|
bazelCtx := ctx.Config().BazelContext
|
||||||
ccInfo, ok, err := bazelCtx.GetCcInfo(label, ctx.Arch().ArchType)
|
ccInfo, ok, err := bazelCtx.GetCcInfo(label, ctx.Arch().ArchType)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@@ -47,12 +47,12 @@ type objectLinker struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type objectBazelHandler struct {
|
type objectBazelHandler struct {
|
||||||
bazelHandler
|
android.BazelHandler
|
||||||
|
|
||||||
module *Module
|
module *Module
|
||||||
}
|
}
|
||||||
|
|
||||||
func (handler *objectBazelHandler) generateBazelBuildActions(ctx android.ModuleContext, label string) bool {
|
func (handler *objectBazelHandler) GenerateBazelBuildActions(ctx android.ModuleContext, label string) bool {
|
||||||
bazelCtx := ctx.Config().BazelContext
|
bazelCtx := ctx.Config().BazelContext
|
||||||
objPaths, ok := bazelCtx.GetOutputFiles(label, ctx.Arch().ArchType)
|
objPaths, ok := bazelCtx.GetOutputFiles(label, ctx.Arch().ArchType)
|
||||||
if ok {
|
if ok {
|
||||||
|
@@ -15,9 +15,10 @@
|
|||||||
package cc
|
package cc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"android/soong/android"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"android/soong/android"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@@ -321,13 +322,13 @@ type prebuiltObjectLinker struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type prebuiltStaticLibraryBazelHandler struct {
|
type prebuiltStaticLibraryBazelHandler struct {
|
||||||
bazelHandler
|
android.BazelHandler
|
||||||
|
|
||||||
module *Module
|
module *Module
|
||||||
library *libraryDecorator
|
library *libraryDecorator
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *prebuiltStaticLibraryBazelHandler) generateBazelBuildActions(ctx android.ModuleContext, label string) bool {
|
func (h *prebuiltStaticLibraryBazelHandler) GenerateBazelBuildActions(ctx android.ModuleContext, label string) bool {
|
||||||
bazelCtx := ctx.Config().BazelContext
|
bazelCtx := ctx.Config().BazelContext
|
||||||
ccInfo, ok, err := bazelCtx.GetCcInfo(label, ctx.Arch().ArchType)
|
ccInfo, ok, err := bazelCtx.GetCcInfo(label, ctx.Arch().ArchType)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@@ -240,7 +240,7 @@ func toolDepsMutator(ctx android.BottomUpMutatorContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Returns true if information was available from Bazel, false if bazel invocation still needs to occur.
|
// Returns true if information was available from Bazel, false if bazel invocation still needs to occur.
|
||||||
func (c *Module) generateBazelBuildActions(ctx android.ModuleContext, label string) bool {
|
func (c *Module) GenerateBazelBuildActions(ctx android.ModuleContext, label string) bool {
|
||||||
bazelCtx := ctx.Config().BazelContext
|
bazelCtx := ctx.Config().BazelContext
|
||||||
filePaths, ok := bazelCtx.GetOutputFiles(label, ctx.Arch().ArchType)
|
filePaths, ok := bazelCtx.GetOutputFiles(label, ctx.Arch().ArchType)
|
||||||
if ok {
|
if ok {
|
||||||
@@ -560,7 +560,7 @@ func (g *Module) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||||||
bazelModuleLabel := g.GetBazelLabel(ctx, g)
|
bazelModuleLabel := g.GetBazelLabel(ctx, g)
|
||||||
bazelActionsUsed := false
|
bazelActionsUsed := false
|
||||||
if g.MixedBuildsEnabled(ctx) {
|
if g.MixedBuildsEnabled(ctx) {
|
||||||
bazelActionsUsed = g.generateBazelBuildActions(ctx, bazelModuleLabel)
|
bazelActionsUsed = g.GenerateBazelBuildActions(ctx, bazelModuleLabel)
|
||||||
}
|
}
|
||||||
if !bazelActionsUsed {
|
if !bazelActionsUsed {
|
||||||
// For <= 6 outputs, just embed those directly in the users. Right now, that covers >90% of
|
// For <= 6 outputs, just embed those directly in the users. Right now, that covers >90% of
|
||||||
|
Reference in New Issue
Block a user