binding.gyp.template 12 KB

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