blob: a2e8c588920515df650ce246eebd96f91e880404 [file] [log] [blame]
murgatroid992d6d3302015-09-21 13:29:40 -07001%YAML 1.2
2--- |
murgatroid99fd994f12015-10-09 14:02:28 -07003 # GRPC Node gyp file
4 # This currently builds the Node extension and dependencies
murgatroid992d6d3302015-09-21 13:29:40 -07005 # This file has been automatically generated from a template file.
6 # Please look at the templates directory instead.
7 # This file can be regenerated from the template by running
8 # tools/buildgen/generate_projects.sh
9
Craig Tiller6169d5f2016-03-31 07:46:18 -070010 # Copyright 2015, Google Inc.
murgatroid992d6d3302015-09-21 13:29:40 -070011 # All rights reserved.
12 #
13 # Redistribution and use in source and binary forms, with or without
14 # modification, are permitted provided that the following conditions are
15 # met:
16 #
17 # * Redistributions of source code must retain the above copyright
18 # notice, this list of conditions and the following disclaimer.
19 # * Redistributions in binary form must reproduce the above
20 # copyright notice, this list of conditions and the following disclaimer
21 # in the documentation and/or other materials provided with the
22 # distribution.
23 # * Neither the name of Google Inc. nor the names of its
24 # contributors may be used to endorse or promote products derived from
25 # this software without specific prior written permission.
26 #
27 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
30 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
31 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
32 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
33 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
34 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
35 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
36 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
37 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38
39 # Some of this file is built with the help of
40 # https://n8.io/converting-a-c-library-to-gyp/
41 {
murgatroid99dc230462016-10-25 14:12:42 -070042 'variables': {
murgatroid991191b722017-02-08 11:56:52 -080043 'runtime%': 'node',
murgatroid99ffe1a992017-03-09 10:04:11 -080044 # UV integration in C core is enabled by default. It can be disabled
45 # by setting this argument to anything else.
46 'grpc_uv%': 'true',
murgatroid99a99c9472017-03-02 11:32:08 -080047 # Some Node installations use the system installation of OpenSSL, and on
48 # some systems, the system OpenSSL still does not have ALPN support. This
49 # will let users recompile gRPC to work without ALPN.
murgatroid99fef39132017-03-23 17:45:21 -070050 'grpc_alpn%': 'true',
51 # Indicates that the library should be built with gcov.
52 'grpc_gcov%': 'false'
murgatroid99dc230462016-10-25 14:12:42 -070053 },
murgatroid992d6d3302015-09-21 13:29:40 -070054 'target_defaults': {
murgatroid99fef39132017-03-23 17:45:21 -070055 'configurations': {
56 % for name, args in configs.iteritems():
57 % if name in ['dbg', 'opt']:
58 '${{'dbg':'Debug', 'opt': 'Release'}[name]}': {
59 % for arg, prop in [('CPPFLAGS', 'cflags'), ('DEFINES', 'defines')]:
60 % if args.get(arg, None) is not None:
61 '${prop}': [
62 % for item in args.get(arg).split():
63 '${item}',
64 % endfor
65 ],
66 % endif
67 % endfor
68 },
69 % endif
70 % endfor
71 },
72 % for arg, prop in [('CPPFLAGS', 'cflags'), ('LDFLAGS', 'ldflags')]:
73 % if defaults['global'].get(arg, None) is not None:
74 '${prop}': [
75 % for item in defaults['global'].get(arg).split():
76 '${item}',
77 % endfor
78 ],
79 % endif
80 % endfor
murgatroid992d6d3302015-09-21 13:29:40 -070081 'include_dirs': [
murgatroid99ca9db402015-09-21 14:39:09 -070082 '.',
murgatroid995c56c922016-01-25 13:32:52 -080083 'include'
murgatroid99a89d9e72015-10-13 16:03:16 -070084 ],
murgatroid99dc230462016-10-25 14:12:42 -070085 'defines': [
murgatroid99cb4b2b52016-10-27 11:30:50 -070086 'GPR_BACKWARDS_COMPATIBILITY_MODE'
murgatroid99dc230462016-10-25 14:12:42 -070087 ],
murgatroid99a89d9e72015-10-13 16:03:16 -070088 'conditions': [
murgatroid998c2946a2017-02-27 10:19:21 -080089 ['grpc_uv=="true"', {
murgatroid99cb4b2b52016-10-27 11:30:50 -070090 'defines': [
Yuchen Zeng3dbb7ea2017-01-25 16:15:17 -080091 'GRPC_ARES=0',
murgatroid996f62c0a2017-02-06 17:31:15 -080092 # Disabling this while bugs are ironed out. Uncomment this to
93 # re-enable libuv integration in C core.
murgatroid991191b722017-02-08 11:56:52 -080094 'GRPC_UV'
murgatroid99cb4b2b52016-10-27 11:30:50 -070095 ]
96 }],
murgatroid99fef39132017-03-23 17:45:21 -070097 ['grpc_gcov=="true"', {
98 % for arg, prop in [('CPPFLAGS', 'cflags'), ('DEFINES', 'defines'), ('LDFLAGS', 'ldflags')]:
99 % if configs['gcov'].get(arg, None) is not None:
100 '${prop}': [
101 % for item in configs['gcov'].get(arg).split():
102 '${item}',
103 % endfor
104 ],
105 % endif
106 % endfor
107 }],
murgatroid99e8ec16d2017-01-13 11:00:53 -0800108 ['OS!="win" and runtime=="electron"', {
Michael Lumish88162f82017-01-12 17:37:58 -0800109 "defines": [
110 'OPENSSL_NO_THREADS'
111 ]
112 }],
murgatroid99dc230462016-10-25 14:12:42 -0700113 # This is the condition for using boringssl
114 ['OS=="win" or runtime=="electron"', {
115 "include_dirs": [
116 "third_party/boringssl/include"
117 ],
118 "defines": [
Michael Lumish88162f82017-01-12 17:37:58 -0800119 'OPENSSL_NO_ASM'
murgatroid99dc230462016-10-25 14:12:42 -0700120 ]
121 }, {
murgatroid99a99c9472017-03-02 11:32:08 -0800122 'conditions': [
123 ['grpc_alpn=="true"', {
124 'defines': [
125 'TSI_OPENSSL_ALPN_SUPPORT=1'
126 ],
127 }, {
128 'defines': [
129 'TSI_OPENSSL_ALPN_SUPPORT=0'
130 ],
131 }]
murgatroid99dc230462016-10-25 14:12:42 -0700132 ],
133 'include_dirs': [
134 '<(node_root_dir)/deps/openssl/openssl/include',
135 ],
136 'conditions': [
137 ["target_arch=='ia32'", {
138 "include_dirs": [ "<(node_root_dir)/deps/openssl/config/piii" ]
139 }],
140 ["target_arch=='x64'", {
141 "include_dirs": [ "<(node_root_dir)/deps/openssl/config/k8" ]
142 }],
143 ["target_arch=='arm'", {
144 "include_dirs": [ "<(node_root_dir)/deps/openssl/config/arm" ]
145 }]
146 ]
147 }],
murgatroid995c56c922016-01-25 13:32:52 -0800148 ['OS == "win"', {
murgatroid99673f65b2016-02-01 11:19:07 -0800149 "include_dirs": [
Yuchen Zengb48000c2016-08-09 22:44:23 -0700150 "third_party/zlib",
Yuchen Zeng6694bb02017-01-23 17:09:51 -0800151 "third_party/cares/cares"
murgatroid99673f65b2016-02-01 11:19:07 -0800152 ],
murgatroid99af6c1782016-01-28 13:14:24 -0800153 "defines": [
154 '_WIN32_WINNT=0x0600',
155 'WIN32_LEAN_AND_MEAN',
156 '_HAS_EXCEPTIONS=0',
157 'UNICODE',
158 '_UNICODE',
159 'NOMINMAX',
murgatroid99af6c1782016-01-28 13:14:24 -0800160 ],
161 "msvs_settings": {
162 'VCCLCompilerTool': {
163 'RuntimeLibrary': 1, # static debug
164 }
165 },
166 "libraries": [
167 "ws2_32"
168 ]
169 }, { # OS != "win"
murgatroid995c56c922016-01-25 13:32:52 -0800170 'include_dirs': [
Yuchen Zengb48000c2016-08-09 22:44:23 -0700171 '<(node_root_dir)/deps/zlib',
Michael Lumish68dff872017-04-03 11:16:41 -0700172 '<(node_root_dir)/deps/cares/include'
murgatroid99a89d9e72015-10-13 16:03:16 -0700173 ]
murgatroid99afe46982015-10-23 10:17:26 -0700174 }]
murgatroid99fd994f12015-10-09 14:02:28 -0700175 ]
murgatroid992d6d3302015-09-21 13:29:40 -0700176 },
murgatroid995c56c922016-01-25 13:32:52 -0800177 'conditions': [
murgatroid99dc230462016-10-25 14:12:42 -0700178 ['OS=="win" or runtime=="electron"', {
179 'targets': [
180 % for module in node_modules:
181 % for lib in libs:
182 % if lib.name in module.transitive_deps and lib.name == 'boringssl':
183 {
184 'cflags': [
185 '-std=c99',
186 '-Wall',
187 '-Werror'
188 ],
189 'target_name': '${lib.name}',
190 'product_prefix': 'lib',
191 'type': 'static_library',
192 'dependencies': [
193 % for dep in getattr(lib, 'deps', []):
194 '${dep}',
195 % endfor
196 ],
197 'sources': [
198 % for source in lib.src:
199 '${source}',
200 % endfor
201 ]
202 },
203 % endif
204 % endfor
205 % endfor
206 ]
207 }],
murgatroid99f25f5052017-04-13 17:22:32 -0700208 ['OS == "win" and runtime!="electron"', {
murgatroid995c56c922016-01-25 13:32:52 -0800209 'targets': [
murgatroid99af6c1782016-01-28 13:14:24 -0800210 {
211 # IMPORTANT WINDOWS BUILD INFORMATION
212 # This library does not build on Windows without modifying the Node
213 # development packages that node-gyp downloads in order to build.
214 # Due to https://github.com/nodejs/node/issues/4932, the headers for
215 # BoringSSL conflict with the OpenSSL headers included by default
216 # when including the Node headers. The remedy for this is to remove
217 # the OpenSSL headers, from the downloaded Node development package,
218 # which is typically located in `.node-gyp` in your home directory.
murgatroid99f25f5052017-04-13 17:22:32 -0700219 #
220 # This is not true of Electron, which does not have OpenSSL headers.
murgatroid998e4103e2016-01-28 14:53:33 -0800221 'target_name': 'WINDOWS_BUILD_WARNING',
murgatroid99025f1102017-04-10 13:07:37 -0700222 'rules': [
murgatroid99af6c1782016-01-28 13:14:24 -0800223 {
murgatroid99025f1102017-04-10 13:07:37 -0700224 'rule_name': 'WINDOWS_BUILD_WARNING',
225 'extension': 'S',
murgatroid998e4103e2016-01-28 14:53:33 -0800226 'inputs': [
227 'package.json'
228 ],
229 'outputs': [
230 'ignore_this_part'
231 ],
232 'action': ['echo', 'IMPORTANT: Due to https://github.com/nodejs/node/issues/4932, to build this library on Windows, you must first remove <(node_root_dir)/include/node/openssl/']
murgatroid99af6c1782016-01-28 13:14:24 -0800233 }
234 ]
235 },
murgatroid99dc230462016-10-25 14:12:42 -0700236 # Only want to compile zlib under Windows
murgatroid995c56c922016-01-25 13:32:52 -0800237 % for module in node_modules:
238 % for lib in libs:
murgatroid99dc230462016-10-25 14:12:42 -0700239 % if lib.name in module.transitive_deps and lib.name == 'z':
murgatroid995c56c922016-01-25 13:32:52 -0800240 {
241 'cflags': [
242 '-std=c99',
243 '-Wall',
244 '-Werror'
245 ],
246 'target_name': '${lib.name}',
247 'product_prefix': 'lib',
248 'type': 'static_library',
249 'dependencies': [
250 % for dep in getattr(lib, 'deps', []):
251 '${dep}',
252 % endfor
253 ],
254 'sources': [
255 % for source in lib.src:
256 '${source}',
257 % endfor
murgatroid99af6c1782016-01-28 13:14:24 -0800258 ]
murgatroid995c56c922016-01-25 13:32:52 -0800259 },
260 % endif
261 % endfor
262 % endfor
263 ]
264 }]
265 ],
murgatroid992d6d3302015-09-21 13:29:40 -0700266 'targets': [
Yuchen Zeng502d6442016-08-22 17:36:24 -0700267 <%
268 for lib in libs:
269 if 'grpc' in lib.transitive_deps or lib.name == 'grpc':
270 lib.deps.append('node_modules/cares/deps/cares/cares.gyp:cares')
271 for module in node_modules:
272 module.deps.append('node_modules/cares/deps/cares/cares.gyp:cares')
273 %>
murgatroid99879bc4f2015-11-05 10:35:04 -0800274 % for module in node_modules:
murgatroid992d6d3302015-09-21 13:29:40 -0700275 % for lib in libs:
murgatroid995c56c922016-01-25 13:32:52 -0800276 % if lib.name in module.transitive_deps and lib.name not in ('boringssl', 'z'):
murgatroid992d6d3302015-09-21 13:29:40 -0700277 {
murgatroid993abed312016-01-07 17:16:46 -0800278 'cflags': [
279 '-std=c99',
280 '-Wall',
281 '-Werror'
282 ],
murgatroid992d6d3302015-09-21 13:29:40 -0700283 'target_name': '${lib.name}',
284 'product_prefix': 'lib',
285 'type': 'static_library',
286 'dependencies': [
287 % for dep in getattr(lib, 'deps', []):
288 '${dep}',
289 % endfor
290 ],
291 'sources': [
292 % for source in lib.src:
murgatroid99ca9db402015-09-21 14:39:09 -0700293 '${source}',
murgatroid992d6d3302015-09-21 13:29:40 -0700294 % endfor
murgatroid99ca9db402015-09-21 14:39:09 -0700295 ],
murgatroid996ffdb942015-10-22 16:10:05 -0700296 "conditions": [
297 ['OS == "mac"', {
298 'xcode_settings': {
murgatroid9922c448b2015-10-23 10:25:30 -0700299 'MACOSX_DEPLOYMENT_TARGET': '10.9'
murgatroid996ffdb942015-10-22 16:10:05 -0700300 }
301 }]
murgatroid995c56c922016-01-25 13:32:52 -0800302 ]
murgatroid992d6d3302015-09-21 13:29:40 -0700303 },
murgatroid99ca9db402015-09-21 14:39:09 -0700304 % endif
murgatroid992d6d3302015-09-21 13:29:40 -0700305 % endfor
murgatroid99fd994f12015-10-09 14:02:28 -0700306 {
307 'include_dirs': [
308 "<!(node -e \"require('nan')\")"
309 ],
310 'cflags': [
murgatroid993abed312016-01-07 17:16:46 -0800311 '-std=c++11',
murgatroid99fd994f12015-10-09 14:02:28 -0700312 '-pthread',
murgatroid99fd994f12015-10-09 14:02:28 -0700313 '-zdefs',
murgatroid99fd994f12015-10-09 14:02:28 -0700314 '-Wno-error=deprecated-declarations'
315 ],
murgatroid99fd994f12015-10-09 14:02:28 -0700316 "conditions": [
murgatroid99dc230462016-10-25 14:12:42 -0700317 ['OS=="win" or runtime=="electron"', {
318 'dependencies': [
319 % for dep in getattr(module, 'deps', []):
320 % if dep == 'boringssl':
321 "${dep}",
322 % endif
323 % endfor
324 ]
325 }],
murgatroid995c56c922016-01-25 13:32:52 -0800326 ['OS=="mac"', {
murgatroid99fd994f12015-10-09 14:02:28 -0700327 'xcode_settings': {
328 'MACOSX_DEPLOYMENT_TARGET': '10.9',
329 'OTHER_CFLAGS': [
murgatroid99673f65b2016-02-01 11:19:07 -0800330 '-stdlib=libc++',
331 '-std=c++11'
murgatroid99fd994f12015-10-09 14:02:28 -0700332 ]
333 }
murgatroid995c56c922016-01-25 13:32:52 -0800334 }],
335 ['OS=="win"', {
336 'dependencies': [
337 % for dep in getattr(module, 'deps', []):
murgatroid99dc230462016-10-25 14:12:42 -0700338 % if dep == 'z':
murgatroid995c56c922016-01-25 13:32:52 -0800339 "${dep}",
340 % endif
341 % endfor
342 ]
Craig Tiller4bef7ce2016-02-02 08:38:43 -0800343 }],
344 ['OS=="linux"', {
345 'ldflags': [
346 '-Wl,-wrap,memcpy'
347 ]
murgatroid99fd994f12015-10-09 14:02:28 -0700348 }]
349 ],
murgatroid99879bc4f2015-11-05 10:35:04 -0800350 "target_name": "${module.name}",
murgatroid99fd994f12015-10-09 14:02:28 -0700351 "sources": [
murgatroid99879bc4f2015-11-05 10:35:04 -0800352 % for source in module.src:
353 "${source}",
354 % endfor
murgatroid99fd994f12015-10-09 14:02:28 -0700355 ],
356 "dependencies": [
murgatroid99879bc4f2015-11-05 10:35:04 -0800357 % for dep in getattr(module, 'deps', []):
murgatroid995c56c922016-01-25 13:32:52 -0800358 % if dep not in ('boringssl', 'z'):
murgatroid99879bc4f2015-11-05 10:35:04 -0800359 "${dep}",
murgatroid995c56c922016-01-25 13:32:52 -0800360 % endif
murgatroid99879bc4f2015-11-05 10:35:04 -0800361 % endfor
murgatroid99fd994f12015-10-09 14:02:28 -0700362 ]
murgatroid99879bc4f2015-11-05 10:35:04 -0800363 },
364 % endfor
murgatroid99e190f352016-01-20 13:52:08 -0800365 {
366 "target_name": "action_after_build",
367 "type": "none",
368 "dependencies": [ "<(module_name)" ],
369 "copies": [
370 {
371 "files": [ "<(PRODUCT_DIR)/<(module_name).node"],
372 "destination": "<(module_path)"
373 }
374 ]
375 }
murgatroid992d6d3302015-09-21 13:29:40 -0700376 ]
377 }