diff --git a/android/bazel_handler.go b/android/bazel_handler.go index 45dfbaa7d..abc793f8e 100644 --- a/android/bazel_handler.go +++ b/android/bazel_handler.go @@ -27,6 +27,7 @@ import ( "sync" "android/soong/bazel/cquery" + "github.com/google/blueprint/bootstrap" "android/soong/bazel" @@ -37,7 +38,6 @@ type CqueryRequestType int const ( getAllFiles CqueryRequestType = iota - getCcObjectFiles getAllFilesAndCcObjectFiles ) @@ -56,10 +56,6 @@ type BazelContext interface { // Returns result files built by building the given bazel target label. 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. // Returns the results of GetOutputFiles and GetCcObjectFiles in a single query (in that order). GetOutputFilesAndCcObjectFiles(label string, archType ArchType) ([]string, []string, bool) @@ -116,11 +112,6 @@ func (m MockBazelContext) GetOutputFiles(label string, archType ArchType) ([]str 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) { result, ok := m.AllFiles[label] return result, result, ok @@ -154,16 +145,6 @@ func (bazelCtx *bazelContext) GetOutputFiles(label string, archType ArchType) ([ 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) { var outputFiles []string var ccObjects []string @@ -183,10 +164,6 @@ func (n noopBazelContext) GetOutputFiles(label string, archType ArchType) ([]str 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) { panic("unimplemented") } @@ -332,8 +309,13 @@ local_repository( name = "sourceroot", 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 { diff --git a/cc/object.go b/cc/object.go index abc3e832a..aa63323e2 100644 --- a/cc/object.go +++ b/cc/object.go @@ -53,8 +53,17 @@ type objectBazelHandler struct { } func (handler *objectBazelHandler) generateBazelBuildActions(ctx android.ModuleContext, label string) bool { - // TODO(b/181794963): restore mixed builds once cc_object incompatibility resolved - return false + 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 + } + + handler.module.outputFile = android.OptionalPathForPath(android.PathForBazelOut(ctx, objPaths[0])) + } + return ok } type ObjectLinkerProperties struct {