binding.gyp.template 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  1. %YAML 1.2
  2. --- |
  3. # GRPC Node gyp file
  4. # This currently builds the Node extension and dependencies
  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. # Copyright 2015, Google Inc.
  10. # All rights reserved.
  11. #
  12. # Redistribution and use in source and binary forms, with or without
  13. # modification, are permitted provided that the following conditions are
  14. # met:
  15. #
  16. # * Redistributions of source code must retain the above copyright
  17. # notice, this list of conditions and the following disclaimer.
  18. # * Redistributions in binary form must reproduce the above
  19. # copyright notice, this list of conditions and the following disclaimer
  20. # in the documentation and/or other materials provided with the
  21. # distribution.
  22. # * Neither the name of Google Inc. nor the names of its
  23. # contributors may be used to endorse or promote products derived from
  24. # this software without specific prior written permission.
  25. #
  26. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  27. # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  28. # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  29. # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  30. # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  31. # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  32. # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  33. # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  34. # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  35. # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  36. # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  37. # Some of this file is built with the help of
  38. # https://n8.io/converting-a-c-library-to-gyp/
  39. {
  40. 'variables': {
  41. 'runtime%': 'node',
  42. # UV integration in C core is enabled by default. It can be disabled
  43. # by setting this argument to anything else.
  44. 'grpc_uv%': 'true',
  45. # Some Node installations use the system installation of OpenSSL, and on
  46. # some systems, the system OpenSSL still does not have ALPN support. This
  47. # will let users recompile gRPC to work without ALPN.
  48. 'grpc_alpn%': 'true'
  49. },
  50. 'target_defaults': {
  51. 'include_dirs': [
  52. '.',
  53. 'include'
  54. ],
  55. 'defines': [
  56. 'GPR_BACKWARDS_COMPATIBILITY_MODE'
  57. ],
  58. 'conditions': [
  59. ['grpc_uv=="true"', {
  60. 'defines': [
  61. 'GRPC_UV'
  62. ]
  63. }],
  64. ['OS!="win" and runtime=="electron"', {
  65. "defines": [
  66. 'OPENSSL_NO_THREADS'
  67. ]
  68. }],
  69. # This is the condition for using boringssl
  70. ['OS=="win" or runtime=="electron"', {
  71. "include_dirs": [
  72. "third_party/boringssl/include"
  73. ],
  74. "defines": [
  75. 'OPENSSL_NO_ASM'
  76. ]
  77. }, {
  78. 'conditions': [
  79. ['grpc_alpn=="true"', {
  80. 'defines': [
  81. 'TSI_OPENSSL_ALPN_SUPPORT=1'
  82. ],
  83. }, {
  84. 'defines': [
  85. 'TSI_OPENSSL_ALPN_SUPPORT=0'
  86. ],
  87. }]
  88. ],
  89. 'include_dirs': [
  90. '<(node_root_dir)/deps/openssl/openssl/include',
  91. ],
  92. 'conditions': [
  93. ["target_arch=='ia32'", {
  94. "include_dirs": [ "<(node_root_dir)/deps/openssl/config/piii" ]
  95. }],
  96. ["target_arch=='x64'", {
  97. "include_dirs": [ "<(node_root_dir)/deps/openssl/config/k8" ]
  98. }],
  99. ["target_arch=='arm'", {
  100. "include_dirs": [ "<(node_root_dir)/deps/openssl/config/arm" ]
  101. }]
  102. ]
  103. }],
  104. ['OS == "win"', {
  105. "include_dirs": [
  106. "third_party/zlib"
  107. ],
  108. "defines": [
  109. '_WIN32_WINNT=0x0600',
  110. 'WIN32_LEAN_AND_MEAN',
  111. '_HAS_EXCEPTIONS=0',
  112. 'UNICODE',
  113. '_UNICODE',
  114. 'NOMINMAX',
  115. ],
  116. "msvs_settings": {
  117. 'VCCLCompilerTool': {
  118. 'RuntimeLibrary': 1, # static debug
  119. }
  120. },
  121. "libraries": [
  122. "ws2_32"
  123. ]
  124. }, { # OS != "win"
  125. 'variables': {
  126. 'config': '<!(echo $CONFIG)',
  127. },
  128. 'include_dirs': [
  129. '<(node_root_dir)/deps/zlib'
  130. ],
  131. 'conditions': [
  132. ['config=="gcov"', {
  133. 'cflags': [
  134. '-ftest-coverage',
  135. '-fprofile-arcs',
  136. '-O0'
  137. ],
  138. 'ldflags': [
  139. '-ftest-coverage',
  140. '-fprofile-arcs'
  141. ]
  142. }
  143. ]
  144. ]
  145. }]
  146. ]
  147. },
  148. 'conditions': [
  149. ['OS=="win" or runtime=="electron"', {
  150. 'targets': [
  151. % for module in node_modules:
  152. % for lib in libs:
  153. % if lib.name in module.transitive_deps and lib.name == 'boringssl':
  154. {
  155. 'cflags': [
  156. '-std=c99',
  157. '-Wall',
  158. '-Werror'
  159. ],
  160. 'target_name': '${lib.name}',
  161. 'product_prefix': 'lib',
  162. 'type': 'static_library',
  163. 'dependencies': [
  164. % for dep in getattr(lib, 'deps', []):
  165. '${dep}',
  166. % endfor
  167. ],
  168. 'sources': [
  169. % for source in lib.src:
  170. '${source}',
  171. % endfor
  172. ]
  173. },
  174. % endif
  175. % endfor
  176. % endfor
  177. ]
  178. }],
  179. ['OS == "win"', {
  180. 'targets': [
  181. {
  182. # IMPORTANT WINDOWS BUILD INFORMATION
  183. # This library does not build on Windows without modifying the Node
  184. # development packages that node-gyp downloads in order to build.
  185. # Due to https://github.com/nodejs/node/issues/4932, the headers for
  186. # BoringSSL conflict with the OpenSSL headers included by default
  187. # when including the Node headers. The remedy for this is to remove
  188. # the OpenSSL headers, from the downloaded Node development package,
  189. # which is typically located in `.node-gyp` in your home directory.
  190. 'target_name': 'WINDOWS_BUILD_WARNING',
  191. 'actions': [
  192. {
  193. 'action_name': 'WINDOWS_BUILD_WARNING',
  194. 'inputs': [
  195. 'package.json'
  196. ],
  197. 'outputs': [
  198. 'ignore_this_part'
  199. ],
  200. '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/']
  201. }
  202. ]
  203. },
  204. # Only want to compile zlib under Windows
  205. % for module in node_modules:
  206. % for lib in libs:
  207. % if lib.name in module.transitive_deps and lib.name == 'z':
  208. {
  209. 'cflags': [
  210. '-std=c99',
  211. '-Wall',
  212. '-Werror'
  213. ],
  214. 'target_name': '${lib.name}',
  215. 'product_prefix': 'lib',
  216. 'type': 'static_library',
  217. 'dependencies': [
  218. % for dep in getattr(lib, 'deps', []):
  219. '${dep}',
  220. % endfor
  221. ],
  222. 'sources': [
  223. % for source in lib.src:
  224. '${source}',
  225. % endfor
  226. ]
  227. },
  228. % endif
  229. % endfor
  230. % endfor
  231. ]
  232. }]
  233. ],
  234. 'targets': [
  235. % for module in node_modules:
  236. % for lib in libs:
  237. % if lib.name in module.transitive_deps and lib.name not in ('boringssl', 'z'):
  238. {
  239. 'cflags': [
  240. '-std=c99',
  241. '-Wall',
  242. '-Werror'
  243. ],
  244. 'target_name': '${lib.name}',
  245. 'product_prefix': 'lib',
  246. 'type': 'static_library',
  247. 'dependencies': [
  248. % for dep in getattr(lib, 'deps', []):
  249. '${dep}',
  250. % endfor
  251. ],
  252. 'sources': [
  253. % for source in lib.src:
  254. '${source}',
  255. % endfor
  256. ],
  257. "conditions": [
  258. ['OS == "mac"', {
  259. 'xcode_settings': {
  260. 'MACOSX_DEPLOYMENT_TARGET': '10.9'
  261. }
  262. }]
  263. ]
  264. },
  265. % endif
  266. % endfor
  267. {
  268. 'include_dirs': [
  269. "<!(node -e \"require('nan')\")"
  270. ],
  271. 'cflags': [
  272. '-std=c++11',
  273. '-Wall',
  274. '-pthread',
  275. '-g',
  276. '-zdefs',
  277. '-Werror',
  278. '-Wno-error=deprecated-declarations'
  279. ],
  280. 'ldflags': [
  281. '-g'
  282. ],
  283. "conditions": [
  284. ['OS=="win" or runtime=="electron"', {
  285. 'dependencies': [
  286. % for dep in getattr(module, 'deps', []):
  287. % if dep == 'boringssl':
  288. "${dep}",
  289. % endif
  290. % endfor
  291. ]
  292. }],
  293. ['OS=="mac"', {
  294. 'xcode_settings': {
  295. 'MACOSX_DEPLOYMENT_TARGET': '10.9',
  296. 'OTHER_CFLAGS': [
  297. '-stdlib=libc++',
  298. '-std=c++11'
  299. ]
  300. }
  301. }],
  302. ['OS=="win"', {
  303. 'dependencies': [
  304. % for dep in getattr(module, 'deps', []):
  305. % if dep == 'z':
  306. "${dep}",
  307. % endif
  308. % endfor
  309. ]
  310. }],
  311. ['OS=="linux"', {
  312. 'ldflags': [
  313. '-Wl,-wrap,memcpy'
  314. ]
  315. }]
  316. ],
  317. "target_name": "${module.name}",
  318. "sources": [
  319. % for source in module.src:
  320. "${source}",
  321. % endfor
  322. ],
  323. "dependencies": [
  324. % for dep in getattr(module, 'deps', []):
  325. % if dep not in ('boringssl', 'z'):
  326. "${dep}",
  327. % endif
  328. % endfor
  329. ]
  330. },
  331. % endfor
  332. {
  333. "target_name": "action_after_build",
  334. "type": "none",
  335. "dependencies": [ "<(module_name)" ],
  336. "copies": [
  337. {
  338. "files": [ "<(PRODUCT_DIR)/<(module_name).node"],
  339. "destination": "<(module_path)"
  340. }
  341. ]
  342. }
  343. ]
  344. }