• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1{
2  # 'force_load' means to include the static libs into the shared lib or
3  # executable. Therefore, it is enabled when building:
4  # 1. The executable and it uses static lib (cctest and node)
5  # 2. The shared lib
6  # Linker optimizes out functions that are not used. When force_load=true,
7  # --whole-archive,force_load and /WHOLEARCHIVE are used to include
8  # all obj files in static libs into the executable or shared lib.
9  'variables': {
10    'variables': {
11      'variables': {
12        'force_load%': 'true',
13        'current_type%': '<(_type)',
14      },
15      'force_load%': '<(force_load)',
16      'conditions': [
17        ['current_type=="static_library"', {
18          'force_load': 'false',
19        }],
20        [ 'current_type=="executable" and node_target_type=="shared_library"', {
21          'force_load': 'false',
22        }]
23      ],
24    },
25    'force_load%': '<(force_load)',
26  },
27
28  'conditions': [
29    [ 'clang==1', {
30      'cflags': [ '-Werror=undefined-inline', '-Werror=extra-semi']
31    }],
32    [ '"<(_type)"=="executable"', {
33      'msvs_settings': {
34        'VCManifestTool': {
35          'EmbedManifest': 'true',
36          'AdditionalManifestFiles': 'src/res/node.exe.extra.manifest'
37        }
38      },
39    }],
40    [ 'node_shared=="true"', {
41      'defines': [
42        'NODE_SHARED_MODE',
43      ],
44      'conditions': [
45        ['"<(_type)"=="executable"', {
46          'defines': [
47            'USING_UV_SHARED',
48            'USING_V8_SHARED',
49            'BUILDING_NODE_EXTENSION'
50          ],
51          'defines!': [
52            'BUILDING_V8_SHARED=1',
53            'BUILDING_UV_SHARED=1'
54          ]
55        }],
56      ],
57    }],
58    [ 'OS=="win"', {
59      'defines!': [
60        'NODE_PLATFORM="win"',
61      ],
62      'defines': [
63        'FD_SETSIZE=1024',
64        # we need to use node's preferred "win32" rather than gyp's preferred "win"
65        'NODE_PLATFORM="win32"',
66        # Stop <windows.h> from defining macros that conflict with
67        # std::min() and std::max().  We don't use <windows.h> (much)
68        # but we still inherit it from uv.h.
69        'NOMINMAX',
70        '_UNICODE=1',
71      ],
72      'msvs_precompiled_header': 'tools/msvs/pch/node_pch.h',
73      'msvs_precompiled_source': 'tools/msvs/pch/node_pch.cc',
74      'sources': [
75        '<(_msvs_precompiled_header)',
76        '<(_msvs_precompiled_source)',
77      ],
78    }, { # POSIX
79      'defines': [ '__POSIX__' ],
80    }],
81    [ 'node_enable_d8=="true"', {
82      'dependencies': [ 'tools/v8_gypfiles/d8.gyp:d8' ],
83    }],
84    [ 'node_use_bundled_v8=="true"', {
85      'dependencies': [
86        'tools/v8_gypfiles/v8.gyp:v8_snapshot',
87        'tools/v8_gypfiles/v8.gyp:v8_libplatform',
88      ],
89    }],
90    [ 'node_use_v8_platform=="true"', {
91      'defines': [
92        'NODE_USE_V8_PLATFORM=1',
93      ],
94    }, {
95      'defines': [
96        'NODE_USE_V8_PLATFORM=0',
97      ],
98    }],
99    [ 'v8_enable_shared_ro_heap==1', {
100      'defines': ['NODE_V8_SHARED_RO_HEAP',],
101    }],
102    [ 'node_tag!=""', {
103      'defines': [ 'NODE_TAG="<(node_tag)"' ],
104    }],
105    [ 'node_v8_options!=""', {
106      'defines': [ 'NODE_V8_OPTIONS="<(node_v8_options)"'],
107    }],
108    [ 'node_release_urlbase!=""', {
109      'defines': [
110        'NODE_RELEASE_URLBASE="<(node_release_urlbase)"',
111      ]
112    }],
113    [ 'v8_enable_i18n_support==1', {
114      'defines': [ 'NODE_HAVE_I18N_SUPPORT=1' ],
115      'dependencies': [
116        '<(icu_gyp_path):icui18n',
117        '<(icu_gyp_path):icuuc',
118      ],
119      'conditions': [
120        [ 'icu_small=="true"', {
121          'defines': [ 'NODE_HAVE_SMALL_ICU=1' ],
122          'conditions': [
123            [ 'icu_default_data!=""', {
124              'defines': [
125                'NODE_ICU_DEFAULT_DATA_DIR="<(icu_default_data)"',
126              ],
127            }],
128          ],
129      }]],
130    }],
131    [ 'node_use_bundled_v8=="true" and \
132       node_enable_v8_vtunejit=="true" and (target_arch=="x64" or \
133       target_arch=="ia32" or target_arch=="x32")', {
134      'defines': [ 'NODE_ENABLE_VTUNE_PROFILING' ],
135      'dependencies': [
136        'tools/v8_gypfiles/v8vtune.gyp:v8_vtune'
137      ],
138    }],
139    [ 'node_no_browser_globals=="true"', {
140      'defines': [ 'NODE_NO_BROWSER_GLOBALS' ],
141    } ],
142    [ 'node_shared_zlib=="false"', {
143      'dependencies': [ 'deps/zlib/zlib.gyp:zlib' ],
144      'conditions': [
145        [ 'force_load=="true"', {
146          'xcode_settings': {
147            'OTHER_LDFLAGS': [
148              '-Wl,-force_load,<(PRODUCT_DIR)/<(STATIC_LIB_PREFIX)zlib<(STATIC_LIB_SUFFIX)',
149            ],
150          },
151          'msvs_settings': {
152            'VCLinkerTool': {
153              'AdditionalOptions': [
154                '/WHOLEARCHIVE:zlib<(STATIC_LIB_SUFFIX)',
155              ],
156            },
157          },
158          'conditions': [
159            ['OS!="aix" and OS!="os400" and OS!="ios" and node_shared=="false"', {
160              'ldflags': [
161                '-Wl,--whole-archive',
162                '<(obj_dir)/deps/zlib/<(STATIC_LIB_PREFIX)zlib<(STATIC_LIB_SUFFIX)',
163                '-Wl,--no-whole-archive',
164              ],
165            }],
166          ],
167        }],
168      ],
169    }],
170
171    [ 'node_shared_http_parser=="false"', {
172      'dependencies': [
173        'deps/llhttp/llhttp.gyp:llhttp'
174      ],
175    } ],
176
177    [ 'node_shared_cares=="false"', {
178      'dependencies': [ 'deps/cares/cares.gyp:cares' ],
179    }],
180
181    [ 'node_shared_libuv=="false"', {
182      'dependencies': [ 'deps/uv/uv.gyp:libuv' ],
183      'conditions': [
184        [ 'force_load=="true"', {
185          'xcode_settings': {
186            'OTHER_LDFLAGS': [
187              '-Wl,-force_load,<(PRODUCT_DIR)/libuv<(STATIC_LIB_SUFFIX)',
188            ],
189          },
190          'msvs_settings': {
191            'VCLinkerTool': {
192              'AdditionalOptions': [
193                '/WHOLEARCHIVE:libuv<(STATIC_LIB_SUFFIX)',
194              ],
195            },
196          },
197          'conditions': [
198            ['OS!="aix" and OS!="os400" and OS!="ios" and node_shared=="false"', {
199              'ldflags': [
200                '-Wl,--whole-archive',
201                '<(obj_dir)/deps/uv/<(STATIC_LIB_PREFIX)uv<(STATIC_LIB_SUFFIX)',
202                '-Wl,--no-whole-archive',
203              ],
204            }],
205          ],
206        }],
207      ],
208    }],
209
210    [ 'node_shared_nghttp2=="false"', {
211      'dependencies': [ 'deps/nghttp2/nghttp2.gyp:nghttp2' ],
212    }],
213
214    [ 'node_shared_brotli=="false"', {
215      'dependencies': [ 'deps/brotli/brotli.gyp:brotli' ],
216    }],
217
218    [ 'OS=="mac"', {
219      # linking Corefoundation is needed since certain OSX debugging tools
220      # like Instruments require it for some features
221      'libraries': [ '-framework CoreFoundation' ],
222      'defines!': [
223        'NODE_PLATFORM="mac"',
224      ],
225      'defines': [
226        # we need to use node's preferred "darwin" rather than gyp's preferred "mac"
227        'NODE_PLATFORM="darwin"',
228      ],
229    }],
230    [ 'OS=="freebsd"', {
231      'libraries': [
232        '-lutil',
233        '-lkvm',
234      ],
235    }],
236    [ 'OS in "aix os400"', {
237      'defines': [
238        '_LINUX_SOURCE_COMPAT',
239        '__STDC_FORMAT_MACROS',
240      ],
241      'conditions': [
242        [ 'force_load=="true"', {
243          'variables': {
244            'exp_filename': '<(PRODUCT_DIR)/<(_target_name).exp',
245          },
246          'actions': [
247            {
248              'action_name': 'expfile',
249              'inputs': [
250                '<(obj_dir)',
251              ],
252              'outputs': [
253                '<(exp_filename)',
254              ],
255              'action': [
256                'sh', 'tools/create_expfile.sh',
257                '<@(_inputs)',
258                '<@(_outputs)',
259              ],
260            }
261          ],
262          'ldflags': [
263            '-Wl,-bE:<(exp_filename)',
264            '-Wl,-brtl',
265          ],
266        }],
267      ],
268    }],
269    [ 'OS=="solaris"', {
270      'libraries': [
271        '-lkstat',
272        '-lumem',
273      ],
274      'defines!': [
275        'NODE_PLATFORM="solaris"',
276      ],
277      'defines': [
278        # we need to use node's preferred "sunos"
279        # rather than gyp's preferred "solaris"
280        'NODE_PLATFORM="sunos"',
281      ],
282    }],
283    [ '(OS=="freebsd" or OS=="linux") and node_shared=="false"'
284        ' and force_load=="true"', {
285      'ldflags': [
286        '-Wl,-z,noexecstack',
287        '-Wl,--whole-archive <(v8_base)',
288        '-Wl,--no-whole-archive',
289      ]
290    }],
291    [ 'node_use_bundled_v8=="true" and v8_postmortem_support==1 and force_load=="true"', {
292      'xcode_settings': {
293        'OTHER_LDFLAGS': [
294          '-Wl,-force_load,<(v8_base)',
295        ],
296      },
297    }],
298    [ 'debug_node=="true"', {
299      'cflags!': [ '-O3' ],
300      'cflags': [ '-g', '-O0' ],
301      'defines': [ 'DEBUG' ],
302      'xcode_settings': {
303        'OTHER_CFLAGS': [
304          '-g', '-O0'
305        ],
306      },
307    }],
308    [ 'coverage=="true" and node_shared=="false" and OS in "mac freebsd linux"', {
309      'cflags!': [ '-O3' ],
310      'ldflags': [ '--coverage',
311                   '-g',
312                   '-O0' ],
313      'cflags': [ '--coverage',
314                   '-g',
315                   '-O0' ],
316      'xcode_settings': {
317        'OTHER_CFLAGS': [
318          '--coverage',
319          '-g',
320          '-O0'
321        ],
322      },
323      'conditions': [
324        [ '_type=="executable"', {
325          'xcode_settings': {
326            'OTHER_LDFLAGS': [ '--coverage', ],
327          },
328        }],
329      ],
330    }],
331    [ 'coverage=="true"', {
332      'defines': [
333        'ALLOW_ATTACHING_DEBUGGER_IN_WATCH_MODE',
334        'ALLOW_ATTACHING_DEBUGGER_IN_TEST_RUNNER',
335      ],
336    }],
337    [ 'OS=="sunos"', {
338      'ldflags': [ '-Wl,-M,/usr/lib/ld/map.noexstk' ],
339    }],
340    [ 'OS=="linux"', {
341      'libraries!': [
342        '-lrt'
343      ],
344    }],
345    [ 'OS in "freebsd linux"', {
346      'ldflags': [ '-Wl,-z,relro',
347                   '-Wl,-z,now' ]
348    }],
349    [ 'node_use_openssl=="true"', {
350      'defines': [ 'HAVE_OPENSSL=1' ],
351      'conditions': [
352        [ 'node_shared_openssl=="false"', {
353          'defines': [ 'OPENSSL_API_COMPAT=0x10100000L', ],
354          'dependencies': [
355            './deps/openssl/openssl.gyp:openssl',
356
357            # For tests
358            './deps/openssl/openssl.gyp:openssl-cli',
359          ],
360          'conditions': [
361            # -force_load or --whole-archive are not applicable for
362            # the static library
363            [ 'force_load=="true"', {
364              'xcode_settings': {
365                'OTHER_LDFLAGS': [
366                  '-Wl,-force_load,<(PRODUCT_DIR)/<(openssl_product)',
367                ],
368              },
369              'msvs_settings': {
370                'VCLinkerTool': {
371                  'AdditionalOptions': [
372                    '/WHOLEARCHIVE:<(openssl_product)',
373                  ],
374                },
375              },
376              'conditions': [
377                ['OS in "linux freebsd" and node_shared=="false"', {
378                  'ldflags': [
379                    '-Wl,--whole-archive,'
380                      '<(obj_dir)/deps/openssl/<(openssl_product)',
381                    '-Wl,--no-whole-archive',
382                  ],
383                }],
384                # openssl.def is based on zlib.def, zlib symbols
385                # are always exported.
386                ['use_openssl_def==1', {
387                  'sources': ['<(SHARED_INTERMEDIATE_DIR)/openssl.def'],
388                }],
389                ['OS=="win" and use_openssl_def==0', {
390                  'sources': ['deps/zlib/win32/zlib.def'],
391                }],
392              ],
393            }],
394          ]
395        }],
396        [ 'openssl_quic=="true" and node_shared_ngtcp2=="false"', {
397          'dependencies': [ './deps/ngtcp2/ngtcp2.gyp:ngtcp2' ]
398        }],
399        [ 'openssl_quic=="true" and node_shared_nghttp3=="false"', {
400          'dependencies': [ './deps/ngtcp2/ngtcp2.gyp:nghttp3' ]
401        }]
402      ]
403    }, {
404      'defines': [ 'HAVE_OPENSSL=0' ]
405    }],
406  ],
407}
408