aboutsummaryrefslogtreecommitdiff
path: root/tools/mhmake/addstdafxh.py
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2010-10-30 18:34:27 +0000
committermarha <marha@users.sourceforge.net>2010-10-30 18:34:27 +0000
commit75ef19188d021a5e965198bde774c1c33bedc1f3 (patch)
treef20be1d1e684a5388c0e386ea302c1b3e98359d0 /tools/mhmake/addstdafxh.py
parentd9ddf066b898491827ffd6f1d115534c54c82f6b (diff)
downloadvcxsrv-75ef19188d021a5e965198bde774c1c33bedc1f3.tar.gz
vcxsrv-75ef19188d021a5e965198bde774c1c33bedc1f3.tar.bz2
vcxsrv-75ef19188d021a5e965198bde774c1c33bedc1f3.zip
Increased gnu make compatibility.
Diffstat (limited to 'tools/mhmake/addstdafxh.py')
-rw-r--r--tools/mhmake/addstdafxh.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/tools/mhmake/addstdafxh.py b/tools/mhmake/addstdafxh.py
new file mode 100644
index 000000000..45413a474
--- /dev/null
+++ b/tools/mhmake/addstdafxh.py
@@ -0,0 +1,33 @@
+import sys,re,os
+
+try:
+ InputFile=sys.argv[1]
+except:
+ print "No input file specified"
+ sys.exit(1)
+
+try:
+ InputFile=sys.argv[1]
+ pIN=open(InputFile,"r")
+ data=pIN.read()
+ pIN.close()
+except:
+ print "Error reading input file",InputFile
+ sys.exit(1)
+
+try:
+ pOUT=open(InputFile,"w")
+except:
+ print "Error opening",InputFile,"for writing"
+ sys.exit(1)
+
+pOUT.write("""#include "stdafx.h"\n""")
+#since we are going to add one line we need to update all line statements
+def IncrementLine(matchobj):
+ return "#line %d%s"%(int(matchobj.group(1))+1,matchobj.group(2))
+
+data=re.sub(r"#\s*line\s+(\d+)(.*%s)"%os.path.split(InputFile)[1],IncrementLine,data)
+
+pOUT.write(data)
+pOUT.close()
+