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