2015-05-06 01:47:53 +01:00
|
|
|
# Copyright (c) 2015, Google Inc.
|
|
|
|
#
|
|
|
|
# Permission to use, copy, modify, and/or distribute this software for any
|
|
|
|
# purpose with or without fee is hereby granted, provided that the above
|
|
|
|
# copyright notice and this permission notice appear in all copies.
|
|
|
|
#
|
|
|
|
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
|
|
|
# SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
|
|
|
# OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
|
|
|
# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
|
2016-06-09 17:34:11 +01:00
|
|
|
"""Enumerates source files for consumption by various build systems."""
|
2015-05-06 01:47:53 +01:00
|
|
|
|
2016-06-09 17:34:11 +01:00
|
|
|
import optparse
|
2015-05-06 01:47:53 +01:00
|
|
|
import os
|
|
|
|
import subprocess
|
|
|
|
import sys
|
2015-06-11 02:54:47 +01:00
|
|
|
import json
|
2015-05-06 01:47:53 +01:00
|
|
|
|
|
|
|
|
|
|
|
# OS_ARCH_COMBOS maps from OS and platform to the OpenSSL assembly "style" for
|
|
|
|
# that platform and the extension used by asm files.
|
|
|
|
OS_ARCH_COMBOS = [
|
|
|
|
('linux', 'arm', 'linux32', [], 'S'),
|
|
|
|
('linux', 'aarch64', 'linux64', [], 'S'),
|
2016-09-27 21:30:22 +01:00
|
|
|
('linux', 'ppc64le', 'ppc64le', [], 'S'),
|
2015-05-06 01:47:53 +01:00
|
|
|
('linux', 'x86', 'elf', ['-fPIC', '-DOPENSSL_IA32_SSE2'], 'S'),
|
|
|
|
('linux', 'x86_64', 'elf', [], 'S'),
|
|
|
|
('mac', 'x86', 'macosx', ['-fPIC', '-DOPENSSL_IA32_SSE2'], 'S'),
|
|
|
|
('mac', 'x86_64', 'macosx', [], 'S'),
|
|
|
|
('win', 'x86', 'win32n', ['-DOPENSSL_IA32_SSE2'], 'asm'),
|
|
|
|
('win', 'x86_64', 'nasm', [], 'asm'),
|
|
|
|
]
|
|
|
|
|
|
|
|
# NON_PERL_FILES enumerates assembly files that are not processed by the
|
|
|
|
# perlasm system.
|
|
|
|
NON_PERL_FILES = {
|
|
|
|
('linux', 'arm'): [
|
2016-01-04 15:13:00 +00:00
|
|
|
'src/crypto/curve25519/asm/x25519-asm-arm.S',
|
2016-03-29 22:43:31 +01:00
|
|
|
'src/crypto/poly1305/poly1305_arm_asm.S',
|
2015-05-06 01:47:53 +01:00
|
|
|
],
|
2016-01-14 21:41:46 +00:00
|
|
|
('linux', 'x86_64'): [
|
|
|
|
'src/crypto/curve25519/asm/x25519-asm-x86_64.S',
|
|
|
|
],
|
2016-06-02 19:59:21 +01:00
|
|
|
('mac', 'x86_64'): [
|
|
|
|
'src/crypto/curve25519/asm/x25519-asm-x86_64.S',
|
|
|
|
],
|
2015-05-06 01:47:53 +01:00
|
|
|
}
|
|
|
|
|
2016-06-09 17:34:11 +01:00
|
|
|
PREFIX = None
|
|
|
|
|
|
|
|
|
|
|
|
def PathOf(x):
|
|
|
|
return x if not PREFIX else os.path.join(PREFIX, x)
|
|
|
|
|
2015-05-06 01:47:53 +01:00
|
|
|
|
|
|
|
class Android(object):
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
self.header = \
|
|
|
|
"""# Copyright (C) 2015 The Android Open Source Project
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
|
2016-07-21 19:08:44 +01:00
|
|
|
# This file is created by generate_build_files.py. Do not edit manually.
|
|
|
|
|
2015-05-06 01:47:53 +01:00
|
|
|
"""
|
|
|
|
|
|
|
|
def PrintVariableSection(self, out, name, files):
|
|
|
|
out.write('%s := \\\n' % name)
|
|
|
|
for f in sorted(files):
|
|
|
|
out.write(' %s\\\n' % f)
|
|
|
|
out.write('\n')
|
|
|
|
|
|
|
|
def WriteFiles(self, files, asm_outputs):
|
2016-07-21 19:08:44 +01:00
|
|
|
# New Android.bp format
|
|
|
|
with open('sources.bp', 'w+') as blueprint:
|
|
|
|
blueprint.write(self.header.replace('#', '//'))
|
|
|
|
|
|
|
|
blueprint.write('cc_defaults {\n')
|
|
|
|
blueprint.write(' name: "libcrypto_sources",\n')
|
|
|
|
blueprint.write(' srcs: [\n')
|
2016-10-01 02:34:31 +01:00
|
|
|
for f in sorted(files['crypto']):
|
2016-07-21 19:08:44 +01:00
|
|
|
blueprint.write(' "%s",\n' % f)
|
|
|
|
blueprint.write(' ],\n')
|
|
|
|
blueprint.write(' target: {\n')
|
|
|
|
|
|
|
|
for ((osname, arch), asm_files) in asm_outputs:
|
2016-10-06 18:49:01 +01:00
|
|
|
if osname != 'linux' or arch == 'ppc64le':
|
2016-07-21 19:08:44 +01:00
|
|
|
continue
|
|
|
|
if arch == 'aarch64':
|
|
|
|
arch = 'arm64'
|
|
|
|
|
|
|
|
blueprint.write(' android_%s: {\n' % arch)
|
|
|
|
blueprint.write(' srcs: [\n')
|
|
|
|
for f in sorted(asm_files):
|
|
|
|
blueprint.write(' "%s",\n' % f)
|
|
|
|
blueprint.write(' ],\n')
|
|
|
|
blueprint.write(' },\n')
|
|
|
|
|
|
|
|
if arch == 'x86' or arch == 'x86_64':
|
|
|
|
blueprint.write(' linux_%s: {\n' % arch)
|
|
|
|
blueprint.write(' srcs: [\n')
|
|
|
|
for f in sorted(asm_files):
|
|
|
|
blueprint.write(' "%s",\n' % f)
|
|
|
|
blueprint.write(' ],\n')
|
|
|
|
blueprint.write(' },\n')
|
|
|
|
|
|
|
|
blueprint.write(' },\n')
|
|
|
|
blueprint.write('}\n\n')
|
|
|
|
|
|
|
|
blueprint.write('cc_defaults {\n')
|
|
|
|
blueprint.write(' name: "libssl_sources",\n')
|
|
|
|
blueprint.write(' srcs: [\n')
|
|
|
|
for f in sorted(files['ssl']):
|
|
|
|
blueprint.write(' "%s",\n' % f)
|
|
|
|
blueprint.write(' ],\n')
|
|
|
|
blueprint.write('}\n\n')
|
|
|
|
|
|
|
|
blueprint.write('cc_defaults {\n')
|
|
|
|
blueprint.write(' name: "bssl_sources",\n')
|
|
|
|
blueprint.write(' srcs: [\n')
|
|
|
|
for f in sorted(files['tool']):
|
|
|
|
blueprint.write(' "%s",\n' % f)
|
|
|
|
blueprint.write(' ],\n')
|
|
|
|
blueprint.write('}\n\n')
|
|
|
|
|
|
|
|
blueprint.write('cc_defaults {\n')
|
|
|
|
blueprint.write(' name: "boringssl_test_support_sources",\n')
|
|
|
|
blueprint.write(' srcs: [\n')
|
|
|
|
for f in sorted(files['test_support']):
|
|
|
|
blueprint.write(' "%s",\n' % f)
|
|
|
|
blueprint.write(' ],\n')
|
|
|
|
blueprint.write('}\n\n')
|
|
|
|
|
Do a cursory conversion of a few tests to GTest.
For now, this is the laziest conversion possible. The intent is to just
get the build setup ready so that we can get everything working in our
consumers. The intended end state is:
- The standalone build produces three test targets, one per library:
{crypto,ssl,decrepit}_tests.
- Each FOO_test is made up of:
FOO/**/*_test.cc
crypto/test/gtest_main.cc
test_support
- generate_build_files.py emits variables crypto_test_sources and
ssl_test_sources. These variables are populated with FindCFiles,
looking for *_test.cc.
- The consuming file assembles those variables into the two test targets
(plus decrepit) from there. This avoids having generate_build_files.py
emit actual build rules.
- Our standalone builders, Chromium, and Android just run the top-level
test targets using whatever GTest-based reporting story they have.
In transition, we start by converting one of two tests in each library
to populate the three test targets. Those are added to all_tests.json
and all_tests.go hacked to handle them transparently. This keeps our
standalone builder working.
generate_build_files.py, to start with, populates the new source lists
manually and subtracts them out of the old machinery. We emit both for
the time being. When this change rolls in, we'll write all the build
glue needed to build the GTest-based tests and add it to consumers'
continuous builders.
Next, we'll subsume a file-based test and get the consumers working with
that. (I.e. make sure the GTest targets can depend on a data file.)
Once that's all done, we'll be sure all this will work. At that point,
we start subsuming the remaining tests into the GTest targets and,
asynchronously, rewriting tests to use GTest properly rather than
cursory conversion here.
When all non-GTest tests are gone, the old generate_build_files.py hooks
will be removed, consumers updated to not depend on them, and standalone
builders converted to not rely on all_tests.go, which can then be
removed. (Unless bits end up being needed as a malloc test driver. I'm
thinking we'll want to do something with --gtest_filter.)
As part of this CL, I've bumped the CMake requirements (for
target_include_directories) and added a few suppressions for warnings
that GTest doesn't pass.
BUG=129
Change-Id: I881b26b07a8739cc0b52dbb51a30956908e1b71a
Reviewed-on: https://boringssl-review.googlesource.com/13232
Reviewed-by: Adam Langley <agl@google.com>
2017-01-20 00:05:47 +00:00
|
|
|
blueprint.write('cc_defaults {\n')
|
|
|
|
blueprint.write(' name: "boringssl_crypto_test_sources",\n')
|
|
|
|
blueprint.write(' srcs: [\n')
|
|
|
|
for f in sorted(files['crypto_test']):
|
|
|
|
blueprint.write(' "%s",\n' % f)
|
|
|
|
blueprint.write(' ],\n')
|
|
|
|
blueprint.write('}\n\n')
|
|
|
|
|
|
|
|
blueprint.write('cc_defaults {\n')
|
|
|
|
blueprint.write(' name: "boringssl_ssl_test_sources",\n')
|
|
|
|
blueprint.write(' srcs: [\n')
|
|
|
|
for f in sorted(files['ssl_test']):
|
|
|
|
blueprint.write(' "%s",\n' % f)
|
|
|
|
blueprint.write(' ],\n')
|
|
|
|
blueprint.write('}\n\n')
|
|
|
|
|
2016-07-21 19:08:44 +01:00
|
|
|
blueprint.write('cc_defaults {\n')
|
|
|
|
blueprint.write(' name: "boringssl_tests_sources",\n')
|
|
|
|
blueprint.write(' srcs: [\n')
|
|
|
|
for f in sorted(files['test']):
|
|
|
|
blueprint.write(' "%s",\n' % f)
|
|
|
|
blueprint.write(' ],\n')
|
|
|
|
blueprint.write('}\n')
|
|
|
|
|
|
|
|
# Legacy Android.mk format, only used by Trusty in new branches
|
2015-05-06 01:47:53 +01:00
|
|
|
with open('sources.mk', 'w+') as makefile:
|
|
|
|
makefile.write(self.header)
|
|
|
|
|
2016-10-01 02:34:31 +01:00
|
|
|
self.PrintVariableSection(makefile, 'crypto_sources', files['crypto'])
|
2015-05-06 01:47:53 +01:00
|
|
|
|
|
|
|
for ((osname, arch), asm_files) in asm_outputs:
|
2016-07-21 19:08:44 +01:00
|
|
|
if osname != 'linux':
|
|
|
|
continue
|
2015-05-06 01:47:53 +01:00
|
|
|
self.PrintVariableSection(
|
|
|
|
makefile, '%s_%s_sources' % (osname, arch), asm_files)
|
|
|
|
|
|
|
|
|
2015-06-10 02:20:57 +01:00
|
|
|
class Bazel(object):
|
|
|
|
"""Bazel outputs files suitable for including in Bazel files."""
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
self.firstSection = True
|
|
|
|
self.header = \
|
|
|
|
"""# This file is created by generate_build_files.py. Do not edit manually.
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
def PrintVariableSection(self, out, name, files):
|
|
|
|
if not self.firstSection:
|
|
|
|
out.write('\n')
|
|
|
|
self.firstSection = False
|
|
|
|
|
|
|
|
out.write('%s = [\n' % name)
|
|
|
|
for f in sorted(files):
|
2016-06-09 17:34:11 +01:00
|
|
|
out.write(' "%s",\n' % PathOf(f))
|
2015-06-10 02:20:57 +01:00
|
|
|
out.write(']\n')
|
|
|
|
|
|
|
|
def WriteFiles(self, files, asm_outputs):
|
2015-10-07 01:54:16 +01:00
|
|
|
with open('BUILD.generated.bzl', 'w+') as out:
|
2015-06-10 02:20:57 +01:00
|
|
|
out.write(self.header)
|
|
|
|
|
|
|
|
self.PrintVariableSection(out, 'ssl_headers', files['ssl_headers'])
|
|
|
|
self.PrintVariableSection(
|
|
|
|
out, 'ssl_internal_headers', files['ssl_internal_headers'])
|
|
|
|
self.PrintVariableSection(out, 'ssl_sources', files['ssl'])
|
2017-01-23 21:07:50 +00:00
|
|
|
self.PrintVariableSection(out, 'ssl_c_sources', files['ssl_c'])
|
|
|
|
self.PrintVariableSection(out, 'ssl_cc_sources', files['ssl_cc'])
|
2015-06-10 02:20:57 +01:00
|
|
|
self.PrintVariableSection(out, 'crypto_headers', files['crypto_headers'])
|
|
|
|
self.PrintVariableSection(
|
|
|
|
out, 'crypto_internal_headers', files['crypto_internal_headers'])
|
|
|
|
self.PrintVariableSection(out, 'crypto_sources', files['crypto'])
|
|
|
|
self.PrintVariableSection(out, 'tool_sources', files['tool'])
|
2016-06-30 19:56:19 +01:00
|
|
|
self.PrintVariableSection(out, 'tool_headers', files['tool_headers'])
|
2015-06-10 02:20:57 +01:00
|
|
|
|
|
|
|
for ((osname, arch), asm_files) in asm_outputs:
|
|
|
|
self.PrintVariableSection(
|
2015-10-28 19:24:35 +00:00
|
|
|
out, 'crypto_sources_%s_%s' % (osname, arch), asm_files)
|
2015-06-10 02:20:57 +01:00
|
|
|
|
2015-10-07 01:54:16 +01:00
|
|
|
with open('BUILD.generated_tests.bzl', 'w+') as out:
|
2015-06-11 02:54:47 +01:00
|
|
|
out.write(self.header)
|
|
|
|
|
|
|
|
out.write('test_support_sources = [\n')
|
2016-07-29 22:41:58 +01:00
|
|
|
for filename in sorted(files['test_support'] +
|
|
|
|
files['test_support_headers'] +
|
|
|
|
files['crypto_internal_headers'] +
|
|
|
|
files['ssl_internal_headers']):
|
2015-06-11 02:54:47 +01:00
|
|
|
if os.path.basename(filename) == 'malloc.cc':
|
|
|
|
continue
|
2016-06-09 17:34:11 +01:00
|
|
|
out.write(' "%s",\n' % PathOf(filename))
|
2015-06-11 02:54:47 +01:00
|
|
|
|
2015-10-07 01:54:16 +01:00
|
|
|
out.write(']\n\n')
|
|
|
|
|
Do a cursory conversion of a few tests to GTest.
For now, this is the laziest conversion possible. The intent is to just
get the build setup ready so that we can get everything working in our
consumers. The intended end state is:
- The standalone build produces three test targets, one per library:
{crypto,ssl,decrepit}_tests.
- Each FOO_test is made up of:
FOO/**/*_test.cc
crypto/test/gtest_main.cc
test_support
- generate_build_files.py emits variables crypto_test_sources and
ssl_test_sources. These variables are populated with FindCFiles,
looking for *_test.cc.
- The consuming file assembles those variables into the two test targets
(plus decrepit) from there. This avoids having generate_build_files.py
emit actual build rules.
- Our standalone builders, Chromium, and Android just run the top-level
test targets using whatever GTest-based reporting story they have.
In transition, we start by converting one of two tests in each library
to populate the three test targets. Those are added to all_tests.json
and all_tests.go hacked to handle them transparently. This keeps our
standalone builder working.
generate_build_files.py, to start with, populates the new source lists
manually and subtracts them out of the old machinery. We emit both for
the time being. When this change rolls in, we'll write all the build
glue needed to build the GTest-based tests and add it to consumers'
continuous builders.
Next, we'll subsume a file-based test and get the consumers working with
that. (I.e. make sure the GTest targets can depend on a data file.)
Once that's all done, we'll be sure all this will work. At that point,
we start subsuming the remaining tests into the GTest targets and,
asynchronously, rewriting tests to use GTest properly rather than
cursory conversion here.
When all non-GTest tests are gone, the old generate_build_files.py hooks
will be removed, consumers updated to not depend on them, and standalone
builders converted to not rely on all_tests.go, which can then be
removed. (Unless bits end up being needed as a malloc test driver. I'm
thinking we'll want to do something with --gtest_filter.)
As part of this CL, I've bumped the CMake requirements (for
target_include_directories) and added a few suppressions for warnings
that GTest doesn't pass.
BUG=129
Change-Id: I881b26b07a8739cc0b52dbb51a30956908e1b71a
Reviewed-on: https://boringssl-review.googlesource.com/13232
Reviewed-by: Adam Langley <agl@google.com>
2017-01-20 00:05:47 +00:00
|
|
|
self.PrintVariableSection(out, 'crypto_test_sources',
|
|
|
|
files['crypto_test'])
|
|
|
|
self.PrintVariableSection(out, 'ssl_test_sources', files['ssl_test'])
|
|
|
|
|
2016-06-14 01:06:48 +01:00
|
|
|
out.write('def create_tests(copts, crypto, ssl):\n')
|
2015-06-11 02:54:47 +01:00
|
|
|
name_counts = {}
|
|
|
|
for test in files['tests']:
|
|
|
|
name = os.path.basename(test[0])
|
|
|
|
name_counts[name] = name_counts.get(name, 0) + 1
|
|
|
|
|
|
|
|
first = True
|
|
|
|
for test in files['tests']:
|
|
|
|
name = os.path.basename(test[0])
|
|
|
|
if name_counts[name] > 1:
|
|
|
|
if '/' in test[1]:
|
|
|
|
name += '_' + os.path.splitext(os.path.basename(test[1]))[0]
|
|
|
|
else:
|
|
|
|
name += '_' + test[1].replace('-', '_')
|
|
|
|
|
|
|
|
if not first:
|
|
|
|
out.write('\n')
|
|
|
|
first = False
|
|
|
|
|
|
|
|
src_prefix = 'src/' + test[0]
|
|
|
|
for src in files['test']:
|
|
|
|
if src.startswith(src_prefix):
|
|
|
|
src = src
|
|
|
|
break
|
|
|
|
else:
|
|
|
|
raise ValueError("Can't find source for %s" % test[0])
|
|
|
|
|
2015-10-07 01:54:16 +01:00
|
|
|
out.write(' native.cc_test(\n')
|
|
|
|
out.write(' name = "%s",\n' % name)
|
|
|
|
out.write(' size = "small",\n')
|
2016-06-14 01:06:48 +01:00
|
|
|
out.write(' srcs = ["%s"] + test_support_sources,\n' %
|
2016-06-09 17:34:11 +01:00
|
|
|
PathOf(src))
|
2015-06-11 02:54:47 +01:00
|
|
|
|
|
|
|
data_files = []
|
|
|
|
if len(test) > 1:
|
|
|
|
|
2015-10-07 01:54:16 +01:00
|
|
|
out.write(' args = [\n')
|
2015-06-11 02:54:47 +01:00
|
|
|
for arg in test[1:]:
|
|
|
|
if '/' in arg:
|
2016-06-09 17:34:11 +01:00
|
|
|
out.write(' "$(location %s)",\n' %
|
|
|
|
PathOf(os.path.join('src', arg)))
|
2015-06-11 02:54:47 +01:00
|
|
|
data_files.append('src/%s' % arg)
|
|
|
|
else:
|
2015-10-07 01:54:16 +01:00
|
|
|
out.write(' "%s",\n' % arg)
|
|
|
|
out.write(' ],\n')
|
2015-06-11 02:54:47 +01:00
|
|
|
|
2016-11-17 17:02:01 +00:00
|
|
|
out.write(' copts = copts + ["-DBORINGSSL_SHARED_LIBRARY"],\n')
|
2015-06-11 02:54:47 +01:00
|
|
|
|
|
|
|
if len(data_files) > 0:
|
2015-10-07 01:54:16 +01:00
|
|
|
out.write(' data = [\n')
|
2015-06-11 02:54:47 +01:00
|
|
|
for filename in data_files:
|
2016-06-09 17:34:11 +01:00
|
|
|
out.write(' "%s",\n' % PathOf(filename))
|
2015-10-07 01:54:16 +01:00
|
|
|
out.write(' ],\n')
|
2015-06-11 02:54:47 +01:00
|
|
|
|
|
|
|
if 'ssl/' in test[0]:
|
2015-10-07 01:54:16 +01:00
|
|
|
out.write(' deps = [\n')
|
2016-06-14 01:06:48 +01:00
|
|
|
out.write(' crypto,\n')
|
|
|
|
out.write(' ssl,\n')
|
2015-10-07 01:54:16 +01:00
|
|
|
out.write(' ],\n')
|
2015-06-11 02:54:47 +01:00
|
|
|
else:
|
2016-06-14 01:06:48 +01:00
|
|
|
out.write(' deps = [crypto],\n')
|
2015-10-07 01:54:16 +01:00
|
|
|
out.write(' )\n')
|
2015-06-11 02:54:47 +01:00
|
|
|
|
2015-06-10 02:20:57 +01:00
|
|
|
|
2016-04-21 23:47:57 +01:00
|
|
|
class GN(object):
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
self.firstSection = True
|
|
|
|
self.header = \
|
|
|
|
"""# Copyright (c) 2016 The Chromium Authors. All rights reserved.
|
|
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
|
|
# found in the LICENSE file.
|
|
|
|
|
|
|
|
# This file is created by generate_build_files.py. Do not edit manually.
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
def PrintVariableSection(self, out, name, files):
|
|
|
|
if not self.firstSection:
|
|
|
|
out.write('\n')
|
|
|
|
self.firstSection = False
|
|
|
|
|
|
|
|
out.write('%s = [\n' % name)
|
|
|
|
for f in sorted(files):
|
|
|
|
out.write(' "%s",\n' % f)
|
|
|
|
out.write(']\n')
|
|
|
|
|
|
|
|
def WriteFiles(self, files, asm_outputs):
|
|
|
|
with open('BUILD.generated.gni', 'w+') as out:
|
|
|
|
out.write(self.header)
|
|
|
|
|
2016-07-29 22:41:58 +01:00
|
|
|
self.PrintVariableSection(out, 'crypto_sources',
|
|
|
|
files['crypto'] + files['crypto_headers'] +
|
|
|
|
files['crypto_internal_headers'])
|
|
|
|
self.PrintVariableSection(out, 'ssl_sources',
|
|
|
|
files['ssl'] + files['ssl_headers'] +
|
|
|
|
files['ssl_internal_headers'])
|
2016-04-21 23:47:57 +01:00
|
|
|
|
|
|
|
for ((osname, arch), asm_files) in asm_outputs:
|
|
|
|
self.PrintVariableSection(
|
|
|
|
out, 'crypto_sources_%s_%s' % (osname, arch), asm_files)
|
|
|
|
|
|
|
|
fuzzers = [os.path.splitext(os.path.basename(fuzzer))[0]
|
|
|
|
for fuzzer in files['fuzz']]
|
|
|
|
self.PrintVariableSection(out, 'fuzzers', fuzzers)
|
|
|
|
|
|
|
|
with open('BUILD.generated_tests.gni', 'w+') as out:
|
|
|
|
self.firstSection = True
|
|
|
|
out.write(self.header)
|
|
|
|
|
Do a cursory conversion of a few tests to GTest.
For now, this is the laziest conversion possible. The intent is to just
get the build setup ready so that we can get everything working in our
consumers. The intended end state is:
- The standalone build produces three test targets, one per library:
{crypto,ssl,decrepit}_tests.
- Each FOO_test is made up of:
FOO/**/*_test.cc
crypto/test/gtest_main.cc
test_support
- generate_build_files.py emits variables crypto_test_sources and
ssl_test_sources. These variables are populated with FindCFiles,
looking for *_test.cc.
- The consuming file assembles those variables into the two test targets
(plus decrepit) from there. This avoids having generate_build_files.py
emit actual build rules.
- Our standalone builders, Chromium, and Android just run the top-level
test targets using whatever GTest-based reporting story they have.
In transition, we start by converting one of two tests in each library
to populate the three test targets. Those are added to all_tests.json
and all_tests.go hacked to handle them transparently. This keeps our
standalone builder working.
generate_build_files.py, to start with, populates the new source lists
manually and subtracts them out of the old machinery. We emit both for
the time being. When this change rolls in, we'll write all the build
glue needed to build the GTest-based tests and add it to consumers'
continuous builders.
Next, we'll subsume a file-based test and get the consumers working with
that. (I.e. make sure the GTest targets can depend on a data file.)
Once that's all done, we'll be sure all this will work. At that point,
we start subsuming the remaining tests into the GTest targets and,
asynchronously, rewriting tests to use GTest properly rather than
cursory conversion here.
When all non-GTest tests are gone, the old generate_build_files.py hooks
will be removed, consumers updated to not depend on them, and standalone
builders converted to not rely on all_tests.go, which can then be
removed. (Unless bits end up being needed as a malloc test driver. I'm
thinking we'll want to do something with --gtest_filter.)
As part of this CL, I've bumped the CMake requirements (for
target_include_directories) and added a few suppressions for warnings
that GTest doesn't pass.
BUG=129
Change-Id: I881b26b07a8739cc0b52dbb51a30956908e1b71a
Reviewed-on: https://boringssl-review.googlesource.com/13232
Reviewed-by: Adam Langley <agl@google.com>
2017-01-20 00:05:47 +00:00
|
|
|
self.PrintVariableSection(out, 'test_support_sources',
|
2016-07-29 22:41:58 +01:00
|
|
|
files['test_support'] +
|
|
|
|
files['test_support_headers'])
|
Do a cursory conversion of a few tests to GTest.
For now, this is the laziest conversion possible. The intent is to just
get the build setup ready so that we can get everything working in our
consumers. The intended end state is:
- The standalone build produces three test targets, one per library:
{crypto,ssl,decrepit}_tests.
- Each FOO_test is made up of:
FOO/**/*_test.cc
crypto/test/gtest_main.cc
test_support
- generate_build_files.py emits variables crypto_test_sources and
ssl_test_sources. These variables are populated with FindCFiles,
looking for *_test.cc.
- The consuming file assembles those variables into the two test targets
(plus decrepit) from there. This avoids having generate_build_files.py
emit actual build rules.
- Our standalone builders, Chromium, and Android just run the top-level
test targets using whatever GTest-based reporting story they have.
In transition, we start by converting one of two tests in each library
to populate the three test targets. Those are added to all_tests.json
and all_tests.go hacked to handle them transparently. This keeps our
standalone builder working.
generate_build_files.py, to start with, populates the new source lists
manually and subtracts them out of the old machinery. We emit both for
the time being. When this change rolls in, we'll write all the build
glue needed to build the GTest-based tests and add it to consumers'
continuous builders.
Next, we'll subsume a file-based test and get the consumers working with
that. (I.e. make sure the GTest targets can depend on a data file.)
Once that's all done, we'll be sure all this will work. At that point,
we start subsuming the remaining tests into the GTest targets and,
asynchronously, rewriting tests to use GTest properly rather than
cursory conversion here.
When all non-GTest tests are gone, the old generate_build_files.py hooks
will be removed, consumers updated to not depend on them, and standalone
builders converted to not rely on all_tests.go, which can then be
removed. (Unless bits end up being needed as a malloc test driver. I'm
thinking we'll want to do something with --gtest_filter.)
As part of this CL, I've bumped the CMake requirements (for
target_include_directories) and added a few suppressions for warnings
that GTest doesn't pass.
BUG=129
Change-Id: I881b26b07a8739cc0b52dbb51a30956908e1b71a
Reviewed-on: https://boringssl-review.googlesource.com/13232
Reviewed-by: Adam Langley <agl@google.com>
2017-01-20 00:05:47 +00:00
|
|
|
self.PrintVariableSection(out, 'crypto_test_sources',
|
|
|
|
files['crypto_test'])
|
|
|
|
self.PrintVariableSection(out, 'ssl_test_sources', files['ssl_test'])
|
2016-04-21 23:47:57 +01:00
|
|
|
out.write('\n')
|
|
|
|
|
|
|
|
out.write('template("create_tests") {\n')
|
|
|
|
|
|
|
|
all_tests = []
|
|
|
|
for test in sorted(files['test']):
|
|
|
|
test_name = 'boringssl_%s' % os.path.splitext(os.path.basename(test))[0]
|
|
|
|
all_tests.append(test_name)
|
|
|
|
|
|
|
|
out.write(' executable("%s") {\n' % test_name)
|
|
|
|
out.write(' sources = [\n')
|
|
|
|
out.write(' "%s",\n' % test)
|
|
|
|
out.write(' ]\n')
|
Do a cursory conversion of a few tests to GTest.
For now, this is the laziest conversion possible. The intent is to just
get the build setup ready so that we can get everything working in our
consumers. The intended end state is:
- The standalone build produces three test targets, one per library:
{crypto,ssl,decrepit}_tests.
- Each FOO_test is made up of:
FOO/**/*_test.cc
crypto/test/gtest_main.cc
test_support
- generate_build_files.py emits variables crypto_test_sources and
ssl_test_sources. These variables are populated with FindCFiles,
looking for *_test.cc.
- The consuming file assembles those variables into the two test targets
(plus decrepit) from there. This avoids having generate_build_files.py
emit actual build rules.
- Our standalone builders, Chromium, and Android just run the top-level
test targets using whatever GTest-based reporting story they have.
In transition, we start by converting one of two tests in each library
to populate the three test targets. Those are added to all_tests.json
and all_tests.go hacked to handle them transparently. This keeps our
standalone builder working.
generate_build_files.py, to start with, populates the new source lists
manually and subtracts them out of the old machinery. We emit both for
the time being. When this change rolls in, we'll write all the build
glue needed to build the GTest-based tests and add it to consumers'
continuous builders.
Next, we'll subsume a file-based test and get the consumers working with
that. (I.e. make sure the GTest targets can depend on a data file.)
Once that's all done, we'll be sure all this will work. At that point,
we start subsuming the remaining tests into the GTest targets and,
asynchronously, rewriting tests to use GTest properly rather than
cursory conversion here.
When all non-GTest tests are gone, the old generate_build_files.py hooks
will be removed, consumers updated to not depend on them, and standalone
builders converted to not rely on all_tests.go, which can then be
removed. (Unless bits end up being needed as a malloc test driver. I'm
thinking we'll want to do something with --gtest_filter.)
As part of this CL, I've bumped the CMake requirements (for
target_include_directories) and added a few suppressions for warnings
that GTest doesn't pass.
BUG=129
Change-Id: I881b26b07a8739cc0b52dbb51a30956908e1b71a
Reviewed-on: https://boringssl-review.googlesource.com/13232
Reviewed-by: Adam Langley <agl@google.com>
2017-01-20 00:05:47 +00:00
|
|
|
out.write(' sources += test_support_sources\n')
|
2016-04-28 00:15:06 +01:00
|
|
|
out.write(' if (defined(invoker.configs_exclude)) {\n')
|
|
|
|
out.write(' configs -= invoker.configs_exclude\n')
|
|
|
|
out.write(' }\n')
|
2016-04-21 23:47:57 +01:00
|
|
|
out.write(' configs += invoker.configs\n')
|
|
|
|
out.write(' deps = invoker.deps\n')
|
|
|
|
out.write(' }\n')
|
|
|
|
out.write('\n')
|
|
|
|
|
|
|
|
out.write(' group(target_name) {\n')
|
|
|
|
out.write(' deps = [\n')
|
|
|
|
for test_name in sorted(all_tests):
|
|
|
|
out.write(' ":%s",\n' % test_name)
|
|
|
|
out.write(' ]\n')
|
|
|
|
out.write(' }\n')
|
|
|
|
out.write('}\n')
|
|
|
|
|
|
|
|
|
|
|
|
class GYP(object):
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
self.header = \
|
|
|
|
"""# Copyright (c) 2016 The Chromium Authors. All rights reserved.
|
|
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
|
|
# found in the LICENSE file.
|
|
|
|
|
|
|
|
# This file is created by generate_build_files.py. Do not edit manually.
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
def PrintVariableSection(self, out, name, files):
|
|
|
|
out.write(' \'%s\': [\n' % name)
|
|
|
|
for f in sorted(files):
|
|
|
|
out.write(' \'%s\',\n' % f)
|
|
|
|
out.write(' ],\n')
|
|
|
|
|
|
|
|
def WriteFiles(self, files, asm_outputs):
|
|
|
|
with open('boringssl.gypi', 'w+') as gypi:
|
|
|
|
gypi.write(self.header + '{\n \'variables\': {\n')
|
|
|
|
|
2016-07-29 22:41:58 +01:00
|
|
|
self.PrintVariableSection(gypi, 'boringssl_ssl_sources',
|
|
|
|
files['ssl'] + files['ssl_headers'] +
|
|
|
|
files['ssl_internal_headers'])
|
|
|
|
self.PrintVariableSection(gypi, 'boringssl_crypto_sources',
|
|
|
|
files['crypto'] + files['crypto_headers'] +
|
|
|
|
files['crypto_internal_headers'])
|
2016-04-21 23:47:57 +01:00
|
|
|
|
|
|
|
for ((osname, arch), asm_files) in asm_outputs:
|
|
|
|
self.PrintVariableSection(gypi, 'boringssl_%s_%s_sources' %
|
|
|
|
(osname, arch), asm_files)
|
|
|
|
|
|
|
|
gypi.write(' }\n}\n')
|
|
|
|
|
|
|
|
|
2015-05-06 01:47:53 +01:00
|
|
|
def FindCMakeFiles(directory):
|
|
|
|
"""Returns list of all CMakeLists.txt files recursively in directory."""
|
|
|
|
cmakefiles = []
|
|
|
|
|
|
|
|
for (path, _, filenames) in os.walk(directory):
|
|
|
|
for filename in filenames:
|
|
|
|
if filename == 'CMakeLists.txt':
|
|
|
|
cmakefiles.append(os.path.join(path, filename))
|
|
|
|
|
|
|
|
return cmakefiles
|
|
|
|
|
|
|
|
|
|
|
|
def NoTests(dent, is_dir):
|
|
|
|
"""Filter function that can be passed to FindCFiles in order to remove test
|
|
|
|
sources."""
|
|
|
|
if is_dir:
|
|
|
|
return dent != 'test'
|
|
|
|
return 'test.' not in dent and not dent.startswith('example_')
|
|
|
|
|
|
|
|
|
|
|
|
def OnlyTests(dent, is_dir):
|
|
|
|
"""Filter function that can be passed to FindCFiles in order to remove
|
|
|
|
non-test sources."""
|
|
|
|
if is_dir:
|
2015-05-12 01:52:48 +01:00
|
|
|
return dent != 'test'
|
2015-05-06 01:47:53 +01:00
|
|
|
return '_test.' in dent or dent.startswith('example_')
|
|
|
|
|
|
|
|
|
2015-05-12 01:52:48 +01:00
|
|
|
def AllFiles(dent, is_dir):
|
|
|
|
"""Filter function that can be passed to FindCFiles in order to include all
|
|
|
|
sources."""
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
Do a cursory conversion of a few tests to GTest.
For now, this is the laziest conversion possible. The intent is to just
get the build setup ready so that we can get everything working in our
consumers. The intended end state is:
- The standalone build produces three test targets, one per library:
{crypto,ssl,decrepit}_tests.
- Each FOO_test is made up of:
FOO/**/*_test.cc
crypto/test/gtest_main.cc
test_support
- generate_build_files.py emits variables crypto_test_sources and
ssl_test_sources. These variables are populated with FindCFiles,
looking for *_test.cc.
- The consuming file assembles those variables into the two test targets
(plus decrepit) from there. This avoids having generate_build_files.py
emit actual build rules.
- Our standalone builders, Chromium, and Android just run the top-level
test targets using whatever GTest-based reporting story they have.
In transition, we start by converting one of two tests in each library
to populate the three test targets. Those are added to all_tests.json
and all_tests.go hacked to handle them transparently. This keeps our
standalone builder working.
generate_build_files.py, to start with, populates the new source lists
manually and subtracts them out of the old machinery. We emit both for
the time being. When this change rolls in, we'll write all the build
glue needed to build the GTest-based tests and add it to consumers'
continuous builders.
Next, we'll subsume a file-based test and get the consumers working with
that. (I.e. make sure the GTest targets can depend on a data file.)
Once that's all done, we'll be sure all this will work. At that point,
we start subsuming the remaining tests into the GTest targets and,
asynchronously, rewriting tests to use GTest properly rather than
cursory conversion here.
When all non-GTest tests are gone, the old generate_build_files.py hooks
will be removed, consumers updated to not depend on them, and standalone
builders converted to not rely on all_tests.go, which can then be
removed. (Unless bits end up being needed as a malloc test driver. I'm
thinking we'll want to do something with --gtest_filter.)
As part of this CL, I've bumped the CMake requirements (for
target_include_directories) and added a few suppressions for warnings
that GTest doesn't pass.
BUG=129
Change-Id: I881b26b07a8739cc0b52dbb51a30956908e1b71a
Reviewed-on: https://boringssl-review.googlesource.com/13232
Reviewed-by: Adam Langley <agl@google.com>
2017-01-20 00:05:47 +00:00
|
|
|
def NotGTestMain(dent, is_dir):
|
|
|
|
return dent != 'gtest_main.cc'
|
|
|
|
|
|
|
|
|
2015-06-10 02:20:57 +01:00
|
|
|
def SSLHeaderFiles(dent, is_dir):
|
|
|
|
return dent in ['ssl.h', 'tls1.h', 'ssl23.h', 'ssl3.h', 'dtls1.h']
|
|
|
|
|
|
|
|
|
2015-05-06 01:47:53 +01:00
|
|
|
def FindCFiles(directory, filter_func):
|
|
|
|
"""Recurses through directory and returns a list of paths to all the C source
|
|
|
|
files that pass filter_func."""
|
|
|
|
cfiles = []
|
|
|
|
|
|
|
|
for (path, dirnames, filenames) in os.walk(directory):
|
|
|
|
for filename in filenames:
|
|
|
|
if not filename.endswith('.c') and not filename.endswith('.cc'):
|
|
|
|
continue
|
|
|
|
if not filter_func(filename, False):
|
|
|
|
continue
|
|
|
|
cfiles.append(os.path.join(path, filename))
|
|
|
|
|
|
|
|
for (i, dirname) in enumerate(dirnames):
|
|
|
|
if not filter_func(dirname, True):
|
|
|
|
del dirnames[i]
|
|
|
|
|
|
|
|
return cfiles
|
|
|
|
|
|
|
|
|
2015-06-10 02:20:57 +01:00
|
|
|
def FindHeaderFiles(directory, filter_func):
|
|
|
|
"""Recurses through directory and returns a list of paths to all the header files that pass filter_func."""
|
|
|
|
hfiles = []
|
|
|
|
|
|
|
|
for (path, dirnames, filenames) in os.walk(directory):
|
|
|
|
for filename in filenames:
|
|
|
|
if not filename.endswith('.h'):
|
|
|
|
continue
|
|
|
|
if not filter_func(filename, False):
|
|
|
|
continue
|
|
|
|
hfiles.append(os.path.join(path, filename))
|
|
|
|
|
2016-06-14 01:06:48 +01:00
|
|
|
for (i, dirname) in enumerate(dirnames):
|
|
|
|
if not filter_func(dirname, True):
|
|
|
|
del dirnames[i]
|
|
|
|
|
2015-06-10 02:20:57 +01:00
|
|
|
return hfiles
|
|
|
|
|
|
|
|
|
2015-05-06 01:47:53 +01:00
|
|
|
def ExtractPerlAsmFromCMakeFile(cmakefile):
|
|
|
|
"""Parses the contents of the CMakeLists.txt file passed as an argument and
|
|
|
|
returns a list of all the perlasm() directives found in the file."""
|
|
|
|
perlasms = []
|
|
|
|
with open(cmakefile) as f:
|
|
|
|
for line in f:
|
|
|
|
line = line.strip()
|
|
|
|
if not line.startswith('perlasm('):
|
|
|
|
continue
|
|
|
|
if not line.endswith(')'):
|
|
|
|
raise ValueError('Bad perlasm line in %s' % cmakefile)
|
|
|
|
# Remove "perlasm(" from start and ")" from end
|
|
|
|
params = line[8:-1].split()
|
|
|
|
if len(params) < 2:
|
|
|
|
raise ValueError('Bad perlasm line in %s' % cmakefile)
|
|
|
|
perlasms.append({
|
|
|
|
'extra_args': params[2:],
|
|
|
|
'input': os.path.join(os.path.dirname(cmakefile), params[1]),
|
|
|
|
'output': os.path.join(os.path.dirname(cmakefile), params[0]),
|
|
|
|
})
|
|
|
|
|
|
|
|
return perlasms
|
|
|
|
|
|
|
|
|
|
|
|
def ReadPerlAsmOperations():
|
|
|
|
"""Returns a list of all perlasm() directives found in CMake config files in
|
|
|
|
src/."""
|
|
|
|
perlasms = []
|
|
|
|
cmakefiles = FindCMakeFiles('src')
|
|
|
|
|
|
|
|
for cmakefile in cmakefiles:
|
|
|
|
perlasms.extend(ExtractPerlAsmFromCMakeFile(cmakefile))
|
|
|
|
|
|
|
|
return perlasms
|
|
|
|
|
|
|
|
|
|
|
|
def PerlAsm(output_filename, input_filename, perlasm_style, extra_args):
|
|
|
|
"""Runs the a perlasm script and puts the output into output_filename."""
|
|
|
|
base_dir = os.path.dirname(output_filename)
|
|
|
|
if not os.path.isdir(base_dir):
|
|
|
|
os.makedirs(base_dir)
|
2016-06-26 18:18:50 +01:00
|
|
|
subprocess.check_call(
|
|
|
|
['perl', input_filename, perlasm_style] + extra_args + [output_filename])
|
2015-05-06 01:47:53 +01:00
|
|
|
|
|
|
|
|
|
|
|
def ArchForAsmFilename(filename):
|
|
|
|
"""Returns the architectures that a given asm file should be compiled for
|
|
|
|
based on substrings in the filename."""
|
|
|
|
|
|
|
|
if 'x86_64' in filename or 'avx2' in filename:
|
|
|
|
return ['x86_64']
|
|
|
|
elif ('x86' in filename and 'x86_64' not in filename) or '586' in filename:
|
|
|
|
return ['x86']
|
|
|
|
elif 'armx' in filename:
|
|
|
|
return ['arm', 'aarch64']
|
|
|
|
elif 'armv8' in filename:
|
|
|
|
return ['aarch64']
|
|
|
|
elif 'arm' in filename:
|
|
|
|
return ['arm']
|
2016-09-27 21:30:22 +01:00
|
|
|
elif 'ppc' in filename:
|
|
|
|
return ['ppc64le']
|
2015-05-06 01:47:53 +01:00
|
|
|
else:
|
|
|
|
raise ValueError('Unknown arch for asm filename: ' + filename)
|
|
|
|
|
|
|
|
|
|
|
|
def WriteAsmFiles(perlasms):
|
|
|
|
"""Generates asm files from perlasm directives for each supported OS x
|
|
|
|
platform combination."""
|
|
|
|
asmfiles = {}
|
|
|
|
|
|
|
|
for osarch in OS_ARCH_COMBOS:
|
|
|
|
(osname, arch, perlasm_style, extra_args, asm_ext) = osarch
|
|
|
|
key = (osname, arch)
|
|
|
|
outDir = '%s-%s' % key
|
|
|
|
|
|
|
|
for perlasm in perlasms:
|
|
|
|
filename = os.path.basename(perlasm['input'])
|
|
|
|
output = perlasm['output']
|
|
|
|
if not output.startswith('src'):
|
|
|
|
raise ValueError('output missing src: %s' % output)
|
|
|
|
output = os.path.join(outDir, output[4:])
|
2015-06-22 15:34:02 +01:00
|
|
|
if output.endswith('-armx.${ASM_EXT}'):
|
|
|
|
output = output.replace('-armx',
|
|
|
|
'-armx64' if arch == 'aarch64' else '-armx32')
|
2015-05-06 01:47:53 +01:00
|
|
|
output = output.replace('${ASM_EXT}', asm_ext)
|
|
|
|
|
|
|
|
if arch in ArchForAsmFilename(filename):
|
|
|
|
PerlAsm(output, perlasm['input'], perlasm_style,
|
|
|
|
perlasm['extra_args'] + extra_args)
|
|
|
|
asmfiles.setdefault(key, []).append(output)
|
|
|
|
|
|
|
|
for (key, non_perl_asm_files) in NON_PERL_FILES.iteritems():
|
|
|
|
asmfiles.setdefault(key, []).extend(non_perl_asm_files)
|
|
|
|
|
|
|
|
return asmfiles
|
|
|
|
|
|
|
|
|
2017-02-14 03:11:49 +00:00
|
|
|
def IsGTest(path):
|
|
|
|
with open(path) as f:
|
|
|
|
return "#include <gtest/gtest.h>" in f.read()
|
|
|
|
|
|
|
|
|
2015-06-10 02:20:57 +01:00
|
|
|
def main(platforms):
|
2015-05-06 01:47:53 +01:00
|
|
|
crypto_c_files = FindCFiles(os.path.join('src', 'crypto'), NoTests)
|
2017-01-23 21:07:50 +00:00
|
|
|
ssl_source_files = FindCFiles(os.path.join('src', 'ssl'), NoTests)
|
2016-04-21 23:47:57 +01:00
|
|
|
tool_c_files = FindCFiles(os.path.join('src', 'tool'), NoTests)
|
2016-06-30 19:56:19 +01:00
|
|
|
tool_h_files = FindHeaderFiles(os.path.join('src', 'tool'), AllFiles)
|
2015-05-06 01:47:53 +01:00
|
|
|
|
|
|
|
# Generate err_data.c
|
|
|
|
with open('err_data.c', 'w+') as err_data:
|
|
|
|
subprocess.check_call(['go', 'run', 'err_data_generate.go'],
|
|
|
|
cwd=os.path.join('src', 'crypto', 'err'),
|
|
|
|
stdout=err_data)
|
|
|
|
crypto_c_files.append('err_data.c')
|
|
|
|
|
2016-04-21 23:47:57 +01:00
|
|
|
test_support_c_files = FindCFiles(os.path.join('src', 'crypto', 'test'),
|
Do a cursory conversion of a few tests to GTest.
For now, this is the laziest conversion possible. The intent is to just
get the build setup ready so that we can get everything working in our
consumers. The intended end state is:
- The standalone build produces three test targets, one per library:
{crypto,ssl,decrepit}_tests.
- Each FOO_test is made up of:
FOO/**/*_test.cc
crypto/test/gtest_main.cc
test_support
- generate_build_files.py emits variables crypto_test_sources and
ssl_test_sources. These variables are populated with FindCFiles,
looking for *_test.cc.
- The consuming file assembles those variables into the two test targets
(plus decrepit) from there. This avoids having generate_build_files.py
emit actual build rules.
- Our standalone builders, Chromium, and Android just run the top-level
test targets using whatever GTest-based reporting story they have.
In transition, we start by converting one of two tests in each library
to populate the three test targets. Those are added to all_tests.json
and all_tests.go hacked to handle them transparently. This keeps our
standalone builder working.
generate_build_files.py, to start with, populates the new source lists
manually and subtracts them out of the old machinery. We emit both for
the time being. When this change rolls in, we'll write all the build
glue needed to build the GTest-based tests and add it to consumers'
continuous builders.
Next, we'll subsume a file-based test and get the consumers working with
that. (I.e. make sure the GTest targets can depend on a data file.)
Once that's all done, we'll be sure all this will work. At that point,
we start subsuming the remaining tests into the GTest targets and,
asynchronously, rewriting tests to use GTest properly rather than
cursory conversion here.
When all non-GTest tests are gone, the old generate_build_files.py hooks
will be removed, consumers updated to not depend on them, and standalone
builders converted to not rely on all_tests.go, which can then be
removed. (Unless bits end up being needed as a malloc test driver. I'm
thinking we'll want to do something with --gtest_filter.)
As part of this CL, I've bumped the CMake requirements (for
target_include_directories) and added a few suppressions for warnings
that GTest doesn't pass.
BUG=129
Change-Id: I881b26b07a8739cc0b52dbb51a30956908e1b71a
Reviewed-on: https://boringssl-review.googlesource.com/13232
Reviewed-by: Adam Langley <agl@google.com>
2017-01-20 00:05:47 +00:00
|
|
|
NotGTestMain)
|
2016-06-14 01:06:48 +01:00
|
|
|
test_support_h_files = (
|
|
|
|
FindHeaderFiles(os.path.join('src', 'crypto', 'test'), AllFiles) +
|
|
|
|
FindHeaderFiles(os.path.join('src', 'ssl', 'test'), AllFiles))
|
2015-05-12 01:52:48 +01:00
|
|
|
|
2017-02-14 03:11:49 +00:00
|
|
|
test_c_files = []
|
|
|
|
crypto_test_files = ['src/crypto/test/gtest_main.cc']
|
|
|
|
# TODO(davidben): Remove this loop once all tests are converted.
|
|
|
|
for path in FindCFiles(os.path.join('src', 'crypto'), OnlyTests):
|
|
|
|
if IsGTest(path):
|
|
|
|
crypto_test_files.append(path)
|
|
|
|
else:
|
|
|
|
test_c_files.append(path)
|
|
|
|
|
|
|
|
ssl_test_files = FindCFiles(os.path.join('src', 'ssl'), OnlyTests)
|
|
|
|
ssl_test_files.append('src/crypto/test/gtest_main.cc')
|
2015-05-06 01:47:53 +01:00
|
|
|
|
2016-04-21 23:47:57 +01:00
|
|
|
fuzz_c_files = FindCFiles(os.path.join('src', 'fuzz'), NoTests)
|
|
|
|
|
2015-06-10 02:20:57 +01:00
|
|
|
ssl_h_files = (
|
|
|
|
FindHeaderFiles(
|
|
|
|
os.path.join('src', 'include', 'openssl'),
|
|
|
|
SSLHeaderFiles))
|
|
|
|
|
|
|
|
def NotSSLHeaderFiles(filename, is_dir):
|
|
|
|
return not SSLHeaderFiles(filename, is_dir)
|
|
|
|
crypto_h_files = (
|
|
|
|
FindHeaderFiles(
|
|
|
|
os.path.join('src', 'include', 'openssl'),
|
|
|
|
NotSSLHeaderFiles))
|
|
|
|
|
|
|
|
ssl_internal_h_files = FindHeaderFiles(os.path.join('src', 'ssl'), NoTests)
|
|
|
|
crypto_internal_h_files = FindHeaderFiles(
|
|
|
|
os.path.join('src', 'crypto'), NoTests)
|
|
|
|
|
2015-06-11 02:54:47 +01:00
|
|
|
with open('src/util/all_tests.json', 'r') as f:
|
|
|
|
tests = json.load(f)
|
Do a cursory conversion of a few tests to GTest.
For now, this is the laziest conversion possible. The intent is to just
get the build setup ready so that we can get everything working in our
consumers. The intended end state is:
- The standalone build produces three test targets, one per library:
{crypto,ssl,decrepit}_tests.
- Each FOO_test is made up of:
FOO/**/*_test.cc
crypto/test/gtest_main.cc
test_support
- generate_build_files.py emits variables crypto_test_sources and
ssl_test_sources. These variables are populated with FindCFiles,
looking for *_test.cc.
- The consuming file assembles those variables into the two test targets
(plus decrepit) from there. This avoids having generate_build_files.py
emit actual build rules.
- Our standalone builders, Chromium, and Android just run the top-level
test targets using whatever GTest-based reporting story they have.
In transition, we start by converting one of two tests in each library
to populate the three test targets. Those are added to all_tests.json
and all_tests.go hacked to handle them transparently. This keeps our
standalone builder working.
generate_build_files.py, to start with, populates the new source lists
manually and subtracts them out of the old machinery. We emit both for
the time being. When this change rolls in, we'll write all the build
glue needed to build the GTest-based tests and add it to consumers'
continuous builders.
Next, we'll subsume a file-based test and get the consumers working with
that. (I.e. make sure the GTest targets can depend on a data file.)
Once that's all done, we'll be sure all this will work. At that point,
we start subsuming the remaining tests into the GTest targets and,
asynchronously, rewriting tests to use GTest properly rather than
cursory conversion here.
When all non-GTest tests are gone, the old generate_build_files.py hooks
will be removed, consumers updated to not depend on them, and standalone
builders converted to not rely on all_tests.go, which can then be
removed. (Unless bits end up being needed as a malloc test driver. I'm
thinking we'll want to do something with --gtest_filter.)
As part of this CL, I've bumped the CMake requirements (for
target_include_directories) and added a few suppressions for warnings
that GTest doesn't pass.
BUG=129
Change-Id: I881b26b07a8739cc0b52dbb51a30956908e1b71a
Reviewed-on: https://boringssl-review.googlesource.com/13232
Reviewed-by: Adam Langley <agl@google.com>
2017-01-20 00:05:47 +00:00
|
|
|
# For now, GTest-based tests are specified manually.
|
|
|
|
tests = [test for test in tests if test[0] not in ['crypto/crypto_test',
|
|
|
|
'decrepit/decrepit_test',
|
|
|
|
'ssl/ssl_test']]
|
2015-06-11 02:54:47 +01:00
|
|
|
test_binaries = set([test[0] for test in tests])
|
|
|
|
test_sources = set([
|
|
|
|
test.replace('.cc', '').replace('.c', '').replace(
|
|
|
|
'src/',
|
|
|
|
'')
|
|
|
|
for test in test_c_files])
|
|
|
|
if test_binaries != test_sources:
|
|
|
|
print 'Test sources and configured tests do not match'
|
|
|
|
a = test_binaries.difference(test_sources)
|
|
|
|
if len(a) > 0:
|
|
|
|
print 'These tests are configured without sources: ' + str(a)
|
|
|
|
b = test_sources.difference(test_binaries)
|
|
|
|
if len(b) > 0:
|
|
|
|
print 'These test sources are not configured: ' + str(b)
|
|
|
|
|
2015-05-06 01:47:53 +01:00
|
|
|
files = {
|
|
|
|
'crypto': crypto_c_files,
|
2015-06-10 02:20:57 +01:00
|
|
|
'crypto_headers': crypto_h_files,
|
|
|
|
'crypto_internal_headers': crypto_internal_h_files,
|
2017-02-14 03:11:49 +00:00
|
|
|
'crypto_test': sorted(crypto_test_files),
|
2016-04-21 23:47:57 +01:00
|
|
|
'fuzz': fuzz_c_files,
|
2017-01-23 21:07:50 +00:00
|
|
|
'ssl': ssl_source_files,
|
|
|
|
'ssl_c': [s for s in ssl_source_files if s.endswith('.c')],
|
|
|
|
'ssl_cc': [s for s in ssl_source_files if s.endswith('.cc')],
|
2015-06-10 02:20:57 +01:00
|
|
|
'ssl_headers': ssl_h_files,
|
|
|
|
'ssl_internal_headers': ssl_internal_h_files,
|
2017-02-14 03:11:49 +00:00
|
|
|
'ssl_test': sorted(ssl_test_files),
|
2016-04-21 23:47:57 +01:00
|
|
|
'tool': tool_c_files,
|
2016-06-30 19:56:19 +01:00
|
|
|
'tool_headers': tool_h_files,
|
2015-05-06 01:47:53 +01:00
|
|
|
'test': test_c_files,
|
2016-07-29 22:41:58 +01:00
|
|
|
'test_support': test_support_c_files,
|
|
|
|
'test_support_headers': test_support_h_files,
|
2015-06-11 02:54:47 +01:00
|
|
|
'tests': tests,
|
2015-05-06 01:47:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
asm_outputs = sorted(WriteAsmFiles(ReadPerlAsmOperations()).iteritems())
|
|
|
|
|
2015-06-10 02:20:57 +01:00
|
|
|
for platform in platforms:
|
|
|
|
platform.WriteFiles(files, asm_outputs)
|
2015-05-06 01:47:53 +01:00
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2016-06-09 17:34:11 +01:00
|
|
|
parser = optparse.OptionParser(usage='Usage: %prog [--prefix=<path>]'
|
2016-10-01 02:34:31 +01:00
|
|
|
' [android|bazel|gn|gyp]')
|
2016-06-09 17:34:11 +01:00
|
|
|
parser.add_option('--prefix', dest='prefix',
|
|
|
|
help='For Bazel, prepend argument to all source files')
|
|
|
|
options, args = parser.parse_args(sys.argv[1:])
|
|
|
|
PREFIX = options.prefix
|
|
|
|
|
|
|
|
if not args:
|
|
|
|
parser.print_help()
|
|
|
|
sys.exit(1)
|
2015-05-06 01:47:53 +01:00
|
|
|
|
2015-06-10 02:20:57 +01:00
|
|
|
platforms = []
|
2016-06-09 17:34:11 +01:00
|
|
|
for s in args:
|
2016-04-21 23:47:57 +01:00
|
|
|
if s == 'android':
|
2015-06-10 02:20:57 +01:00
|
|
|
platforms.append(Android())
|
|
|
|
elif s == 'bazel':
|
|
|
|
platforms.append(Bazel())
|
2016-04-21 23:47:57 +01:00
|
|
|
elif s == 'gn':
|
|
|
|
platforms.append(GN())
|
|
|
|
elif s == 'gyp':
|
|
|
|
platforms.append(GYP())
|
2015-06-10 02:20:57 +01:00
|
|
|
else:
|
2016-06-09 17:34:11 +01:00
|
|
|
parser.print_help()
|
|
|
|
sys.exit(1)
|
2015-06-10 02:20:57 +01:00
|
|
|
|
|
|
|
sys.exit(main(platforms))
|