Updates to the build-file generation script.
This change adds ‘android-standalone’ and ‘bazel’ targets to the build-file generation script. It also allows multiple build outputs to be written in one invocation, which saves the cost of Perl to build all the assembly files multiple times. Note that this will require changes to the Chromium GYP files when its rolled out because “boringssl_lib_sources” has been broken into “boringssl_crypto_sources” and “boringssl_ssl_sources”. Change-Id: Icfe9678d08fba74fd215cf92521831e9cdc265da Reviewed-on: https://boringssl-review.googlesource.com/5070 Reviewed-by: Adam Langley <agl@google.com>
This commit is contained in:
parent
2b2b0f909d
commit
049ef415c5
@ -68,7 +68,9 @@ class Chromium(object):
|
|||||||
gypi.write(self.header + '{\n \'variables\': {\n')
|
gypi.write(self.header + '{\n \'variables\': {\n')
|
||||||
|
|
||||||
self.PrintVariableSection(
|
self.PrintVariableSection(
|
||||||
gypi, 'boringssl_lib_sources', files['crypto'] + files['ssl'])
|
gypi, 'boringssl_ssl_sources', files['ssl'])
|
||||||
|
self.PrintVariableSection(
|
||||||
|
gypi, 'boringssl_crypto_sources', files['crypto'])
|
||||||
|
|
||||||
for ((osname, arch), asm_files) in asm_outputs:
|
for ((osname, arch), asm_files) in asm_outputs:
|
||||||
self.PrintVariableSection(gypi, 'boringssl_%s_%s_sources' %
|
self.PrintVariableSection(gypi, 'boringssl_%s_%s_sources' %
|
||||||
@ -133,6 +135,9 @@ class Android(object):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
def ExtraFiles(self):
|
||||||
|
return ['android_compat_hacks.c', 'android_compat_keywrap.c']
|
||||||
|
|
||||||
def PrintVariableSection(self, out, name, files):
|
def PrintVariableSection(self, out, name, files):
|
||||||
out.write('%s := \\\n' % name)
|
out.write('%s := \\\n' % name)
|
||||||
for f in sorted(files):
|
for f in sorted(files):
|
||||||
@ -143,8 +148,7 @@ class Android(object):
|
|||||||
with open('sources.mk', 'w+') as makefile:
|
with open('sources.mk', 'w+') as makefile:
|
||||||
makefile.write(self.header)
|
makefile.write(self.header)
|
||||||
|
|
||||||
files['crypto'].append('android_compat_hacks.c')
|
files['crypto'].extend(self.ExtraFiles())
|
||||||
files['crypto'].append('android_compat_keywrap.c')
|
|
||||||
self.PrintVariableSection(makefile, 'crypto_sources', files['crypto'])
|
self.PrintVariableSection(makefile, 'crypto_sources', files['crypto'])
|
||||||
self.PrintVariableSection(makefile, 'ssl_sources', files['ssl'])
|
self.PrintVariableSection(makefile, 'ssl_sources', files['ssl'])
|
||||||
self.PrintVariableSection(makefile, 'tool_sources', files['tool'])
|
self.PrintVariableSection(makefile, 'tool_sources', files['tool'])
|
||||||
@ -154,6 +158,57 @@ class Android(object):
|
|||||||
makefile, '%s_%s_sources' % (osname, arch), asm_files)
|
makefile, '%s_%s_sources' % (osname, arch), asm_files)
|
||||||
|
|
||||||
|
|
||||||
|
class AndroidStandalone(Android):
|
||||||
|
"""AndroidStandalone is for Android builds outside of the Android-system, i.e.
|
||||||
|
|
||||||
|
for applications that wish wish to ship BoringSSL.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def ExtraFiles(self):
|
||||||
|
return []
|
||||||
|
|
||||||
|
|
||||||
|
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):
|
||||||
|
out.write(' "%s",\n' % f)
|
||||||
|
out.write(']\n')
|
||||||
|
|
||||||
|
def WriteFiles(self, files, asm_outputs):
|
||||||
|
with open('BUILD.generated', 'w+') as out:
|
||||||
|
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'])
|
||||||
|
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'])
|
||||||
|
|
||||||
|
for ((osname, arch), asm_files) in asm_outputs:
|
||||||
|
if osname is not 'linux':
|
||||||
|
continue
|
||||||
|
self.PrintVariableSection(
|
||||||
|
out, 'crypto_sources_%s' % arch, asm_files)
|
||||||
|
|
||||||
|
|
||||||
def FindCMakeFiles(directory):
|
def FindCMakeFiles(directory):
|
||||||
"""Returns list of all CMakeLists.txt files recursively in directory."""
|
"""Returns list of all CMakeLists.txt files recursively in directory."""
|
||||||
cmakefiles = []
|
cmakefiles = []
|
||||||
@ -188,6 +243,10 @@ def AllFiles(dent, is_dir):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def SSLHeaderFiles(dent, is_dir):
|
||||||
|
return dent in ['ssl.h', 'tls1.h', 'ssl23.h', 'ssl3.h', 'dtls1.h']
|
||||||
|
|
||||||
|
|
||||||
def FindCFiles(directory, filter_func):
|
def FindCFiles(directory, filter_func):
|
||||||
"""Recurses through directory and returns a list of paths to all the C source
|
"""Recurses through directory and returns a list of paths to all the C source
|
||||||
files that pass filter_func."""
|
files that pass filter_func."""
|
||||||
@ -208,6 +267,21 @@ def FindCFiles(directory, filter_func):
|
|||||||
return cfiles
|
return cfiles
|
||||||
|
|
||||||
|
|
||||||
|
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))
|
||||||
|
|
||||||
|
return hfiles
|
||||||
|
|
||||||
|
|
||||||
def ExtractPerlAsmFromCMakeFile(cmakefile):
|
def ExtractPerlAsmFromCMakeFile(cmakefile):
|
||||||
"""Parses the contents of the CMakeLists.txt file passed as an argument and
|
"""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."""
|
returns a list of all the perlasm() directives found in the file."""
|
||||||
@ -302,7 +376,7 @@ def WriteAsmFiles(perlasms):
|
|||||||
return asmfiles
|
return asmfiles
|
||||||
|
|
||||||
|
|
||||||
def main(platform):
|
def main(platforms):
|
||||||
crypto_c_files = FindCFiles(os.path.join('src', 'crypto'), NoTests)
|
crypto_c_files = FindCFiles(os.path.join('src', 'crypto'), NoTests)
|
||||||
ssl_c_files = FindCFiles(os.path.join('src', 'ssl'), NoTests)
|
ssl_c_files = FindCFiles(os.path.join('src', 'ssl'), NoTests)
|
||||||
tool_cc_files = FindCFiles(os.path.join('src', 'tool'), NoTests)
|
tool_cc_files = FindCFiles(os.path.join('src', 'tool'), NoTests)
|
||||||
@ -320,9 +394,29 @@ def main(platform):
|
|||||||
test_c_files = FindCFiles(os.path.join('src', 'crypto'), OnlyTests)
|
test_c_files = FindCFiles(os.path.join('src', 'crypto'), OnlyTests)
|
||||||
test_c_files += FindCFiles(os.path.join('src', 'ssl'), OnlyTests)
|
test_c_files += FindCFiles(os.path.join('src', 'ssl'), OnlyTests)
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
files = {
|
files = {
|
||||||
'crypto': crypto_c_files,
|
'crypto': crypto_c_files,
|
||||||
|
'crypto_headers': crypto_h_files,
|
||||||
|
'crypto_internal_headers': crypto_internal_h_files,
|
||||||
'ssl': ssl_c_files,
|
'ssl': ssl_c_files,
|
||||||
|
'ssl_headers': ssl_h_files,
|
||||||
|
'ssl_internal_headers': ssl_internal_h_files,
|
||||||
'tool': tool_cc_files,
|
'tool': tool_cc_files,
|
||||||
'test': test_c_files,
|
'test': test_c_files,
|
||||||
'test_support': test_support_cc_files,
|
'test_support': test_support_cc_files,
|
||||||
@ -330,26 +424,32 @@ def main(platform):
|
|||||||
|
|
||||||
asm_outputs = sorted(WriteAsmFiles(ReadPerlAsmOperations()).iteritems())
|
asm_outputs = sorted(WriteAsmFiles(ReadPerlAsmOperations()).iteritems())
|
||||||
|
|
||||||
platform.WriteFiles(files, asm_outputs)
|
for platform in platforms:
|
||||||
|
platform.WriteFiles(files, asm_outputs)
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
def Usage():
|
def Usage():
|
||||||
print 'Usage: python %s [chromium|android]' % sys.argv[0]
|
print 'Usage: python %s [chromium|android|android-standalone|bazel]' % sys.argv[0]
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
if len(sys.argv) != 2:
|
if len(sys.argv) < 2:
|
||||||
Usage()
|
Usage()
|
||||||
|
|
||||||
platform = None
|
platforms = []
|
||||||
if sys.argv[1] == 'chromium':
|
for s in sys.argv[1:]:
|
||||||
platform = Chromium()
|
if s == 'chromium' or s == 'gyp':
|
||||||
elif sys.argv[1] == 'android':
|
platforms.append(Chromium())
|
||||||
platform = Android()
|
elif s == 'android':
|
||||||
else:
|
platforms.append(Android())
|
||||||
Usage()
|
elif s == 'android-standalone':
|
||||||
|
platforms.append(AndroidStandalone())
|
||||||
|
elif s == 'bazel':
|
||||||
|
platforms.append(Bazel())
|
||||||
|
else:
|
||||||
|
Usage()
|
||||||
|
|
||||||
sys.exit(main(platform))
|
sys.exit(main(platforms))
|
||||||
|
Loading…
Reference in New Issue
Block a user