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 16from __future__ import print_function 17import shutil 18import sys 19import os 20import yaml 21 22sys.dont_write_bytecode = True 23 24boring_ssl_root = os.path.abspath( 25 os.path.join(os.path.dirname(sys.argv[0]), 26 '../../third_party/boringssl-with-bazel/src')) 27sys.path.append(os.path.join(boring_ssl_root, 'util')) 28 29try: 30 import generate_build_files 31except ImportError: 32 print(yaml.dump({})) 33 sys.exit() 34 35 36def map_dir(filename): 37 return 'third_party/boringssl-with-bazel/' + filename 38 39 40class Grpc(object): 41 """Implements a "platform" in the sense of boringssl's generate_build_files.py""" 42 yaml = None 43 44 def WriteFiles(self, files, asm_outputs): 45 test_binaries = ['ssl_test', 'crypto_test'] 46 47 self.yaml = { 48 '#': 49 'generated with src/boringssl/gen_build_yaml.py', 50 'raw_boringssl_build_output_for_debugging': { 51 'files': files, 52 'asm_outputs': asm_outputs, 53 }, 54 'libs': [ 55 { 56 'name': 57 'boringssl', 58 'build': 59 'private', 60 'language': 61 'c', 62 'secure': 63 False, 64 'src': 65 sorted( 66 map_dir(f) for f in files['ssl'] + files['crypto']), 67 'headers': 68 sorted( 69 map_dir(f) 70 # We want to include files['fips_fragments'], but not build them as objects. 71 # See https://boringssl-review.googlesource.com/c/boringssl/+/16946 72 for f in files['ssl_headers'] + 73 files['ssl_internal_headers'] + 74 files['crypto_headers'] + 75 files['crypto_internal_headers'] + 76 files['fips_fragments']), 77 'boringssl': 78 True, 79 'defaults': 80 'boringssl', 81 }, 82 { 83 'name': 'boringssl_test_util', 84 'build': 'private', 85 'language': 'c++', 86 'secure': False, 87 'boringssl': True, 88 'defaults': 'boringssl', 89 'src': [map_dir(f) for f in sorted(files['test_support'])], 90 } 91 ], 92 'targets': [{ 93 'name': 'boringssl_%s' % test, 94 'build': 'test', 95 'run': False, 96 'secure': False, 97 'language': 'c++', 98 'src': sorted(map_dir(f) for f in files[test]), 99 'vs_proj_dir': 'test/boringssl', 100 'boringssl': True, 101 'defaults': 'boringssl', 102 'deps': [ 103 'boringssl_test_util', 104 'boringssl', 105 ] 106 } for test in test_binaries], 107 'tests': [{ 108 'name': 'boringssl_%s' % test, 109 'args': [], 110 'exclude_configs': ['asan', 'ubsan'], 111 'ci_platforms': ['linux', 'mac', 'posix', 'windows'], 112 'platforms': ['linux', 'mac', 'posix', 'windows'], 113 'flaky': False, 114 'gtest': True, 115 'language': 'c++', 116 'boringssl': True, 117 'defaults': 'boringssl', 118 'cpu_cost': 1.0 119 } for test in test_binaries] 120 } 121 122 123os.chdir(os.path.dirname(sys.argv[0])) 124os.mkdir('src') 125try: 126 for f in os.listdir(boring_ssl_root): 127 os.symlink(os.path.join(boring_ssl_root, f), os.path.join('src', f)) 128 129 grpc_platform = Grpc() 130 # We use a hack to run boringssl's util/generate_build_files.py as part of this script. 131 # The call will populate "grpc_platform" with boringssl's source file metadata. 132 # As a side effect this script generates err_data.c and crypto_test_data.cc (requires golang) 133 # Both of these files are already available under third_party/boringssl-with-bazel 134 # so we don't need to generate them again, but there's no option to disable that behavior. 135 # - crypto_test_data.cc is required to run boringssl_crypto_test but we already 136 # use the copy under third_party/boringssl-with-bazel so we just delete it 137 # - err_data.c is already under third_party/boringssl-with-bazel so we just delete it 138 generate_build_files.main([grpc_platform]) 139 140 print(yaml.dump(grpc_platform.yaml)) 141 142finally: 143 # we don't want err_data.c and crypto_test_data.cc (see comment above) 144 if os.path.exists('err_data.c'): 145 os.remove('err_data.c') 146 if os.path.exists('crypto_test_data.cc'): 147 os.remove('crypto_test_data.cc') 148 shutil.rmtree('src') 149