From 977ce4995d9690e3f875f024f0d5be81b334490a Mon Sep 17 00:00:00 2001
From: Marc Bonnici <marc.bonnici@arm.com>
Date: Thu, 16 Jan 2020 14:49:26 +0000
Subject: [PATCH] utils/types: Add `module_name_set` type

The list of modules retrieved from a `Target` may include configuration
as a dictionary. This helper function will produce a set of only the
module names allowing for comparison.
---
 wa/utils/types.py | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/wa/utils/types.py b/wa/utils/types.py
index 81fecaf6..03ab3206 100644
--- a/wa/utils/types.py
+++ b/wa/utils/types.py
@@ -218,6 +218,20 @@ def version_tuple(v):
     return tuple(map(str, (v.split("."))))
 
 
+def module_name_set(l):
+    """
+    Converts a list of target modules into a set of module names, disregarding
+    any configuration that may be present.
+    """
+    modules = set()
+    for m in l:
+        if m and isinstance(m, dict):
+            modules.update({k for k in m.keys()})
+        else:
+            modules.add(m)
+    return modules
+
+
 __counters = defaultdict(int)