diff options
author | Treeki <treeki@gmail.com> | 2012-09-16 04:59:03 +0200 |
---|---|---|
committer | Treeki <treeki@gmail.com> | 2012-09-16 04:59:03 +0200 |
commit | 7404c596e96bf18f458f10fb8f23ca6e1a25ca7d (patch) | |
tree | 4fcdf733873a6d74b13a986c98b6f845dd0ad3ca /tools/kamek.py | |
parent | 8102791c2222c31d80858cd1d12b208dcd4ecbc3 (diff) | |
download | kamek-7404c596e96bf18f458f10fb8f23ca6e1a25ca7d.tar.gz kamek-7404c596e96bf18f458f10fb8f23ca6e1a25ca7d.zip |
go speed! a terrible hack to make builds far faster
Diffstat (limited to 'tools/kamek.py')
-rw-r--r-- | tools/kamek.py | 35 |
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') |