diff options
Diffstat (limited to 'methods.py')
-rw-r--r-- | methods.py | 114 |
1 files changed, 19 insertions, 95 deletions
diff --git a/methods.py b/methods.py index 33b8f1cbe7..f6c9e939c6 100644 --- a/methods.py +++ b/methods.py @@ -137,6 +137,7 @@ def detect_modules(): includes_cpp = "" register_cpp = "" unregister_cpp = "" + preregister_cpp = "" files = glob.glob("modules/*") files.sort() # so register_module_types does not change that often, and also plugins are registered in alphabetic order @@ -154,26 +155,37 @@ def detect_modules(): register_cpp += '#ifdef MODULE_' + x.upper() + '_ENABLED\n' register_cpp += '\tregister_' + x + '_types();\n' register_cpp += '#endif\n' + preregister_cpp += '#ifdef MODULE_' + x.upper() + '_ENABLED\n' + preregister_cpp += '#ifdef MODULE_' + x.upper() + '_HAS_PREREGISTER\n' + preregister_cpp += '\tpreregister_' + x + '_types();\n' + preregister_cpp += '#endif\n' + preregister_cpp += '#endif\n' unregister_cpp += '#ifdef MODULE_' + x.upper() + '_ENABLED\n' unregister_cpp += '\tunregister_' + x + '_types();\n' unregister_cpp += '#endif\n' except IOError: pass - modules_cpp = """ -// modules.cpp - THIS FILE IS GENERATED, DO NOT EDIT!!!!!!! + modules_cpp = """// register_module_types.gen.cpp +/* THIS FILE IS GENERATED DO NOT EDIT */ #include "register_module_types.h" -""" + includes_cpp + """ +#include "modules/modules_enabled.gen.h" + +%s + +void preregister_module_types() { +%s +} void register_module_types() { -""" + register_cpp + """ +%s } void unregister_module_types() { -""" + unregister_cpp + """ +%s } -""" +""" % (includes_cpp, preregister_cpp, register_cpp, unregister_cpp) # NOTE: It is safe to generate this file here, since this is still executed serially with open("modules/register_module_types.gen.cpp", "w") as f: @@ -200,38 +212,11 @@ def win32_spawn(sh, escape, cmd, args, env): print("=====") return rv -""" -def win32_spawn(sh, escape, cmd, args, spawnenv): - import win32file - import win32event - import win32process - import win32security - for var in spawnenv: - spawnenv[var] = spawnenv[var].encode('ascii', 'replace') - - sAttrs = win32security.SECURITY_ATTRIBUTES() - StartupInfo = win32process.STARTUPINFO() - newargs = ' '.join(map(escape, args[1:])) - cmdline = cmd + " " + newargs - - # check for any special operating system commands - if cmd == 'del': - for arg in args[1:]: - win32file.DeleteFile(arg) - exit_code = 0 - else: - # otherwise execute the command. - hProcess, hThread, dwPid, dwTid = win32process.CreateProcess(None, cmdline, None, None, 1, 0, spawnenv, None, StartupInfo) - win32event.WaitForSingleObject(hProcess, win32event.INFINITE) - exit_code = win32process.GetExitCodeProcess(hProcess) - win32file.CloseHandle(hProcess); - win32file.CloseHandle(hThread); - return exit_code -""" def disable_module(self): self.disabled_modules.append(self.current_module) + def use_windows_spawn_fix(self, platform=None): if (os.name != "nt"): @@ -282,67 +267,6 @@ def use_windows_spawn_fix(self, platform=None): self['SPAWN'] = mySpawn -def split_lib(self, libname, src_list = None, env_lib = None): - env = self - - num = 0 - cur_base = "" - max_src = 64 - list = [] - lib_list = [] - - if src_list is None: - src_list = getattr(env, libname + "_sources") - - if type(env_lib) == type(None): - env_lib = env - - for f in src_list: - fname = "" - if type(f) == type(""): - fname = env.File(f).path - else: - fname = env.File(f)[0].path - fname = fname.replace("\\", "/") - base = "/".join(fname.split("/")[:2]) - if base != cur_base and len(list) > max_src: - if num > 0: - lib = env_lib.add_library(libname + str(num), list) - lib_list.append(lib) - list = [] - num = num + 1 - cur_base = base - list.append(f) - - lib = env_lib.add_library(libname + str(num), list) - lib_list.append(lib) - - lib_base = [] - env_lib.add_source_files(lib_base, "*.cpp") - lib = env_lib.add_library(libname, lib_base) - lib_list.insert(0, lib) - - env.Prepend(LIBS=lib_list) - - # When we split modules into arbitrary chunks, we end up with linking issues - # due to symbol dependencies split over several libs, which may not be linked - # in the required order. We use --start-group and --end-group to tell the - # linker that those archives should be searched repeatedly to resolve all - # undefined references. - # As SCons doesn't give us much control over how inserting libs in LIBS - # impacts the linker call, we need to hack our way into the linking commands - # LINKCOM and SHLINKCOM to set those flags. - - if '-Wl,--start-group' in env['LINKCOM'] and '-Wl,--start-group' in env['SHLINKCOM']: - # Already added by a previous call, skip. - return - - env['LINKCOM'] = str(env['LINKCOM']).replace('$_LIBFLAGS', - '-Wl,--start-group $_LIBFLAGS -Wl,--end-group') - env['SHLINKCOM'] = str(env['LINKCOM']).replace('$_LIBFLAGS', - '-Wl,--start-group $_LIBFLAGS -Wl,--end-group') - - def save_active_platforms(apnames, ap): for x in ap: |