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