blob: 055c0880e67949c5ace7b713cef51f27aff3ea91 [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"', {
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',
60 'OPENSSL_NO_ASM'
61 ],
62 "msvs_settings": {
63 'VCCLCompilerTool': {
64 'RuntimeLibrary': 1, # static debug
65 }
66 },
67 "libraries": [
68 "ws2_32"
69 ]
70 }, { # OS != "win"
murgatroid99673f65b2016-02-01 11:19:07 -080071 'variables': {
72 'config': '<!(echo $CONFIG)',
73 # The output of "node --version" is "v[version]". We use cut to
74 # remove the first character.
75 'target%': '<!(node --version | cut -c2-)'
76 },
murgatroid99af6c1782016-01-28 13:14:24 -080077 # Empirically, Node only exports ALPN symbols if its major version is >0.
78 # io.js always reports versions >0 and always exports ALPN symbols.
79 # Therefore, Node's major version will be truthy if and only if it
murgatroid99673f65b2016-02-01 11:19:07 -080080 # supports ALPN. The target is "[major].[minor].[patch]". We split by
81 # periods and take the first field to get the major version.
murgatroid99af6c1782016-01-28 13:14:24 -080082 'defines': [
murgatroid99673f65b2016-02-01 11:19:07 -080083 'TSI_OPENSSL_ALPN_SUPPORT=<!(echo <(target) | cut -d. -f1)'
murgatroid99af6c1782016-01-28 13:14:24 -080084 ],
murgatroid995c56c922016-01-25 13:32:52 -080085 'include_dirs': [
86 '<(node_root_dir)/deps/openssl/openssl/include',
87 '<(node_root_dir)/deps/zlib'
88 ],
murgatroid99a89d9e72015-10-13 16:03:16 -070089 'conditions': [
90 ['config=="gcov"', {
91 'cflags': [
92 '-ftest-coverage',
93 '-fprofile-arcs',
94 '-O0'
95 ],
96 'ldflags': [
97 '-ftest-coverage',
98 '-fprofile-arcs'
99 ]
100 }
murgatroid995c56c922016-01-25 13:32:52 -0800101 ],
102 ["target_arch=='ia32'", {
103 "include_dirs": [ "<(node_root_dir)/deps/openssl/config/piii" ]
104 }],
105 ["target_arch=='x64'", {
106 "include_dirs": [ "<(node_root_dir)/deps/openssl/config/k8" ]
107 }],
108 ["target_arch=='arm'", {
109 "include_dirs": [ "<(node_root_dir)/deps/openssl/config/arm" ]
110 }]
murgatroid99a89d9e72015-10-13 16:03:16 -0700111 ]
murgatroid99afe46982015-10-23 10:17:26 -0700112 }]
murgatroid99fd994f12015-10-09 14:02:28 -0700113 ]
murgatroid992d6d3302015-09-21 13:29:40 -0700114 },
murgatroid995c56c922016-01-25 13:32:52 -0800115 'conditions': [
116 ['OS == "win"', {
117 'targets': [
murgatroid99af6c1782016-01-28 13:14:24 -0800118 {
119 # IMPORTANT WINDOWS BUILD INFORMATION
120 # This library does not build on Windows without modifying the Node
121 # development packages that node-gyp downloads in order to build.
122 # Due to https://github.com/nodejs/node/issues/4932, the headers for
123 # BoringSSL conflict with the OpenSSL headers included by default
124 # when including the Node headers. The remedy for this is to remove
125 # the OpenSSL headers, from the downloaded Node development package,
126 # which is typically located in `.node-gyp` in your home directory.
murgatroid998e4103e2016-01-28 14:53:33 -0800127 'target_name': 'WINDOWS_BUILD_WARNING',
murgatroid99af6c1782016-01-28 13:14:24 -0800128 'actions': [
129 {
murgatroid998e4103e2016-01-28 14:53:33 -0800130 'action_name': 'WINDOWS_BUILD_WARNING',
131 'inputs': [
132 'package.json'
133 ],
134 'outputs': [
135 'ignore_this_part'
136 ],
137 '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 -0800138 }
139 ]
140 },
murgatroid995c56c922016-01-25 13:32:52 -0800141 # Only want to compile BoringSSL and zlib under Windows
142 % for module in node_modules:
143 % for lib in libs:
144 % if lib.name in module.transitive_deps and lib.name in ('boringssl', 'z'):
145 {
146 'cflags': [
147 '-std=c99',
148 '-Wall',
149 '-Werror'
150 ],
151 'target_name': '${lib.name}',
152 'product_prefix': 'lib',
153 'type': 'static_library',
154 'dependencies': [
155 % for dep in getattr(lib, 'deps', []):
156 '${dep}',
157 % endfor
158 ],
159 'sources': [
160 % for source in lib.src:
161 '${source}',
162 % endfor
murgatroid99af6c1782016-01-28 13:14:24 -0800163 ]
murgatroid995c56c922016-01-25 13:32:52 -0800164 },
165 % endif
166 % endfor
167 % endfor
168 ]
169 }]
170 ],
murgatroid992d6d3302015-09-21 13:29:40 -0700171 'targets': [
murgatroid99879bc4f2015-11-05 10:35:04 -0800172 % for module in node_modules:
murgatroid992d6d3302015-09-21 13:29:40 -0700173 % for lib in libs:
murgatroid995c56c922016-01-25 13:32:52 -0800174 % if lib.name in module.transitive_deps and lib.name not in ('boringssl', 'z'):
murgatroid992d6d3302015-09-21 13:29:40 -0700175 {
murgatroid993abed312016-01-07 17:16:46 -0800176 'cflags': [
177 '-std=c99',
178 '-Wall',
179 '-Werror'
180 ],
murgatroid992d6d3302015-09-21 13:29:40 -0700181 'target_name': '${lib.name}',
182 'product_prefix': 'lib',
183 'type': 'static_library',
184 'dependencies': [
185 % for dep in getattr(lib, 'deps', []):
186 '${dep}',
187 % endfor
188 ],
189 'sources': [
190 % for source in lib.src:
murgatroid99ca9db402015-09-21 14:39:09 -0700191 '${source}',
murgatroid992d6d3302015-09-21 13:29:40 -0700192 % endfor
murgatroid99ca9db402015-09-21 14:39:09 -0700193 ],
murgatroid996ffdb942015-10-22 16:10:05 -0700194 "conditions": [
195 ['OS == "mac"', {
196 'xcode_settings': {
murgatroid9922c448b2015-10-23 10:25:30 -0700197 'MACOSX_DEPLOYMENT_TARGET': '10.9'
murgatroid996ffdb942015-10-22 16:10:05 -0700198 }
199 }]
murgatroid995c56c922016-01-25 13:32:52 -0800200 ]
murgatroid992d6d3302015-09-21 13:29:40 -0700201 },
murgatroid99ca9db402015-09-21 14:39:09 -0700202 % endif
murgatroid992d6d3302015-09-21 13:29:40 -0700203 % endfor
murgatroid99fd994f12015-10-09 14:02:28 -0700204 {
205 'include_dirs': [
206 "<!(node -e \"require('nan')\")"
207 ],
208 'cflags': [
murgatroid993abed312016-01-07 17:16:46 -0800209 '-std=c++11',
murgatroid99fd994f12015-10-09 14:02:28 -0700210 '-Wall',
211 '-pthread',
212 '-g',
213 '-zdefs',
214 '-Werror',
215 '-Wno-error=deprecated-declarations'
216 ],
217 'ldflags': [
218 '-g'
219 ],
220 "conditions": [
murgatroid995c56c922016-01-25 13:32:52 -0800221 ['OS=="mac"', {
murgatroid99fd994f12015-10-09 14:02:28 -0700222 'xcode_settings': {
223 'MACOSX_DEPLOYMENT_TARGET': '10.9',
224 'OTHER_CFLAGS': [
murgatroid99673f65b2016-02-01 11:19:07 -0800225 '-stdlib=libc++',
226 '-std=c++11'
murgatroid99fd994f12015-10-09 14:02:28 -0700227 ]
228 }
murgatroid995c56c922016-01-25 13:32:52 -0800229 }],
230 ['OS=="win"', {
231 'dependencies': [
232 % for dep in getattr(module, 'deps', []):
233 % if dep in ('boringssl', 'z'):
234 "${dep}",
235 % endif
236 % endfor
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 }