blob: 851effc4f3dab98edf493cdb823f9babe4c22f32 [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': {
43 'runtime%': 'node'
44 },
murgatroid992d6d3302015-09-21 13:29:40 -070045 'target_defaults': {
murgatroid992d6d3302015-09-21 13:29:40 -070046 'include_dirs': [
murgatroid99ca9db402015-09-21 14:39:09 -070047 '.',
murgatroid995c56c922016-01-25 13:32:52 -080048 'include'
murgatroid99a89d9e72015-10-13 16:03:16 -070049 ],
murgatroid99dc230462016-10-25 14:12:42 -070050 'defines': [
murgatroid99cb4b2b52016-10-27 11:30:50 -070051 'GPR_BACKWARDS_COMPATIBILITY_MODE'
murgatroid99dc230462016-10-25 14:12:42 -070052 ],
murgatroid99a89d9e72015-10-13 16:03:16 -070053 'conditions': [
murgatroid99cb4b2b52016-10-27 11:30:50 -070054 ['runtime=="node"', {
55 'defines': [
56 'GRPC_UV'
57 ]
58 }],
murgatroid99e8ec16d2017-01-13 11:00:53 -080059 ['OS!="win" and runtime=="electron"', {
Michael Lumish88162f82017-01-12 17:37:58 -080060 "defines": [
61 'OPENSSL_NO_THREADS'
62 ]
63 }],
murgatroid99dc230462016-10-25 14:12:42 -070064 # This is the condition for using boringssl
65 ['OS=="win" or runtime=="electron"', {
66 "include_dirs": [
67 "third_party/boringssl/include"
68 ],
69 "defines": [
Michael Lumish88162f82017-01-12 17:37:58 -080070 'OPENSSL_NO_ASM'
murgatroid99dc230462016-10-25 14:12:42 -070071 ]
72 }, {
73 # Based on logic above, we know that this must be a non-Windows system
74 'variables': {
75 # The output of "node --version" is "v[version]". We use cut to
76 # remove the first character.
77 'target%': '<!(node --version | cut -c2-)'
78 },
79 # Empirically, Node only exports ALPN symbols if its major version is >0.
80 # io.js always reports versions >0 and always exports ALPN symbols.
81 # Therefore, Node's major version will be truthy if and only if it
82 # supports ALPN. The target is "[major].[minor].[patch]". We split by
83 # periods and take the first field to get the major version.
84 'defines': [
85 'TSI_OPENSSL_ALPN_SUPPORT=<!(echo <(target) | cut -d. -f1)'
86 ],
87 'include_dirs': [
88 '<(node_root_dir)/deps/openssl/openssl/include',
89 ],
90 'conditions': [
91 ["target_arch=='ia32'", {
92 "include_dirs": [ "<(node_root_dir)/deps/openssl/config/piii" ]
93 }],
94 ["target_arch=='x64'", {
95 "include_dirs": [ "<(node_root_dir)/deps/openssl/config/k8" ]
96 }],
97 ["target_arch=='arm'", {
98 "include_dirs": [ "<(node_root_dir)/deps/openssl/config/arm" ]
99 }]
100 ]
101 }],
murgatroid995c56c922016-01-25 13:32:52 -0800102 ['OS == "win"', {
murgatroid99673f65b2016-02-01 11:19:07 -0800103 "include_dirs": [
murgatroid99673f65b2016-02-01 11:19:07 -0800104 "third_party/zlib"
105 ],
murgatroid99af6c1782016-01-28 13:14:24 -0800106 "defines": [
107 '_WIN32_WINNT=0x0600',
108 'WIN32_LEAN_AND_MEAN',
109 '_HAS_EXCEPTIONS=0',
110 'UNICODE',
111 '_UNICODE',
112 'NOMINMAX',
murgatroid99af6c1782016-01-28 13:14:24 -0800113 ],
114 "msvs_settings": {
115 'VCCLCompilerTool': {
116 'RuntimeLibrary': 1, # static debug
117 }
118 },
119 "libraries": [
120 "ws2_32"
121 ]
122 }, { # OS != "win"
murgatroid99673f65b2016-02-01 11:19:07 -0800123 'variables': {
124 'config': '<!(echo $CONFIG)',
murgatroid99673f65b2016-02-01 11:19:07 -0800125 },
murgatroid995c56c922016-01-25 13:32:52 -0800126 'include_dirs': [
murgatroid995c56c922016-01-25 13:32:52 -0800127 '<(node_root_dir)/deps/zlib'
128 ],
murgatroid99a89d9e72015-10-13 16:03:16 -0700129 'conditions': [
130 ['config=="gcov"', {
131 'cflags': [
132 '-ftest-coverage',
133 '-fprofile-arcs',
134 '-O0'
135 ],
136 'ldflags': [
137 '-ftest-coverage',
138 '-fprofile-arcs'
139 ]
140 }
murgatroid99dc230462016-10-25 14:12:42 -0700141 ]
murgatroid99a89d9e72015-10-13 16:03:16 -0700142 ]
murgatroid99afe46982015-10-23 10:17:26 -0700143 }]
murgatroid99fd994f12015-10-09 14:02:28 -0700144 ]
murgatroid992d6d3302015-09-21 13:29:40 -0700145 },
murgatroid995c56c922016-01-25 13:32:52 -0800146 'conditions': [
murgatroid99dc230462016-10-25 14:12:42 -0700147 ['OS=="win" or runtime=="electron"', {
148 'targets': [
149 % for module in node_modules:
150 % for lib in libs:
151 % if lib.name in module.transitive_deps and lib.name == 'boringssl':
152 {
153 'cflags': [
154 '-std=c99',
155 '-Wall',
156 '-Werror'
157 ],
158 'target_name': '${lib.name}',
159 'product_prefix': 'lib',
160 'type': 'static_library',
161 'dependencies': [
162 % for dep in getattr(lib, 'deps', []):
163 '${dep}',
164 % endfor
165 ],
166 'sources': [
167 % for source in lib.src:
168 '${source}',
169 % endfor
170 ]
171 },
172 % endif
173 % endfor
174 % endfor
175 ]
176 }],
murgatroid995c56c922016-01-25 13:32:52 -0800177 ['OS == "win"', {
178 'targets': [
murgatroid99af6c1782016-01-28 13:14:24 -0800179 {
180 # IMPORTANT WINDOWS BUILD INFORMATION
181 # This library does not build on Windows without modifying the Node
182 # development packages that node-gyp downloads in order to build.
183 # Due to https://github.com/nodejs/node/issues/4932, the headers for
184 # BoringSSL conflict with the OpenSSL headers included by default
185 # when including the Node headers. The remedy for this is to remove
186 # the OpenSSL headers, from the downloaded Node development package,
187 # which is typically located in `.node-gyp` in your home directory.
murgatroid998e4103e2016-01-28 14:53:33 -0800188 'target_name': 'WINDOWS_BUILD_WARNING',
murgatroid99af6c1782016-01-28 13:14:24 -0800189 'actions': [
190 {
murgatroid998e4103e2016-01-28 14:53:33 -0800191 'action_name': 'WINDOWS_BUILD_WARNING',
192 'inputs': [
193 'package.json'
194 ],
195 'outputs': [
196 'ignore_this_part'
197 ],
198 '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 -0800199 }
200 ]
201 },
murgatroid99dc230462016-10-25 14:12:42 -0700202 # Only want to compile zlib under Windows
murgatroid995c56c922016-01-25 13:32:52 -0800203 % for module in node_modules:
204 % for lib in libs:
murgatroid99dc230462016-10-25 14:12:42 -0700205 % if lib.name in module.transitive_deps and lib.name == 'z':
murgatroid995c56c922016-01-25 13:32:52 -0800206 {
207 'cflags': [
208 '-std=c99',
209 '-Wall',
210 '-Werror'
211 ],
212 'target_name': '${lib.name}',
213 'product_prefix': 'lib',
214 'type': 'static_library',
215 'dependencies': [
216 % for dep in getattr(lib, 'deps', []):
217 '${dep}',
218 % endfor
219 ],
220 'sources': [
221 % for source in lib.src:
222 '${source}',
223 % endfor
murgatroid99af6c1782016-01-28 13:14:24 -0800224 ]
murgatroid995c56c922016-01-25 13:32:52 -0800225 },
226 % endif
227 % endfor
228 % endfor
229 ]
230 }]
231 ],
murgatroid992d6d3302015-09-21 13:29:40 -0700232 'targets': [
murgatroid99879bc4f2015-11-05 10:35:04 -0800233 % for module in node_modules:
murgatroid992d6d3302015-09-21 13:29:40 -0700234 % for lib in libs:
murgatroid995c56c922016-01-25 13:32:52 -0800235 % if lib.name in module.transitive_deps and lib.name not in ('boringssl', 'z'):
murgatroid992d6d3302015-09-21 13:29:40 -0700236 {
murgatroid993abed312016-01-07 17:16:46 -0800237 'cflags': [
238 '-std=c99',
239 '-Wall',
240 '-Werror'
241 ],
murgatroid992d6d3302015-09-21 13:29:40 -0700242 'target_name': '${lib.name}',
243 'product_prefix': 'lib',
244 'type': 'static_library',
245 'dependencies': [
246 % for dep in getattr(lib, 'deps', []):
247 '${dep}',
248 % endfor
249 ],
250 'sources': [
251 % for source in lib.src:
murgatroid99ca9db402015-09-21 14:39:09 -0700252 '${source}',
murgatroid992d6d3302015-09-21 13:29:40 -0700253 % endfor
murgatroid99ca9db402015-09-21 14:39:09 -0700254 ],
murgatroid996ffdb942015-10-22 16:10:05 -0700255 "conditions": [
256 ['OS == "mac"', {
257 'xcode_settings': {
murgatroid9922c448b2015-10-23 10:25:30 -0700258 'MACOSX_DEPLOYMENT_TARGET': '10.9'
murgatroid996ffdb942015-10-22 16:10:05 -0700259 }
260 }]
murgatroid995c56c922016-01-25 13:32:52 -0800261 ]
murgatroid992d6d3302015-09-21 13:29:40 -0700262 },
murgatroid99ca9db402015-09-21 14:39:09 -0700263 % endif
murgatroid992d6d3302015-09-21 13:29:40 -0700264 % endfor
murgatroid99fd994f12015-10-09 14:02:28 -0700265 {
266 'include_dirs': [
267 "<!(node -e \"require('nan')\")"
268 ],
269 'cflags': [
murgatroid993abed312016-01-07 17:16:46 -0800270 '-std=c++11',
murgatroid99fd994f12015-10-09 14:02:28 -0700271 '-Wall',
272 '-pthread',
273 '-g',
274 '-zdefs',
275 '-Werror',
276 '-Wno-error=deprecated-declarations'
277 ],
278 'ldflags': [
279 '-g'
280 ],
281 "conditions": [
murgatroid99dc230462016-10-25 14:12:42 -0700282 ['OS=="win" or runtime=="electron"', {
283 'dependencies': [
284 % for dep in getattr(module, 'deps', []):
285 % if dep == 'boringssl':
286 "${dep}",
287 % endif
288 % endfor
289 ]
290 }],
murgatroid995c56c922016-01-25 13:32:52 -0800291 ['OS=="mac"', {
murgatroid99fd994f12015-10-09 14:02:28 -0700292 'xcode_settings': {
293 'MACOSX_DEPLOYMENT_TARGET': '10.9',
294 'OTHER_CFLAGS': [
murgatroid99673f65b2016-02-01 11:19:07 -0800295 '-stdlib=libc++',
296 '-std=c++11'
murgatroid99fd994f12015-10-09 14:02:28 -0700297 ]
298 }
murgatroid995c56c922016-01-25 13:32:52 -0800299 }],
300 ['OS=="win"', {
301 'dependencies': [
302 % for dep in getattr(module, 'deps', []):
murgatroid99dc230462016-10-25 14:12:42 -0700303 % if dep == 'z':
murgatroid995c56c922016-01-25 13:32:52 -0800304 "${dep}",
305 % endif
306 % endfor
307 ]
Craig Tiller4bef7ce2016-02-02 08:38:43 -0800308 }],
309 ['OS=="linux"', {
310 'ldflags': [
311 '-Wl,-wrap,memcpy'
312 ]
murgatroid99fd994f12015-10-09 14:02:28 -0700313 }]
314 ],
murgatroid99879bc4f2015-11-05 10:35:04 -0800315 "target_name": "${module.name}",
murgatroid99fd994f12015-10-09 14:02:28 -0700316 "sources": [
murgatroid99879bc4f2015-11-05 10:35:04 -0800317 % for source in module.src:
318 "${source}",
319 % endfor
murgatroid99fd994f12015-10-09 14:02:28 -0700320 ],
321 "dependencies": [
murgatroid99879bc4f2015-11-05 10:35:04 -0800322 % for dep in getattr(module, 'deps', []):
murgatroid995c56c922016-01-25 13:32:52 -0800323 % if dep not in ('boringssl', 'z'):
murgatroid99879bc4f2015-11-05 10:35:04 -0800324 "${dep}",
murgatroid995c56c922016-01-25 13:32:52 -0800325 % endif
murgatroid99879bc4f2015-11-05 10:35:04 -0800326 % endfor
murgatroid99fd994f12015-10-09 14:02:28 -0700327 ]
murgatroid99879bc4f2015-11-05 10:35:04 -0800328 },
329 % endfor
murgatroid99e190f352016-01-20 13:52:08 -0800330 {
331 "target_name": "action_after_build",
332 "type": "none",
333 "dependencies": [ "<(module_name)" ],
334 "copies": [
335 {
336 "files": [ "<(PRODUCT_DIR)/<(module_name).node"],
337 "destination": "<(module_path)"
338 }
339 ]
340 }
murgatroid992d6d3302015-09-21 13:29:40 -0700341 ]
342 }