blob: 9d7034e18bc81b99eb15548212eea192438b0147 [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',
44 # UV integration in C core is disabled by default while bugs are ironed
45 # out. It can be re-enabled for one build by setting the npm config
46 # variable grpc_uv to true, and it can be re-enabled permanently by
47 # setting it to true here.
48 'grpc_uv%': 'false'
murgatroid99dc230462016-10-25 14:12:42 -070049 },
murgatroid992d6d3302015-09-21 13:29:40 -070050 'target_defaults': {
murgatroid992d6d3302015-09-21 13:29:40 -070051 'include_dirs': [
murgatroid99ca9db402015-09-21 14:39:09 -070052 '.',
murgatroid995c56c922016-01-25 13:32:52 -080053 'include'
murgatroid99a89d9e72015-10-13 16:03:16 -070054 ],
murgatroid99dc230462016-10-25 14:12:42 -070055 'defines': [
murgatroid99cb4b2b52016-10-27 11:30:50 -070056 'GPR_BACKWARDS_COMPATIBILITY_MODE'
murgatroid99dc230462016-10-25 14:12:42 -070057 ],
murgatroid99a89d9e72015-10-13 16:03:16 -070058 'conditions': [
murgatroid991191b722017-02-08 11:56:52 -080059 ['runtime=="node" and grpc_uv=="true"', {
murgatroid99cb4b2b52016-10-27 11:30:50 -070060 'defines': [
murgatroid996f62c0a2017-02-06 17:31:15 -080061 # Disabling this while bugs are ironed out. Uncomment this to
62 # re-enable libuv integration in C core.
murgatroid991191b722017-02-08 11:56:52 -080063 'GRPC_UV'
murgatroid99cb4b2b52016-10-27 11:30:50 -070064 ]
65 }],
murgatroid99e8ec16d2017-01-13 11:00:53 -080066 ['OS!="win" and runtime=="electron"', {
Michael Lumish88162f82017-01-12 17:37:58 -080067 "defines": [
68 'OPENSSL_NO_THREADS'
69 ]
70 }],
murgatroid99dc230462016-10-25 14:12:42 -070071 # This is the condition for using boringssl
72 ['OS=="win" or runtime=="electron"', {
73 "include_dirs": [
74 "third_party/boringssl/include"
75 ],
76 "defines": [
Michael Lumish88162f82017-01-12 17:37:58 -080077 'OPENSSL_NO_ASM'
murgatroid99dc230462016-10-25 14:12:42 -070078 ]
79 }, {
murgatroid991191b722017-02-08 11:56:52 -080080 # As of the beginning of 2017, we only support versions of Node with
81 # embedded versions of OpenSSL that support ALPN
murgatroid99dc230462016-10-25 14:12:42 -070082 'defines': [
murgatroid991191b722017-02-08 11:56:52 -080083 'TSI_OPENSSL_ALPN_SUPPORT=1'
murgatroid99dc230462016-10-25 14:12:42 -070084 ],
85 'include_dirs': [
86 '<(node_root_dir)/deps/openssl/openssl/include',
87 ],
88 'conditions': [
89 ["target_arch=='ia32'", {
90 "include_dirs": [ "<(node_root_dir)/deps/openssl/config/piii" ]
91 }],
92 ["target_arch=='x64'", {
93 "include_dirs": [ "<(node_root_dir)/deps/openssl/config/k8" ]
94 }],
95 ["target_arch=='arm'", {
96 "include_dirs": [ "<(node_root_dir)/deps/openssl/config/arm" ]
97 }]
98 ]
99 }],
murgatroid995c56c922016-01-25 13:32:52 -0800100 ['OS == "win"', {
murgatroid99673f65b2016-02-01 11:19:07 -0800101 "include_dirs": [
murgatroid99673f65b2016-02-01 11:19:07 -0800102 "third_party/zlib"
103 ],
murgatroid99af6c1782016-01-28 13:14:24 -0800104 "defines": [
105 '_WIN32_WINNT=0x0600',
106 'WIN32_LEAN_AND_MEAN',
107 '_HAS_EXCEPTIONS=0',
108 'UNICODE',
109 '_UNICODE',
110 'NOMINMAX',
murgatroid99af6c1782016-01-28 13:14:24 -0800111 ],
112 "msvs_settings": {
113 'VCCLCompilerTool': {
114 'RuntimeLibrary': 1, # static debug
115 }
116 },
117 "libraries": [
118 "ws2_32"
119 ]
120 }, { # OS != "win"
murgatroid99673f65b2016-02-01 11:19:07 -0800121 'variables': {
122 'config': '<!(echo $CONFIG)',
murgatroid99673f65b2016-02-01 11:19:07 -0800123 },
murgatroid995c56c922016-01-25 13:32:52 -0800124 'include_dirs': [
murgatroid995c56c922016-01-25 13:32:52 -0800125 '<(node_root_dir)/deps/zlib'
126 ],
murgatroid99a89d9e72015-10-13 16:03:16 -0700127 'conditions': [
128 ['config=="gcov"', {
129 'cflags': [
130 '-ftest-coverage',
131 '-fprofile-arcs',
132 '-O0'
133 ],
134 'ldflags': [
135 '-ftest-coverage',
136 '-fprofile-arcs'
137 ]
138 }
murgatroid99dc230462016-10-25 14:12:42 -0700139 ]
murgatroid99a89d9e72015-10-13 16:03:16 -0700140 ]
murgatroid99afe46982015-10-23 10:17:26 -0700141 }]
murgatroid99fd994f12015-10-09 14:02:28 -0700142 ]
murgatroid992d6d3302015-09-21 13:29:40 -0700143 },
murgatroid995c56c922016-01-25 13:32:52 -0800144 'conditions': [
murgatroid99dc230462016-10-25 14:12:42 -0700145 ['OS=="win" or runtime=="electron"', {
146 'targets': [
147 % for module in node_modules:
148 % for lib in libs:
149 % if lib.name in module.transitive_deps and lib.name == 'boringssl':
150 {
151 'cflags': [
152 '-std=c99',
153 '-Wall',
154 '-Werror'
155 ],
156 'target_name': '${lib.name}',
157 'product_prefix': 'lib',
158 'type': 'static_library',
159 'dependencies': [
160 % for dep in getattr(lib, 'deps', []):
161 '${dep}',
162 % endfor
163 ],
164 'sources': [
165 % for source in lib.src:
166 '${source}',
167 % endfor
168 ]
169 },
170 % endif
171 % endfor
172 % endfor
173 ]
174 }],
murgatroid995c56c922016-01-25 13:32:52 -0800175 ['OS == "win"', {
176 'targets': [
murgatroid99af6c1782016-01-28 13:14:24 -0800177 {
178 # IMPORTANT WINDOWS BUILD INFORMATION
179 # This library does not build on Windows without modifying the Node
180 # development packages that node-gyp downloads in order to build.
181 # Due to https://github.com/nodejs/node/issues/4932, the headers for
182 # BoringSSL conflict with the OpenSSL headers included by default
183 # when including the Node headers. The remedy for this is to remove
184 # the OpenSSL headers, from the downloaded Node development package,
185 # which is typically located in `.node-gyp` in your home directory.
murgatroid998e4103e2016-01-28 14:53:33 -0800186 'target_name': 'WINDOWS_BUILD_WARNING',
murgatroid99af6c1782016-01-28 13:14:24 -0800187 'actions': [
188 {
murgatroid998e4103e2016-01-28 14:53:33 -0800189 'action_name': 'WINDOWS_BUILD_WARNING',
190 'inputs': [
191 'package.json'
192 ],
193 'outputs': [
194 'ignore_this_part'
195 ],
196 '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 -0800197 }
198 ]
199 },
murgatroid99dc230462016-10-25 14:12:42 -0700200 # Only want to compile zlib under Windows
murgatroid995c56c922016-01-25 13:32:52 -0800201 % for module in node_modules:
202 % for lib in libs:
murgatroid99dc230462016-10-25 14:12:42 -0700203 % if lib.name in module.transitive_deps and lib.name == 'z':
murgatroid995c56c922016-01-25 13:32:52 -0800204 {
205 'cflags': [
206 '-std=c99',
207 '-Wall',
208 '-Werror'
209 ],
210 'target_name': '${lib.name}',
211 'product_prefix': 'lib',
212 'type': 'static_library',
213 'dependencies': [
214 % for dep in getattr(lib, 'deps', []):
215 '${dep}',
216 % endfor
217 ],
218 'sources': [
219 % for source in lib.src:
220 '${source}',
221 % endfor
murgatroid99af6c1782016-01-28 13:14:24 -0800222 ]
murgatroid995c56c922016-01-25 13:32:52 -0800223 },
224 % endif
225 % endfor
226 % endfor
227 ]
228 }]
229 ],
murgatroid992d6d3302015-09-21 13:29:40 -0700230 'targets': [
murgatroid99879bc4f2015-11-05 10:35:04 -0800231 % for module in node_modules:
murgatroid992d6d3302015-09-21 13:29:40 -0700232 % for lib in libs:
murgatroid995c56c922016-01-25 13:32:52 -0800233 % if lib.name in module.transitive_deps and lib.name not in ('boringssl', 'z'):
murgatroid992d6d3302015-09-21 13:29:40 -0700234 {
murgatroid993abed312016-01-07 17:16:46 -0800235 'cflags': [
236 '-std=c99',
237 '-Wall',
238 '-Werror'
239 ],
murgatroid992d6d3302015-09-21 13:29:40 -0700240 'target_name': '${lib.name}',
241 'product_prefix': 'lib',
242 'type': 'static_library',
243 'dependencies': [
244 % for dep in getattr(lib, 'deps', []):
245 '${dep}',
246 % endfor
247 ],
248 'sources': [
249 % for source in lib.src:
murgatroid99ca9db402015-09-21 14:39:09 -0700250 '${source}',
murgatroid992d6d3302015-09-21 13:29:40 -0700251 % endfor
murgatroid99ca9db402015-09-21 14:39:09 -0700252 ],
murgatroid996ffdb942015-10-22 16:10:05 -0700253 "conditions": [
254 ['OS == "mac"', {
255 'xcode_settings': {
murgatroid9922c448b2015-10-23 10:25:30 -0700256 'MACOSX_DEPLOYMENT_TARGET': '10.9'
murgatroid996ffdb942015-10-22 16:10:05 -0700257 }
258 }]
murgatroid995c56c922016-01-25 13:32:52 -0800259 ]
murgatroid992d6d3302015-09-21 13:29:40 -0700260 },
murgatroid99ca9db402015-09-21 14:39:09 -0700261 % endif
murgatroid992d6d3302015-09-21 13:29:40 -0700262 % endfor
murgatroid99fd994f12015-10-09 14:02:28 -0700263 {
264 'include_dirs': [
265 "<!(node -e \"require('nan')\")"
266 ],
267 'cflags': [
murgatroid993abed312016-01-07 17:16:46 -0800268 '-std=c++11',
murgatroid99fd994f12015-10-09 14:02:28 -0700269 '-Wall',
270 '-pthread',
271 '-g',
272 '-zdefs',
273 '-Werror',
274 '-Wno-error=deprecated-declarations'
275 ],
276 'ldflags': [
277 '-g'
278 ],
279 "conditions": [
murgatroid99dc230462016-10-25 14:12:42 -0700280 ['OS=="win" or runtime=="electron"', {
281 'dependencies': [
282 % for dep in getattr(module, 'deps', []):
283 % if dep == 'boringssl':
284 "${dep}",
285 % endif
286 % endfor
287 ]
288 }],
murgatroid995c56c922016-01-25 13:32:52 -0800289 ['OS=="mac"', {
murgatroid99fd994f12015-10-09 14:02:28 -0700290 'xcode_settings': {
291 'MACOSX_DEPLOYMENT_TARGET': '10.9',
292 'OTHER_CFLAGS': [
murgatroid99673f65b2016-02-01 11:19:07 -0800293 '-stdlib=libc++',
294 '-std=c++11'
murgatroid99fd994f12015-10-09 14:02:28 -0700295 ]
296 }
murgatroid995c56c922016-01-25 13:32:52 -0800297 }],
298 ['OS=="win"', {
299 'dependencies': [
300 % for dep in getattr(module, 'deps', []):
murgatroid99dc230462016-10-25 14:12:42 -0700301 % if dep == 'z':
murgatroid995c56c922016-01-25 13:32:52 -0800302 "${dep}",
303 % endif
304 % endfor
305 ]
Craig Tiller4bef7ce2016-02-02 08:38:43 -0800306 }],
307 ['OS=="linux"', {
308 'ldflags': [
309 '-Wl,-wrap,memcpy'
310 ]
murgatroid99fd994f12015-10-09 14:02:28 -0700311 }]
312 ],
murgatroid99879bc4f2015-11-05 10:35:04 -0800313 "target_name": "${module.name}",
murgatroid99fd994f12015-10-09 14:02:28 -0700314 "sources": [
murgatroid99879bc4f2015-11-05 10:35:04 -0800315 % for source in module.src:
316 "${source}",
317 % endfor
murgatroid99fd994f12015-10-09 14:02:28 -0700318 ],
319 "dependencies": [
murgatroid99879bc4f2015-11-05 10:35:04 -0800320 % for dep in getattr(module, 'deps', []):
murgatroid995c56c922016-01-25 13:32:52 -0800321 % if dep not in ('boringssl', 'z'):
murgatroid99879bc4f2015-11-05 10:35:04 -0800322 "${dep}",
murgatroid995c56c922016-01-25 13:32:52 -0800323 % endif
murgatroid99879bc4f2015-11-05 10:35:04 -0800324 % endfor
murgatroid99fd994f12015-10-09 14:02:28 -0700325 ]
murgatroid99879bc4f2015-11-05 10:35:04 -0800326 },
327 % endfor
murgatroid99e190f352016-01-20 13:52:08 -0800328 {
329 "target_name": "action_after_build",
330 "type": "none",
331 "dependencies": [ "<(module_name)" ],
332 "copies": [
333 {
334 "files": [ "<(PRODUCT_DIR)/<(module_name).node"],
335 "destination": "<(module_path)"
336 }
337 ]
338 }
murgatroid992d6d3302015-09-21 13:29:40 -0700339 ]
340 }