Merge "Don't use custom mixed build logic for cc_object"

This commit is contained in:
Liz Kammer 2021-03-31 18:43:55 +00:00 committed by Gerrit Code Review
commit 7dfaa3a732
2 changed files with 18 additions and 27 deletions

View File

@ -27,6 +27,7 @@ import (
"sync" "sync"
"android/soong/bazel/cquery" "android/soong/bazel/cquery"
"github.com/google/blueprint/bootstrap" "github.com/google/blueprint/bootstrap"
"android/soong/bazel" "android/soong/bazel"
@ -37,7 +38,6 @@ type CqueryRequestType int
const ( const (
getAllFiles CqueryRequestType = iota getAllFiles CqueryRequestType = iota
getCcObjectFiles
getAllFilesAndCcObjectFiles getAllFilesAndCcObjectFiles
) )
@ -56,10 +56,6 @@ type BazelContext interface {
// Returns result files built by building the given bazel target label. // Returns result files built by building the given bazel target label.
GetOutputFiles(label string, archType ArchType) ([]string, bool) GetOutputFiles(label string, archType ArchType) ([]string, bool)
// Returns object files produced by compiling the given cc-related target.
// Retrieves these files from Bazel's CcInfo provider.
GetCcObjectFiles(label string, archType ArchType) ([]string, bool)
// TODO(cparsons): Other cquery-related methods should be added here. // TODO(cparsons): Other cquery-related methods should be added here.
// Returns the results of GetOutputFiles and GetCcObjectFiles in a single query (in that order). // Returns the results of GetOutputFiles and GetCcObjectFiles in a single query (in that order).
GetOutputFilesAndCcObjectFiles(label string, archType ArchType) ([]string, []string, bool) GetOutputFilesAndCcObjectFiles(label string, archType ArchType) ([]string, []string, bool)
@ -116,11 +112,6 @@ func (m MockBazelContext) GetOutputFiles(label string, archType ArchType) ([]str
return result, ok return result, ok
} }
func (m MockBazelContext) GetCcObjectFiles(label string, archType ArchType) ([]string, bool) {
result, ok := m.AllFiles[label]
return result, ok
}
func (m MockBazelContext) GetOutputFilesAndCcObjectFiles(label string, archType ArchType) ([]string, []string, bool) { func (m MockBazelContext) GetOutputFilesAndCcObjectFiles(label string, archType ArchType) ([]string, []string, bool) {
result, ok := m.AllFiles[label] result, ok := m.AllFiles[label]
return result, result, ok return result, result, ok
@ -154,16 +145,6 @@ func (bazelCtx *bazelContext) GetOutputFiles(label string, archType ArchType) ([
return ret, ok return ret, ok
} }
func (bazelCtx *bazelContext) GetCcObjectFiles(label string, archType ArchType) ([]string, bool) {
rawString, ok := bazelCtx.cquery(label, cquery.GetCcObjectFiles, archType)
var returnResult []string
if ok {
bazelOutput := strings.TrimSpace(rawString)
returnResult = cquery.GetCcObjectFiles.ParseResult(bazelOutput).([]string)
}
return returnResult, ok
}
func (bazelCtx *bazelContext) GetOutputFilesAndCcObjectFiles(label string, archType ArchType) ([]string, []string, bool) { func (bazelCtx *bazelContext) GetOutputFilesAndCcObjectFiles(label string, archType ArchType) ([]string, []string, bool) {
var outputFiles []string var outputFiles []string
var ccObjects []string var ccObjects []string
@ -183,10 +164,6 @@ func (n noopBazelContext) GetOutputFiles(label string, archType ArchType) ([]str
panic("unimplemented") panic("unimplemented")
} }
func (n noopBazelContext) GetCcObjectFiles(label string, archType ArchType) ([]string, bool) {
panic("unimplemented")
}
func (n noopBazelContext) GetOutputFilesAndCcObjectFiles(label string, archType ArchType) ([]string, []string, bool) { func (n noopBazelContext) GetOutputFilesAndCcObjectFiles(label string, archType ArchType) ([]string, []string, bool) {
panic("unimplemented") panic("unimplemented")
} }
@ -332,8 +309,13 @@ local_repository(
name = "sourceroot", name = "sourceroot",
path = "%s", path = "%s",
) )
local_repository(
name = "rules_cc",
path = "%s/build/bazel/rules_cc",
)
` `
return []byte(fmt.Sprintf(formatString, context.workspaceDir)) return []byte(fmt.Sprintf(formatString, context.workspaceDir, context.workspaceDir))
} }
func (context *bazelContext) mainBzlFileContents() []byte { func (context *bazelContext) mainBzlFileContents() []byte {

View File

@ -53,8 +53,17 @@ type objectBazelHandler struct {
} }
func (handler *objectBazelHandler) generateBazelBuildActions(ctx android.ModuleContext, label string) bool { func (handler *objectBazelHandler) generateBazelBuildActions(ctx android.ModuleContext, label string) bool {
// TODO(b/181794963): restore mixed builds once cc_object incompatibility resolved bazelCtx := ctx.Config().BazelContext
objPaths, ok := bazelCtx.GetOutputFiles(label, ctx.Arch().ArchType)
if ok {
if len(objPaths) != 1 {
ctx.ModuleErrorf("expected exactly one object file for '%s', but got %s", label, objPaths)
return false return false
}
handler.module.outputFile = android.OptionalPathForPath(android.PathForBazelOut(ctx, objPaths[0]))
}
return ok
} }
type ObjectLinkerProperties struct { type ObjectLinkerProperties struct {