summaryrefslogtreecommitdiff
path: root/tools/kamek.py
diff options
context:
space:
mode:
authorTreeki <treeki@gmail.com>2012-09-16 20:13:29 +0200
committerTreeki <treeki@gmail.com>2012-09-16 20:13:29 +0200
commit7cccf6fd2715cd1fae9745ae2b15c077a97e4e2f (patch)
treec79a81d147511fcad842e8f1a64d9c0e58828ebb /tools/kamek.py
parentbe31f99777d00238151df5851042a9e896d24f74 (diff)
parenteb4b6edcbef13c80b0051abe9dc89c93e7a960d0 (diff)
downloadkamek-7cccf6fd2715cd1fae9745ae2b15c077a97e4e2f.tar.gz
kamek-7cccf6fd2715cd1fae9745ae2b15c077a97e4e2f.zip
Merge branch 'file-select' into level-select
Diffstat (limited to '')
-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')