pimgen: Enable multiple interface files

Allow more than one interface file and put declared interface yaml
files in interfaces.d, to draw attention to the intent is for
packages to install their interface requirements there.

Change-Id: Iab0d85eca7c5c3370978dc692d6ab8807108a2f7
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
diff --git a/pimgen.py b/pimgen.py
index 8e12944..95d9b72 100755
--- a/pimgen.py
+++ b/pimgen.py
@@ -49,9 +49,21 @@
             for e in yaml.load(fd.read()).get('events', {}):
                 events.append(parse_event(e))
 
-    # Import interfaces.yaml.
-    with open(os.path.join(args.inputdir, 'interfaces.yaml'), 'r') as fd:
-        interfaces = yaml.load(fd.read())
+    # Aggregate all the interface YAML in the interfaces.d
+    # directory into a single list of interfaces.
+    template = os.path.join(script_dir, 'generated.mako.cpp')
+    t = Template(filename=template)
+
+    interfaces_dir = os.path.join(args.inputdir, 'interfaces.d')
+    yaml_files = filter(
+        lambda x: x.endswith('.yaml'),
+        os.listdir(interfaces_dir))
+
+    interfaces = []
+    for x in yaml_files:
+        with open(os.path.join(interfaces_dir, x), 'r') as fd:
+            for i in yaml.load(fd.read()):
+                interfaces.append(i)
 
     # Render the template with the provided events and interfaces.
     template = os.path.join(script_dir, 'generated.mako.cpp')