Bug 1621785 - Build configuration for Botan. r=kaie

Script and moz.build configuration for Botan for use in Thunderbird.

Runs Botan's configure.py with the desired options to generate a usable
build.h.

Differential Revision: https://phabricator.services.mozilla.com/D70756

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Rob Lemley 2020-04-14 22:29:17 +00:00
Родитель 4061714503
Коммит 2191778b5d
3 изменённых файлов: 333 добавлений и 0 удалений

8
third_party/botan/Makefile.in поставляемый Normal file
Просмотреть файл

@ -0,0 +1,8 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
include $(moztopsrcdir)/config/config.mk
include $(topsrcdir)/config/rules.mk
export:: build/build.h

78
third_party/botan/botan_configure.py поставляемый Executable file
Просмотреть файл

@ -0,0 +1,78 @@
#!python3
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import print_function, absolute_import, unicode_literals
import os
import sys
import subprocess
import six
from mozbuild.util import system_encoding
# This script is a wrapper for Botan's configure.py to adapt it for moz.build.
# Its main purpose is to return some output on stdout for mozbuild to handle,
# but secondary to that is to set --enable-modules. Mozbuild/Make mangle
# the list otherwise due to the embedded commas.
botan_modules = ','.join((
'aead', 'aes', 'auto_rng', 'bigint', 'blowfish', 'camellia', 'cast128',
'cbc', 'cfb', 'crc24', 'curve25519', 'des', 'dl_group', 'dsa', 'eax',
'ec_group', 'ecdh', 'ecdsa', 'ed25519', 'elgamal', 'eme_pkcs1', 'emsa_pkcs1',
'emsa_raw', 'ffi', 'hash', 'hmac', 'hmac_drbg', 'idea', 'kdf', 'md5', 'ocb',
'pgp_s2k', 'pubkey', 'rfc3394', 'rmd160', 'rsa', 'sha1', 'sha2_32',
'sha2_64', 'sha3', 'sm2', 'sm3', 'sm4', 'sp800_56a', 'twofish'
))
##
here = os.path.abspath(os.path.dirname(__file__))
configure = os.path.join(here, 'configure.py')
# A wrapper to obtain a process' output and return code.
# Returns a tuple (retcode, stdout, stderr).
# from build/moz.configure/util.configure
def get_cmd_output(*args, **kwargs):
proc = subprocess.Popen(
args, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
close_fds=os.name != 'nt')
stdout, stderr = proc.communicate()
stdout = six.ensure_text(stdout, encoding=system_encoding, errors='replace')
stderr = six.ensure_text(stderr, encoding=system_encoding, errors='replace')
return proc.wait(), stdout, stderr
def _run_configure(argv):
"""Call Botan's configure.py. Arguments are passed "shell-style"."""
args = [configure] + list(argv) # passed as a tuple
botan_modules_arg = '--enable-modules={}'.format(botan_modules)
args.append(botan_modules_arg)
try:
rv = get_cmd_output(*args)
except Exception:
raise
return rv
def main(output, *args):
real_output = os.path.join(os.getcwd(), 'build', 'build.h')
rv = _run_configure(args)
if rv[0] == 0:
# GENERATED_FILES expects this script to write something back to output
if os.path.isfile(real_output):
with open(real_output, 'r') as fp:
data = fp.read()
output.write(data)
else:
# Probably an error
raise Exception('Unable to locate real output at {}'.format(real_output))
else:
return rv
return rv[0]
if __name__ == '__main__':
main(*sys.argv)

247
third_party/botan/moz.build поставляемый Normal file
Просмотреть файл

@ -0,0 +1,247 @@
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
Library('botan')
FINAL_LIBRARY = 'rnp'
include('../rnpdefs.mozbuild')
DEFINES['BOTAN_IS_BEING_BUILT'] = 1
DEFINES['_REENTRANT'] = 1
if CONFIG['CC_TYPE'] == 'clang-cl':
DEFINES['_ENABLE_EXTENDED_ALIGNED_STORAGE'] = 1
CXXFLAGS += [
'-bigobj',
'-clang:-fno-force-enable-int128',
'-Xclang',
'-fcxx-exceptions',
]
else:
CXXFLAGS += [
'-fexceptions',
'-fstack-protector'
]
if CONFIG['OS_ARCH'] == 'WINNT':
botan_os = 'windows'
elif CONFIG['OS_ARCH'] == 'Linux':
botan_os = 'linux'
CXXFLAGS += ['-pthread']
else:
botan_os = CONFIG['OS_ARCH'].lower()
# Run Botan's configure.py to generate build.h. Use --with-cmake to avoid
# writing a Makefile that would overwrite our own.
botan_generated = [
'build/build.h',
'build/build_config.json',
'CMakeLists.txt',
]
GENERATED_FILES += botan_generated
botan_build = GENERATED_FILES['build/build.h']
botan_build.script = 'botan_configure.py'
botan_build.flags = [
'--cc-bin={}'.format(CONFIG['MZLA_RNP_CXX']),
'--cpu={}'.format(CONFIG['target_cpu']),
'--os={}'.format(botan_os),
'--with-build-dir={}'.format(OBJDIR),
'--minimized-build',
'--disable-shared-library',
'--link-method=copy',
'--without-sphinx',
'--distribution-info={}'.format(rnp_dist_info),
'--without-rst2man',
'--with-cmake',
]
# Botan assumes this file exists on Linux, but it is not present on Taskcluster.
if not CONFIG['HAVE_SYS_AUXV_H']:
botan_build.flags.append('--without-os-features=getauxval')
# clock_gettime is not part of OSX until 10.12 sdk, Taskcluster builds with 10.11
if CONFIG['OS_ARCH'] == 'Darwin':
botan_build.flags.append('--without-os-features=clock_gettime')
LOCAL_INCLUDES = ['!build/include']
# This list was obtained by running Botan's configure script in CMake mode
# with the desired options and extracting the information from CMakeLists.txt.
SOURCES += [
'src/lib/asn1/alg_id.cpp',
'src/lib/asn1/asn1_attribute.cpp',
'src/lib/asn1/asn1_obj.cpp',
'src/lib/asn1/asn1_oid.cpp',
'src/lib/asn1/asn1_print.cpp',
'src/lib/asn1/asn1_str.cpp',
'src/lib/asn1/asn1_time.cpp',
'src/lib/asn1/ber_dec.cpp',
'src/lib/asn1/der_enc.cpp',
'src/lib/asn1/oid_maps.cpp',
'src/lib/asn1/oids.cpp',
'src/lib/base/buf_comp.cpp',
'src/lib/base/scan_name.cpp',
'src/lib/base/sym_algo.cpp',
'src/lib/base/symkey.cpp',
'src/lib/block/aes/aes.cpp',
'src/lib/block/block_cipher.cpp',
'src/lib/block/blowfish/blowfish.cpp',
'src/lib/block/camellia/camellia.cpp',
'src/lib/block/cast128/cast128.cpp',
'src/lib/block/des/des.cpp',
'src/lib/block/des/des_tab.cpp',
'src/lib/block/des/desx.cpp',
'src/lib/block/idea/idea.cpp',
'src/lib/block/sm4/sm4.cpp',
'src/lib/block/twofish/twofish.cpp',
'src/lib/block/twofish/twofish_tab.cpp',
'src/lib/codec/base64/base64.cpp',
'src/lib/codec/hex/hex.cpp',
'src/lib/entropy/entropy_srcs.cpp',
'src/lib/ffi/ffi.cpp',
'src/lib/ffi/ffi_block.cpp',
'src/lib/ffi/ffi_cert.cpp',
'src/lib/ffi/ffi_cipher.cpp',
'src/lib/ffi/ffi_fpe.cpp',
'src/lib/ffi/ffi_hash.cpp',
'src/lib/ffi/ffi_hotp.cpp',
'src/lib/ffi/ffi_kdf.cpp',
'src/lib/ffi/ffi_keywrap.cpp',
'src/lib/ffi/ffi_mac.cpp',
'src/lib/ffi/ffi_mp.cpp',
'src/lib/ffi/ffi_pk_op.cpp',
'src/lib/ffi/ffi_pkey.cpp',
'src/lib/ffi/ffi_pkey_algs.cpp',
'src/lib/ffi/ffi_rng.cpp',
'src/lib/ffi/ffi_totp.cpp',
'src/lib/hash/checksum/crc24/crc24.cpp',
'src/lib/hash/hash.cpp',
'src/lib/hash/md5/md5.cpp',
'src/lib/hash/mdx_hash/mdx_hash.cpp',
'src/lib/hash/rmd160/rmd160.cpp',
'src/lib/hash/sha1/sha160.cpp',
'src/lib/hash/sha2_32/sha2_32.cpp',
'src/lib/hash/sha2_64/sha2_64.cpp',
'src/lib/hash/sha3/sha3.cpp',
'src/lib/hash/sm3/sm3.cpp',
'src/lib/kdf/kdf.cpp',
'src/lib/kdf/kdf2/kdf2.cpp',
'src/lib/kdf/sp800_56a/sp800_56a.cpp',
'src/lib/mac/cmac/cmac.cpp',
'src/lib/mac/hmac/hmac.cpp',
'src/lib/mac/mac.cpp',
'src/lib/math/bigint/big_code.cpp',
'src/lib/math/bigint/big_io.cpp',
'src/lib/math/bigint/big_ops2.cpp',
'src/lib/math/bigint/big_ops3.cpp',
'src/lib/math/bigint/big_rand.cpp',
'src/lib/math/bigint/bigint.cpp',
'src/lib/math/bigint/divide.cpp',
'src/lib/math/mp/mp_comba.cpp',
'src/lib/math/mp/mp_karat.cpp',
'src/lib/math/mp/mp_monty.cpp',
'src/lib/math/mp/mp_monty_n.cpp',
'src/lib/math/numbertheory/dsa_gen.cpp',
'src/lib/math/numbertheory/jacobi.cpp',
'src/lib/math/numbertheory/make_prm.cpp',
'src/lib/math/numbertheory/monty.cpp',
'src/lib/math/numbertheory/monty_exp.cpp',
'src/lib/math/numbertheory/mp_numth.cpp',
'src/lib/math/numbertheory/nistp_redc.cpp',
'src/lib/math/numbertheory/numthry.cpp',
'src/lib/math/numbertheory/pow_mod.cpp',
'src/lib/math/numbertheory/primality.cpp',
'src/lib/math/numbertheory/primes.cpp',
'src/lib/math/numbertheory/reducer.cpp',
'src/lib/math/numbertheory/ressol.cpp',
'src/lib/misc/nist_keywrap/nist_keywrap.cpp',
'src/lib/misc/rfc3394/rfc3394.cpp',
'src/lib/modes/aead/aead.cpp',
'src/lib/modes/aead/eax/eax.cpp',
'src/lib/modes/aead/ocb/ocb.cpp',
'src/lib/modes/cbc/cbc.cpp',
'src/lib/modes/cfb/cfb.cpp',
'src/lib/modes/cipher_mode.cpp',
'src/lib/modes/mode_pad/mode_pad.cpp',
'src/lib/pbkdf/pbkdf.cpp',
'src/lib/pbkdf/pgp_s2k/pgp_s2k.cpp',
'src/lib/pbkdf/pwdhash.cpp',
'src/lib/pk_pad/eme.cpp',
'src/lib/pk_pad/eme_pkcs1/eme_pkcs.cpp',
'src/lib/pk_pad/emsa.cpp',
'src/lib/pk_pad/emsa1/emsa1.cpp',
'src/lib/pk_pad/emsa_pkcs1/emsa_pkcs1.cpp',
'src/lib/pk_pad/emsa_pssr/pssr.cpp',
'src/lib/pk_pad/emsa_raw/emsa_raw.cpp',
'src/lib/pk_pad/hash_id/hash_id.cpp',
'src/lib/pk_pad/mgf1/mgf1.cpp',
'src/lib/pk_pad/padding.cpp',
'src/lib/pubkey/blinding.cpp',
'src/lib/pubkey/curve25519/curve25519.cpp',
'src/lib/pubkey/curve25519/donna.cpp',
'src/lib/pubkey/dl_algo/dl_algo.cpp',
'src/lib/pubkey/dl_group/dl_group.cpp',
'src/lib/pubkey/dl_group/dl_named.cpp',
'src/lib/pubkey/dsa/dsa.cpp',
'src/lib/pubkey/ec_group/curve_gfp.cpp',
'src/lib/pubkey/ec_group/ec_group.cpp',
'src/lib/pubkey/ec_group/ec_named.cpp',
'src/lib/pubkey/ec_group/point_gfp.cpp',
'src/lib/pubkey/ec_group/point_mul.cpp',
'src/lib/pubkey/ecc_key/ecc_key.cpp',
'src/lib/pubkey/ecdh/ecdh.cpp',
'src/lib/pubkey/ecdsa/ecdsa.cpp',
'src/lib/pubkey/ed25519/ed25519.cpp',
'src/lib/pubkey/ed25519/ed25519_fe.cpp',
'src/lib/pubkey/ed25519/ed25519_key.cpp',
'src/lib/pubkey/ed25519/ge.cpp',
'src/lib/pubkey/ed25519/sc_muladd.cpp',
'src/lib/pubkey/ed25519/sc_reduce.cpp',
'src/lib/pubkey/elgamal/elgamal.cpp',
'src/lib/pubkey/keypair/keypair.cpp',
'src/lib/pubkey/pem/pem.cpp',
'src/lib/pubkey/pk_algs.cpp',
'src/lib/pubkey/pk_keys.cpp',
'src/lib/pubkey/pk_ops.cpp',
'src/lib/pubkey/pkcs8.cpp',
'src/lib/pubkey/pubkey.cpp',
'src/lib/pubkey/rsa/rsa.cpp',
'src/lib/pubkey/sm2/sm2.cpp',
'src/lib/pubkey/sm2/sm2_enc.cpp',
'src/lib/pubkey/workfactor.cpp',
'src/lib/pubkey/x509_key.cpp',
'src/lib/rng/auto_rng/auto_rng.cpp',
'src/lib/rng/hmac_drbg/hmac_drbg.cpp',
'src/lib/rng/rng.cpp',
'src/lib/rng/stateful_rng/stateful_rng.cpp',
'src/lib/rng/system_rng/system_rng.cpp',
'src/lib/stream/ctr/ctr.cpp',
'src/lib/stream/stream_cipher.cpp',
'src/lib/utils/assert.cpp',
'src/lib/utils/calendar.cpp',
'src/lib/utils/charset.cpp',
'src/lib/utils/cpuid/cpuid.cpp',
'src/lib/utils/cpuid/cpuid_arm.cpp',
'src/lib/utils/cpuid/cpuid_ppc.cpp',
'src/lib/utils/cpuid/cpuid_x86.cpp',
'src/lib/utils/ct_utils.cpp',
'src/lib/utils/data_src.cpp',
'src/lib/utils/exceptn.cpp',
'src/lib/utils/filesystem.cpp',
'src/lib/utils/mem_ops.cpp',
'src/lib/utils/os_utils.cpp',
'src/lib/utils/parsing.cpp',
'src/lib/utils/poly_dbl/poly_dbl.cpp',
'src/lib/utils/read_cfg.cpp',
'src/lib/utils/read_kv.cpp',
'src/lib/utils/timer.cpp',
'src/lib/utils/version.cpp',
]
if CONFIG['CC_TYPE'] == 'clang-cl':
SOURCES += [
'src/lib/utils/dyn_load/dyn_load.cpp',
]