summaryrefslogtreecommitdiff
path: root/tools/kamek.py
diff options
context:
space:
mode:
authorColin Noga <Tempus@chronometry.ca>2012-09-21 20:43:21 -0500
committerColin Noga <Tempus@chronometry.ca>2012-09-21 20:43:21 -0500
commitd47a9ed57a826d60c37bfa8a4ae00ccaba0ed806 (patch)
treec3f6657118d71abcd1ce3b4584b3e0472841e53f /tools/kamek.py
parent8d0a306f0a526a76182c8d2b513d7a0441d6f466 (diff)
parent5654d5c0a056f9cfc99ac608d16aa0a601b997f5 (diff)
downloadkamek-d47a9ed57a826d60c37bfa8a4ae00ccaba0ed806.tar.gz
kamek-d47a9ed57a826d60c37bfa8a4ae00ccaba0ed806.zip
Merge branch 'level-select' of ssh://treeki.rustedlogic.net:30000/Kamek into level-select
Diffstat (limited to 'tools/kamek.py')
-rw-r--r--tools/kamek.py35
1 files changed, 33 insertions, 2 deletions
diff --git a/tools/kamek.py b/tools/kamek.py
index ee67a5a..a82740f 100644
--- a/tools/kamek.py
+++ b/tools/kamek.py
@@ -35,10 +35,11 @@ show_cmd = False
delete_temp = True
override_config_file = None
only_build = None
+fast_hack = False
def parse_cmd_options():
- global use_rels, use_mw, use_wine, show_cmd, delete_temp, only_build
+ global use_rels, use_mw, use_wine, show_cmd, delete_temp, only_build, fast_hack
global override_config_file, gcc_type, gcc_path, mw_path
if '--no-rels' in sys.argv:
@@ -56,7 +57,9 @@ def parse_cmd_options():
if '--keep-temp' in sys.argv:
delete_temp = False
-
+ if '--fast-hack' in sys.argv:
+ fast_hack = True
+
only_build = []
@@ -408,6 +411,11 @@ class KamekBuilder(object):
self._moduleFiles = []
+
+ if fast_hack:
+ fast_cpp_path = os.path.join(self._configTempDir, 'fasthack.cpp')
+ fast_cpp = open(fast_cpp_path, 'w')
+
for m in self.project.modules:
for normal_sourcefile in m.data['source_files']:
print_debug('Compiling %s : %s' % (m.moduleName, normal_sourcefile))
@@ -421,6 +429,11 @@ class KamekBuilder(object):
# todo: better extension detection
if sourcefile.endswith('.s') or sourcefile.endswith('.S'):
command = as_command
+ elif sourcefile.endswith('.cpp') and fast_hack:
+ fast_cpp.write('//\n// %s\n//\n\n' % sourcefile)
+ fast_cpp.write(open(sourcefile, 'r').read())
+ fast_cpp.write('\n')
+ continue
else:
command = cc_command
@@ -440,6 +453,24 @@ class KamekBuilder(object):
self._moduleFiles.append(objfile)
+ if fast_hack:
+ fast_cpp.close()
+
+ print_debug('Fast compilation!!')
+ objfile = os.path.join(self._configTempDir, 'fasthack.o')
+
+ new_command = cc_command + ['-c', '-o', objfile, fast_cpp_path]
+ if show_cmd:
+ print_debug(new_command)
+
+ errorVal = subprocess.call(new_command)
+ if errorVal != 0:
+ print 'BUILD FAILED!'
+ print 'compiler returned %d - an error occurred while compiling the fast hack' % errorVal
+ sys.exit(1)
+
+ self._moduleFiles.append(objfile)
+
print_debug('Compilation complete')