binding.gyp.template 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  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 disabled by default while bugs are ironed
  43. # out. It can be re-enabled for one build by setting the npm config
  44. # variable grpc_uv to true, and it can be re-enabled permanently by
  45. # setting it to true here.
  46. 'grpc_uv%': 'false',
  47. # Some Node installations use the system installation of OpenSSL, and on
  48. # some systems, the system OpenSSL still does not have ALPN support. This
  49. # will let users recompile gRPC to work without ALPN.
  50. 'grpc_alpn%': 'true',
  51. # Indicates that the library should be built with gcov.
  52. 'grpc_gcov%': 'false'
  53. },
  54. 'target_defaults': {
  55. 'configurations': {
  56. % for name, args in configs.iteritems():
  57. % if name in ['dbg', 'opt']:
  58. '${{'dbg':'Debug', 'opt': 'Release'}[name]}': {
  59. % for arg, prop in [('CPPFLAGS', 'cflags'), ('DEFINES', 'defines')]:
  60. % if args.get(arg, None) is not None:
  61. '${prop}': [
  62. % for item in args.get(arg).split():
  63. '${item}',
  64. % endfor
  65. ],
  66. % endif
  67. % endfor
  68. },
  69. % endif
  70. % endfor
  71. },
  72. % for arg, prop in [('CPPFLAGS', 'cflags'), ('LDFLAGS', 'ldflags')]:
  73. % if defaults['global'].get(arg, None) is not None:
  74. '${prop}': [
  75. % for item in defaults['global'].get(arg).split():
  76. '${item}',
  77. % endfor
  78. ],
  79. % endif
  80. % endfor
  81. 'include_dirs': [
  82. '.',
  83. 'include'
  84. ],
  85. 'defines': [
  86. 'GPR_BACKWARDS_COMPATIBILITY_MODE'
  87. ],
  88. 'conditions': [
  89. ['grpc_uv=="true"', {
  90. 'defines': [
  91. 'GRPC_UV'
  92. ]
  93. }],
  94. ['grpc_gcov=="true"', {
  95. % for arg, prop in [('CPPFLAGS', 'cflags'), ('DEFINES', 'defines'), ('LDFLAGS', 'ldflags')]:
  96. % if configs['gcov'].get(arg, None) is not None:
  97. '${prop}': [
  98. % for item in configs['gcov'].get(arg).split():
  99. '${item}',
  100. % endfor
  101. ],
  102. % endif
  103. % endfor
  104. }],
  105. ['OS!="win" and runtime=="electron"', {
  106. "defines": [
  107. 'OPENSSL_NO_THREADS'
  108. ]
  109. }],
  110. # This is the condition for using boringssl
  111. ['OS=="win" or runtime=="electron"', {
  112. "include_dirs": [
  113. "third_party/boringssl/include"
  114. ],
  115. "defines": [
  116. 'OPENSSL_NO_ASM'
  117. ]
  118. }, {
  119. 'conditions': [
  120. ['grpc_alpn=="true"', {
  121. 'defines': [
  122. 'TSI_OPENSSL_ALPN_SUPPORT=1'
  123. ],
  124. }, {
  125. 'defines': [
  126. 'TSI_OPENSSL_ALPN_SUPPORT=0'
  127. ],
  128. }]
  129. ],
  130. 'include_dirs': [
  131. '<(node_root_dir)/deps/openssl/openssl/include',
  132. ],
  133. 'conditions': [
  134. ["target_arch=='ia32'", {
  135. "include_dirs": [ "<(node_root_dir)/deps/openssl/config/piii" ]
  136. }],
  137. ["target_arch=='x64'", {
  138. "include_dirs": [ "<(node_root_dir)/deps/openssl/config/k8" ]
  139. }],
  140. ["target_arch=='arm'", {
  141. "include_dirs": [ "<(node_root_dir)/deps/openssl/config/arm" ]
  142. }]
  143. ]
  144. }],
  145. ['OS == "win"', {
  146. "include_dirs": [
  147. "third_party/zlib"
  148. ],
  149. "defines": [
  150. '_WIN32_WINNT=0x0600',
  151. 'WIN32_LEAN_AND_MEAN',
  152. '_HAS_EXCEPTIONS=0',
  153. 'UNICODE',
  154. '_UNICODE',
  155. 'NOMINMAX',
  156. ],
  157. "msvs_settings": {
  158. 'VCCLCompilerTool': {
  159. 'RuntimeLibrary': 1, # static debug
  160. }
  161. },
  162. "libraries": [
  163. "ws2_32"
  164. ]
  165. }, { # OS != "win"
  166. 'include_dirs': [
  167. '<(node_root_dir)/deps/zlib'
  168. ]
  169. }]
  170. ]
  171. },
  172. 'conditions': [
  173. ['OS=="win" or runtime=="electron"', {
  174. 'targets': [
  175. % for module in node_modules:
  176. % for lib in libs:
  177. % if lib.name in module.transitive_deps and lib.name == 'boringssl':
  178. {
  179. 'cflags': [
  180. '-std=c99',
  181. '-Wall',
  182. '-Werror'
  183. ],
  184. 'target_name': '${lib.name}',
  185. 'product_prefix': 'lib',
  186. 'type': 'static_library',
  187. 'dependencies': [
  188. % for dep in getattr(lib, 'deps', []):
  189. '${dep}',
  190. % endfor
  191. ],
  192. 'sources': [
  193. % for source in lib.src:
  194. '${source}',
  195. % endfor
  196. ]
  197. },
  198. % endif
  199. % endfor
  200. % endfor
  201. ]
  202. }],
  203. ['OS == "win"', {
  204. 'targets': [
  205. {
  206. # IMPORTANT WINDOWS BUILD INFORMATION
  207. # This library does not build on Windows without modifying the Node
  208. # development packages that node-gyp downloads in order to build.
  209. # Due to https://github.com/nodejs/node/issues/4932, the headers for
  210. # BoringSSL conflict with the OpenSSL headers included by default
  211. # when including the Node headers. The remedy for this is to remove
  212. # the OpenSSL headers, from the downloaded Node development package,
  213. # which is typically located in `.node-gyp` in your home directory.
  214. 'target_name': 'WINDOWS_BUILD_WARNING',
  215. 'actions': [
  216. {
  217. 'action_name': 'WINDOWS_BUILD_WARNING',
  218. 'inputs': [
  219. 'package.json'
  220. ],
  221. 'outputs': [
  222. 'ignore_this_part'
  223. ],
  224. '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/']
  225. }
  226. ]
  227. },
  228. # Only want to compile zlib under Windows
  229. % for module in node_modules:
  230. % for lib in libs:
  231. % if lib.name in module.transitive_deps and lib.name == 'z':
  232. {
  233. 'cflags': [
  234. '-std=c99',
  235. '-Wall',
  236. '-Werror'
  237. ],
  238. 'target_name': '${lib.name}',
  239. 'product_prefix': 'lib',
  240. 'type': 'static_library',
  241. 'dependencies': [
  242. % for dep in getattr(lib, 'deps', []):
  243. '${dep}',
  244. % endfor
  245. ],
  246. 'sources': [
  247. % for source in lib.src:
  248. '${source}',
  249. % endfor
  250. ]
  251. },
  252. % endif
  253. % endfor
  254. % endfor
  255. ]
  256. }]
  257. ],
  258. 'targets': [
  259. % for module in node_modules:
  260. % for lib in libs:
  261. % if lib.name in module.transitive_deps and lib.name not in ('boringssl', 'z'):
  262. {
  263. 'cflags': [
  264. '-std=c99',
  265. '-Wall',
  266. '-Werror'
  267. ],
  268. 'target_name': '${lib.name}',
  269. 'product_prefix': 'lib',
  270. 'type': 'static_library',
  271. 'dependencies': [
  272. % for dep in getattr(lib, 'deps', []):
  273. '${dep}',
  274. % endfor
  275. ],
  276. 'sources': [
  277. % for source in lib.src:
  278. '${source}',
  279. % endfor
  280. ],
  281. "conditions": [
  282. ['OS == "mac"', {
  283. 'xcode_settings': {
  284. 'MACOSX_DEPLOYMENT_TARGET': '10.9'
  285. }
  286. }]
  287. ]
  288. },
  289. % endif
  290. % endfor
  291. {
  292. 'include_dirs': [
  293. "<!(node -e \"require('nan')\")"
  294. ],
  295. 'cflags': [
  296. '-std=c++11',
  297. '-pthread',
  298. '-zdefs',
  299. '-Wno-error=deprecated-declarations'
  300. ],
  301. "conditions": [
  302. ['OS=="win" or runtime=="electron"', {
  303. 'dependencies': [
  304. % for dep in getattr(module, 'deps', []):
  305. % if dep == 'boringssl':
  306. "${dep}",
  307. % endif
  308. % endfor
  309. ]
  310. }],
  311. ['OS=="mac"', {
  312. 'xcode_settings': {
  313. 'MACOSX_DEPLOYMENT_TARGET': '10.9',
  314. 'OTHER_CFLAGS': [
  315. '-stdlib=libc++',
  316. '-std=c++11'
  317. ]
  318. }
  319. }],
  320. ['OS=="win"', {
  321. 'dependencies': [
  322. % for dep in getattr(module, 'deps', []):
  323. % if dep == 'z':
  324. "${dep}",
  325. % endif
  326. % endfor
  327. ]
  328. }],
  329. ['OS=="linux"', {
  330. 'ldflags': [
  331. '-Wl,-wrap,memcpy'
  332. ]
  333. }]
  334. ],
  335. "target_name": "${module.name}",
  336. "sources": [
  337. % for source in module.src:
  338. "${source}",
  339. % endfor
  340. ],
  341. "dependencies": [
  342. % for dep in getattr(module, 'deps', []):
  343. % if dep not in ('boringssl', 'z'):
  344. "${dep}",
  345. % endif
  346. % endfor
  347. ]
  348. },
  349. % endfor
  350. {
  351. "target_name": "action_after_build",
  352. "type": "none",
  353. "dependencies": [ "<(module_name)" ],
  354. "copies": [
  355. {
  356. "files": [ "<(PRODUCT_DIR)/<(module_name).node"],
  357. "destination": "<(module_path)"
  358. }
  359. ]
  360. }
  361. ]
  362. }