]> rtime.felk.cvut.cz Git - omk/sssa.git/commitdiff
Small enhancements
authorMichal Sojka <sojkam1@fel.cvut.cz>
Thu, 4 May 2006 15:59:00 +0000 (15:59 +0000)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Thu, 4 May 2006 15:59:00 +0000 (15:59 +0000)
darcs-hash:20060504155915-f2ef6-937bc9ea146fd2190e62fe2c5c99bac4b7517b8c.gz

omkbuild.py
test.py [new file with mode: 0755]
test/test1.rules [new file with mode: 0644]
test/test2.rules [new file with mode: 0644]
test/test3.rules [new file with mode: 0644]

index e88b29466010a8281fafd43cf26dd8779983fabb..f0b8a7cbbd2012eecfb76b3ad332221ca872a67b 100755 (executable)
@@ -3,6 +3,7 @@
 from optparse import OptionParser
 import os
 import sys
+import string
 
 class Snippet:
 
@@ -21,8 +22,9 @@ class Snippet:
         for line in f:
             if current == self.legal:
                 if line.strip() == "#": counter += 1
-                else: counter = 0
-                if counter == 2: current = self.doc
+                else:
+                    if counter == 2: current = self.doc
+                    counter = 0
             if line[0] != "#": current = self.code
             
             current.append(line)
@@ -51,7 +53,7 @@ def parseCommandLine():
                       help="Split given Makefile.rules to the original snippets")
     parser.add_option("-o", "--output",
                       action="store", dest="output", default=False, metavar="RULES",
-                      help="Split given Makefile.rules to the original snippets")
+                      help="Output built Makefile.rules to file RULES")
     (options, args) = parser.parse_args()
     return options, args
 
@@ -71,7 +73,10 @@ def buildRules(snippets, output):
 
     for type in ['legal', 'doc', 'code']:
         for snip in parts:
-            f.writelines(snip.__dict__[type])
+            if len(snip.__dict__[type]) == 0: continue
+            firstLine = string.rstrip(snip.__dict__[type][0])
+            f.write(firstLine.ljust(60)+" #@omk@%s\n"%snip.name)
+            f.writelines(snip.__dict__[type][1:])
     f.close()
 
 def main():
diff --git a/test.py b/test.py
new file mode 100755 (executable)
index 0000000..7983481
--- /dev/null
+++ b/test.py
@@ -0,0 +1,8 @@
+#!/usr/bin/env python
+
+import omkbuild
+import sys
+
+sys.argv = ['./omkbuild.py', 'test/test1.rules', 'test/test2.rules', 'test/test3.rules']
+
+omkbuild.main()
diff --git a/test/test1.rules b/test/test1.rules
new file mode 100644 (file)
index 0000000..adb9d09
--- /dev/null
@@ -0,0 +1,8 @@
+# Copyright blablabla
+#
+#
+# Doc strings here:
+# ble bleble
+
+all:
+       echo "Hello"
diff --git a/test/test2.rules b/test/test2.rules
new file mode 100644 (file)
index 0000000..094e7d5
--- /dev/null
@@ -0,0 +1,8 @@
+# Copyright ououou
+#
+#
+# Doc strings here:
+# zzzzzzzzzzz
+
+test2:
+       echo "Hello2"
diff --git a/test/test3.rules b/test/test3.rules
new file mode 100644 (file)
index 0000000..f19262c
--- /dev/null
@@ -0,0 +1,5 @@
+# Doc strings here:
+# wwwwwwwwwww
+
+test3:
+       echo "Hello3"