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

Commit 9feb19ca authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge changes I6df9a14d,I830c53ef am: 62b843b9 am: 1309335a am: ee471c8e

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1818018

Change-Id: I61d70b553f355b90a8194d29e303413286ebc9fc
parents f8366ac0 ee471c8e
Loading
Loading
Loading
Loading
+5 −0
Original line number Original line Diff line number Diff line
@@ -182,6 +182,7 @@ var (
		"external/jemalloc_new":           Bp2BuildDefaultTrueRecursively,
		"external/jemalloc_new":           Bp2BuildDefaultTrueRecursively,
		"external/libcxx":                 Bp2BuildDefaultTrueRecursively,
		"external/libcxx":                 Bp2BuildDefaultTrueRecursively,
		"external/libcxxabi":              Bp2BuildDefaultTrueRecursively,
		"external/libcxxabi":              Bp2BuildDefaultTrueRecursively,
		"external/libcap":                 Bp2BuildDefaultTrueRecursively,
		"external/scudo":                  Bp2BuildDefaultTrueRecursively,
		"external/scudo":                  Bp2BuildDefaultTrueRecursively,
		"prebuilts/clang/host/linux-x86":  Bp2BuildDefaultTrueRecursively,
		"prebuilts/clang/host/linux-x86":  Bp2BuildDefaultTrueRecursively,
	}
	}
@@ -231,6 +232,10 @@ var (
		//external/brotli/...
		//external/brotli/...
		"brotli-fuzzer-corpus", // "declared output 'external/brotli/c/fuzz/73231c6592f195ffd41100b8706d1138ff6893b9' was not created by genrule"
		"brotli-fuzzer-corpus", // "declared output 'external/brotli/c/fuzz/73231c6592f195ffd41100b8706d1138ff6893b9' was not created by genrule"


		// //external/libcap/...
		"libcap",      // http://b/198595332, depends on _makenames, a cc_binary
		"cap_names.h", // http://b/198596102, depends on _makenames, a cc_binary

		// Tests. Handle later.
		// Tests. Handle later.
		"libbionic_tests_headers_posix", // http://b/186024507, cc_library_static, sched.h, time.h not found
		"libbionic_tests_headers_posix", // http://b/186024507, cc_library_static, sched.h, time.h not found
		"libjemalloc5_integrationtest",
		"libjemalloc5_integrationtest",
+28 −7
Original line number Original line Diff line number Diff line
@@ -27,9 +27,9 @@ import (
	"sync"
	"sync"


	"android/soong/bazel/cquery"
	"android/soong/bazel/cquery"
	"android/soong/shared"


	"android/soong/bazel"
	"android/soong/bazel"
	"android/soong/shared"
)
)


type cqueryRequest interface {
type cqueryRequest interface {
@@ -490,6 +490,12 @@ config_node(name = "%s",
    arch = "%s",
    arch = "%s",
    deps = [%s],
    deps = [%s],
)
)
`

	commonArchFilegroupString := `
filegroup(name = "common",
    srcs = [%s],
)
`
`


	configNodesSection := ""
	configNodesSection := ""
@@ -501,14 +507,22 @@ config_node(name = "%s",
		labelsByArch[archString] = append(labelsByArch[archString], labelString)
		labelsByArch[archString] = append(labelsByArch[archString], labelString)
	}
	}


	configNodeLabels := []string{}
	allLabels := []string{}
	for archString, labels := range labelsByArch {
	for archString, labels := range labelsByArch {
		configNodeLabels = append(configNodeLabels, fmt.Sprintf("\":%s\"", archString))
		if archString == "common" {
			// arch-less labels (e.g. filegroups) don't need a config_node
			allLabels = append(allLabels, "\":common\"")
			labelsString := strings.Join(labels, ",\n            ")
			configNodesSection += fmt.Sprintf(commonArchFilegroupString, labelsString)
		} else {
			// Create a config_node, and add the config_node's label to allLabels
			allLabels = append(allLabels, fmt.Sprintf("\":%s\"", archString))
			labelsString := strings.Join(labels, ",\n            ")
			labelsString := strings.Join(labels, ",\n            ")
			configNodesSection += fmt.Sprintf(configNodeFormatString, archString, archString, labelsString)
			configNodesSection += fmt.Sprintf(configNodeFormatString, archString, archString, labelsString)
		}
		}
	}


	return []byte(fmt.Sprintf(formatString, configNodesSection, strings.Join(configNodeLabels, ",\n            ")))
	return []byte(fmt.Sprintf(formatString, configNodesSection, strings.Join(allLabels, ",\n            ")))
}
}


func indent(original string) string {
func indent(original string) string {
@@ -573,6 +587,12 @@ def %s(target):
%s
%s


def get_arch(target):
def get_arch(target):
  # TODO(b/199363072): filegroups and file targets aren't associated with any
  # specific platform architecture in mixed builds. This is consistent with how
  # Soong treats filegroups, but it may not be the case with manually-written
  # filegroup BUILD targets.
  if target.kind in ["filegroup", ""]:
    return "common"
  buildoptions = build_options(target)
  buildoptions = build_options(target)
  platforms = build_options(target)["//command_line_option:platforms"]
  platforms = build_options(target)["//command_line_option:platforms"]
  if len(platforms) != 1:
  if len(platforms) != 1:
@@ -671,11 +691,12 @@ func (context *bazelContext) InvokeBazel() error {
	if err != nil {
	if err != nil {
		return err
		return err
	}
	}

	buildrootLabel := "@soong_injection//mixed_builds:buildroot"
	buildrootLabel := "@soong_injection//mixed_builds:buildroot"
	cqueryOutput, cqueryErr, err = context.issueBazelCommand(
	cqueryOutput, cqueryErr, err = context.issueBazelCommand(
		context.paths,
		context.paths,
		bazel.CqueryBuildRootRunName,
		bazel.CqueryBuildRootRunName,
		bazelCommand{"cquery", fmt.Sprintf("kind(rule, deps(%s))", buildrootLabel)},
		bazelCommand{"cquery", fmt.Sprintf("deps(%s)", buildrootLabel)},
		"--output=starlark",
		"--output=starlark",
		"--starlark:file="+absolutePath(cqueryFileRelpath))
		"--starlark:file="+absolutePath(cqueryFileRelpath))
	err = ioutil.WriteFile(filepath.Join(soongInjectionPath, "cquery.out"),
	err = ioutil.WriteFile(filepath.Join(soongInjectionPath, "cquery.out"),
+1 −1
Original line number Original line Diff line number Diff line
@@ -11,7 +11,7 @@ func TestRequestResultsAfterInvokeBazel(t *testing.T) {
	label := "//foo:bar"
	label := "//foo:bar"
	arch := Arm64
	arch := Arm64
	bazelContext, _ := testBazelContext(t, map[bazelCommand]string{
	bazelContext, _ := testBazelContext(t, map[bazelCommand]string{
		bazelCommand{command: "cquery", expression: "kind(rule, deps(@soong_injection//mixed_builds:buildroot))"}: `//foo:bar|arm64>>out/foo/bar.txt`,
		bazelCommand{command: "cquery", expression: "deps(@soong_injection//mixed_builds:buildroot)"}: `//foo:bar|arm64>>out/foo/bar.txt`,
	})
	})
	g, ok := bazelContext.GetOutputFiles(label, arch)
	g, ok := bazelContext.GetOutputFiles(label, arch)
	if ok {
	if ok {
+22 −1
Original line number Original line Diff line number Diff line
@@ -42,6 +42,27 @@ func FilegroupBp2Build(ctx TopDownMutatorContext) {


	srcs := bazel.MakeLabelListAttribute(
	srcs := bazel.MakeLabelListAttribute(
		BazelLabelForModuleSrcExcludes(ctx, fg.properties.Srcs, fg.properties.Exclude_srcs))
		BazelLabelForModuleSrcExcludes(ctx, fg.properties.Srcs, fg.properties.Exclude_srcs))

	// For Bazel compatibility, don't generate the filegroup if there is only 1
	// source file, and that the source file is named the same as the module
	// itself. In Bazel, eponymous filegroups like this would be an error.
	//
	// Instead, dependents on this single-file filegroup can just depend
	// on the file target, instead of rule target, directly.
	//
	// You may ask: what if a filegroup has multiple files, and one of them
	// shares the name? The answer: we haven't seen that in the wild, and
	// should lock Soong itself down to prevent the behavior. For now,
	// we raise an error if bp2build sees this problem.
	for _, f := range srcs.Value.Includes {
		if f.Label == fg.Name() {
			if len(srcs.Value.Includes) > 1 {
				ctx.ModuleErrorf("filegroup '%s' cannot contain a file with the same name", fg.Name())
			}
			return
		}
	}

	attrs := &bazelFilegroupAttributes{
	attrs := &bazelFilegroupAttributes{
		Srcs: srcs,
		Srcs: srcs,
	}
	}
@@ -97,7 +118,7 @@ func (fg *fileGroup) GenerateBazelBuildActions(ctx ModuleContext) bool {
	}
	}


	bazelCtx := ctx.Config().BazelContext
	bazelCtx := ctx.Config().BazelContext
	filePaths, ok := bazelCtx.GetOutputFiles(fg.GetBazelLabel(ctx, fg), ctx.Arch().ArchType)
	filePaths, ok := bazelCtx.GetOutputFiles(fg.GetBazelLabel(ctx, fg), Common)
	if !ok {
	if !ok {
		return false
		return false
	}
	}
+1 −0
Original line number Original line Diff line number Diff line
@@ -39,6 +39,7 @@ bootstrap_go_package {
        "cc_library_static_conversion_test.go",
        "cc_library_static_conversion_test.go",
        "cc_object_conversion_test.go",
        "cc_object_conversion_test.go",
        "conversion_test.go",
        "conversion_test.go",
        "filegroup_conversion_test.go",
        "performance_test.go",
        "performance_test.go",
        "prebuilt_etc_conversion_test.go",
        "prebuilt_etc_conversion_test.go",
        "python_binary_conversion_test.go",
        "python_binary_conversion_test.go",
Loading