murgatroid99 | 2d6d330 | 2015-09-21 13:29:40 -0700 | [diff] [blame] | 1 | %YAML 1.2 |
| 2 | --- | |
murgatroid99 | fd994f1 | 2015-10-09 14:02:28 -0700 | [diff] [blame] | 3 | # GRPC Node gyp file |
| 4 | # This currently builds the Node extension and dependencies |
murgatroid99 | 2d6d330 | 2015-09-21 13:29:40 -0700 | [diff] [blame] | 5 | # 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 Tiller | 6169d5f | 2016-03-31 07:46:18 -0700 | [diff] [blame] | 10 | # Copyright 2015, Google Inc. |
murgatroid99 | 2d6d330 | 2015-09-21 13:29:40 -0700 | [diff] [blame] | 11 | # 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 | { |
murgatroid99 | dc23046 | 2016-10-25 14:12:42 -0700 | [diff] [blame] | 42 | 'variables': { |
| 43 | 'runtime%': 'node' |
| 44 | }, |
murgatroid99 | 2d6d330 | 2015-09-21 13:29:40 -0700 | [diff] [blame] | 45 | 'target_defaults': { |
murgatroid99 | 2d6d330 | 2015-09-21 13:29:40 -0700 | [diff] [blame] | 46 | 'include_dirs': [ |
murgatroid99 | ca9db40 | 2015-09-21 14:39:09 -0700 | [diff] [blame] | 47 | '.', |
murgatroid99 | 5c56c92 | 2016-01-25 13:32:52 -0800 | [diff] [blame] | 48 | 'include' |
murgatroid99 | a89d9e7 | 2015-10-13 16:03:16 -0700 | [diff] [blame] | 49 | ], |
murgatroid99 | dc23046 | 2016-10-25 14:12:42 -0700 | [diff] [blame] | 50 | 'defines': [ |
murgatroid99 | cb4b2b5 | 2016-10-27 11:30:50 -0700 | [diff] [blame] | 51 | 'GPR_BACKWARDS_COMPATIBILITY_MODE' |
murgatroid99 | dc23046 | 2016-10-25 14:12:42 -0700 | [diff] [blame] | 52 | ], |
murgatroid99 | a89d9e7 | 2015-10-13 16:03:16 -0700 | [diff] [blame] | 53 | 'conditions': [ |
murgatroid99 | cb4b2b5 | 2016-10-27 11:30:50 -0700 | [diff] [blame] | 54 | ['runtime=="node"', { |
| 55 | 'defines': [ |
| 56 | 'GRPC_UV' |
| 57 | ] |
| 58 | }], |
murgatroid99 | e8ec16d | 2017-01-13 11:00:53 -0800 | [diff] [blame] | 59 | ['OS!="win" and runtime=="electron"', { |
Michael Lumish | 88162f8 | 2017-01-12 17:37:58 -0800 | [diff] [blame] | 60 | "defines": [ |
| 61 | 'OPENSSL_NO_THREADS' |
| 62 | ] |
| 63 | }], |
murgatroid99 | dc23046 | 2016-10-25 14:12:42 -0700 | [diff] [blame] | 64 | # This is the condition for using boringssl |
| 65 | ['OS=="win" or runtime=="electron"', { |
| 66 | "include_dirs": [ |
| 67 | "third_party/boringssl/include" |
| 68 | ], |
| 69 | "defines": [ |
Michael Lumish | 88162f8 | 2017-01-12 17:37:58 -0800 | [diff] [blame] | 70 | 'OPENSSL_NO_ASM' |
murgatroid99 | dc23046 | 2016-10-25 14:12:42 -0700 | [diff] [blame] | 71 | ] |
| 72 | }, { |
| 73 | # Based on logic above, we know that this must be a non-Windows system |
| 74 | 'variables': { |
| 75 | # The output of "node --version" is "v[version]". We use cut to |
| 76 | # remove the first character. |
| 77 | 'target%': '<!(node --version | cut -c2-)' |
| 78 | }, |
| 79 | # Empirically, Node only exports ALPN symbols if its major version is >0. |
| 80 | # io.js always reports versions >0 and always exports ALPN symbols. |
| 81 | # Therefore, Node's major version will be truthy if and only if it |
| 82 | # supports ALPN. The target is "[major].[minor].[patch]". We split by |
| 83 | # periods and take the first field to get the major version. |
| 84 | 'defines': [ |
| 85 | 'TSI_OPENSSL_ALPN_SUPPORT=<!(echo <(target) | cut -d. -f1)' |
| 86 | ], |
| 87 | 'include_dirs': [ |
| 88 | '<(node_root_dir)/deps/openssl/openssl/include', |
| 89 | ], |
| 90 | 'conditions': [ |
| 91 | ["target_arch=='ia32'", { |
| 92 | "include_dirs": [ "<(node_root_dir)/deps/openssl/config/piii" ] |
| 93 | }], |
| 94 | ["target_arch=='x64'", { |
| 95 | "include_dirs": [ "<(node_root_dir)/deps/openssl/config/k8" ] |
| 96 | }], |
| 97 | ["target_arch=='arm'", { |
| 98 | "include_dirs": [ "<(node_root_dir)/deps/openssl/config/arm" ] |
| 99 | }] |
| 100 | ] |
| 101 | }], |
murgatroid99 | 5c56c92 | 2016-01-25 13:32:52 -0800 | [diff] [blame] | 102 | ['OS == "win"', { |
murgatroid99 | 673f65b | 2016-02-01 11:19:07 -0800 | [diff] [blame] | 103 | "include_dirs": [ |
murgatroid99 | 673f65b | 2016-02-01 11:19:07 -0800 | [diff] [blame] | 104 | "third_party/zlib" |
| 105 | ], |
murgatroid99 | af6c178 | 2016-01-28 13:14:24 -0800 | [diff] [blame] | 106 | "defines": [ |
| 107 | '_WIN32_WINNT=0x0600', |
| 108 | 'WIN32_LEAN_AND_MEAN', |
| 109 | '_HAS_EXCEPTIONS=0', |
| 110 | 'UNICODE', |
| 111 | '_UNICODE', |
| 112 | 'NOMINMAX', |
murgatroid99 | af6c178 | 2016-01-28 13:14:24 -0800 | [diff] [blame] | 113 | ], |
| 114 | "msvs_settings": { |
| 115 | 'VCCLCompilerTool': { |
| 116 | 'RuntimeLibrary': 1, # static debug |
| 117 | } |
| 118 | }, |
| 119 | "libraries": [ |
| 120 | "ws2_32" |
| 121 | ] |
| 122 | }, { # OS != "win" |
murgatroid99 | 673f65b | 2016-02-01 11:19:07 -0800 | [diff] [blame] | 123 | 'variables': { |
| 124 | 'config': '<!(echo $CONFIG)', |
murgatroid99 | 673f65b | 2016-02-01 11:19:07 -0800 | [diff] [blame] | 125 | }, |
murgatroid99 | 5c56c92 | 2016-01-25 13:32:52 -0800 | [diff] [blame] | 126 | 'include_dirs': [ |
murgatroid99 | 5c56c92 | 2016-01-25 13:32:52 -0800 | [diff] [blame] | 127 | '<(node_root_dir)/deps/zlib' |
| 128 | ], |
murgatroid99 | a89d9e7 | 2015-10-13 16:03:16 -0700 | [diff] [blame] | 129 | 'conditions': [ |
| 130 | ['config=="gcov"', { |
| 131 | 'cflags': [ |
| 132 | '-ftest-coverage', |
| 133 | '-fprofile-arcs', |
| 134 | '-O0' |
| 135 | ], |
| 136 | 'ldflags': [ |
| 137 | '-ftest-coverage', |
| 138 | '-fprofile-arcs' |
| 139 | ] |
| 140 | } |
murgatroid99 | dc23046 | 2016-10-25 14:12:42 -0700 | [diff] [blame] | 141 | ] |
murgatroid99 | a89d9e7 | 2015-10-13 16:03:16 -0700 | [diff] [blame] | 142 | ] |
murgatroid99 | afe4698 | 2015-10-23 10:17:26 -0700 | [diff] [blame] | 143 | }] |
murgatroid99 | fd994f1 | 2015-10-09 14:02:28 -0700 | [diff] [blame] | 144 | ] |
murgatroid99 | 2d6d330 | 2015-09-21 13:29:40 -0700 | [diff] [blame] | 145 | }, |
murgatroid99 | 5c56c92 | 2016-01-25 13:32:52 -0800 | [diff] [blame] | 146 | 'conditions': [ |
murgatroid99 | dc23046 | 2016-10-25 14:12:42 -0700 | [diff] [blame] | 147 | ['OS=="win" or runtime=="electron"', { |
| 148 | 'targets': [ |
| 149 | % for module in node_modules: |
| 150 | % for lib in libs: |
| 151 | % if lib.name in module.transitive_deps and lib.name == 'boringssl': |
| 152 | { |
| 153 | 'cflags': [ |
| 154 | '-std=c99', |
| 155 | '-Wall', |
| 156 | '-Werror' |
| 157 | ], |
| 158 | 'target_name': '${lib.name}', |
| 159 | 'product_prefix': 'lib', |
| 160 | 'type': 'static_library', |
| 161 | 'dependencies': [ |
| 162 | % for dep in getattr(lib, 'deps', []): |
| 163 | '${dep}', |
| 164 | % endfor |
| 165 | ], |
| 166 | 'sources': [ |
| 167 | % for source in lib.src: |
| 168 | '${source}', |
| 169 | % endfor |
| 170 | ] |
| 171 | }, |
| 172 | % endif |
| 173 | % endfor |
| 174 | % endfor |
| 175 | ] |
| 176 | }], |
murgatroid99 | 5c56c92 | 2016-01-25 13:32:52 -0800 | [diff] [blame] | 177 | ['OS == "win"', { |
| 178 | 'targets': [ |
murgatroid99 | af6c178 | 2016-01-28 13:14:24 -0800 | [diff] [blame] | 179 | { |
| 180 | # IMPORTANT WINDOWS BUILD INFORMATION |
| 181 | # This library does not build on Windows without modifying the Node |
| 182 | # development packages that node-gyp downloads in order to build. |
| 183 | # Due to https://github.com/nodejs/node/issues/4932, the headers for |
| 184 | # BoringSSL conflict with the OpenSSL headers included by default |
| 185 | # when including the Node headers. The remedy for this is to remove |
| 186 | # the OpenSSL headers, from the downloaded Node development package, |
| 187 | # which is typically located in `.node-gyp` in your home directory. |
murgatroid99 | 8e4103e | 2016-01-28 14:53:33 -0800 | [diff] [blame] | 188 | 'target_name': 'WINDOWS_BUILD_WARNING', |
murgatroid99 | af6c178 | 2016-01-28 13:14:24 -0800 | [diff] [blame] | 189 | 'actions': [ |
| 190 | { |
murgatroid99 | 8e4103e | 2016-01-28 14:53:33 -0800 | [diff] [blame] | 191 | 'action_name': 'WINDOWS_BUILD_WARNING', |
| 192 | 'inputs': [ |
| 193 | 'package.json' |
| 194 | ], |
| 195 | 'outputs': [ |
| 196 | 'ignore_this_part' |
| 197 | ], |
| 198 | '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/'] |
murgatroid99 | af6c178 | 2016-01-28 13:14:24 -0800 | [diff] [blame] | 199 | } |
| 200 | ] |
| 201 | }, |
murgatroid99 | dc23046 | 2016-10-25 14:12:42 -0700 | [diff] [blame] | 202 | # Only want to compile zlib under Windows |
murgatroid99 | 5c56c92 | 2016-01-25 13:32:52 -0800 | [diff] [blame] | 203 | % for module in node_modules: |
| 204 | % for lib in libs: |
murgatroid99 | dc23046 | 2016-10-25 14:12:42 -0700 | [diff] [blame] | 205 | % if lib.name in module.transitive_deps and lib.name == 'z': |
murgatroid99 | 5c56c92 | 2016-01-25 13:32:52 -0800 | [diff] [blame] | 206 | { |
| 207 | 'cflags': [ |
| 208 | '-std=c99', |
| 209 | '-Wall', |
| 210 | '-Werror' |
| 211 | ], |
| 212 | 'target_name': '${lib.name}', |
| 213 | 'product_prefix': 'lib', |
| 214 | 'type': 'static_library', |
| 215 | 'dependencies': [ |
| 216 | % for dep in getattr(lib, 'deps', []): |
| 217 | '${dep}', |
| 218 | % endfor |
| 219 | ], |
| 220 | 'sources': [ |
| 221 | % for source in lib.src: |
| 222 | '${source}', |
| 223 | % endfor |
murgatroid99 | af6c178 | 2016-01-28 13:14:24 -0800 | [diff] [blame] | 224 | ] |
murgatroid99 | 5c56c92 | 2016-01-25 13:32:52 -0800 | [diff] [blame] | 225 | }, |
| 226 | % endif |
| 227 | % endfor |
| 228 | % endfor |
| 229 | ] |
| 230 | }] |
| 231 | ], |
murgatroid99 | 2d6d330 | 2015-09-21 13:29:40 -0700 | [diff] [blame] | 232 | 'targets': [ |
murgatroid99 | 879bc4f | 2015-11-05 10:35:04 -0800 | [diff] [blame] | 233 | % for module in node_modules: |
murgatroid99 | 2d6d330 | 2015-09-21 13:29:40 -0700 | [diff] [blame] | 234 | % for lib in libs: |
murgatroid99 | 5c56c92 | 2016-01-25 13:32:52 -0800 | [diff] [blame] | 235 | % if lib.name in module.transitive_deps and lib.name not in ('boringssl', 'z'): |
murgatroid99 | 2d6d330 | 2015-09-21 13:29:40 -0700 | [diff] [blame] | 236 | { |
murgatroid99 | 3abed31 | 2016-01-07 17:16:46 -0800 | [diff] [blame] | 237 | 'cflags': [ |
| 238 | '-std=c99', |
| 239 | '-Wall', |
| 240 | '-Werror' |
| 241 | ], |
murgatroid99 | 2d6d330 | 2015-09-21 13:29:40 -0700 | [diff] [blame] | 242 | 'target_name': '${lib.name}', |
| 243 | 'product_prefix': 'lib', |
| 244 | 'type': 'static_library', |
| 245 | 'dependencies': [ |
| 246 | % for dep in getattr(lib, 'deps', []): |
| 247 | '${dep}', |
| 248 | % endfor |
| 249 | ], |
| 250 | 'sources': [ |
| 251 | % for source in lib.src: |
murgatroid99 | ca9db40 | 2015-09-21 14:39:09 -0700 | [diff] [blame] | 252 | '${source}', |
murgatroid99 | 2d6d330 | 2015-09-21 13:29:40 -0700 | [diff] [blame] | 253 | % endfor |
murgatroid99 | ca9db40 | 2015-09-21 14:39:09 -0700 | [diff] [blame] | 254 | ], |
murgatroid99 | 6ffdb94 | 2015-10-22 16:10:05 -0700 | [diff] [blame] | 255 | "conditions": [ |
| 256 | ['OS == "mac"', { |
| 257 | 'xcode_settings': { |
murgatroid99 | 22c448b | 2015-10-23 10:25:30 -0700 | [diff] [blame] | 258 | 'MACOSX_DEPLOYMENT_TARGET': '10.9' |
murgatroid99 | 6ffdb94 | 2015-10-22 16:10:05 -0700 | [diff] [blame] | 259 | } |
| 260 | }] |
murgatroid99 | 5c56c92 | 2016-01-25 13:32:52 -0800 | [diff] [blame] | 261 | ] |
murgatroid99 | 2d6d330 | 2015-09-21 13:29:40 -0700 | [diff] [blame] | 262 | }, |
murgatroid99 | ca9db40 | 2015-09-21 14:39:09 -0700 | [diff] [blame] | 263 | % endif |
murgatroid99 | 2d6d330 | 2015-09-21 13:29:40 -0700 | [diff] [blame] | 264 | % endfor |
murgatroid99 | fd994f1 | 2015-10-09 14:02:28 -0700 | [diff] [blame] | 265 | { |
| 266 | 'include_dirs': [ |
| 267 | "<!(node -e \"require('nan')\")" |
| 268 | ], |
| 269 | 'cflags': [ |
murgatroid99 | 3abed31 | 2016-01-07 17:16:46 -0800 | [diff] [blame] | 270 | '-std=c++11', |
murgatroid99 | fd994f1 | 2015-10-09 14:02:28 -0700 | [diff] [blame] | 271 | '-Wall', |
| 272 | '-pthread', |
| 273 | '-g', |
| 274 | '-zdefs', |
| 275 | '-Werror', |
| 276 | '-Wno-error=deprecated-declarations' |
| 277 | ], |
| 278 | 'ldflags': [ |
| 279 | '-g' |
| 280 | ], |
| 281 | "conditions": [ |
murgatroid99 | dc23046 | 2016-10-25 14:12:42 -0700 | [diff] [blame] | 282 | ['OS=="win" or runtime=="electron"', { |
| 283 | 'dependencies': [ |
| 284 | % for dep in getattr(module, 'deps', []): |
| 285 | % if dep == 'boringssl': |
| 286 | "${dep}", |
| 287 | % endif |
| 288 | % endfor |
| 289 | ] |
| 290 | }], |
murgatroid99 | 5c56c92 | 2016-01-25 13:32:52 -0800 | [diff] [blame] | 291 | ['OS=="mac"', { |
murgatroid99 | fd994f1 | 2015-10-09 14:02:28 -0700 | [diff] [blame] | 292 | 'xcode_settings': { |
| 293 | 'MACOSX_DEPLOYMENT_TARGET': '10.9', |
| 294 | 'OTHER_CFLAGS': [ |
murgatroid99 | 673f65b | 2016-02-01 11:19:07 -0800 | [diff] [blame] | 295 | '-stdlib=libc++', |
| 296 | '-std=c++11' |
murgatroid99 | fd994f1 | 2015-10-09 14:02:28 -0700 | [diff] [blame] | 297 | ] |
| 298 | } |
murgatroid99 | 5c56c92 | 2016-01-25 13:32:52 -0800 | [diff] [blame] | 299 | }], |
| 300 | ['OS=="win"', { |
| 301 | 'dependencies': [ |
| 302 | % for dep in getattr(module, 'deps', []): |
murgatroid99 | dc23046 | 2016-10-25 14:12:42 -0700 | [diff] [blame] | 303 | % if dep == 'z': |
murgatroid99 | 5c56c92 | 2016-01-25 13:32:52 -0800 | [diff] [blame] | 304 | "${dep}", |
| 305 | % endif |
| 306 | % endfor |
| 307 | ] |
Craig Tiller | 4bef7ce | 2016-02-02 08:38:43 -0800 | [diff] [blame] | 308 | }], |
| 309 | ['OS=="linux"', { |
| 310 | 'ldflags': [ |
| 311 | '-Wl,-wrap,memcpy' |
| 312 | ] |
murgatroid99 | fd994f1 | 2015-10-09 14:02:28 -0700 | [diff] [blame] | 313 | }] |
| 314 | ], |
murgatroid99 | 879bc4f | 2015-11-05 10:35:04 -0800 | [diff] [blame] | 315 | "target_name": "${module.name}", |
murgatroid99 | fd994f1 | 2015-10-09 14:02:28 -0700 | [diff] [blame] | 316 | "sources": [ |
murgatroid99 | 879bc4f | 2015-11-05 10:35:04 -0800 | [diff] [blame] | 317 | % for source in module.src: |
| 318 | "${source}", |
| 319 | % endfor |
murgatroid99 | fd994f1 | 2015-10-09 14:02:28 -0700 | [diff] [blame] | 320 | ], |
| 321 | "dependencies": [ |
murgatroid99 | 879bc4f | 2015-11-05 10:35:04 -0800 | [diff] [blame] | 322 | % for dep in getattr(module, 'deps', []): |
murgatroid99 | 5c56c92 | 2016-01-25 13:32:52 -0800 | [diff] [blame] | 323 | % if dep not in ('boringssl', 'z'): |
murgatroid99 | 879bc4f | 2015-11-05 10:35:04 -0800 | [diff] [blame] | 324 | "${dep}", |
murgatroid99 | 5c56c92 | 2016-01-25 13:32:52 -0800 | [diff] [blame] | 325 | % endif |
murgatroid99 | 879bc4f | 2015-11-05 10:35:04 -0800 | [diff] [blame] | 326 | % endfor |
murgatroid99 | fd994f1 | 2015-10-09 14:02:28 -0700 | [diff] [blame] | 327 | ] |
murgatroid99 | 879bc4f | 2015-11-05 10:35:04 -0800 | [diff] [blame] | 328 | }, |
| 329 | % endfor |
murgatroid99 | e190f35 | 2016-01-20 13:52:08 -0800 | [diff] [blame] | 330 | { |
| 331 | "target_name": "action_after_build", |
| 332 | "type": "none", |
| 333 | "dependencies": [ "<(module_name)" ], |
| 334 | "copies": [ |
| 335 | { |
| 336 | "files": [ "<(PRODUCT_DIR)/<(module_name).node"], |
| 337 | "destination": "<(module_path)" |
| 338 | } |
| 339 | ] |
| 340 | } |
murgatroid99 | 2d6d330 | 2015-09-21 13:29:40 -0700 | [diff] [blame] | 341 | ] |
| 342 | } |