Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7dfaa3a7 authored by Liz Kammer's avatar Liz Kammer Committed by Gerrit Code Review
Browse files

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

parents 301099e4 8206d4ff
Loading
Loading
Loading
Loading
+7 −25
Original line number Diff line number Diff line
@@ -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 {
+11 −2
Original line number Diff line number Diff line
@@ -53,10 +53,19 @@ type objectBazelHandler struct {
}

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
		}

		handler.module.outputFile = android.OptionalPathForPath(android.PathForBazelOut(ctx, objPaths[0]))
	}
	return ok
}

type ObjectLinkerProperties struct {
	// list of modules that should only provide headers for this module.
	Header_libs []string `android:"arch_variant,variant_prepend"`