about summary refs log tree commit diff
path: root/scripts/compiler.py
diff options
context:
space:
mode:
authorMagnus Auvinen <magnus.auvinen@gmail.com>2007-12-15 10:24:49 +0000
committerMagnus Auvinen <magnus.auvinen@gmail.com>2007-12-15 10:24:49 +0000
commita2566b3ebd93e0bbc55a920a7be08054a9377f11 (patch)
tree44a4612805d894168fe4b3b4c065fccc1a1686e9 /scripts/compiler.py
parentac9873056aa1fe529b098f19ff31e9ffa0e016a2 (diff)
downloadzcatch-a2566b3ebd93e0bbc55a920a7be08054a9377f11.tar.gz
zcatch-a2566b3ebd93e0bbc55a920a7be08054a9377f11.zip
cleaned up code structure a bit
Diffstat (limited to 'scripts/compiler.py')
-rwxr-xr-xscripts/compiler.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/scripts/compiler.py b/scripts/compiler.py
index 53b9fd29..b883398a 100755
--- a/scripts/compiler.py
+++ b/scripts/compiler.py
@@ -2,6 +2,7 @@
 
 import sys
 import struct
+import os
 
 option_ptrsize = struct.calcsize("P")
 option_intsize = struct.calcsize("l")
@@ -491,10 +492,10 @@ class translator:
 		print >>out, ""
 		
 
-	def emit_source_code(self, out):
+	def emit_source_code(self, out, header_filename):
 		print >>out, '''
 
-#include "../data.h"
+#include "%s"
 #include <stdio.h>
 #include <stdlib.h>
 
@@ -502,7 +503,7 @@ static void patch_ptr(char **ptr, char *base)
 {
 	*ptr = base+(size_t)(*ptr);
 }
-'''
+''' % header_filename
 
 		for s in self.structs:
 			s.emit_source_code(out)
@@ -611,11 +612,13 @@ output_filename = 0
 coutput_filename = 0
 header_filename = 0
 source_filename = 0
+sheader_filename = 0
 
 if sys.argv[3] == '-h':
 	header_filename = sys.argv[4]
 elif sys.argv[3] == '-s':
 	source_filename = sys.argv[4]
+	sheader_filename = sys.argv[5]
 elif sys.argv[3] == '-d':
 	output_filename = sys.argv[4]
 elif sys.argv[3] == '-c':
@@ -629,7 +632,7 @@ translator = create_translator(script, srcdata)
 if header_filename:
 	translator.emit_header_code(file(header_filename, "w"))
 if source_filename:
-	translator.emit_source_code(file(source_filename, "w"))
+	translator.emit_source_code(file(source_filename, "w"), os.path.basename(sheader_filename))
 
 if output_filename:
 	rawdata = translator.emit_data()