• 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', ]
31    }],
32    [ 'node_shared=="false" and "<(_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    }],
45    [ 'OS=="win"', {
46      'defines!': [
47        'NODE_PLATFORM="win"',
48      ],
49      'defines': [
50        'FD_SETSIZE=1024',
51        # we need to use node's preferred "win32" rather than gyp's preferred "win"
52        'NODE_PLATFORM="win32"',
53        # Stop <windows.h> from defining macros that conflict with
54        # std::min() and std::max().  We don't use <windows.h> (much)
55        # but we still inherit it from uv.h.
56        'NOMINMAX',
57        '_UNICODE=1',
58      ],
59      'msvs_precompiled_header': 'tools/msvs/pch/node_pch.h',
60      'msvs_precompiled_source': 'tools/msvs/pch/node_pch.cc',
61      'sources': [
62        '<(_msvs_precompiled_header)',
63        '<(_msvs_precompiled_source)',
64      ],
65    }, { # POSIX
66      'defines': [ '__POSIX__' ],
67    }],
68    [ 'node_enable_d8=="true"', {
69      'dependencies': [ 'tools/v8_gypfiles/d8.gyp:d8' ],
70    }],
71    [ 'node_use_bundled_v8=="true"', {
72      'dependencies': [
73        'tools/v8_gypfiles/v8.gyp:v8_snapshot',
74        'tools/v8_gypfiles/v8.gyp:v8_libplatform',
75      ],
76    }],
77    [ 'node_use_v8_platform=="true"', {
78      'defines': [
79        'NODE_USE_V8_PLATFORM=1',
80      ],
81    }, {
82      'defines': [
83        'NODE_USE_V8_PLATFORM=0',
84      ],
85    }],
86    [ 'node_tag!=""', {
87      'defines': [ 'NODE_TAG="<(node_tag)"' ],
88    }],
89    [ 'node_v8_options!=""', {
90      'defines': [ 'NODE_V8_OPTIONS="<(node_v8_options)"'],
91    }],
92    [ 'node_release_urlbase!=""', {
93      'defines': [
94        'NODE_RELEASE_URLBASE="<(node_release_urlbase)"',
95      ]
96    }],
97    [ 'v8_enable_i18n_support==1', {
98      'defines': [ 'NODE_HAVE_I18N_SUPPORT=1' ],
99      'dependencies': [
100        '<(icu_gyp_path):icui18n',
101        '<(icu_gyp_path):icuuc',
102      ],
103      'conditions': [
104        [ 'icu_small=="true"', {
105          'defines': [ 'NODE_HAVE_SMALL_ICU=1' ],
106          'conditions': [
107            [ 'icu_default_data!=""', {
108              'defines': [
109                'NODE_ICU_DEFAULT_DATA_DIR="<(icu_default_data)"',
110              ],
111            }],
112          ],
113      }]],
114    }],
115    [ 'node_no_browser_globals=="true"', {
116      'defines': [ 'NODE_NO_BROWSER_GLOBALS' ],
117    } ],
118    [ 'node_shared_zlib=="false"', {
119      'dependencies': [ 'deps/zlib/zlib.gyp:zlib' ],
120      'conditions': [
121        [ 'force_load=="true"', {
122          'xcode_settings': {
123            'OTHER_LDFLAGS': [
124              '-Wl,-force_load,<(PRODUCT_DIR)/<(STATIC_LIB_PREFIX)zlib<(STATIC_LIB_SUFFIX)',
125            ],
126          },
127          'msvs_settings': {
128            'VCLinkerTool': {
129              'AdditionalOptions': [
130                '/WHOLEARCHIVE:zlib<(STATIC_LIB_SUFFIX)',
131              ],
132            },
133          },
134          'conditions': [
135            ['OS!="aix" and node_shared=="false"', {
136              'ldflags': [
137                '-Wl,--whole-archive',
138                '<(obj_dir)/deps/zlib/<(STATIC_LIB_PREFIX)zlib<(STATIC_LIB_SUFFIX)',
139                '-Wl,--no-whole-archive',
140              ],
141            }],
142          ],
143        }],
144      ],
145    }],
146
147    [ 'node_shared_http_parser=="false"', {
148      'dependencies': [
149        'deps/llhttp/llhttp.gyp:llhttp'
150      ],
151    } ],
152
153    [ 'node_shared_cares=="false"', {
154      'dependencies': [ 'deps/cares/cares.gyp:cares' ],
155    }],
156
157    [ 'node_shared_libuv=="false"', {
158      'dependencies': [ 'deps/uv/uv.gyp:libuv' ],
159      'conditions': [
160        [ 'force_load=="true"', {
161          'xcode_settings': {
162            'OTHER_LDFLAGS': [
163              '-Wl,-force_load,<(PRODUCT_DIR)/libuv<(STATIC_LIB_SUFFIX)',
164            ],
165          },
166          'msvs_settings': {
167            'VCLinkerTool': {
168              'AdditionalOptions': [
169                '/WHOLEARCHIVE:libuv<(STATIC_LIB_SUFFIX)',
170              ],
171            },
172          },
173          'conditions': [
174            ['OS!="aix" and node_shared=="false"', {
175              'ldflags': [
176                '-Wl,--whole-archive',
177                '<(obj_dir)/deps/uv/<(STATIC_LIB_PREFIX)uv<(STATIC_LIB_SUFFIX)',
178                '-Wl,--no-whole-archive',
179              ],
180            }],
181          ],
182        }],
183      ],
184    }],
185
186    [ 'node_shared_nghttp2=="false"', {
187      'dependencies': [ 'deps/nghttp2/nghttp2.gyp:nghttp2' ],
188    }],
189
190    [ 'node_shared_brotli=="false"', {
191      'dependencies': [ 'deps/brotli/brotli.gyp:brotli' ],
192    }],
193
194    [ 'OS=="mac"', {
195      # linking Corefoundation is needed since certain OSX debugging tools
196      # like Instruments require it for some features
197      'libraries': [ '-framework CoreFoundation' ],
198      'defines!': [
199        'NODE_PLATFORM="mac"',
200      ],
201      'defines': [
202        # we need to use node's preferred "darwin" rather than gyp's preferred "mac"
203        'NODE_PLATFORM="darwin"',
204      ],
205    }],
206    [ 'OS=="freebsd"', {
207      'libraries': [
208        '-lutil',
209        '-lkvm',
210      ],
211    }],
212    [ 'OS=="aix"', {
213      'defines': [
214        '_LINUX_SOURCE_COMPAT',
215        '__STDC_FORMAT_MACROS',
216      ],
217      'conditions': [
218        [ 'force_load=="true"', {
219          'variables': {
220            'exp_filename': '<(PRODUCT_DIR)/<(_target_name).exp',
221          },
222          'actions': [
223            {
224              'action_name': 'expfile',
225              'inputs': [
226                '<(obj_dir)',
227              ],
228              'outputs': [
229                '<(exp_filename)',
230              ],
231              'action': [
232                'sh', 'tools/create_expfile.sh',
233                '<@(_inputs)',
234                '<@(_outputs)',
235              ],
236            }
237          ],
238          'ldflags': [
239            '-Wl,-bE:<(exp_filename)',
240            '-Wl,-brtl',
241          ],
242        }],
243      ],
244    }],
245    [ 'OS=="solaris"', {
246      'libraries': [
247        '-lkstat',
248        '-lumem',
249      ],
250      'defines!': [
251        'NODE_PLATFORM="solaris"',
252      ],
253      'defines': [
254        # we need to use node's preferred "sunos"
255        # rather than gyp's preferred "solaris"
256        'NODE_PLATFORM="sunos"',
257      ],
258    }],
259    [ '(OS=="freebsd" or OS=="linux") and node_shared=="false"'
260        ' and force_load=="true"', {
261      'ldflags': [
262        '-Wl,-z,noexecstack',
263        '-Wl,--whole-archive <(v8_base)',
264        '-Wl,--no-whole-archive',
265      ]
266    }],
267    [ 'node_use_bundled_v8=="true" and v8_postmortem_support==1 and force_load=="true"', {
268      'xcode_settings': {
269        'OTHER_LDFLAGS': [
270          '-Wl,-force_load,<(v8_base)',
271        ],
272      },
273    }],
274    [ 'debug_node=="true"', {
275      'cflags!': [ '-O3' ],
276      'cflags': [ '-g', '-O0' ],
277      'defines': [ 'DEBUG' ],
278      'xcode_settings': {
279        'OTHER_CFLAGS': [
280          '-g', '-O0'
281        ],
282      },
283    }],
284    [ 'coverage=="true" and node_shared=="false" and OS in "mac freebsd linux"', {
285      'cflags!': [ '-O3' ],
286      'ldflags': [ '--coverage',
287                   '-g',
288                   '-O0' ],
289      'cflags': [ '--coverage',
290                   '-g',
291                   '-O0' ],
292      'xcode_settings': {
293        'OTHER_CFLAGS': [
294          '--coverage',
295          '-g',
296          '-O0'
297        ],
298      },
299      'conditions': [
300        [ '_type=="executable"', {
301          'xcode_settings': {
302            'OTHER_LDFLAGS': [ '--coverage', ],
303          },
304        }],
305      ],
306    }],
307    [ 'OS=="sunos"', {
308      'ldflags': [ '-Wl,-M,/usr/lib/ld/map.noexstk' ],
309    }],
310    [ 'OS=="linux"', {
311      'libraries!': [
312        '-lrt'
313      ],
314    }],
315    [ 'OS in "freebsd linux"', {
316      'ldflags': [ '-Wl,-z,relro',
317                   '-Wl,-z,now' ]
318    }],
319    [ 'node_use_openssl=="true"', {
320      'defines': [ 'HAVE_OPENSSL=1' ],
321      'conditions': [
322        [ 'node_shared_openssl=="false"', {
323          'dependencies': [
324            './deps/openssl/openssl.gyp:openssl',
325
326            # For tests
327            './deps/openssl/openssl.gyp:openssl-cli',
328          ],
329          'conditions': [
330            # -force_load or --whole-archive are not applicable for
331            # the static library
332            [ 'force_load=="true"', {
333              'xcode_settings': {
334                'OTHER_LDFLAGS': [
335                  '-Wl,-force_load,<(PRODUCT_DIR)/<(openssl_product)',
336                ],
337              },
338              'msvs_settings': {
339                'VCLinkerTool': {
340                  'AdditionalOptions': [
341                    '/WHOLEARCHIVE:<(openssl_product)',
342                  ],
343                },
344              },
345              'conditions': [
346                ['OS in "linux freebsd" and node_shared=="false"', {
347                  'ldflags': [
348                    '-Wl,--whole-archive,'
349                      '<(obj_dir)/deps/openssl/<(openssl_product)',
350                    '-Wl,--no-whole-archive',
351                  ],
352                }],
353                # openssl.def is based on zlib.def, zlib symbols
354                # are always exported.
355                ['use_openssl_def==1', {
356                  'sources': ['<(SHARED_INTERMEDIATE_DIR)/openssl.def'],
357                }],
358                ['OS=="win" and use_openssl_def==0', {
359                  'sources': ['deps/zlib/win32/zlib.def'],
360                }],
361              ],
362            }],
363          ],
364        }]]
365
366    }, {
367      'defines': [ 'HAVE_OPENSSL=0' ]
368    }],
369
370  ],
371}
372