Build: Add valid config list

Some specific build configs are needed to be appended.
It is more convenient to have a valid config list for this purpose.

Add some build configs in per-patch config group,
in case there are some build params not covered by Allow-CI.

Signed-off-by: Xinyu Zhang <xinyu.zhang@arm.com>
Change-Id: I46a713e44feb37a87bd7faad18f59b628dd78a65
diff --git a/build_helper/build_helper_configs.py b/build_helper/build_helper_configs.py
index 00e3325..9ee6c6c 100755
--- a/build_helper/build_helper_configs.py
+++ b/build_helper/build_helper_configs.py
@@ -782,6 +782,23 @@
                 "partition_ps":     ["ON", "OFF"],
                 },
                 "common_params": _common_tfm_builder_cfg,
+                "valid": [
+                    ("mps2/an521", "toolchain_GNUARM.cmake",
+                     False, "1", False, "OFF", "Debug",
+                     "off", True, True, "", "ON"),
+                    ("mps2/an521", "toolchain_ARMCLANG.cmake",
+                     True, "2", False, "OFF", "Debug",
+                     "off", True, True, "", "ON"),
+                    ("mps2/an521", "toolchain_ARMCLANG.cmake",
+                     True, "3", False, "OFF", "Release",
+                     "off", True, True, "", "ON"),
+                    ("mps2/an521", "toolchain_GNUARM.cmake",
+                     True, "2", False, "OFF", "Debug",
+                     "off", True, True, "profile_medium", "ON"),
+                    ("mps2/an521", "toolchain_GNUARM.cmake",
+                     True, "3", False, "OFF", "Debug",
+                     "off", True, True, "profile_large", "ON"),
+                ],
                 "invalid": _common_tfm_invalid_configs + [
                     # invalid configs that are not supported by TF-M
                     ("musca_s1", "*", "*", "*", "*", "*",
@@ -811,7 +828,7 @@
                      "*",  "*", "*", "*", "profile_small", "*"),
                     ("*", "toolchain_ARMCLANG.cmake", "*", "*", "*", "*",
                      "*",  "*", "*", "*", "profile_medium", "*"),
-                    ("*", "toolchain_ARMCLANG.cmake", "False", "*", "*", "*",
+                    ("*", "toolchain_ARMCLANG.cmake", False, "*", "*", "*",
                      "*",  "*", "*", "*", "*", "*"),
                 ]
                 }
diff --git a/tfm_ci_pylib/tfm_build_manager.py b/tfm_ci_pylib/tfm_build_manager.py
index a33c714..0c15bb6 100644
--- a/tfm_ci_pylib/tfm_build_manager.py
+++ b/tfm_ci_pylib/tfm_build_manager.py
@@ -502,6 +502,15 @@
                 # Subtract the two configurations
                 ret_cfg = {k: v for k, v in ret_cfg.items()
                            if k not in rejection_cfg}
+            # valid is an optional field. Do not proccess if it is missing
+            if "valid" in cfg:
+                # Valid configurations(Need to build)
+                valid_cfg = cfg["valid"]
+                # Add valid configs to build list
+                ret_cfg.update(TFM_Build_Manager.generate_optional_list(
+                    comb_cfg,
+                    static_cfg,
+                    valid_cfg))
             self.simple_config = False
         else:
             self.simple_config = True