blob: 55a91c5b93d57e9e1fcea9b609db27da46840fb8 [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 }],
murgatroid995c56c922016-01-25 13:32:52 -0800208 ['OS == "win"', {
209 '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.
murgatroid998e4103e2016-01-28 14:53:33 -0800219 'target_name': 'WINDOWS_BUILD_WARNING',
murgatroid99025f1102017-04-10 13:07:37 -0700220 'rules': [
murgatroid99af6c1782016-01-28 13:14:24 -0800221 {
murgatroid99025f1102017-04-10 13:07:37 -0700222 'rule_name': 'WINDOWS_BUILD_WARNING',
223 'extension': 'S',
murgatroid998e4103e2016-01-28 14:53:33 -0800224 'inputs': [
225 'package.json'
226 ],
227 'outputs': [
228 'ignore_this_part'
229 ],
230 '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 -0800231 }
232 ]
233 },
murgatroid99dc230462016-10-25 14:12:42 -0700234 # Only want to compile zlib under Windows
murgatroid995c56c922016-01-25 13:32:52 -0800235 % for module in node_modules:
236 % for lib in libs:
murgatroid99dc230462016-10-25 14:12:42 -0700237 % if lib.name in module.transitive_deps and lib.name == 'z':
murgatroid995c56c922016-01-25 13:32:52 -0800238 {
239 'cflags': [
240 '-std=c99',
241 '-Wall',
242 '-Werror'
243 ],
244 'target_name': '${lib.name}',
245 'product_prefix': 'lib',
246 'type': 'static_library',
247 'dependencies': [
248 % for dep in getattr(lib, 'deps', []):
249 '${dep}',
250 % endfor
251 ],
252 'sources': [
253 % for source in lib.src:
254 '${source}',
255 % endfor
murgatroid99af6c1782016-01-28 13:14:24 -0800256 ]
murgatroid995c56c922016-01-25 13:32:52 -0800257 },
258 % endif
259 % endfor
260 % endfor
261 ]
262 }]
263 ],
murgatroid992d6d3302015-09-21 13:29:40 -0700264 'targets': [
Yuchen Zeng502d6442016-08-22 17:36:24 -0700265 <%
266 for lib in libs:
267 if 'grpc' in lib.transitive_deps or lib.name == 'grpc':
268 lib.deps.append('node_modules/cares/deps/cares/cares.gyp:cares')
269 for module in node_modules:
270 module.deps.append('node_modules/cares/deps/cares/cares.gyp:cares')
271 %>
murgatroid99879bc4f2015-11-05 10:35:04 -0800272 % for module in node_modules:
murgatroid992d6d3302015-09-21 13:29:40 -0700273 % for lib in libs:
murgatroid995c56c922016-01-25 13:32:52 -0800274 % if lib.name in module.transitive_deps and lib.name not in ('boringssl', 'z'):
murgatroid992d6d3302015-09-21 13:29:40 -0700275 {
murgatroid993abed312016-01-07 17:16:46 -0800276 'cflags': [
277 '-std=c99',
278 '-Wall',
279 '-Werror'
280 ],
murgatroid992d6d3302015-09-21 13:29:40 -0700281 'target_name': '${lib.name}',
282 'product_prefix': 'lib',
283 'type': 'static_library',
284 'dependencies': [
285 % for dep in getattr(lib, 'deps', []):
286 '${dep}',
287 % endfor
288 ],
289 'sources': [
290 % for source in lib.src:
murgatroid99ca9db402015-09-21 14:39:09 -0700291 '${source}',
murgatroid992d6d3302015-09-21 13:29:40 -0700292 % endfor
murgatroid99ca9db402015-09-21 14:39:09 -0700293 ],
murgatroid996ffdb942015-10-22 16:10:05 -0700294 "conditions": [
295 ['OS == "mac"', {
296 'xcode_settings': {
murgatroid9922c448b2015-10-23 10:25:30 -0700297 'MACOSX_DEPLOYMENT_TARGET': '10.9'
murgatroid996ffdb942015-10-22 16:10:05 -0700298 }
299 }]
murgatroid995c56c922016-01-25 13:32:52 -0800300 ]
murgatroid992d6d3302015-09-21 13:29:40 -0700301 },
murgatroid99ca9db402015-09-21 14:39:09 -0700302 % endif
murgatroid992d6d3302015-09-21 13:29:40 -0700303 % endfor
murgatroid99fd994f12015-10-09 14:02:28 -0700304 {
305 'include_dirs': [
306 "<!(node -e \"require('nan')\")"
307 ],
308 'cflags': [
murgatroid993abed312016-01-07 17:16:46 -0800309 '-std=c++11',
murgatroid99fd994f12015-10-09 14:02:28 -0700310 '-pthread',
murgatroid99fd994f12015-10-09 14:02:28 -0700311 '-zdefs',
murgatroid99fd994f12015-10-09 14:02:28 -0700312 '-Wno-error=deprecated-declarations'
313 ],
murgatroid99fd994f12015-10-09 14:02:28 -0700314 "conditions": [
murgatroid99dc230462016-10-25 14:12:42 -0700315 ['OS=="win" or runtime=="electron"', {
316 'dependencies': [
317 % for dep in getattr(module, 'deps', []):
318 % if dep == 'boringssl':
319 "${dep}",
320 % endif
321 % endfor
322 ]
323 }],
murgatroid995c56c922016-01-25 13:32:52 -0800324 ['OS=="mac"', {
murgatroid99fd994f12015-10-09 14:02:28 -0700325 'xcode_settings': {
326 'MACOSX_DEPLOYMENT_TARGET': '10.9',
327 'OTHER_CFLAGS': [
murgatroid99673f65b2016-02-01 11:19:07 -0800328 '-stdlib=libc++',
329 '-std=c++11'
murgatroid99fd994f12015-10-09 14:02:28 -0700330 ]
331 }
murgatroid995c56c922016-01-25 13:32:52 -0800332 }],
333 ['OS=="win"', {
334 'dependencies': [
335 % for dep in getattr(module, 'deps', []):
murgatroid99dc230462016-10-25 14:12:42 -0700336 % if dep == 'z':
murgatroid995c56c922016-01-25 13:32:52 -0800337 "${dep}",
338 % endif
339 % endfor
340 ]
Craig Tiller4bef7ce2016-02-02 08:38:43 -0800341 }],
342 ['OS=="linux"', {
343 'ldflags': [
344 '-Wl,-wrap,memcpy'
345 ]
murgatroid99fd994f12015-10-09 14:02:28 -0700346 }]
347 ],
murgatroid99879bc4f2015-11-05 10:35:04 -0800348 "target_name": "${module.name}",
murgatroid99fd994f12015-10-09 14:02:28 -0700349 "sources": [
murgatroid99879bc4f2015-11-05 10:35:04 -0800350 % for source in module.src:
351 "${source}",
352 % endfor
murgatroid99fd994f12015-10-09 14:02:28 -0700353 ],
354 "dependencies": [
murgatroid99879bc4f2015-11-05 10:35:04 -0800355 % for dep in getattr(module, 'deps', []):
murgatroid995c56c922016-01-25 13:32:52 -0800356 % if dep not in ('boringssl', 'z'):
murgatroid99879bc4f2015-11-05 10:35:04 -0800357 "${dep}",
murgatroid995c56c922016-01-25 13:32:52 -0800358 % endif
murgatroid99879bc4f2015-11-05 10:35:04 -0800359 % endfor
murgatroid99fd994f12015-10-09 14:02:28 -0700360 ]
murgatroid99879bc4f2015-11-05 10:35:04 -0800361 },
362 % endfor
murgatroid99e190f352016-01-20 13:52:08 -0800363 {
364 "target_name": "action_after_build",
365 "type": "none",
366 "dependencies": [ "<(module_name)" ],
367 "copies": [
368 {
369 "files": [ "<(PRODUCT_DIR)/<(module_name).node"],
370 "destination": "<(module_path)"
371 }
372 ]
373 }
murgatroid992d6d3302015-09-21 13:29:40 -0700374 ]
375 }