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

Commit 9eb4b706 authored by Jingwen Chen's avatar Jingwen Chen Committed by Automerger Merge Worker
Browse files

Stop relying on target.kind in mixed builds. am: 8f222742 am: ad5acd94 am: ab55d27f

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

Change-Id: Ifa3fcc9d6ba6efbc47f4e6a373803c40bbde54c8
parents 880554e2 ab55d27f
Loading
Loading
Loading
Loading
+4 −6
Original line number Original line Diff line number Diff line
@@ -587,13 +587,11 @@ 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)
  if buildoptions == None:
    # File targets do not have buildoptions. File targets aren't associated with
    #  any specific platform architecture in mixed builds.
    return "common"
  platforms = build_options(target)["//command_line_option:platforms"]
  platforms = build_options(target)["//command_line_option:platforms"]
  if len(platforms) != 1:
  if len(platforms) != 1:
    # An individual configured target should have only one platform architecture.
    # An individual configured target should have only one platform architecture.
+13 −10
Original line number Original line Diff line number Diff line
@@ -112,15 +112,22 @@ func FileGroupFactory() Module {
	return module
	return module
}
}


func (fg *fileGroup) GenerateBazelBuildActions(ctx ModuleContext) bool {
func (fg *fileGroup) maybeGenerateBazelBuildActions(ctx ModuleContext) {
	if !fg.MixedBuildsEnabled(ctx) {
	if !fg.MixedBuildsEnabled(ctx) {
		return false
		return
	}

	archVariant := ctx.Arch().ArchType
	if len(fg.Srcs()) == 1 && fg.Srcs()[0].Base() == fg.Name() {
		// This will be a regular file target, not filegroup, in Bazel.
		// See FilegroupBp2Build for more information.
		archVariant = Common
	}
	}


	bazelCtx := ctx.Config().BazelContext
	bazelCtx := ctx.Config().BazelContext
	filePaths, ok := bazelCtx.GetOutputFiles(fg.GetBazelLabel(ctx, fg), Common)
	filePaths, ok := bazelCtx.GetOutputFiles(fg.GetBazelLabel(ctx, fg), archVariant)
	if !ok {
	if !ok {
		return false
		return
	}
	}


	bazelOuts := make(Paths, 0, len(filePaths))
	bazelOuts := make(Paths, 0, len(filePaths))
@@ -130,19 +137,15 @@ func (fg *fileGroup) GenerateBazelBuildActions(ctx ModuleContext) bool {
	}
	}


	fg.srcs = bazelOuts
	fg.srcs = bazelOuts

	return true
}
}


func (fg *fileGroup) GenerateAndroidBuildActions(ctx ModuleContext) {
func (fg *fileGroup) GenerateAndroidBuildActions(ctx ModuleContext) {
	if fg.GenerateBazelBuildActions(ctx) {
		return
	}

	fg.srcs = PathsForModuleSrcExcludes(ctx, fg.properties.Srcs, fg.properties.Exclude_srcs)
	fg.srcs = PathsForModuleSrcExcludes(ctx, fg.properties.Srcs, fg.properties.Exclude_srcs)
	if fg.properties.Path != nil {
	if fg.properties.Path != nil {
		fg.srcs = PathsWithModuleSrcSubDir(ctx, fg.srcs, String(fg.properties.Path))
		fg.srcs = PathsWithModuleSrcSubDir(ctx, fg.srcs, String(fg.properties.Path))
	}
	}

	fg.maybeGenerateBazelBuildActions(ctx)
}
}


func (fg *fileGroup) Srcs() Paths {
func (fg *fileGroup) Srcs() Paths {