| 18 | output_dir = os.path.join(os.path.abspath(node_root), 'out') |
| 19 | |
| 20 | def run_gyp(args): |
| 21 | # GYP bug. |
| 22 | # On msvs it will crash if it gets an absolute path. |
| 23 | # On Mac/make it will crash if it doesn't get an absolute path. |
| 24 | a_path = node_root if sys.platform == 'win32' else os.path.abspath(node_root) |
| 25 | args.append(os.path.join(a_path, 'node.gyp')) |
| 26 | common_fn = os.path.join(a_path, 'common.gypi') |
| 27 | options_fn = os.path.join(a_path, 'config.gypi') |
| 28 | |
| 29 | if os.path.exists(common_fn): |
| 30 | args.extend(['-I', common_fn]) |
| 31 | |
| 32 | if os.path.exists(options_fn): |
| 33 | args.extend(['-I', options_fn]) |
| 34 | |
| 35 | args.append('--depth=' + node_root) |
| 36 | |
| 37 | # There's a bug with windows which doesn't allow this feature. |
| 38 | if sys.platform != 'win32' and 'ninja' not in args: |
| 39 | # Tell gyp to write the Makefiles into output_dir |
| 40 | args.extend(['--generator-output', output_dir]) |
| 41 | |
| 42 | # Tell make to write its output into the same dir |
| 43 | args.extend(['-Goutput_dir=' + output_dir]) |
| 44 | |
| 45 | args.append('-Dcomponent=static_library') |
| 46 | args.append('-Dlibrary=static_library') |
| 47 | |
| 48 | rc = gyp.main(args) |
| 49 | if rc != 0: |
| 50 | print('Error running GYP') |
| 51 | sys.exit(rc) |
| 52 | |
| 53 | |
| 54 | if __name__ == '__main__': |