Bp2build product variables on non-arch-variant module types

Mostly so that genrules can have their command qualified on a product
variable.

Bug: 295910468
Test: m nothing
Change-Id: I28cc18a1b3b00368f4768a1326259a656ce970ec
diff --git a/bp2build/genrule_conversion_test.go b/bp2build/genrule_conversion_test.go
index 2dcc5e4..5ca8bd7 100644
--- a/bp2build/genrule_conversion_test.go
+++ b/bp2build/genrule_conversion_test.go
@@ -773,7 +773,7 @@
 	}
 }
 
-func TestGenruleWithConfiguredCmd(t *testing.T) {
+func TestGenruleWithSoongConfigVariableConfiguredCmd(t *testing.T) {
 	testCases := []struct {
 		moduleType string
 		factory    android.ModuleFactory
@@ -846,3 +846,70 @@
 		})
 	}
 }
+
+func TestGenruleWithProductVariableConfiguredCmd(t *testing.T) {
+	testCases := []struct {
+		moduleType string
+		factory    android.ModuleFactory
+		hod        android.HostOrDeviceSupported
+	}{
+		{
+			moduleType: "genrule",
+			factory:    genrule.GenRuleFactory,
+		},
+		{
+			moduleType: "cc_genrule",
+			factory:    cc.GenRuleFactory,
+			hod:        android.DeviceSupported,
+		},
+		{
+			moduleType: "java_genrule",
+			factory:    java.GenRuleFactory,
+			hod:        android.DeviceSupported,
+		},
+		{
+			moduleType: "java_genrule_host",
+			factory:    java.GenRuleFactoryHost,
+			hod:        android.HostSupported,
+		},
+	}
+
+	bp := `
+
+%s {
+    name: "foo",
+    out: ["foo.txt"],
+    cmd: "echo 'no variable' > $(out)",
+    product_variables: {
+        debuggable: {
+            cmd: "echo 'with variable' > $(out)",
+        },
+    },
+    bazel_module: { bp2build_available: true },
+}
+`
+
+	for _, tc := range testCases {
+		moduleAttrs := AttrNameToString{
+			"cmd": `select({
+        "//build/bazel/product_config/config_settings:debuggable": "echo 'with variable' > $(OUTS)",
+        "//conditions:default": "echo 'no variable' > $(OUTS)",
+    })`,
+			"outs": `["foo.txt"]`,
+		}
+
+		expectedBazelTargets := []string{
+			makeBazelTargetHostOrDevice("genrule", "foo", moduleAttrs, tc.hod),
+		}
+
+		t.Run(tc.moduleType, func(t *testing.T) {
+			RunBp2BuildTestCase(t, func(ctx android.RegistrationContext) { android.RegisterSoongConfigModuleBuildComponents(ctx) },
+				Bp2buildTestCase{
+					Blueprint:                  fmt.Sprintf(bp, tc.moduleType),
+					ModuleTypeUnderTest:        tc.moduleType,
+					ModuleTypeUnderTestFactory: tc.factory,
+					ExpectedBazelTargets:       expectedBazelTargets,
+				})
+		})
+	}
+}