blob: e6592acebbc520314277baea7f40af2186b506e2 [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 {
42 'target_defaults': {
murgatroid992d6d3302015-09-21 13:29:40 -070043 'include_dirs': [
murgatroid99ca9db402015-09-21 14:39:09 -070044 '.',
murgatroid995c56c922016-01-25 13:32:52 -080045 'include'
murgatroid99a89d9e72015-10-13 16:03:16 -070046 ],
murgatroid999030c812016-09-16 13:25:08 -070047 'defines': [
48 'GRPC_UV'
49 ],
murgatroid99a89d9e72015-10-13 16:03:16 -070050 'conditions': [
murgatroid995c56c922016-01-25 13:32:52 -080051 ['OS == "win"', {
murgatroid99673f65b2016-02-01 11:19:07 -080052 "include_dirs": [
53 "third_party/boringssl/include",
54 "third_party/zlib"
55 ],
murgatroid99af6c1782016-01-28 13:14:24 -080056 "defines": [
57 '_WIN32_WINNT=0x0600',
58 'WIN32_LEAN_AND_MEAN',
59 '_HAS_EXCEPTIONS=0',
60 'UNICODE',
61 '_UNICODE',
62 'NOMINMAX',
Craig Tiller71ea4a12016-02-04 15:06:41 -080063 'OPENSSL_NO_ASM',
64 'GPR_BACKWARDS_COMPATIBILITY_MODE'
murgatroid99af6c1782016-01-28 13:14:24 -080065 ],
66 "msvs_settings": {
67 'VCCLCompilerTool': {
68 'RuntimeLibrary': 1, # static debug
69 }
70 },
71 "libraries": [
72 "ws2_32"
73 ]
74 }, { # OS != "win"
murgatroid99673f65b2016-02-01 11:19:07 -080075 'variables': {
76 'config': '<!(echo $CONFIG)',
77 # The output of "node --version" is "v[version]". We use cut to
78 # remove the first character.
79 'target%': '<!(node --version | cut -c2-)'
80 },
murgatroid99af6c1782016-01-28 13:14:24 -080081 # Empirically, Node only exports ALPN symbols if its major version is >0.
82 # io.js always reports versions >0 and always exports ALPN symbols.
83 # Therefore, Node's major version will be truthy if and only if it
murgatroid99673f65b2016-02-01 11:19:07 -080084 # supports ALPN. The target is "[major].[minor].[patch]". We split by
85 # periods and take the first field to get the major version.
murgatroid99af6c1782016-01-28 13:14:24 -080086 'defines': [
Craig Tiller71ea4a12016-02-04 15:06:41 -080087 'TSI_OPENSSL_ALPN_SUPPORT=<!(echo <(target) | cut -d. -f1)',
88 'GPR_BACKWARDS_COMPATIBILITY_MODE'
murgatroid99af6c1782016-01-28 13:14:24 -080089 ],
murgatroid995c56c922016-01-25 13:32:52 -080090 'include_dirs': [
91 '<(node_root_dir)/deps/openssl/openssl/include',
92 '<(node_root_dir)/deps/zlib'
93 ],
murgatroid99a89d9e72015-10-13 16:03:16 -070094 'conditions': [
95 ['config=="gcov"', {
96 'cflags': [
97 '-ftest-coverage',
98 '-fprofile-arcs',
99 '-O0'
100 ],
101 'ldflags': [
102 '-ftest-coverage',
103 '-fprofile-arcs'
104 ]
105 }
murgatroid995c56c922016-01-25 13:32:52 -0800106 ],
107 ["target_arch=='ia32'", {
108 "include_dirs": [ "<(node_root_dir)/deps/openssl/config/piii" ]
109 }],
110 ["target_arch=='x64'", {
111 "include_dirs": [ "<(node_root_dir)/deps/openssl/config/k8" ]
112 }],
113 ["target_arch=='arm'", {
114 "include_dirs": [ "<(node_root_dir)/deps/openssl/config/arm" ]
115 }]
murgatroid99a89d9e72015-10-13 16:03:16 -0700116 ]
murgatroid99afe46982015-10-23 10:17:26 -0700117 }]
murgatroid99fd994f12015-10-09 14:02:28 -0700118 ]
murgatroid992d6d3302015-09-21 13:29:40 -0700119 },
murgatroid995c56c922016-01-25 13:32:52 -0800120 'conditions': [
121 ['OS == "win"', {
122 'targets': [
murgatroid99af6c1782016-01-28 13:14:24 -0800123 {
124 # IMPORTANT WINDOWS BUILD INFORMATION
125 # This library does not build on Windows without modifying the Node
126 # development packages that node-gyp downloads in order to build.
127 # Due to https://github.com/nodejs/node/issues/4932, the headers for
128 # BoringSSL conflict with the OpenSSL headers included by default
129 # when including the Node headers. The remedy for this is to remove
130 # the OpenSSL headers, from the downloaded Node development package,
131 # which is typically located in `.node-gyp` in your home directory.
murgatroid998e4103e2016-01-28 14:53:33 -0800132 'target_name': 'WINDOWS_BUILD_WARNING',
murgatroid99af6c1782016-01-28 13:14:24 -0800133 'actions': [
134 {
murgatroid998e4103e2016-01-28 14:53:33 -0800135 'action_name': 'WINDOWS_BUILD_WARNING',
136 'inputs': [
137 'package.json'
138 ],
139 'outputs': [
140 'ignore_this_part'
141 ],
142 '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 -0800143 }
144 ]
145 },
murgatroid995c56c922016-01-25 13:32:52 -0800146 # Only want to compile BoringSSL and zlib under Windows
147 % for module in node_modules:
148 % for lib in libs:
149 % if lib.name in module.transitive_deps and lib.name in ('boringssl', 'z'):
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
murgatroid99af6c1782016-01-28 13:14:24 -0800168 ]
murgatroid995c56c922016-01-25 13:32:52 -0800169 },
170 % endif
171 % endfor
172 % endfor
173 ]
174 }]
175 ],
murgatroid992d6d3302015-09-21 13:29:40 -0700176 'targets': [
murgatroid99879bc4f2015-11-05 10:35:04 -0800177 % for module in node_modules:
murgatroid992d6d3302015-09-21 13:29:40 -0700178 % for lib in libs:
murgatroid995c56c922016-01-25 13:32:52 -0800179 % if lib.name in module.transitive_deps and lib.name not in ('boringssl', 'z'):
murgatroid992d6d3302015-09-21 13:29:40 -0700180 {
murgatroid993abed312016-01-07 17:16:46 -0800181 'cflags': [
182 '-std=c99',
183 '-Wall',
184 '-Werror'
185 ],
murgatroid992d6d3302015-09-21 13:29:40 -0700186 'target_name': '${lib.name}',
187 'product_prefix': 'lib',
188 'type': 'static_library',
189 'dependencies': [
190 % for dep in getattr(lib, 'deps', []):
191 '${dep}',
192 % endfor
193 ],
194 'sources': [
195 % for source in lib.src:
murgatroid99ca9db402015-09-21 14:39:09 -0700196 '${source}',
murgatroid992d6d3302015-09-21 13:29:40 -0700197 % endfor
murgatroid99ca9db402015-09-21 14:39:09 -0700198 ],
murgatroid996ffdb942015-10-22 16:10:05 -0700199 "conditions": [
200 ['OS == "mac"', {
201 'xcode_settings': {
murgatroid9922c448b2015-10-23 10:25:30 -0700202 'MACOSX_DEPLOYMENT_TARGET': '10.9'
murgatroid996ffdb942015-10-22 16:10:05 -0700203 }
204 }]
murgatroid995c56c922016-01-25 13:32:52 -0800205 ]
murgatroid992d6d3302015-09-21 13:29:40 -0700206 },
murgatroid99ca9db402015-09-21 14:39:09 -0700207 % endif
murgatroid992d6d3302015-09-21 13:29:40 -0700208 % endfor
murgatroid99fd994f12015-10-09 14:02:28 -0700209 {
210 'include_dirs': [
211 "<!(node -e \"require('nan')\")"
212 ],
213 'cflags': [
murgatroid993abed312016-01-07 17:16:46 -0800214 '-std=c++11',
murgatroid99fd994f12015-10-09 14:02:28 -0700215 '-Wall',
216 '-pthread',
217 '-g',
218 '-zdefs',
219 '-Werror',
220 '-Wno-error=deprecated-declarations'
221 ],
222 'ldflags': [
223 '-g'
224 ],
225 "conditions": [
murgatroid995c56c922016-01-25 13:32:52 -0800226 ['OS=="mac"', {
murgatroid99fd994f12015-10-09 14:02:28 -0700227 'xcode_settings': {
228 'MACOSX_DEPLOYMENT_TARGET': '10.9',
229 'OTHER_CFLAGS': [
murgatroid99673f65b2016-02-01 11:19:07 -0800230 '-stdlib=libc++',
231 '-std=c++11'
murgatroid99fd994f12015-10-09 14:02:28 -0700232 ]
233 }
murgatroid995c56c922016-01-25 13:32:52 -0800234 }],
235 ['OS=="win"', {
236 'dependencies': [
237 % for dep in getattr(module, 'deps', []):
238 % if dep in ('boringssl', 'z'):
239 "${dep}",
240 % endif
241 % endfor
242 ]
Craig Tiller4bef7ce2016-02-02 08:38:43 -0800243 }],
244 ['OS=="linux"', {
245 'ldflags': [
246 '-Wl,-wrap,memcpy'
247 ]
murgatroid99fd994f12015-10-09 14:02:28 -0700248 }]
249 ],
murgatroid99879bc4f2015-11-05 10:35:04 -0800250 "target_name": "${module.name}",
murgatroid99fd994f12015-10-09 14:02:28 -0700251 "sources": [
murgatroid99879bc4f2015-11-05 10:35:04 -0800252 % for source in module.src:
253 "${source}",
254 % endfor
murgatroid99fd994f12015-10-09 14:02:28 -0700255 ],
256 "dependencies": [
murgatroid99879bc4f2015-11-05 10:35:04 -0800257 % for dep in getattr(module, 'deps', []):
murgatroid995c56c922016-01-25 13:32:52 -0800258 % if dep not in ('boringssl', 'z'):
murgatroid99879bc4f2015-11-05 10:35:04 -0800259 "${dep}",
murgatroid995c56c922016-01-25 13:32:52 -0800260 % endif
murgatroid99879bc4f2015-11-05 10:35:04 -0800261 % endfor
murgatroid99fd994f12015-10-09 14:02:28 -0700262 ]
murgatroid99879bc4f2015-11-05 10:35:04 -0800263 },
264 % endfor
murgatroid99e190f352016-01-20 13:52:08 -0800265 {
266 "target_name": "action_after_build",
267 "type": "none",
268 "dependencies": [ "<(module_name)" ],
269 "copies": [
270 {
271 "files": [ "<(PRODUCT_DIR)/<(module_name).node"],
272 "destination": "<(module_path)"
273 }
274 ]
275 }
murgatroid992d6d3302015-09-21 13:29:40 -0700276 ]
277 }