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 options_fips_fn = os.path.join(a_path, 'config_fips.gypi') 25 26 if os.path.exists(common_fn): 27 args.extend(['-I', common_fn]) 28 29 if os.path.exists(options_fn): 30 args.extend(['-I', options_fn]) 31 32 if os.path.exists(options_fips_fn): 33 args.extend(['-I', options_fips_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 54if __name__ == '__main__': 55 run_gyp(sys.argv[1:]) 56