gen_build_yaml.py 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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. from __future__ import print_function
  16. import shutil
  17. import sys
  18. import os
  19. import yaml
  20. sys.dont_write_bytecode = True
  21. boring_ssl_root = os.path.abspath(os.path.join(
  22. os.path.dirname(sys.argv[0]),
  23. '../../third_party/boringssl'))
  24. sys.path.append(os.path.join(boring_ssl_root, 'util'))
  25. try:
  26. import generate_build_files
  27. except ImportError:
  28. print(yaml.dump({}))
  29. sys.exit()
  30. def map_dir(filename):
  31. if filename[0:4] == 'src/':
  32. return 'third_party/boringssl/' + filename[4:]
  33. else:
  34. return 'src/boringssl/' + filename
  35. def map_testarg(arg):
  36. if '/' in arg:
  37. return 'third_party/boringssl/' + arg
  38. else:
  39. return arg
  40. class Grpc(object):
  41. yaml = None
  42. def WriteFiles(self, files, asm_outputs):
  43. test_binaries = ['ssl_test', 'crypto_test']
  44. self.yaml = {
  45. '#': 'generated with tools/buildgen/gen_boring_ssl_build_yaml.py',
  46. 'raw_boringssl_build_output_for_debugging': {
  47. 'files': files,
  48. 'asm_outputs': asm_outputs,
  49. },
  50. 'libs': [
  51. {
  52. 'name': 'boringssl',
  53. 'build': 'private',
  54. 'language': 'c',
  55. 'secure': False,
  56. 'src': sorted(
  57. map_dir(f)
  58. for f in files['ssl'] + files['crypto']
  59. ),
  60. 'headers': sorted(
  61. map_dir(f)
  62. # We want to include files['fips_fragments'], but not build them as objects.
  63. # See https://boringssl-review.googlesource.com/c/boringssl/+/16946
  64. for f in files['ssl_headers'] + files['ssl_internal_headers'] + files['crypto_headers'] + files['crypto_internal_headers'] + files['fips_fragments']
  65. ),
  66. 'boringssl': True,
  67. 'defaults': 'boringssl',
  68. },
  69. {
  70. 'name': 'boringssl_test_util',
  71. 'build': 'private',
  72. 'language': 'c++',
  73. 'secure': False,
  74. 'boringssl': True,
  75. 'defaults': 'boringssl',
  76. 'src': [
  77. map_dir(f)
  78. for f in sorted(files['test_support'])
  79. ],
  80. }
  81. ],
  82. 'targets': [
  83. {
  84. 'name': 'boringssl_%s' % test,
  85. 'build': 'test',
  86. 'run': False,
  87. 'secure': False,
  88. 'language': 'c++',
  89. 'src': sorted(map_dir(f) for f in files[test]),
  90. 'vs_proj_dir': 'test/boringssl',
  91. 'boringssl': True,
  92. 'defaults': 'boringssl',
  93. 'deps': [
  94. 'boringssl_test_util',
  95. 'boringssl',
  96. ]
  97. }
  98. for test in test_binaries
  99. ],
  100. 'tests': [
  101. {
  102. 'name': 'boringssl_%s' % test,
  103. 'args': [],
  104. 'exclude_configs': ['asan', 'ubsan'],
  105. 'ci_platforms': ['linux', 'mac', 'posix', 'windows'],
  106. 'platforms': ['linux', 'mac', 'posix', 'windows'],
  107. 'flaky': False,
  108. 'gtest': True,
  109. 'language': 'c++',
  110. 'boringssl': True,
  111. 'defaults': 'boringssl',
  112. 'cpu_cost': 1.0
  113. }
  114. for test in test_binaries
  115. ]
  116. }
  117. os.chdir(os.path.dirname(sys.argv[0]))
  118. os.mkdir('src')
  119. try:
  120. for f in os.listdir(boring_ssl_root):
  121. os.symlink(os.path.join(boring_ssl_root, f),
  122. os.path.join('src', f))
  123. g = Grpc()
  124. generate_build_files.main([g])
  125. print(yaml.dump(g.yaml))
  126. finally:
  127. shutil.rmtree('src')