From 0d4a397656b45a88647f1f73588012ab5577c904 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 25 May 2017 15:40:51 -0700 Subject: [PATCH] Only rebuild test modules on non-Windows or release builds --- script/lib/util.py | 2 +- script/test.py | 23 +++++++++++++++++------ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/script/lib/util.py b/script/lib/util.py index b08f13996bc..053023dad09 100644 --- a/script/lib/util.py +++ b/script/lib/util.py @@ -265,7 +265,7 @@ def update_electron_modules(dirname, target_arch, nodedir): env['npm_config_target'] = version env['npm_config_nodedir'] = nodedir update_node_modules(dirname, env) - execute_stdout([NPM, 'rebuild'], env) + execute_stdout([NPM, 'rebuild'], env, dirname) def update_node_modules(dirname, env=None): diff --git a/script/test.py b/script/test.py index 19aeb5009c2..d9ed9c2b772 100755 --- a/script/test.py +++ b/script/test.py @@ -28,8 +28,7 @@ def main(): spec_modules = os.path.join(SOURCE_ROOT, 'spec', 'node_modules') if args.rebuild_native_modules or not os.path.isdir(spec_modules): - rebuild_native_modules(spec_modules, - os.path.join(SOURCE_ROOT, 'out', config)) + rebuild_native_modules(config, spec_modules) if sys.platform == 'darwin': electron = os.path.join(SOURCE_ROOT, 'out', config, @@ -79,6 +78,10 @@ def parse_args(): help='Rebuild native modules used by specs', action='store_true', required=False) + parser.add_argument('--ci', + help='Run tests in CI mode', + action='store_true', + required=False) parser.add_argument('-v', '--verbose', action='store_true', help='Prints the output of the subprocesses') @@ -112,20 +115,28 @@ def run_python_script(script, *args): return execute([sys.executable, script_path] + list(args)) -def rebuild_native_modules(modules_path, out_dir): +def rebuild_native_modules(config, modules_path): + out_dir = os.path.join(SOURCE_ROOT, 'out', config) version = get_electron_version() + node_dir = os.path.join(out_dir, 'node-{0}'.format(version)) run_python_script('create-node-headers.py', '--version', version, '--directory', out_dir) if PLATFORM == 'win32': - iojs_lib = os.path.join(out_dir, 'Release', 'iojs.lib') + lib_dir = os.path.join(node_dir, 'Release') + safe_mkdir(lib_dir) + iojs_lib = os.path.join(lib_dir, 'iojs.lib') atom_lib = os.path.join(out_dir, 'node.dll.lib') shutil.copy2(atom_lib, iojs_lib) - update_electron_modules(os.path.dirname(modules_path), get_target_arch(), - os.path.join(out_dir, 'node-{0}'.format(version))) + # Native modules can only be compiled against release builds on Windows + if config == 'R' or PLATFORM != 'win32': + update_electron_modules(os.path.dirname(modules_path), get_target_arch(), + node_dir) + else: + update_node_modules(os.path.dirname(modules_path)) if __name__ == '__main__':