Imported Upstream version 1.27.0
[platform/upstream/grpc.git] / src / boringssl / gen_build_yaml.py
1 #!/usr/bin/env python2.7
2 # Copyright 2015 gRPC authors.
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #     http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15
16 from __future__ import print_function
17 import shutil
18 import sys
19 import os
20 import yaml
21
22 sys.dont_write_bytecode = True
23
24 boring_ssl_root = os.path.abspath(
25     os.path.join(os.path.dirname(sys.argv[0]), '../../third_party/boringssl'))
26 sys.path.append(os.path.join(boring_ssl_root, 'util'))
27
28 try:
29     import generate_build_files
30 except ImportError:
31     print(yaml.dump({}))
32     sys.exit()
33
34
35 def map_dir(filename):
36     if filename[0:4] == 'src/':
37         return 'third_party/boringssl/' + filename[4:]
38     else:
39         return 'src/boringssl/' + filename
40
41
42 def map_testarg(arg):
43     if '/' in arg:
44         return 'third_party/boringssl/' + arg
45     else:
46         return arg
47
48
49 class Grpc(object):
50
51     yaml = None
52
53     def WriteFiles(self, files, asm_outputs):
54         test_binaries = ['ssl_test', 'crypto_test']
55
56         self.yaml = {
57             '#':
58                 'generated with tools/buildgen/gen_boring_ssl_build_yaml.py',
59             'raw_boringssl_build_output_for_debugging': {
60                 'files': files,
61                 'asm_outputs': asm_outputs,
62             },
63             'libs': [
64                 {
65                     'name':
66                         'boringssl',
67                     'build':
68                         'private',
69                     'language':
70                         'c',
71                     'secure':
72                         False,
73                     'src':
74                         sorted(
75                             map_dir(f) for f in files['ssl'] + files['crypto']),
76                     'headers':
77                         sorted(
78                             map_dir(f)
79                             # We want to include files['fips_fragments'], but not build them as objects.
80                             # See https://boringssl-review.googlesource.com/c/boringssl/+/16946
81                             for f in files['ssl_headers'] +
82                             files['ssl_internal_headers'] +
83                             files['crypto_headers'] +
84                             files['crypto_internal_headers'] +
85                             files['fips_fragments']),
86                     'boringssl':
87                         True,
88                     'defaults':
89                         'boringssl',
90                 },
91                 {
92                     'name': 'boringssl_test_util',
93                     'build': 'private',
94                     'language': 'c++',
95                     'secure': False,
96                     'boringssl': True,
97                     'defaults': 'boringssl',
98                     'src': [map_dir(f) for f in sorted(files['test_support'])],
99                 }
100             ],
101             'targets': [{
102                 'name': 'boringssl_%s' % test,
103                 'build': 'test',
104                 'run': False,
105                 'secure': False,
106                 'language': 'c++',
107                 'src': sorted(map_dir(f) for f in files[test]),
108                 'vs_proj_dir': 'test/boringssl',
109                 'boringssl': True,
110                 'defaults': 'boringssl',
111                 'deps': [
112                     'boringssl_test_util',
113                     'boringssl',
114                 ]
115             } for test in test_binaries],
116             'tests': [{
117                 'name': 'boringssl_%s' % test,
118                 'args': [],
119                 'exclude_configs': ['asan', 'ubsan'],
120                 'ci_platforms': ['linux', 'mac', 'posix', 'windows'],
121                 'platforms': ['linux', 'mac', 'posix', 'windows'],
122                 'flaky': False,
123                 'gtest': True,
124                 'language': 'c++',
125                 'boringssl': True,
126                 'defaults': 'boringssl',
127                 'cpu_cost': 1.0
128             } for test in test_binaries]
129         }
130
131
132 os.chdir(os.path.dirname(sys.argv[0]))
133 os.mkdir('src')
134 try:
135     for f in os.listdir(boring_ssl_root):
136         os.symlink(os.path.join(boring_ssl_root, f), os.path.join('src', f))
137
138     g = Grpc()
139     generate_build_files.main([g])
140
141     print(yaml.dump(g.yaml))
142
143 finally:
144     shutil.rmtree('src')