blob: 31c9f8c96cf698cf92c50a08b779fc1e59f3c57a [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
murgatroid997586db82016-01-20 14:02:42 -080010 # Copyright 2015-2016, 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"', {
murgatroid99af6c1782016-01-28 13:14:24 -080049 "include_dirs": [ "third_party/boringssl/include" ],
50 "defines": [
51 '_WIN32_WINNT=0x0600',
52 'WIN32_LEAN_AND_MEAN',
53 '_HAS_EXCEPTIONS=0',
54 'UNICODE',
55 '_UNICODE',
56 'NOMINMAX',
57 'OPENSSL_NO_ASM'
58 ],
59 "msvs_settings": {
60 'VCCLCompilerTool': {
61 'RuntimeLibrary': 1, # static debug
62 }
63 },
64 "libraries": [
65 "ws2_32"
66 ]
67 }, { # OS != "win"
68 # Empirically, Node only exports ALPN symbols if its major version is >0.
69 # io.js always reports versions >0 and always exports ALPN symbols.
70 # Therefore, Node's major version will be truthy if and only if it
71 # supports ALPN. The output of "node -v" is v[major].[minor].[patch],
72 # like "v4.1.1" in a recent version. We use cut to split by period and
73 # take the first field (resulting in "v[major]"), then use cut again
74 # to take all but the first character, removing the "v".
75 'defines': [
76 'TSI_OPENSSL_ALPN_SUPPORT=<!(node --version | cut -d. -f1 | cut -c2-)'
77 ],
78 'variables': {
79 'config': '<!(echo $CONFIG)'
80 },
murgatroid995c56c922016-01-25 13:32:52 -080081 'include_dirs': [
82 '<(node_root_dir)/deps/openssl/openssl/include',
83 '<(node_root_dir)/deps/zlib'
84 ],
murgatroid99a89d9e72015-10-13 16:03:16 -070085 'conditions': [
86 ['config=="gcov"', {
87 'cflags': [
88 '-ftest-coverage',
89 '-fprofile-arcs',
90 '-O0'
91 ],
92 'ldflags': [
93 '-ftest-coverage',
94 '-fprofile-arcs'
95 ]
96 }
murgatroid995c56c922016-01-25 13:32:52 -080097 ],
98 ["target_arch=='ia32'", {
99 "include_dirs": [ "<(node_root_dir)/deps/openssl/config/piii" ]
100 }],
101 ["target_arch=='x64'", {
102 "include_dirs": [ "<(node_root_dir)/deps/openssl/config/k8" ]
103 }],
104 ["target_arch=='arm'", {
105 "include_dirs": [ "<(node_root_dir)/deps/openssl/config/arm" ]
106 }]
murgatroid99a89d9e72015-10-13 16:03:16 -0700107 ]
murgatroid99afe46982015-10-23 10:17:26 -0700108 }]
murgatroid99fd994f12015-10-09 14:02:28 -0700109 ]
murgatroid992d6d3302015-09-21 13:29:40 -0700110 },
murgatroid995c56c922016-01-25 13:32:52 -0800111 'conditions': [
112 ['OS == "win"', {
113 'targets': [
murgatroid99af6c1782016-01-28 13:14:24 -0800114 {
115 # IMPORTANT WINDOWS BUILD INFORMATION
116 # This library does not build on Windows without modifying the Node
117 # development packages that node-gyp downloads in order to build.
118 # Due to https://github.com/nodejs/node/issues/4932, the headers for
119 # BoringSSL conflict with the OpenSSL headers included by default
120 # when including the Node headers. The remedy for this is to remove
121 # the OpenSSL headers, from the downloaded Node development package,
122 # which is typically located in `.node-gyp` in your home directory.
murgatroid998e4103e2016-01-28 14:53:33 -0800123 'target_name': 'WINDOWS_BUILD_WARNING',
murgatroid99af6c1782016-01-28 13:14:24 -0800124 'actions': [
125 {
murgatroid998e4103e2016-01-28 14:53:33 -0800126 'action_name': 'WINDOWS_BUILD_WARNING',
127 'inputs': [
128 'package.json'
129 ],
130 'outputs': [
131 'ignore_this_part'
132 ],
133 '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 -0800134 }
135 ]
136 },
murgatroid995c56c922016-01-25 13:32:52 -0800137 # Only want to compile BoringSSL and zlib under Windows
138 % for module in node_modules:
139 % for lib in libs:
140 % if lib.name in module.transitive_deps and lib.name in ('boringssl', 'z'):
141 {
142 'cflags': [
143 '-std=c99',
144 '-Wall',
145 '-Werror'
146 ],
147 'target_name': '${lib.name}',
148 'product_prefix': 'lib',
149 'type': 'static_library',
150 'dependencies': [
151 % for dep in getattr(lib, 'deps', []):
152 '${dep}',
153 % endfor
154 ],
155 'sources': [
156 % for source in lib.src:
157 '${source}',
158 % endfor
murgatroid99af6c1782016-01-28 13:14:24 -0800159 ]
murgatroid995c56c922016-01-25 13:32:52 -0800160 },
161 % endif
162 % endfor
163 % endfor
164 ]
165 }]
166 ],
murgatroid992d6d3302015-09-21 13:29:40 -0700167 'targets': [
murgatroid99879bc4f2015-11-05 10:35:04 -0800168 % for module in node_modules:
murgatroid992d6d3302015-09-21 13:29:40 -0700169 % for lib in libs:
murgatroid995c56c922016-01-25 13:32:52 -0800170 % if lib.name in module.transitive_deps and lib.name not in ('boringssl', 'z'):
murgatroid992d6d3302015-09-21 13:29:40 -0700171 {
murgatroid993abed312016-01-07 17:16:46 -0800172 'cflags': [
173 '-std=c99',
174 '-Wall',
175 '-Werror'
176 ],
murgatroid992d6d3302015-09-21 13:29:40 -0700177 'target_name': '${lib.name}',
178 'product_prefix': 'lib',
179 'type': 'static_library',
180 'dependencies': [
181 % for dep in getattr(lib, 'deps', []):
182 '${dep}',
183 % endfor
184 ],
185 'sources': [
186 % for source in lib.src:
murgatroid99ca9db402015-09-21 14:39:09 -0700187 '${source}',
murgatroid992d6d3302015-09-21 13:29:40 -0700188 % endfor
murgatroid99ca9db402015-09-21 14:39:09 -0700189 ],
murgatroid996ffdb942015-10-22 16:10:05 -0700190 "conditions": [
191 ['OS == "mac"', {
192 'xcode_settings': {
murgatroid9922c448b2015-10-23 10:25:30 -0700193 'MACOSX_DEPLOYMENT_TARGET': '10.9'
murgatroid996ffdb942015-10-22 16:10:05 -0700194 }
195 }]
murgatroid995c56c922016-01-25 13:32:52 -0800196 ]
murgatroid992d6d3302015-09-21 13:29:40 -0700197 },
murgatroid99ca9db402015-09-21 14:39:09 -0700198 % endif
murgatroid992d6d3302015-09-21 13:29:40 -0700199 % endfor
murgatroid99fd994f12015-10-09 14:02:28 -0700200 {
201 'include_dirs': [
202 "<!(node -e \"require('nan')\")"
203 ],
204 'cflags': [
murgatroid993abed312016-01-07 17:16:46 -0800205 '-std=c++11',
murgatroid99fd994f12015-10-09 14:02:28 -0700206 '-Wall',
207 '-pthread',
208 '-g',
209 '-zdefs',
210 '-Werror',
211 '-Wno-error=deprecated-declarations'
212 ],
213 'ldflags': [
214 '-g'
215 ],
216 "conditions": [
murgatroid995c56c922016-01-25 13:32:52 -0800217 ['OS=="mac"', {
murgatroid99fd994f12015-10-09 14:02:28 -0700218 'xcode_settings': {
219 'MACOSX_DEPLOYMENT_TARGET': '10.9',
220 'OTHER_CFLAGS': [
murgatroid99fd994f12015-10-09 14:02:28 -0700221 '-stdlib=libc++'
222 ]
223 }
murgatroid995c56c922016-01-25 13:32:52 -0800224 }],
225 ['OS=="win"', {
226 'dependencies': [
227 % for dep in getattr(module, 'deps', []):
228 % if dep in ('boringssl', 'z'):
229 "${dep}",
230 % endif
231 % endfor
232 ]
Craig Tiller4bef7ce2016-02-02 08:38:43 -0800233 }],
234 ['OS=="linux"', {
235 'ldflags': [
236 '-Wl,-wrap,memcpy'
237 ]
murgatroid99fd994f12015-10-09 14:02:28 -0700238 }]
239 ],
murgatroid99879bc4f2015-11-05 10:35:04 -0800240 "target_name": "${module.name}",
murgatroid99fd994f12015-10-09 14:02:28 -0700241 "sources": [
murgatroid99879bc4f2015-11-05 10:35:04 -0800242 % for source in module.src:
243 "${source}",
244 % endfor
murgatroid99fd994f12015-10-09 14:02:28 -0700245 ],
246 "dependencies": [
murgatroid99879bc4f2015-11-05 10:35:04 -0800247 % for dep in getattr(module, 'deps', []):
murgatroid995c56c922016-01-25 13:32:52 -0800248 % if dep not in ('boringssl', 'z'):
murgatroid99879bc4f2015-11-05 10:35:04 -0800249 "${dep}",
murgatroid995c56c922016-01-25 13:32:52 -0800250 % endif
murgatroid99879bc4f2015-11-05 10:35:04 -0800251 % endfor
murgatroid99fd994f12015-10-09 14:02:28 -0700252 ]
murgatroid99879bc4f2015-11-05 10:35:04 -0800253 },
254 % endfor
murgatroid99e190f352016-01-20 13:52:08 -0800255 {
256 "target_name": "action_after_build",
257 "type": "none",
258 "dependencies": [ "<(module_name)" ],
259 "copies": [
260 {
261 "files": [ "<(PRODUCT_DIR)/<(module_name).node"],
262 "destination": "<(module_path)"
263 }
264 ]
265 }
murgatroid992d6d3302015-09-21 13:29:40 -0700266 ]
267 }