blob: 40d430f79255673ff30f9f05b3a8edd9a7324904 [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 ],
47 'conditions': [
murgatroid995c56c922016-01-25 13:32:52 -080048 ['OS == "win"', {
murgatroid99673f65b2016-02-01 11:19:07 -080049 "include_dirs": [
50 "third_party/boringssl/include",
51 "third_party/zlib"
52 ],
murgatroid99af6c1782016-01-28 13:14:24 -080053 "defines": [
54 '_WIN32_WINNT=0x0600',
55 'WIN32_LEAN_AND_MEAN',
56 '_HAS_EXCEPTIONS=0',
57 'UNICODE',
58 '_UNICODE',
59 'NOMINMAX',
Craig Tiller71ea4a12016-02-04 15:06:41 -080060 'OPENSSL_NO_ASM',
61 'GPR_BACKWARDS_COMPATIBILITY_MODE'
murgatroid99af6c1782016-01-28 13:14:24 -080062 ],
63 "msvs_settings": {
64 'VCCLCompilerTool': {
65 'RuntimeLibrary': 1, # static debug
66 }
67 },
68 "libraries": [
69 "ws2_32"
70 ]
71 }, { # OS != "win"
murgatroid99673f65b2016-02-01 11:19:07 -080072 'variables': {
73 'config': '<!(echo $CONFIG)',
74 # The output of "node --version" is "v[version]". We use cut to
75 # remove the first character.
76 'target%': '<!(node --version | cut -c2-)'
77 },
murgatroid99af6c1782016-01-28 13:14:24 -080078 # Empirically, Node only exports ALPN symbols if its major version is >0.
79 # io.js always reports versions >0 and always exports ALPN symbols.
80 # Therefore, Node's major version will be truthy if and only if it
murgatroid99673f65b2016-02-01 11:19:07 -080081 # supports ALPN. The target is "[major].[minor].[patch]". We split by
82 # periods and take the first field to get the major version.
murgatroid99af6c1782016-01-28 13:14:24 -080083 'defines': [
Craig Tiller71ea4a12016-02-04 15:06:41 -080084 'TSI_OPENSSL_ALPN_SUPPORT=<!(echo <(target) | cut -d. -f1)',
85 'GPR_BACKWARDS_COMPATIBILITY_MODE'
murgatroid99af6c1782016-01-28 13:14:24 -080086 ],
murgatroid995c56c922016-01-25 13:32:52 -080087 'include_dirs': [
88 '<(node_root_dir)/deps/openssl/openssl/include',
89 '<(node_root_dir)/deps/zlib'
90 ],
murgatroid99a89d9e72015-10-13 16:03:16 -070091 'conditions': [
92 ['config=="gcov"', {
93 'cflags': [
94 '-ftest-coverage',
95 '-fprofile-arcs',
96 '-O0'
97 ],
98 'ldflags': [
99 '-ftest-coverage',
100 '-fprofile-arcs'
101 ]
102 }
murgatroid995c56c922016-01-25 13:32:52 -0800103 ],
104 ["target_arch=='ia32'", {
105 "include_dirs": [ "<(node_root_dir)/deps/openssl/config/piii" ]
106 }],
107 ["target_arch=='x64'", {
108 "include_dirs": [ "<(node_root_dir)/deps/openssl/config/k8" ]
109 }],
110 ["target_arch=='arm'", {
111 "include_dirs": [ "<(node_root_dir)/deps/openssl/config/arm" ]
112 }]
murgatroid99a89d9e72015-10-13 16:03:16 -0700113 ]
murgatroid99afe46982015-10-23 10:17:26 -0700114 }]
murgatroid99fd994f12015-10-09 14:02:28 -0700115 ]
murgatroid992d6d3302015-09-21 13:29:40 -0700116 },
murgatroid995c56c922016-01-25 13:32:52 -0800117 'conditions': [
118 ['OS == "win"', {
119 'targets': [
murgatroid99af6c1782016-01-28 13:14:24 -0800120 {
121 # IMPORTANT WINDOWS BUILD INFORMATION
122 # This library does not build on Windows without modifying the Node
123 # development packages that node-gyp downloads in order to build.
124 # Due to https://github.com/nodejs/node/issues/4932, the headers for
125 # BoringSSL conflict with the OpenSSL headers included by default
126 # when including the Node headers. The remedy for this is to remove
127 # the OpenSSL headers, from the downloaded Node development package,
128 # which is typically located in `.node-gyp` in your home directory.
murgatroid998e4103e2016-01-28 14:53:33 -0800129 'target_name': 'WINDOWS_BUILD_WARNING',
murgatroid99af6c1782016-01-28 13:14:24 -0800130 'actions': [
131 {
murgatroid998e4103e2016-01-28 14:53:33 -0800132 'action_name': 'WINDOWS_BUILD_WARNING',
133 'inputs': [
134 'package.json'
135 ],
136 'outputs': [
137 'ignore_this_part'
138 ],
139 '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 -0800140 }
141 ]
142 },
murgatroid995c56c922016-01-25 13:32:52 -0800143 # Only want to compile BoringSSL and zlib under Windows
144 % for module in node_modules:
145 % for lib in libs:
146 % if lib.name in module.transitive_deps and lib.name in ('boringssl', 'z'):
147 {
148 'cflags': [
149 '-std=c99',
150 '-Wall',
151 '-Werror'
152 ],
153 'target_name': '${lib.name}',
154 'product_prefix': 'lib',
155 'type': 'static_library',
156 'dependencies': [
157 % for dep in getattr(lib, 'deps', []):
158 '${dep}',
159 % endfor
160 ],
161 'sources': [
162 % for source in lib.src:
163 '${source}',
164 % endfor
murgatroid99af6c1782016-01-28 13:14:24 -0800165 ]
murgatroid995c56c922016-01-25 13:32:52 -0800166 },
167 % endif
168 % endfor
169 % endfor
170 ]
171 }]
172 ],
murgatroid992d6d3302015-09-21 13:29:40 -0700173 'targets': [
murgatroid99879bc4f2015-11-05 10:35:04 -0800174 % for module in node_modules:
murgatroid992d6d3302015-09-21 13:29:40 -0700175 % for lib in libs:
murgatroid995c56c922016-01-25 13:32:52 -0800176 % if lib.name in module.transitive_deps and lib.name not in ('boringssl', 'z'):
murgatroid992d6d3302015-09-21 13:29:40 -0700177 {
murgatroid993abed312016-01-07 17:16:46 -0800178 'cflags': [
179 '-std=c99',
180 '-Wall',
181 '-Werror'
182 ],
murgatroid992d6d3302015-09-21 13:29:40 -0700183 'target_name': '${lib.name}',
184 'product_prefix': 'lib',
185 'type': 'static_library',
186 'dependencies': [
187 % for dep in getattr(lib, 'deps', []):
188 '${dep}',
189 % endfor
190 ],
191 'sources': [
192 % for source in lib.src:
murgatroid99ca9db402015-09-21 14:39:09 -0700193 '${source}',
murgatroid992d6d3302015-09-21 13:29:40 -0700194 % endfor
murgatroid99ca9db402015-09-21 14:39:09 -0700195 ],
murgatroid996ffdb942015-10-22 16:10:05 -0700196 "conditions": [
197 ['OS == "mac"', {
198 'xcode_settings': {
murgatroid9922c448b2015-10-23 10:25:30 -0700199 'MACOSX_DEPLOYMENT_TARGET': '10.9'
murgatroid996ffdb942015-10-22 16:10:05 -0700200 }
201 }]
murgatroid995c56c922016-01-25 13:32:52 -0800202 ]
murgatroid992d6d3302015-09-21 13:29:40 -0700203 },
murgatroid99ca9db402015-09-21 14:39:09 -0700204 % endif
murgatroid992d6d3302015-09-21 13:29:40 -0700205 % endfor
murgatroid99fd994f12015-10-09 14:02:28 -0700206 {
207 'include_dirs': [
208 "<!(node -e \"require('nan')\")"
209 ],
210 'cflags': [
murgatroid993abed312016-01-07 17:16:46 -0800211 '-std=c++11',
murgatroid99fd994f12015-10-09 14:02:28 -0700212 '-Wall',
213 '-pthread',
214 '-g',
215 '-zdefs',
216 '-Werror',
217 '-Wno-error=deprecated-declarations'
218 ],
219 'ldflags': [
220 '-g'
221 ],
222 "conditions": [
murgatroid995c56c922016-01-25 13:32:52 -0800223 ['OS=="mac"', {
murgatroid99fd994f12015-10-09 14:02:28 -0700224 'xcode_settings': {
225 'MACOSX_DEPLOYMENT_TARGET': '10.9',
226 'OTHER_CFLAGS': [
murgatroid99673f65b2016-02-01 11:19:07 -0800227 '-stdlib=libc++',
228 '-std=c++11'
murgatroid99fd994f12015-10-09 14:02:28 -0700229 ]
230 }
murgatroid995c56c922016-01-25 13:32:52 -0800231 }],
232 ['OS=="win"', {
233 'dependencies': [
234 % for dep in getattr(module, 'deps', []):
235 % if dep in ('boringssl', 'z'):
236 "${dep}",
237 % endif
238 % endfor
239 ]
Craig Tiller4bef7ce2016-02-02 08:38:43 -0800240 }],
241 ['OS=="linux"', {
242 'ldflags': [
243 '-Wl,-wrap,memcpy'
244 ]
murgatroid99fd994f12015-10-09 14:02:28 -0700245 }]
246 ],
murgatroid99879bc4f2015-11-05 10:35:04 -0800247 "target_name": "${module.name}",
murgatroid99fd994f12015-10-09 14:02:28 -0700248 "sources": [
murgatroid99879bc4f2015-11-05 10:35:04 -0800249 % for source in module.src:
250 "${source}",
251 % endfor
murgatroid99fd994f12015-10-09 14:02:28 -0700252 ],
253 "dependencies": [
murgatroid99879bc4f2015-11-05 10:35:04 -0800254 % for dep in getattr(module, 'deps', []):
murgatroid995c56c922016-01-25 13:32:52 -0800255 % if dep not in ('boringssl', 'z'):
murgatroid99879bc4f2015-11-05 10:35:04 -0800256 "${dep}",
murgatroid995c56c922016-01-25 13:32:52 -0800257 % endif
murgatroid99879bc4f2015-11-05 10:35:04 -0800258 % endfor
murgatroid99fd994f12015-10-09 14:02:28 -0700259 ]
murgatroid99879bc4f2015-11-05 10:35:04 -0800260 },
261 % endfor
murgatroid99e190f352016-01-20 13:52:08 -0800262 {
263 "target_name": "action_after_build",
264 "type": "none",
265 "dependencies": [ "<(module_name)" ],
266 "copies": [
267 {
268 "files": [ "<(PRODUCT_DIR)/<(module_name).node"],
269 "destination": "<(module_path)"
270 }
271 ]
272 }
murgatroid992d6d3302015-09-21 13:29:40 -0700273 ]
274 }