xref: /aosp_15_r20/external/grpc-grpc/src/boringssl/gen_build_yaml.py (revision cc02d7e222339f7a4f6ba5f422e6413f4bd931f2)
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
16import json
17import os
18import sys
19import yaml
20
21run_dir = os.path.dirname(sys.argv[0])
22sources_path = os.path.abspath(
23    os.path.join(run_dir, "../../third_party/boringssl-with-bazel/sources.json")
24)
25try:
26    with open(sources_path, "r") as s:
27        sources = json.load(s)
28except IOError:
29    sources_path = os.path.abspath(
30        os.path.join(
31            run_dir, "../../../../third_party/openssl/boringssl/sources.json"
32        )
33    )
34    with open(sources_path, "r") as s:
35        sources = json.load(s)
36
37
38def map_dir(filename):
39    return "third_party/boringssl-with-bazel/" + filename
40
41
42class Grpc(object):
43    """Adapter for boring-SSL json sources files."""
44
45    def __init__(self, sources):
46        self.yaml = None
47        self.WriteFiles(sources)
48
49    def WriteFiles(self, files):
50        test_binaries = ["ssl_test", "crypto_test"]
51        asm_outputs = {
52            key: value
53            for key, value in files.items()
54            if any(f.endswith(".S") or f.endswith(".asm") for f in value)
55        }
56        self.yaml = {
57            "#": "generated with src/boringssl/gen_build_yaml.py",
58            "raw_boringssl_build_output_for_debugging": {
59                "files": files,
60            },
61            "libs": [
62                {
63                    "name": "boringssl",
64                    "build": "private",
65                    "language": "c",
66                    "secure": False,
67                    "src": sorted(
68                        map_dir(f) for f in files["ssl"] + files["crypto"]
69                    ),
70                    "asm_src": {
71                        k: [map_dir(f) for f in value]
72                        for k, value in asm_outputs.items()
73                    },
74                    "headers": sorted(
75                        map_dir(f)
76                        # We want to include files['fips_fragments'], but not build them as objects.
77                        # See https://boringssl-review.googlesource.com/c/boringssl/+/16946
78                        for f in files["ssl_headers"]
79                        + files["ssl_internal_headers"]
80                        + files["crypto_headers"]
81                        + files["crypto_internal_headers"]
82                        + files["fips_fragments"]
83                    ),
84                    "boringssl": True,
85                    "defaults": "boringssl",
86                },
87                {
88                    "name": "boringssl_test_util",
89                    "build": "private",
90                    "language": "c++",
91                    "secure": False,
92                    "boringssl": True,
93                    "defaults": "boringssl",
94                    "src": [map_dir(f) for f in sorted(files["test_support"])],
95                },
96            ],
97            "targets": [
98                {
99                    "name": "boringssl_%s" % test,
100                    "build": "test",
101                    "run": False,
102                    "secure": False,
103                    "language": "c++",
104                    "src": sorted(map_dir(f) for f in files[test]),
105                    "vs_proj_dir": "test/boringssl",
106                    "boringssl": True,
107                    "defaults": "boringssl",
108                    "deps": [
109                        "boringssl_test_util",
110                        "boringssl",
111                    ],
112                }
113                for test in test_binaries
114            ],
115            "tests": [
116                {
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                }
129                for test in test_binaries
130            ],
131        }
132
133
134grpc_platform = Grpc(sources)
135print(yaml.dump(grpc_platform.yaml))
136