summaryrefslogtreecommitdiffstats
path: root/comm/third_party/rnp/moz.build
diff options
context:
space:
mode:
Diffstat (limited to 'comm/third_party/rnp/moz.build')
-rw-r--r--comm/third_party/rnp/moz.build227
1 files changed, 227 insertions, 0 deletions
diff --git a/comm/third_party/rnp/moz.build b/comm/third_party/rnp/moz.build
new file mode 100644
index 0000000000..3ab156a4b2
--- /dev/null
+++ b/comm/third_party/rnp/moz.build
@@ -0,0 +1,227 @@
+# 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/.
+
+SharedLibrary("rnp")
+
+include("../rnpdefs.mozbuild")
+
+
+@template
+def IQuote(*paths):
+ """Add a set of paths to the include path via -iquote"""
+ if CONFIG["CC_TYPE"] == "clang-cl":
+ flags = ["-Xclang", "-iquote", "-Xclang"]
+ else:
+ flags = ["-iquote"]
+ for p in paths:
+ CXXFLAGS += flags + [p]
+
+
+def get_defines(defines):
+ """For DEFINES that are False, do not include them in the preprocesser
+ commandline. Such preprocessor macros will be #undef'd in the output file while
+ allowing the build code to be explicit (and hopefully more readable)."""
+
+ for define, value in defines.items():
+ if value is True:
+ yield ("-D%s" % define)
+ elif value is not False:
+ yield ("-D%s=%s" % (define, value))
+
+
+COMPILE_FLAGS["WARNINGS_CFLAGS"] += [
+ "-Wall",
+ "-Wextra",
+ "-Wunreachable-code",
+ "-Wpointer-arith",
+ "-Wmissing-declarations",
+ "-Wno-pedantic",
+ "-Wno-ignored-qualifiers",
+ "-Wno-unused-parameter",
+ "-Wno-missing-field-initializers",
+]
+
+if CONFIG["CC_TYPE"] == "clang-cl":
+ CXXFLAGS += [
+ "/EHs",
+ ]
+
+LOCAL_INCLUDES = [
+ "include",
+ "src",
+ "src/common",
+ "src/lib",
+ "src/libsexp/include"
+]
+
+IQuote(
+ "{}/src/lib".format(OBJDIR),
+)
+
+# Set up defines for src/lib/config.h
+rnp_defines = {
+ "HAVE_BZLIB_H": True,
+ "HAVE_ZLIB_H": True,
+ "ENABLE_SM2": False,
+ "ENABLE_IDEA": True,
+ "ENABLE_AEAD": True,
+ "ENABLE_BLOWFISH": True,
+ "ENABLE_CAST5": True,
+ "ENABLE_RIPEMD160": True,
+ "PACKAGE_BUGREPORT": '"https://bugzilla.mozilla.org/enter_bug.cgi?product=Thunderbird"',
+}
+if CONFIG["MZLA_LIBRNP_BACKEND"] == "botan":
+ LOCAL_INCLUDES += ["!../botan/build/include"]
+ if CONFIG["MZLA_SYSTEM_BOTAN"]:
+ CXXFLAGS += CONFIG["MZLA_BOTAN_CFLAGS"]
+
+ rnp_defines.update({
+ "CRYPTO_BACKEND_BOTAN": True,
+ "ENABLE_TWOFISH": True,
+ "ENABLE_BRAINPOOL": True,
+ })
+elif CONFIG["MZLA_LIBRNP_BACKEND"] == "openssl":
+ CXXFLAGS += CONFIG["MZLA_LIBRNP_OPENSSL_CFLAGS"]
+ OS_LIBS += CONFIG["MZLA_LIBRNP_OPENSSL_LIBS"]
+
+ rnp_defines.update({
+ "CRYPTO_BACKEND_OPENSSL": True,
+ # Not supported by OpenSSL https://github.com/openssl/openssl/issues/2046
+ "ENABLE_TWOFISH": False,
+ # Supported, but not with RHEL's OpenSSL, disabled for now;
+ "ENABLE_BRAINPOOL": False,
+ })
+ rnp_defines["PACKAGE_STRING"] = rnp_defines["PACKAGE_STRING"][:-1] + '-openssl"'
+ if CONFIG["MZLA_LIBRNP_OPENSSL_VERSION"][0] == "3":
+ rnp_defines["CRYPTO_BACKEND_OPENSSL3"] = True
+
+
+gen_files_flags = [d for d in get_defines(rnp_defines)]
+
+GeneratedFile(
+ "src/lib/version.h", "src/lib/config.h",
+ script="/comm/python/thirdroc/rnp_generated.py",
+ inputs=["src/lib/version.h.in", "src/lib/config.h.in"],
+ flags=["-V", f"{SRCDIR}/version.txt",
+ "-m", CONFIG["MOZ_APP_VERSION_DISPLAY"]] + gen_files_flags
+)
+
+if CONFIG["MOZ_SYSTEM_ZLIB"]:
+ CXXFLAGS += CONFIG["MOZ_ZLIB_CFLAGS"]
+else:
+ LOCAL_INCLUDES += ["../zlib"]
+
+if CONFIG["MZLA_SYSTEM_JSONC"]:
+ CXXFLAGS += CONFIG["MZLA_JSONC_CFLAGS"]
+else:
+ IQuote("{}/../json-c".format(OBJDIR))
+ LOCAL_INCLUDES += ["!../json-c", "../json-c"]
+
+if CONFIG["MZLA_SYSTEM_BZIP2"]:
+ CXXFLAGS += CONFIG["MZLA_BZIP2_CFLAGS"]
+else:
+ LOCAL_INCLUDES += ["../bzip2"]
+
+if CONFIG["CC_TYPE"] == "clang-cl":
+ LOCAL_INCLUDES += [
+ "../niwcompat",
+ ]
+
+ if CONFIG["CPU_ARCH"] == "x86":
+ LDFLAGS += ["clang_rt.builtins-i386.lib"]
+ elif CONFIG["CPU_ARCH"] == "x86_64":
+ LDFLAGS += ["clang_rt.builtins-x86_64.lib"]
+
+SYMBOLS_FILE = "rnp.symbols"
+
+
+SOURCES += [
+ "src/common/file-utils.cpp",
+ "src/common/str-utils.cpp",
+ "src/common/time-utils.cpp",
+ "src/lib/crypto.cpp",
+ "src/lib/crypto/backend_version.cpp",
+ "src/lib/crypto/cipher.cpp",
+ "src/lib/crypto/ec_curves.cpp",
+ "src/lib/crypto/ecdh_utils.cpp",
+ "src/lib/crypto/hash_common.cpp",
+ "src/lib/crypto/hash_sha1cd.cpp",
+ "src/lib/crypto/mpi.cpp",
+ "src/lib/crypto/s2k.cpp",
+ "src/lib/crypto/sha1cd/sha1.c",
+ "src/lib/crypto/sha1cd/ubc_check.c",
+ "src/lib/crypto/signatures.cpp",
+ "src/lib/fingerprint.cpp",
+ "src/lib/generate-key.cpp",
+ "src/lib/json-utils.cpp",
+ "src/lib/key-provider.cpp",
+ "src/lib/logging.cpp",
+ "src/lib/pass-provider.cpp",
+ "src/lib/pgp-key.cpp",
+ "src/lib/rnp.cpp",
+ "src/lib/sec_profile.cpp",
+ "src/lib/utils.cpp",
+ # librekey
+ "src/librekey/key_store_g10.cpp",
+ "src/librekey/key_store_kbx.cpp",
+ "src/librekey/key_store_pgp.cpp",
+ "src/librekey/rnp_key_store.cpp",
+ # librepgp
+ "src/librepgp/stream-armor.cpp",
+ "src/librepgp/stream-common.cpp",
+ "src/librepgp/stream-ctx.cpp",
+ "src/librepgp/stream-dump.cpp",
+ "src/librepgp/stream-key.cpp",
+ "src/librepgp/stream-packet.cpp",
+ "src/librepgp/stream-parse.cpp",
+ "src/librepgp/stream-sig.cpp",
+ "src/librepgp/stream-write.cpp",
+ # libsexp
+ "src/libsexp/src/ext-key-format.cpp",
+ "src/libsexp/src/sexp-char-defs.cpp",
+ "src/libsexp/src/sexp-error.cpp",
+ "src/libsexp/src/sexp-input.cpp",
+ "src/libsexp/src/sexp-object.cpp",
+ "src/libsexp/src/sexp-output.cpp",
+ "src/libsexp/src/sexp-simple-string.cpp",
+]
+
+if CONFIG["MZLA_LIBRNP_BACKEND"] == "botan":
+ SOURCES += [
+ "src/lib/crypto/bn.cpp",
+ "src/lib/crypto/cipher_botan.cpp",
+ "src/lib/crypto/dsa.cpp",
+ "src/lib/crypto/ec.cpp",
+ "src/lib/crypto/ecdh.cpp",
+ "src/lib/crypto/ecdsa.cpp",
+ "src/lib/crypto/eddsa.cpp",
+ "src/lib/crypto/elgamal.cpp",
+ "src/lib/crypto/hash.cpp",
+ "src/lib/crypto/mem.cpp",
+ "src/lib/crypto/rng.cpp",
+ "src/lib/crypto/rsa.cpp",
+ "src/lib/crypto/symmetric.cpp",
+ ]
+if CONFIG["MZLA_LIBRNP_BACKEND"] == "openssl":
+ SOURCES += [
+ "src/lib/crypto/bn_ossl.cpp",
+ "src/lib/crypto/cipher_ossl.cpp",
+ "src/lib/crypto/dl_ossl.cpp",
+ "src/lib/crypto/dsa_ossl.cpp",
+ "src/lib/crypto/ec_ossl.cpp",
+ "src/lib/crypto/ecdh_ossl.cpp",
+ "src/lib/crypto/ecdsa_ossl.cpp",
+ "src/lib/crypto/eddsa_ossl.cpp",
+ "src/lib/crypto/elgamal_ossl.cpp",
+ "src/lib/crypto/hash_crc24.cpp",
+ "src/lib/crypto/hash_ossl.cpp",
+ "src/lib/crypto/mem_ossl.cpp",
+ "src/lib/crypto/rng_ossl.cpp",
+ "src/lib/crypto/rsa_ossl.cpp",
+ "src/lib/crypto/s2k_ossl.cpp",
+ "src/lib/crypto/symmetric_ossl.cpp",
+ ]
+
+DIRS += ["src/rnp", "src/rnpkeys"]