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