rebuild-test-modules.py 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #!/usr/bin/env python
  2. import argparse
  3. import os
  4. import shutil
  5. import subprocess
  6. import sys
  7. from lib.config import PLATFORM, enable_verbose_mode, get_target_arch
  8. from lib.util import execute_stdout, get_electron_version, safe_mkdir, \
  9. update_node_modules, update_electron_modules
  10. SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
  11. def main():
  12. os.chdir(SOURCE_ROOT)
  13. args = parse_args()
  14. config = args.configuration
  15. if args.verbose:
  16. enable_verbose_mode()
  17. spec_modules = os.path.join(SOURCE_ROOT, 'spec', 'node_modules')
  18. out_dir = os.path.join(SOURCE_ROOT, 'out', config)
  19. version = get_electron_version()
  20. node_dir = os.path.join(out_dir, 'node-{0}'.format(version))
  21. # Create node headers
  22. script_path = os.path.join(SOURCE_ROOT, 'script', 'create-node-headers.py')
  23. execute_stdout([sys.executable, script_path, '--version', version,
  24. '--directory', out_dir])
  25. if PLATFORM == 'win32':
  26. lib_dir = os.path.join(node_dir, 'Release')
  27. safe_mkdir(lib_dir)
  28. iojs_lib = os.path.join(lib_dir, 'iojs.lib')
  29. atom_lib = os.path.join(out_dir, 'node.dll.lib')
  30. shutil.copy2(atom_lib, iojs_lib)
  31. # Native modules can only be compiled against release builds on Windows
  32. if config[0] == 'R' or PLATFORM != 'win32':
  33. update_electron_modules(os.path.dirname(spec_modules), get_target_arch(),
  34. node_dir)
  35. else:
  36. update_node_modules(os.path.dirname(spec_modules))
  37. def parse_args():
  38. parser = argparse.ArgumentParser(description='Rebuild native test modules')
  39. parser.add_argument('-v', '--verbose',
  40. action='store_true',
  41. help='Prints the output of the subprocesses')
  42. parser.add_argument('-c', '--configuration',
  43. help='Build configuration to rebuild modules against',
  44. default='D',
  45. required=False)
  46. return parser.parse_args()
  47. if __name__ == '__main__':
  48. sys.exit(main())