summaryrefslogtreecommitdiff
path: root/node.gyp
blob: 0ca31d5d2e903fd623cb5bacbd4d50b0ef2f7a68 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
{
  'target_defaults': {
    'default_configuration': 'Debug',
    'configurations': {
      # TODO: hoist these out and put them somewhere common, because
      #       RuntimeLibrary MUST MATCH across the entire project
      'Debug': {
        'defines': [ 'DEBUG', '_DEBUG' ],
        'msvs_settings': {
          'VCCLCompilerTool': {
            'RuntimeLibrary': 1, # static debug
            'Optimization': 0, # /Od, no optimization
          },
        },
      },
      'Release': {
        'defines': [ 'NDEBUG' ],
        'msvs_settings': {
          'VCCLCompilerTool': {
            'RuntimeLibrary': 0, # static release
            'Optimization': 3, # /Ox, full optimization
            'FavorSizeOrSpeed': 1, # /Ot, favour speed over size
            'InlineFunctionExpansion': 2, # /Ob2, inline anything eligible
            'WholeProgramOptimization': 'true', # /GL, whole program optimization, needed for LTCG
          },
          'VCLinkerTool': {
            'LinkTimeCodeGeneration': 1, # link-time code generation
          },
        },
      }
    },
    'msvs_settings': {
      'VCCLCompilerTool': {
        'StringPooling': 'true', # pool string literals
        'DebugInformationFormat': 3, # Generate a PDB
        'AdditionalOptions': [
          '/MP', # compile across multiple CPUs, VC2008 setting
        ],
        'MultiProcessorCompilation': 'true', # compile across multiple CPUs, VC2010 setting
      },
      'VCLibrarianTool': {
      },
      'VCLinkerTool': {
        'GenerateDebugInformation': 'true',
      },
    },
    'conditions': [
      ['OS == "win"', {
        'defines': [
          'WIN32',
          # we don't really want VC++ warning us about
          # how dangerous C functions are...
          '_CRT_SECURE_NO_DEPRECATE',
          # ... or that C implementations shouldn't use
          # POSIX names
          '_CRT_NONSTDC_NO_DEPRECATE',
        ],
      }]
    ],
  },

  'variables': {
    'v8_use_snapshot': 'true',
    'target_arch': 'ia32',
    'node_use_dtrace': 'false',
    'node_use_openssl': 'true'
  },

  'targets': [
    {
      'target_name': 'node',
      'type': 'executable',

      'dependencies': [
        'deps/http_parser/http_parser.gyp:http_parser',
        'deps/v8/tools/gyp/v8.gyp:v8',
        'deps/uv/all.gyp:uv',
        'node_js2c#host',
      ],

      'include_dirs': [
        'src',
        'deps/uv/src/ares',
        '<(SHARED_INTERMEDIATE_DIR)' # for node_natives.h
      ],

      'sources': [
        'src/cares_wrap.cc',
        'src/handle_wrap.cc',
        'src/node.cc',
        'src/node_buffer.cc',
        'src/node_constants.cc',
        'src/node_dtrace.cc',
        'src/node_extensions.cc',
        'src/node_file.cc',
        'src/node_http_parser.cc',
        'src/node_javascript.cc',
        'src/node_main.cc',
        'src/node_os.cc',
        'src/node_script.cc',
        'src/node_string.cc',
        'src/pipe_wrap.cc',
        'src/stdio_wrap.cc',
        'src/stream_wrap.cc',
        'src/tcp_wrap.cc',
        'src/timer_wrap.cc',
        'src/process_wrap.cc',
      ],

      'defines': [
        'ARCH="<(target_arch)"',
        'PLATFORM="<(OS)"',
        '_LARGEFILE_SOURCE',
        '_FILE_OFFSET_BITS=64',
      ],

      'conditions': [
        [ 'node_use_openssl=="true"', {
          'libraries': [ '-lssl', '-lcrypto' ],
          'defines': [ 'HAVE_OPENSSL=1' ],
          'sources': [ 'src/node_crypto.cc' ],
        }, {
          'defines': [ 'HAVE_OPENSSL=0' ]
        }],

        [ 'OS=="win"', {
          'dependencies': [
            'deps/uv/deps/pthread-win32/build/all.gyp:pthread-win32',
          ],
          # openssl is not built using gyp, and needs to be 
          # built separately and placed outside the hierarchy.
          # the dependencies aren't set up yet to put it in 
          # place, so I'm going to force it off indiscrimately
          # for the time being. Because the above condition has
          # already kicked in, it's not enough simply to turn
          # 'node_use_openssl' off; I need to undo its effects
          'node_use_openssl': 'false',
          'defines!': [ 'HAVE_OPENSSL=1' ],
          'defines': [ 'HAVE_OPENSSL=0' ],
          'libraries!': [ '-lssl', '-lcrypto' ],
          'sources!': [ 'src/node_crypto.cc' ],
          'sources': [
            'src/platform_win32.cc',
            'src/node_stdio_win32.cc',
            # file operations depend on eio to link. uv contains eio in unix builds, but not win32. So we need to compile it here instead.
            'deps/uv/src/eio/eio.c',
          ],
          'defines': [
            'PTW32_STATIC_LIB',
            'FD_SETSIZE=1024',
            # we need to use node's preferred "win32" rather than gyp's preferred "win"
            'PLATFORM="win32"',
          ],
          'libraries': [
            '-lws2_32.lib',
            '-lwinmm.lib',
          ],
          'msvs_settings': {
            'VCCLCompilerTool': {
              'WarningLevel': '3',
            },
          },
        },{ # POSIX
          'defines': [ '__POSIX__' ],
          'sources': [
            'src/node_cares.cc',
            'src/node_net.cc',
            'src/node_signal_watcher.cc',
            'src/node_stat_watcher.cc',
            'src/node_io_watcher.cc',
            'src/node_stdio.cc',
            'src/node_child_process.cc',
            'src/node_timer.cc'
          ]
        }],
        [ 'OS=="mac"', {
          'sources': [ 'src/platform_darwin.cc' ],
          'libraries': [ '-framework Carbon' ],
        }]
      ]
    },

    {
      'target_name': 'node_js2c',
      'type': 'none',
      'toolsets': ['host'],
      'variables': {
        'library_files': [
          'src/node.js',
          'lib/_debugger.js',
          'lib/_linklist.js',
          'lib/assert.js',
          'lib/buffer.js',
          'lib/buffer_ieee754.js',
          'lib/child_process_legacy.js',
          'lib/child_process_uv.js',
          'lib/console.js',
          'lib/constants.js',
          'lib/crypto.js',
          'lib/dgram.js',
          'lib/dns_legacy.js',
          'lib/dns_uv.js',
          'lib/events.js',
          'lib/freelist.js',
          'lib/fs.js',
          'lib/http.js',
          'lib/http2.js',
          'lib/https.js',
          'lib/https2.js',
          'lib/module.js',
          'lib/net_legacy.js',
          'lib/net_uv.js',
          'lib/os.js',
          'lib/path.js',
          'lib/punycode.js',
          'lib/querystring.js',
          'lib/readline.js',
          'lib/repl.js',
          'lib/stream.js',
          'lib/string_decoder.js',
          'lib/sys.js',
          'lib/timers_legacy.js',
          'lib/timers_uv.js',
          'lib/tls.js',
          'lib/tty.js',
          'lib/tty_posix.js',
          'lib/tty_win32.js',
          'lib/url.js',
          'lib/util.js',
          'lib/vm.js',
        ],
      },

      'actions': [

        {
          'action_name': 'node_js2c',

          'inputs': [
            './tools/js2c.py',
            '<@(library_files)',
          ],

          'outputs': [
            '<(SHARED_INTERMEDIATE_DIR)/node_natives.h',
          ],

          # FIXME can the following conditions be shorted by just setting
          # macros.py into some variable which then gets included in the
          # action?

          'conditions': [
            [ 'node_use_dtrace=="true"', {
              'action': [
                'python',
                'tools/js2c.py',
                '<@(_outputs)',
                '<@(library_files)'
              ],
            }, { # No Dtrace
              'action': [
                'python',
                'tools/js2c.py',
                '<@(_outputs)',
                '<@(library_files)',
                'src/macros.py'
              ],
            }]
          ],
          'msvs_cygwin_shell': 0,
        },
      ],
    }, # end node_js2c
  ] # end targets
}