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

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

Merge "Ensure data is passed to all generation actions" into main

parents b898c112 796921d2
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -115,8 +115,6 @@ var (
		"nos_app_weaver_service_genc++_headers",
		"nos_app_weaver_service_genc++_mock",
		"nos_generator_test_service_genc++",
		"framework-cppstream-protos",
		"framework-javastream-protos",
		"aidl_camera_build_version",
		"cronet_aml_base_android_runtime_unchecked_jni_headers",
		"cronet_aml_base_android_runtime_jni_headers",
+1 −1
Original line number Diff line number Diff line
@@ -435,6 +435,7 @@ func (g *Module) generateCommonBuildActions(ctx android.ModuleContext) {
		cmd = g.CmdModifier(ctx, cmd)
	}

	var extraInputs android.Paths
	// Generate tasks, either from genrule or gensrcs.
	for i, task := range g.taskGenerator(ctx, cmd, srcFiles) {
		if len(task.out) == 0 {
@@ -442,7 +443,6 @@ func (g *Module) generateCommonBuildActions(ctx android.ModuleContext) {
			return
		}

		var extraInputs android.Paths
		// Only handle extra inputs once as these currently are the same across all tasks
		if i == 0 {
			for name, values := range task.extraInputs {
+38 −4
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ import (
	"fmt"
	"os"
	"regexp"
	"strconv"
	"testing"

	"android/soong/android"
@@ -561,6 +562,8 @@ func TestGenSrcs(t *testing.T) {
		cmds   []string
		deps   []string
		files  []string
		shards int
		inputs []string
	}{
		{
			name: "gensrcs",
@@ -627,9 +630,29 @@ func TestGenSrcs(t *testing.T) {
				"out/soong/.intermediates/gen/gen/gensrcs/in2.h",
				"out/soong/.intermediates/gen/gen/gensrcs/in3.h",
			},
			shards: 2,
			inputs: []string{
				"baz.txt",
			},
		},
	}

	checkInputs := func(t *testing.T, rule android.TestingBuildParams, inputs []string) {
		t.Helper()
		if len(inputs) == 0 {
			return
		}
		inputBaseNames := map[string]bool{}
		for _, f := range rule.Implicits {
			inputBaseNames[f.Base()] = true
		}
		for _, f := range inputs {
			if _, ok := inputBaseNames[f]; !ok {
				t.Errorf("Expected to find input file %q for %q, but did not", f, rule.Description)
			}
		}
	}

	for _, test := range testcases {
		t.Run(test.name, func(t *testing.T) {
			bp := "gensrcs {\n"
@@ -647,10 +670,21 @@ func TestGenSrcs(t *testing.T) {
				ExtendWithErrorHandler(android.FixtureExpectsAllErrorsToMatchAPattern(expectedErrors)).
				RunTestWithBp(t, testGenruleBp()+bp)

			mod := result.ModuleForTests("gen", "")
			if expectedErrors != nil {
				return
			}

			if test.shards > 0 {
				for i := 0; i < test.shards; i++ {
					r := mod.Rule("generator" + strconv.Itoa(i))
					checkInputs(t, r, test.inputs)
				}
			} else {
				r := mod.Rule("generator")
				checkInputs(t, r, test.inputs)
			}

			gen := result.Module("gen", "").(*Module)
			android.AssertDeepEquals(t, "cmd", test.cmds, gen.rawCommands)