Commits

Anonymous committed 429c0e0

Started adding support for graph modification based on the use of feature
declarations in module files.

Comments (0)

Files changed (1)

PyQt4-Qt-Embedded-Linux-patches/patch_files.py

 
 import os, glob, shutil, sys
 
-
 def find_files(pattern, path):
 
     files = glob.glob(os.path.join(path, pattern))
     
     return files
 
+def create_feature_map(paths):
+
+    features = {}
+    in_features = []
+    in_structures = []
+    declared_features = set()
+    
+    for path in paths:
+        print path
+        for line in open(path).readlines():
+            line = line.strip()
+            if line.startswith("%If ("):
+                feature = line[5:line.find(")", 5)]
+                in_features.append(feature)
+                in_structures.append(feature)
+                features.setdefault(feature, [])
+            elif line.startswith("%End"):
+                if in_features and in_structures[-1] == in_features[-1]:
+                    in_features.pop()
+                in_structures.pop()
+            elif line.startswith("%Include"):
+                for feature in in_features:
+                    features[feature].append(line[9:-4].strip())
+            elif line.startswith("%Feature"):
+                declared_features.add(line[9:].strip())
+            elif line.startswith("%"):
+                in_structures.append(line[1:])
+    
+    for feature in features.keys():
+        if feature not in declared_features:
+            del features[feature]
+
+    print features
+
+def change_graph(path):
+
+    lines = open(path).readlines()
+    
+    l = 0
+    while l < len(lines):
+
+       break
+
 
 if __name__ == "__main__":
 
             sys.stderr.write("Failed to patch file: %s\n" % target)
             sys.exit(1)
     
+    # Change the graph data structures of existing files to handle features.
+    feature_map = create_feature_map(find_files("Qt*mod"+os.extsep+"sip", target_dir))
+
+    for path in target_files:
+        change_graph(path)
+
     new_files = find_files("*"+os.extsep+"sip", patches_dir)
     
     target_files = map(lambda path: