blob: 2290411d54124319b8596ded3628d55aede6f6ed [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': [
murgatroid998c2946a2017-02-27 10:19:21 -080059 ['grpc_uv=="true"', {
murgatroid99cb4b2b52016-10-27 11:30:50 -070060 'defines': [
murgatroid991191b722017-02-08 11:56:52 -080061 'GRPC_UV'
murgatroid99cb4b2b52016-10-27 11:30:50 -070062 ]
63 }],
murgatroid99e8ec16d2017-01-13 11:00:53 -080064 ['OS!="win" and runtime=="electron"', {
Michael Lumish88162f82017-01-12 17:37:58 -080065 "defines": [
66 'OPENSSL_NO_THREADS'
67 ]
68 }],
murgatroid99dc230462016-10-25 14:12:42 -070069 # This is the condition for using boringssl
70 ['OS=="win" or runtime=="electron"', {
71 "include_dirs": [
72 "third_party/boringssl/include"
73 ],
74 "defines": [
Michael Lumish88162f82017-01-12 17:37:58 -080075 'OPENSSL_NO_ASM'
murgatroid99dc230462016-10-25 14:12:42 -070076 ]
77 }, {
murgatroid991191b722017-02-08 11:56:52 -080078 # As of the beginning of 2017, we only support versions of Node with
79 # embedded versions of OpenSSL that support ALPN
murgatroid99dc230462016-10-25 14:12:42 -070080 'defines': [
murgatroid991191b722017-02-08 11:56:52 -080081 'TSI_OPENSSL_ALPN_SUPPORT=1'
murgatroid99dc230462016-10-25 14:12:42 -070082 ],
83 'include_dirs': [
84 '<(node_root_dir)/deps/openssl/openssl/include',
85 ],
86 'conditions': [
87 ["target_arch=='ia32'", {
88 "include_dirs": [ "<(node_root_dir)/deps/openssl/config/piii" ]
89 }],
90 ["target_arch=='x64'", {
91 "include_dirs": [ "<(node_root_dir)/deps/openssl/config/k8" ]
92 }],
93 ["target_arch=='arm'", {
94 "include_dirs": [ "<(node_root_dir)/deps/openssl/config/arm" ]
95 }]
96 ]
97 }],
murgatroid995c56c922016-01-25 13:32:52 -080098 ['OS == "win"', {
murgatroid99673f65b2016-02-01 11:19:07 -080099 "include_dirs": [
murgatroid99673f65b2016-02-01 11:19:07 -0800100 "third_party/zlib"
101 ],
murgatroid99af6c1782016-01-28 13:14:24 -0800102 "defines": [
103 '_WIN32_WINNT=0x0600',
104 'WIN32_LEAN_AND_MEAN',
105 '_HAS_EXCEPTIONS=0',
106 'UNICODE',
107 '_UNICODE',
108 'NOMINMAX',
murgatroid99af6c1782016-01-28 13:14:24 -0800109 ],
110 "msvs_settings": {
111 'VCCLCompilerTool': {
112 'RuntimeLibrary': 1, # static debug
113 }
114 },
115 "libraries": [
116 "ws2_32"
117 ]
118 }, { # OS != "win"
murgatroid99673f65b2016-02-01 11:19:07 -0800119 'variables': {
120 'config': '<!(echo $CONFIG)',
murgatroid99673f65b2016-02-01 11:19:07 -0800121 },
murgatroid995c56c922016-01-25 13:32:52 -0800122 'include_dirs': [
murgatroid995c56c922016-01-25 13:32:52 -0800123 '<(node_root_dir)/deps/zlib'
124 ],
murgatroid99a89d9e72015-10-13 16:03:16 -0700125 'conditions': [
126 ['config=="gcov"', {
127 'cflags': [
128 '-ftest-coverage',
129 '-fprofile-arcs',
130 '-O0'
131 ],
132 'ldflags': [
133 '-ftest-coverage',
134 '-fprofile-arcs'
135 ]
136 }
murgatroid99dc230462016-10-25 14:12:42 -0700137 ]
murgatroid99a89d9e72015-10-13 16:03:16 -0700138 ]
murgatroid99afe46982015-10-23 10:17:26 -0700139 }]
murgatroid99fd994f12015-10-09 14:02:28 -0700140 ]
murgatroid992d6d3302015-09-21 13:29:40 -0700141 },
murgatroid995c56c922016-01-25 13:32:52 -0800142 'conditions': [
murgatroid99dc230462016-10-25 14:12:42 -0700143 ['OS=="win" or runtime=="electron"', {
144 'targets': [
145 % for module in node_modules:
146 % for lib in libs:
147 % if lib.name in module.transitive_deps and lib.name == 'boringssl':
148 {
149 'cflags': [
150 '-std=c99',
151 '-Wall',
152 '-Werror'
153 ],
154 'target_name': '${lib.name}',
155 'product_prefix': 'lib',
156 'type': 'static_library',
157 'dependencies': [
158 % for dep in getattr(lib, 'deps', []):
159 '${dep}',
160 % endfor
161 ],
162 'sources': [
163 % for source in lib.src:
164 '${source}',
165 % endfor
166 ]
167 },
168 % endif
169 % endfor
170 % endfor
171 ]
172 }],
murgatroid995c56c922016-01-25 13:32:52 -0800173 ['OS == "win"', {
174 'targets': [
murgatroid99af6c1782016-01-28 13:14:24 -0800175 {
176 # IMPORTANT WINDOWS BUILD INFORMATION
177 # This library does not build on Windows without modifying the Node
178 # development packages that node-gyp downloads in order to build.
179 # Due to https://github.com/nodejs/node/issues/4932, the headers for
180 # BoringSSL conflict with the OpenSSL headers included by default
181 # when including the Node headers. The remedy for this is to remove
182 # the OpenSSL headers, from the downloaded Node development package,
183 # which is typically located in `.node-gyp` in your home directory.
murgatroid998e4103e2016-01-28 14:53:33 -0800184 'target_name': 'WINDOWS_BUILD_WARNING',
murgatroid99af6c1782016-01-28 13:14:24 -0800185 'actions': [
186 {
murgatroid998e4103e2016-01-28 14:53:33 -0800187 'action_name': 'WINDOWS_BUILD_WARNING',
188 'inputs': [
189 'package.json'
190 ],
191 'outputs': [
192 'ignore_this_part'
193 ],
194 '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 -0800195 }
196 ]
197 },
murgatroid99dc230462016-10-25 14:12:42 -0700198 # Only want to compile zlib under Windows
murgatroid995c56c922016-01-25 13:32:52 -0800199 % for module in node_modules:
200 % for lib in libs:
murgatroid99dc230462016-10-25 14:12:42 -0700201 % if lib.name in module.transitive_deps and lib.name == 'z':
murgatroid995c56c922016-01-25 13:32:52 -0800202 {
203 'cflags': [
204 '-std=c99',
205 '-Wall',
206 '-Werror'
207 ],
208 'target_name': '${lib.name}',
209 'product_prefix': 'lib',
210 'type': 'static_library',
211 'dependencies': [
212 % for dep in getattr(lib, 'deps', []):
213 '${dep}',
214 % endfor
215 ],
216 'sources': [
217 % for source in lib.src:
218 '${source}',
219 % endfor
murgatroid99af6c1782016-01-28 13:14:24 -0800220 ]
murgatroid995c56c922016-01-25 13:32:52 -0800221 },
222 % endif
223 % endfor
224 % endfor
225 ]
226 }]
227 ],
murgatroid992d6d3302015-09-21 13:29:40 -0700228 'targets': [
murgatroid99879bc4f2015-11-05 10:35:04 -0800229 % for module in node_modules:
murgatroid992d6d3302015-09-21 13:29:40 -0700230 % for lib in libs:
murgatroid995c56c922016-01-25 13:32:52 -0800231 % if lib.name in module.transitive_deps and lib.name not in ('boringssl', 'z'):
murgatroid992d6d3302015-09-21 13:29:40 -0700232 {
murgatroid993abed312016-01-07 17:16:46 -0800233 'cflags': [
234 '-std=c99',
235 '-Wall',
236 '-Werror'
237 ],
murgatroid992d6d3302015-09-21 13:29:40 -0700238 'target_name': '${lib.name}',
239 'product_prefix': 'lib',
240 'type': 'static_library',
241 'dependencies': [
242 % for dep in getattr(lib, 'deps', []):
243 '${dep}',
244 % endfor
245 ],
246 'sources': [
247 % for source in lib.src:
murgatroid99ca9db402015-09-21 14:39:09 -0700248 '${source}',
murgatroid992d6d3302015-09-21 13:29:40 -0700249 % endfor
murgatroid99ca9db402015-09-21 14:39:09 -0700250 ],
murgatroid996ffdb942015-10-22 16:10:05 -0700251 "conditions": [
252 ['OS == "mac"', {
253 'xcode_settings': {
murgatroid9922c448b2015-10-23 10:25:30 -0700254 'MACOSX_DEPLOYMENT_TARGET': '10.9'
murgatroid996ffdb942015-10-22 16:10:05 -0700255 }
256 }]
murgatroid995c56c922016-01-25 13:32:52 -0800257 ]
murgatroid992d6d3302015-09-21 13:29:40 -0700258 },
murgatroid99ca9db402015-09-21 14:39:09 -0700259 % endif
murgatroid992d6d3302015-09-21 13:29:40 -0700260 % endfor
murgatroid99fd994f12015-10-09 14:02:28 -0700261 {
262 'include_dirs': [
263 "<!(node -e \"require('nan')\")"
264 ],
265 'cflags': [
murgatroid993abed312016-01-07 17:16:46 -0800266 '-std=c++11',
murgatroid99fd994f12015-10-09 14:02:28 -0700267 '-Wall',
268 '-pthread',
269 '-g',
270 '-zdefs',
271 '-Werror',
272 '-Wno-error=deprecated-declarations'
273 ],
274 'ldflags': [
275 '-g'
276 ],
277 "conditions": [
murgatroid99dc230462016-10-25 14:12:42 -0700278 ['OS=="win" or runtime=="electron"', {
279 'dependencies': [
280 % for dep in getattr(module, 'deps', []):
281 % if dep == 'boringssl':
282 "${dep}",
283 % endif
284 % endfor
285 ]
286 }],
murgatroid995c56c922016-01-25 13:32:52 -0800287 ['OS=="mac"', {
murgatroid99fd994f12015-10-09 14:02:28 -0700288 'xcode_settings': {
289 'MACOSX_DEPLOYMENT_TARGET': '10.9',
290 'OTHER_CFLAGS': [
murgatroid99673f65b2016-02-01 11:19:07 -0800291 '-stdlib=libc++',
292 '-std=c++11'
murgatroid99fd994f12015-10-09 14:02:28 -0700293 ]
294 }
murgatroid995c56c922016-01-25 13:32:52 -0800295 }],
296 ['OS=="win"', {
297 'dependencies': [
298 % for dep in getattr(module, 'deps', []):
murgatroid99dc230462016-10-25 14:12:42 -0700299 % if dep == 'z':
murgatroid995c56c922016-01-25 13:32:52 -0800300 "${dep}",
301 % endif
302 % endfor
303 ]
Craig Tiller4bef7ce2016-02-02 08:38:43 -0800304 }],
305 ['OS=="linux"', {
306 'ldflags': [
307 '-Wl,-wrap,memcpy'
308 ]
murgatroid99fd994f12015-10-09 14:02:28 -0700309 }]
310 ],
murgatroid99879bc4f2015-11-05 10:35:04 -0800311 "target_name": "${module.name}",
murgatroid99fd994f12015-10-09 14:02:28 -0700312 "sources": [
murgatroid99879bc4f2015-11-05 10:35:04 -0800313 % for source in module.src:
314 "${source}",
315 % endfor
murgatroid99fd994f12015-10-09 14:02:28 -0700316 ],
317 "dependencies": [
murgatroid99879bc4f2015-11-05 10:35:04 -0800318 % for dep in getattr(module, 'deps', []):
murgatroid995c56c922016-01-25 13:32:52 -0800319 % if dep not in ('boringssl', 'z'):
murgatroid99879bc4f2015-11-05 10:35:04 -0800320 "${dep}",
murgatroid995c56c922016-01-25 13:32:52 -0800321 % endif
murgatroid99879bc4f2015-11-05 10:35:04 -0800322 % endfor
murgatroid99fd994f12015-10-09 14:02:28 -0700323 ]
murgatroid99879bc4f2015-11-05 10:35:04 -0800324 },
325 % endfor
murgatroid99e190f352016-01-20 13:52:08 -0800326 {
327 "target_name": "action_after_build",
328 "type": "none",
329 "dependencies": [ "<(module_name)" ],
330 "copies": [
331 {
332 "files": [ "<(PRODUCT_DIR)/<(module_name).node"],
333 "destination": "<(module_path)"
334 }
335 ]
336 }
murgatroid992d6d3302015-09-21 13:29:40 -0700337 ]
338 }