Add --embed_test_data=false option to generate_build_files.py
This allows consumers not to use crypto_test_data.cc (which embeds all
the test files), although they'll have to provide their own
implementation of that functionality.
Change-Id: I309d5b3bd9495137e1df788b34048794b0072f3b
Reviewed-on: https://boringssl-review.googlesource.com/28706
Reviewed-by: David Benjamin <davidben@google.com>
diff --git a/util/generate_build_files.py b/util/generate_build_files.py
index caed812..11b9a8a 100644
--- a/util/generate_build_files.py
+++ b/util/generate_build_files.py
@@ -47,6 +47,7 @@
}
PREFIX = None
+EMBED_TEST_DATA = True
def PathOf(x):
@@ -220,6 +221,8 @@
self.PrintVariableSection(out, 'crypto_test_sources',
files['crypto_test'])
self.PrintVariableSection(out, 'ssl_test_sources', files['ssl_test'])
+ self.PrintVariableSection(out, 'crypto_test_data',
+ files['crypto_test_data'])
class Eureka(object):
@@ -609,16 +612,18 @@
FindHeaderFiles(os.path.join('src', 'crypto', 'test'), AllFiles) +
FindHeaderFiles(os.path.join('src', 'ssl', 'test'), NoTestRunnerFiles))
- # Generate crypto_test_data.cc
- with open('crypto_test_data.cc', 'w+') as out:
- subprocess.check_call(
- ['go', 'run', 'util/embed_test_data.go'] + cmake['CRYPTO_TEST_DATA'],
- cwd='src',
- stdout=out)
+ crypto_test_files = []
+ if EMBED_TEST_DATA:
+ # Generate crypto_test_data.cc
+ with open('crypto_test_data.cc', 'w+') as out:
+ subprocess.check_call(
+ ['go', 'run', 'util/embed_test_data.go'] + cmake['CRYPTO_TEST_DATA'],
+ cwd='src',
+ stdout=out)
+ crypto_test_files += ['crypto_test_data.cc']
- crypto_test_files = FindCFiles(os.path.join('src', 'crypto'), OnlyTests)
+ crypto_test_files += FindCFiles(os.path.join('src', 'crypto'), OnlyTests)
crypto_test_files += [
- 'crypto_test_data.cc',
'src/crypto/test/file_test_gtest.cc',
'src/crypto/test/gtest_main.cc',
]
@@ -650,6 +655,7 @@
'crypto_headers': crypto_h_files,
'crypto_internal_headers': crypto_internal_h_files,
'crypto_test': sorted(crypto_test_files),
+ 'crypto_test_data': sorted('src/' + x for x in cmake['CRYPTO_TEST_DATA']),
'fips_fragments': fips_fragments,
'fuzz': fuzz_c_files,
'ssl': ssl_source_files,
@@ -675,8 +681,13 @@
' [android|bazel|eureka|gn|gyp]')
parser.add_option('--prefix', dest='prefix',
help='For Bazel, prepend argument to all source files')
+ parser.add_option(
+ '--embed_test_data', type='choice', dest='embed_test_data',
+ action='store', default="true", choices=["true", "false"],
+ help='For Bazel, don\'t embed data files in crypto_test_data.cc')
options, args = parser.parse_args(sys.argv[1:])
PREFIX = options.prefix
+ EMBED_TEST_DATA = (options.embed_test_data == "true")
if not args:
parser.print_help()