Migrate from Android.mk to Android.bp

The Android build system uses "blueprint" files now which are
represented by "Android.bp" instead of "Android.mk" files.

Some of the old sources.mk entries still exist, since they're still
being used by the Trusty build system.

Change-Id: I0b04100ace8599c8734bee77f656aab04c06cce9
Reviewed-on: https://boringssl-review.googlesource.com/8891
Reviewed-by: David Benjamin <davidben@google.com>
This commit is contained in:
Dan Willemsen 2016-07-21 11:08:44 -07:00 committed by David Benjamin
parent 00d7a7cee7
commit b57e4fc728

View File

@ -74,6 +74,8 @@ class Android(object):
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
# This file is created by generate_build_files.py. Do not edit manually.
""" """
def ExtraFiles(self): def ExtraFiles(self):
@ -86,15 +88,84 @@ class Android(object):
out.write('\n') out.write('\n')
def WriteFiles(self, files, asm_outputs): def WriteFiles(self, files, asm_outputs):
# 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')
for f in sorted(files['crypto'] + self.ExtraFiles()):
blueprint.write(' "%s",\n' % f)
blueprint.write(' ],\n')
blueprint.write(' target: {\n')
for ((osname, arch), asm_files) in asm_outputs:
if osname != 'linux':
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')
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
with open('sources.mk', 'w+') as makefile: with open('sources.mk', 'w+') as makefile:
makefile.write(self.header) makefile.write(self.header)
crypto_files = files['crypto'] + self.ExtraFiles() crypto_files = files['crypto'] + self.ExtraFiles()
self.PrintVariableSection(makefile, 'crypto_sources', crypto_files) self.PrintVariableSection(makefile, 'crypto_sources', crypto_files)
self.PrintVariableSection(makefile, 'ssl_sources', files['ssl'])
self.PrintVariableSection(makefile, 'tool_sources', files['tool'])
for ((osname, arch), asm_files) in asm_outputs: for ((osname, arch), asm_files) in asm_outputs:
if osname != 'linux':
continue
self.PrintVariableSection( self.PrintVariableSection(
makefile, '%s_%s_sources' % (osname, arch), asm_files) makefile, '%s_%s_sources' % (osname, arch), asm_files)