blob: 933174ab6edb6b12565ad3bd7ec6e7a02177e682 [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',
murgatroid99a99c9472017-03-02 11:32:08 -080044 # Some Node installations use the system installation of OpenSSL, and on
45 # some systems, the system OpenSSL still does not have ALPN support. This
46 # will let users recompile gRPC to work without ALPN.
murgatroid99fef39132017-03-23 17:45:21 -070047 'grpc_alpn%': 'true',
48 # Indicates that the library should be built with gcov.
murgatroid9998058332017-04-19 10:25:34 -070049 'grpc_gcov%': 'false',
50 # Indicates that the library should be built with compatibility for musl
51 # libc, so that it can run on Alpine Linux. This is only necessary if not
52 # building on Alpine Linux
53 'grpc_alpine%': 'false'
murgatroid99dc230462016-10-25 14:12:42 -070054 },
murgatroid992d6d3302015-09-21 13:29:40 -070055 'target_defaults': {
murgatroid99fef39132017-03-23 17:45:21 -070056 'configurations': {
57 % for name, args in configs.iteritems():
58 % if name in ['dbg', 'opt']:
59 '${{'dbg':'Debug', 'opt': 'Release'}[name]}': {
60 % for arg, prop in [('CPPFLAGS', 'cflags'), ('DEFINES', 'defines')]:
61 % if args.get(arg, None) is not None:
62 '${prop}': [
63 % for item in args.get(arg).split():
64 '${item}',
65 % endfor
66 ],
67 % endif
68 % endfor
69 },
70 % endif
71 % endfor
72 },
73 % for arg, prop in [('CPPFLAGS', 'cflags'), ('LDFLAGS', 'ldflags')]:
74 % if defaults['global'].get(arg, None) is not None:
75 '${prop}': [
76 % for item in defaults['global'].get(arg).split():
77 '${item}',
78 % endfor
79 ],
80 % endif
81 % endfor
murgatroid992d6d3302015-09-21 13:29:40 -070082 'include_dirs': [
murgatroid99ca9db402015-09-21 14:39:09 -070083 '.',
murgatroid995c56c922016-01-25 13:32:52 -080084 'include'
murgatroid99a89d9e72015-10-13 16:03:16 -070085 ],
murgatroid99dc230462016-10-25 14:12:42 -070086 'defines': [
murgatroid99f94f64f2017-04-24 13:35:21 -070087 'GPR_BACKWARDS_COMPATIBILITY_MODE',
88 'GRPC_ARES=0',
89 'GRPC_UV'
murgatroid99dc230462016-10-25 14:12:42 -070090 ],
murgatroid99a89d9e72015-10-13 16:03:16 -070091 'conditions': [
murgatroid99fef39132017-03-23 17:45:21 -070092 ['grpc_gcov=="true"', {
93 % for arg, prop in [('CPPFLAGS', 'cflags'), ('DEFINES', 'defines'), ('LDFLAGS', 'ldflags')]:
94 % if configs['gcov'].get(arg, None) is not None:
95 '${prop}': [
96 % for item in configs['gcov'].get(arg).split():
97 '${item}',
98 % endfor
99 ],
100 % endif
101 % endfor
102 }],
murgatroid9998058332017-04-19 10:25:34 -0700103 ['grpc_alpine=="true"', {
104 'defines': [
105 'GPR_MUSL_LIBC_COMPAT'
106 ]
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 },
murgatroid99652210a2017-04-19 13:46:32 -0700236 ]
237 }],
238 ['OS == "win"', {
239 'targets': [
murgatroid99dc230462016-10-25 14:12:42 -0700240 # Only want to compile zlib under Windows
murgatroid995c56c922016-01-25 13:32:52 -0800241 % for module in node_modules:
242 % for lib in libs:
murgatroid99dc230462016-10-25 14:12:42 -0700243 % if lib.name in module.transitive_deps and lib.name == 'z':
murgatroid995c56c922016-01-25 13:32:52 -0800244 {
245 'cflags': [
246 '-std=c99',
247 '-Wall',
248 '-Werror'
249 ],
250 'target_name': '${lib.name}',
251 'product_prefix': 'lib',
252 'type': 'static_library',
253 'dependencies': [
254 % for dep in getattr(lib, 'deps', []):
255 '${dep}',
256 % endfor
257 ],
258 'sources': [
259 % for source in lib.src:
260 '${source}',
261 % endfor
murgatroid99af6c1782016-01-28 13:14:24 -0800262 ]
murgatroid995c56c922016-01-25 13:32:52 -0800263 },
264 % endif
265 % endfor
266 % endfor
267 ]
268 }]
269 ],
murgatroid992d6d3302015-09-21 13:29:40 -0700270 'targets': [
murgatroid99879bc4f2015-11-05 10:35:04 -0800271 % for module in node_modules:
murgatroid992d6d3302015-09-21 13:29:40 -0700272 % for lib in libs:
murgatroid995c56c922016-01-25 13:32:52 -0800273 % if lib.name in module.transitive_deps and lib.name not in ('boringssl', 'z'):
murgatroid992d6d3302015-09-21 13:29:40 -0700274 {
murgatroid993abed312016-01-07 17:16:46 -0800275 'cflags': [
276 '-std=c99',
277 '-Wall',
278 '-Werror'
279 ],
murgatroid992d6d3302015-09-21 13:29:40 -0700280 'target_name': '${lib.name}',
281 'product_prefix': 'lib',
282 'type': 'static_library',
283 'dependencies': [
284 % for dep in getattr(lib, 'deps', []):
285 '${dep}',
286 % endfor
287 ],
288 'sources': [
289 % for source in lib.src:
murgatroid99ca9db402015-09-21 14:39:09 -0700290 '${source}',
murgatroid992d6d3302015-09-21 13:29:40 -0700291 % endfor
murgatroid99ca9db402015-09-21 14:39:09 -0700292 ],
murgatroid996ffdb942015-10-22 16:10:05 -0700293 "conditions": [
294 ['OS == "mac"', {
295 'xcode_settings': {
murgatroid9922c448b2015-10-23 10:25:30 -0700296 'MACOSX_DEPLOYMENT_TARGET': '10.9'
murgatroid996ffdb942015-10-22 16:10:05 -0700297 }
298 }]
murgatroid995c56c922016-01-25 13:32:52 -0800299 ]
murgatroid992d6d3302015-09-21 13:29:40 -0700300 },
murgatroid99ca9db402015-09-21 14:39:09 -0700301 % endif
murgatroid992d6d3302015-09-21 13:29:40 -0700302 % endfor
murgatroid99fd994f12015-10-09 14:02:28 -0700303 {
304 'include_dirs': [
305 "<!(node -e \"require('nan')\")"
306 ],
307 'cflags': [
murgatroid993abed312016-01-07 17:16:46 -0800308 '-std=c++11',
murgatroid99fd994f12015-10-09 14:02:28 -0700309 '-pthread',
murgatroid99fd994f12015-10-09 14:02:28 -0700310 '-zdefs',
murgatroid99fd994f12015-10-09 14:02:28 -0700311 '-Wno-error=deprecated-declarations'
312 ],
murgatroid99fd994f12015-10-09 14:02:28 -0700313 "conditions": [
murgatroid99dc230462016-10-25 14:12:42 -0700314 ['OS=="win" or runtime=="electron"', {
315 'dependencies': [
316 % for dep in getattr(module, 'deps', []):
317 % if dep == 'boringssl':
318 "${dep}",
319 % endif
320 % endfor
321 ]
322 }],
murgatroid995c56c922016-01-25 13:32:52 -0800323 ['OS=="mac"', {
murgatroid99fd994f12015-10-09 14:02:28 -0700324 'xcode_settings': {
325 'MACOSX_DEPLOYMENT_TARGET': '10.9',
326 'OTHER_CFLAGS': [
murgatroid99673f65b2016-02-01 11:19:07 -0800327 '-stdlib=libc++',
328 '-std=c++11'
murgatroid99fd994f12015-10-09 14:02:28 -0700329 ]
330 }
murgatroid995c56c922016-01-25 13:32:52 -0800331 }],
332 ['OS=="win"', {
333 'dependencies': [
334 % for dep in getattr(module, 'deps', []):
murgatroid99dc230462016-10-25 14:12:42 -0700335 % if dep == 'z':
murgatroid995c56c922016-01-25 13:32:52 -0800336 "${dep}",
337 % endif
338 % endfor
339 ]
Craig Tiller4bef7ce2016-02-02 08:38:43 -0800340 }],
341 ['OS=="linux"', {
342 'ldflags': [
343 '-Wl,-wrap,memcpy'
344 ]
murgatroid99fd994f12015-10-09 14:02:28 -0700345 }]
346 ],
murgatroid99879bc4f2015-11-05 10:35:04 -0800347 "target_name": "${module.name}",
murgatroid99fd994f12015-10-09 14:02:28 -0700348 "sources": [
murgatroid99879bc4f2015-11-05 10:35:04 -0800349 % for source in module.src:
350 "${source}",
351 % endfor
murgatroid99fd994f12015-10-09 14:02:28 -0700352 ],
353 "dependencies": [
murgatroid99879bc4f2015-11-05 10:35:04 -0800354 % for dep in getattr(module, 'deps', []):
murgatroid995c56c922016-01-25 13:32:52 -0800355 % if dep not in ('boringssl', 'z'):
murgatroid99879bc4f2015-11-05 10:35:04 -0800356 "${dep}",
murgatroid995c56c922016-01-25 13:32:52 -0800357 % endif
murgatroid99879bc4f2015-11-05 10:35:04 -0800358 % endfor
murgatroid99fd994f12015-10-09 14:02:28 -0700359 ]
murgatroid99879bc4f2015-11-05 10:35:04 -0800360 },
361 % endfor
murgatroid99e190f352016-01-20 13:52:08 -0800362 {
363 "target_name": "action_after_build",
364 "type": "none",
365 "dependencies": [ "<(module_name)" ],
366 "copies": [
367 {
368 "files": [ "<(PRODUCT_DIR)/<(module_name).node"],
369 "destination": "<(module_path)"
370 }
371 ]
372 }
murgatroid992d6d3302015-09-21 13:29:40 -0700373 ]
374 }