1#!/usr/bin/env python 2from __future__ import print_function 3import os 4import sys 5 6script_dir = os.path.dirname(__file__) 7node_root = os.path.normpath(os.path.join(script_dir, os.pardir)) 8 9sys.path.insert(0, os.path.join(node_root, 'tools', 'gyp', 'pylib')) 10import gyp 11 12# Directory within which we want all generated files (including Makefiles) 13# to be written. 14output_dir = os.path.join(os.path.abspath(node_root), 'out') 15 16def run_gyp(args): 17 # GYP bug. 18 # On msvs it will crash if it gets an absolute path. 19 # On Mac/make it will crash if it doesn't get an absolute path. 20 a_path = node_root if sys.platform == 'win32' else os.path.abspath(node_root) 21 args.append(os.path.join(a_path, 'node.gyp')) 22 common_fn = os.path.join(a_path, 'common.gypi') 23 options_fn = os.path.join(a_path, 'config.gypi') 24 25 if os.path.exists(common_fn): 26 args.extend(['-I', common_fn]) 27 28 if os.path.exists(options_fn): 29 args.extend(['-I', options_fn]) 30 31 args.append('--depth=' + node_root) 32 33 # There's a bug with windows which doesn't allow this feature. 34 if sys.platform != 'win32' and 'ninja' not in args: 35 # Tell gyp to write the Makefiles into output_dir 36 args.extend(['--generator-output', output_dir]) 37 38 # Tell make to write its output into the same dir 39 args.extend(['-Goutput_dir=' + output_dir]) 40 41 args.append('-Dcomponent=static_library') 42 args.append('-Dlibrary=static_library') 43 44 rc = gyp.main(args) 45 if rc != 0: 46 print('Error running GYP') 47 sys.exit(rc) 48 49 50if __name__ == '__main__': 51 run_gyp(sys.argv[1:]) 52