grpc.gyp.template 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. %YAML 1.2
  2. --- |
  3. # GRPC GYP build file
  4. # This file has been automatically generated from a template file.
  5. # Please look at the templates directory instead.
  6. # This file can be regenerated from the template by running
  7. # tools/buildgen/generate_projects.sh
  8. # Copyright 2015 gRPC authors.
  9. #
  10. # Licensed under the Apache License, Version 2.0 (the "License");
  11. # you may not use this file except in compliance with the License.
  12. # You may obtain a copy of the License at
  13. #
  14. # http://www.apache.org/licenses/LICENSE-2.0
  15. #
  16. # Unless required by applicable law or agreed to in writing, software
  17. # distributed under the License is distributed on an "AS IS" BASIS,
  18. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  19. # See the License for the specific language governing permissions and
  20. # limitations under the License.
  21. <%
  22. def is_absl_lib(target_name):
  23. return target_name.startswith("absl/");
  24. %>
  25. {
  26. 'variables': {
  27. # The openssl and zlib dependencies must be passed in as variables
  28. # defined in an included gypi file, usually common.gypi.
  29. 'openssl_gyp_target%': 'Please Define openssl_gyp_target variable',
  30. 'zlib_gyp_target%': 'Please Define zlib_gyp_target variable',
  31. 'grpc_gcov%': 'false',
  32. 'grpc_alpine%': 'false',
  33. },
  34. 'target_defaults': {
  35. 'configurations': {
  36. % for name, args in configs.items():
  37. % if name in ['dbg', 'opt']:
  38. '${{'dbg':'Debug', 'opt': 'Release'}[name]}': {
  39. % for arg, prop in [('CPPFLAGS', 'cflags'), ('DEFINES', 'defines')]:
  40. % if args.get(arg, None) is not None:
  41. '${prop}': [
  42. % for item in args.get(arg).split():
  43. '${item}',
  44. % endfor
  45. ],
  46. % endif
  47. % endfor
  48. },
  49. % endif
  50. % endfor
  51. },
  52. % for arg, prop in [('CPPFLAGS', 'cflags'), ('LDFLAGS', 'ldflags')]:
  53. % if defaults['global'].get(arg, None) is not None:
  54. '${prop}': [
  55. % for item in defaults['global'].get(arg).split():
  56. '${item}',
  57. % endfor
  58. ],
  59. % endif
  60. % endfor
  61. 'cflags_c': [
  62. '-Werror',
  63. '-std=c99',
  64. ],
  65. 'cflags_cc': [
  66. '-Werror',
  67. '-std=c++11',
  68. ],
  69. 'include_dirs': [
  70. '.',
  71. '../..',
  72. 'include',
  73. ],
  74. 'defines': [
  75. 'GRPC_ARES=0',
  76. ],
  77. 'dependencies': [
  78. '<(openssl_gyp_target)',
  79. '<(zlib_gyp_target)',
  80. ],
  81. 'conditions': [
  82. ['grpc_gcov=="true"', {
  83. % for arg, prop in [('CPPFLAGS', 'cflags'), ('DEFINES', 'defines'), ('LDFLAGS', 'ldflags')]:
  84. % if configs['gcov'].get(arg, None) is not None:
  85. '${prop}': [
  86. % for item in configs['gcov'].get(arg).split():
  87. '${item}',
  88. % endfor
  89. ],
  90. % endif
  91. % endfor
  92. }],
  93. ['grpc_alpine=="true"', {
  94. 'defines': [
  95. 'GPR_MUSL_LIBC_COMPAT'
  96. ]
  97. }],
  98. ['OS == "win"', {
  99. 'defines': [
  100. '_WIN32_WINNT=0x0600',
  101. 'WIN32_LEAN_AND_MEAN',
  102. '_HAS_EXCEPTIONS=0',
  103. 'UNICODE',
  104. '_UNICODE',
  105. 'NOMINMAX',
  106. ],
  107. 'msvs_settings': {
  108. 'VCCLCompilerTool': {
  109. 'RuntimeLibrary': 1, # static debug
  110. }
  111. },
  112. "libraries": [
  113. "ws2_32"
  114. ]
  115. }],
  116. ['OS == "mac"', {
  117. 'xcode_settings': {
  118. % if defaults['global'].get('CPPFLAGS', None) is not None:
  119. 'OTHER_CFLAGS': [
  120. % for item in defaults['global'].get('CPPFLAGS').split():
  121. '${item}',
  122. % endfor
  123. ],
  124. 'OTHER_CPLUSPLUSFLAGS': [
  125. % for item in defaults['global'].get('CPPFLAGS').split():
  126. '${item}',
  127. % endfor
  128. '-stdlib=libc++',
  129. '-std=c++11',
  130. '-Wno-error=deprecated-declarations',
  131. ],
  132. % endif
  133. },
  134. }]
  135. ]
  136. },
  137. 'targets': [
  138. % for lib in libs:
  139. % if getattr(lib, 'platforms', None) is None and lib.name != 'ares' and not is_absl_lib(lib.name):
  140. {
  141. 'target_name': '${lib.name}',
  142. 'type': 'static_library',
  143. 'dependencies': [
  144. % for dep in getattr(lib, 'deps', []):
  145. % if dep != 'libssl':
  146. '${dep}',
  147. % endif
  148. % endfor
  149. ],
  150. 'sources': [
  151. % for source in lib.src:
  152. '${source}',
  153. % endfor
  154. ],
  155. },
  156. % endif
  157. % endfor
  158. ]
  159. }