]> rtime.felk.cvut.cz Git - omk.git/commitdiff
Hopefully, the final version of omkbuild script.
authorMichal Sojka <sojkam1@fel.cvut.cz>
Thu, 15 Jun 2006 11:56:00 +0000 (11:56 +0000)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Thu, 15 Jun 2006 11:56:00 +0000 (11:56 +0000)
darcs-hash:20060615115643-f2ef6-03af8c966be9eba0088f6d383ff08322b8f36fb5.gz

Makefile [new file with mode: 0644]
omkbuild.py

diff --git a/Makefile b/Makefile
new file mode 100644 (file)
index 0000000..54200ba
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,8 @@
+
+.PHONY: all split
+
+all:
+       ./omkbuild.py --all
+
+split:
+       ./omkbuild.py --split=Makefile.rules
\ No newline at end of file
index aab40c8d91f245b4856179d32704cb3fdf01bf85..3554e6485eb49900209226192094c1e3b260b324 100755 (executable)
@@ -31,10 +31,14 @@ Snippet syntax:
 
 from optparse import OptionParser
 import os
+import os.path
 import sys
 import string
 import re
 
+rulesDir = "rules"
+snippetsDir = "snippets"
+
 class LineList(list):
     """List of text lines"""
     def getDiff(self, other):
@@ -54,7 +58,12 @@ class LineList(list):
 
     def loadFromFile(self, fname):
         """Loads itself from file."""
-        f = open(fname, "r")
+        try:
+            f = open(fname, "r")
+        except IOError:
+            sys.stderr.write("Cannot open %s\n" % fname)
+            sys.exit(1)
+            
         self.extend(f.readlines())
         f.close
 
@@ -232,6 +241,9 @@ def parseCommandLine():
     parser.add_option("-o", "--output",
                       action="store", dest="output", default=False, metavar="RULES",
                       help="Write Makefile.rules to file RULES")
+    parser.add_option("-a", "--all",
+                      action="store_true", dest="all",
+                      help="Rebuild all rules acording to rulesdef.py")
     (options, args) = parser.parse_args()
     return options, args
 
@@ -278,10 +290,20 @@ def splitRules(rulesFN, output):
 #     f.writelines(rules.rules)
 #     f.close()
 
+def buildAllRules():
+    import rulesdef
+    os.chdir(snippetsDir)
+    for rules in rulesdef.rules:
+        print 'Building rules: %s' % rules
+        outputDir = os.path.join(sys.path[0], rulesDir, rules)
+        if not os.path.isdir(outputDir): os.makedirs(outputDir)
+        buildRules(rulesdef.rules[rules], os.path.join(outputDir, 'Makefile.rules'))
 
 def main():
     (options, args) = parseCommandLine()
-    if options.split:
+    if options.all:
+        buildAllRules()
+    elif options.split:
         splitRules(options.split, options.output)
     else:
         buildRules(args, options.output)