aboutsummaryrefslogtreecommitdiffhomepage
path: root/templates/grpc.gyp.template
blob: d71de9f441b0179802189753488484169f988a98 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
%YAML 1.2
--- |
  # GRPC GYP build file

  # This file has been automatically generated from a template file.
  # Please look at the templates directory instead.
  # This file can be regenerated from the template by running
  # tools/buildgen/generate_projects.sh

  # Copyright 2015 gRPC authors.
  #
  # Licensed under the Apache License, Version 2.0 (the "License");
  # you may not use this file except in compliance with the License.
  # You may obtain a copy of the License at
  #
  #     http://www.apache.org/licenses/LICENSE-2.0
  #
  # Unless required by applicable law or agreed to in writing, software
  # distributed under the License is distributed on an "AS IS" BASIS,
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  # See the License for the specific language governing permissions and
  # limitations under the License.

  {
    'variables': {
     # The openssl and zlib dependencies must be passed in as variables
     # defined in an included gypi file, usually common.gypi.
     'openssl_gyp_target%': 'Please Define openssl_gyp_target variable',
     'zlib_gyp_target%': 'Please Define zlib_gyp_target variable',

     'grpc_gcov%': 'false',
     'grpc_alpine%': 'false',
    },
    'target_defaults': {
      'configurations': {
        % for name, args in configs.iteritems():
        %  if name in ['dbg', 'opt']:
        '${{'dbg':'Debug', 'opt': 'Release'}[name]}': {
          % for arg, prop in [('CPPFLAGS', 'cflags'), ('DEFINES', 'defines')]:
          %  if args.get(arg, None) is not None:
          '${prop}': [
            % for item in args.get(arg).split():
            '${item}',
            % endfor
          ],
          %  endif
          % endfor
        },
        %  endif
        % endfor
      },
      % for arg, prop in [('CPPFLAGS', 'cflags'), ('LDFLAGS', 'ldflags')]:
      %  if defaults['global'].get(arg, None) is not None:
      '${prop}': [
        % for item in defaults['global'].get(arg).split():
        '${item}',
        % endfor
      ],
      %  endif
      % endfor
      'cflags_c': [
        '-Werror',
        '-std=c99',
      ],
      'cflags_cc': [
        '-Werror',
        '-std=c++11',
      ],
      'include_dirs': [
        '.',
        '../..',
        'include',
        '../../third_party/nanopb',
      ],
      'defines': [
        'GRPC_ARES=0',
      ],
      'dependencies': [
        '<(openssl_gyp_target)',
        '<(zlib_gyp_target)',
      ],
      'conditions': [
        ['grpc_gcov=="true"', {
          % for arg, prop in [('CPPFLAGS', 'cflags'), ('DEFINES', 'defines'), ('LDFLAGS', 'ldflags')]:
          %  if configs['gcov'].get(arg, None) is not None:
          '${prop}': [
            % for item in configs['gcov'].get(arg).split():
            '${item}',
            % endfor
          ],
          %  endif
          % endfor
        }],
        ['grpc_alpine=="true"', {
          'defines': [
            'GPR_MUSL_LIBC_COMPAT'
          ]
        }],
        ['OS == "win"', {
          'defines': [
            '_WIN32_WINNT=0x0600',
            'WIN32_LEAN_AND_MEAN',
            '_HAS_EXCEPTIONS=0',
            'UNICODE',
            '_UNICODE',
            'NOMINMAX',
          ],
          'msvs_settings': {
            'VCCLCompilerTool': {
              'RuntimeLibrary': 1, # static debug
            }
          },
          "libraries": [
            "ws2_32"
          ]
        }],
        ['OS == "mac"', {
          'xcode_settings': {
            % if defaults['global'].get('CPPFLAGS', None) is not None:
            'OTHER_CFLAGS': [
              % for item in defaults['global'].get('CPPFLAGS').split():
              '${item}',
              % endfor
            ],
            'OTHER_CPLUSPLUSFLAGS': [
              % for item in defaults['global'].get('CPPFLAGS').split():
              '${item}',
              % endfor
              '-stdlib=libc++',
              '-std=c++11',
              '-Wno-error=deprecated-declarations',
            ],
            % endif
          },
        }]
      ]
    },
    'targets': [
      % for lib in libs:
      %  if getattr(lib, 'platforms', None) is None and lib.name != 'ares':
      {
        'target_name': '${lib.name}',
        'type': 'static_library',
        'dependencies': [
          % for dep in getattr(lib, 'deps', []):
          '${dep}',
          % endfor
        ],
        'sources': [
          % for source in lib.src:
          '${source}',
          % endfor
        ],
      },
      %  endif
      % endfor
    ]
  }