Debian Codegraph @

src/boringssl/gen_build_yaml.py

raw
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 import json
17 import os
18 import sys
19 import yaml
20
21 run_dir = os.path.dirname(sys.argv[0])
22 sources_path = os.path.abspath(
23 os.path.join(run_dir,
24 '../../third_party/boringssl-with-bazel/sources.json'))
25 try:
26 with open(sources_path, 'r') as s:
27 sources = json.load(s)
28 except IOError:
29 sources_path = os.path.abspath(
30 os.path.join(run_dir,
31 '../../../../third_party/openssl/boringssl/sources.json'))
32 with open(sources_path, 'r') as s:
33 sources = json.load(s)
34
35
36 def map_dir(filename):
37 return 'third_party/boringssl-with-bazel/' + filename
38
39
40 class Grpc(object):
41 """Adapter for boring-SSL json sources files. """
42
43 def __init__(self, sources):
44 self.yaml = None
45 self.WriteFiles(sources)
46
47 def WriteFiles(self, files):
48 test_binaries = ['ssl_test', 'crypto_test']
49 asm_outputs = {
50 key: value for key, value in files.items() if any(
51 f.endswith(".S") or f.endswith(".asm") for f in value)
52 }
53 self.yaml = {
54 '#':
55 'generated with src/boringssl/gen_build_yaml.py',
56 'raw_boringssl_build_output_for_debugging': {
57 'files': files,
58 },
59 'libs': [
60 {
61 'name':
62 'boringssl',
63 'build':
64 'private',
65 'language':
66 'c',
67 'secure':
68 False,
69 'src':
70 sorted(
71 map_dir(f) for f in files['ssl'] + files['crypto']),
72 'asm_src': {
73 k: [map_dir(f) for f in value
74 ] for k, value in asm_outputs.items()
75 },
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 grpc_platform = Grpc(sources)
133 print(yaml.dump(grpc_platform.yaml))