fc5871
# HG changeset patch
fc5871
# User Rob Lemley <rob@thunderbird.net>
fc5871
# Date 1662997034 0
fc5871
#      Mon Sep 12 15:37:14 2022 +0000
fc5871
# Node ID 17dc6bb322b5d40299bba0a90d59c0593137d4f6
fc5871
# Parent  c9e44c0a569253884961ad2e18fae23f5ed0f6dc
fc5871
Bug 1790446 - Get RNP version during configure and set in config.h. r=dandarnell
fc5871
fc5871
fc5871
fc5871
fc5871
Depends on D157152
fc5871
fc5871
Differential Revision: https://phabricator.services.mozilla.com/D157153
fc5871
fc5871
diff --git a/comm/third_party/openpgp.configure b/comm/third_party/openpgp.configure
fc5871
--- a/comm/third_party/openpgp.configure
fc5871
+++ b/comm/third_party/openpgp.configure
fc5871
@@ -86,10 +86,42 @@ with only_when("--enable-compile-environ
fc5871
     set_config("MZLA_LIBRNP", depends_if(in_tree_librnp)(lambda _: True))
fc5871
     set_define("MZLA_LIBRNP", depends_if(in_tree_librnp)(lambda _: True))
fc5871
 
fc5871
 
fc5871
 with only_when(in_tree_librnp):
fc5871
+
fc5871
+    @depends(build_environment, c_compiler)
fc5871
+    @imports(_from="textwrap", _import="dedent")
fc5871
+    @imports(_from="os.path", _import="join")
fc5871
+    def rnp_version_string(build_env, compiler):
fc5871
+        log.info("Determining librnp version from version.h.")
fc5871
+        include_path = join(
fc5871
+            build_env.topsrcdir, "comm", "third_party", "rnp", "src", "lib"
fc5871
+        )
fc5871
+        check = dedent(
fc5871
+            """\
fc5871
+        #include "version.h"
fc5871
+        RNP_VERSION_STRING_FULL
fc5871
+        """
fc5871
+        )
fc5871
+        result = try_preprocess(
fc5871
+            compiler.wrapper
fc5871
+            + [compiler.compiler]
fc5871
+            + compiler.flags
fc5871
+            + ["-I", include_path],
fc5871
+            "C",
fc5871
+            check,
fc5871
+        )
fc5871
+        if result:
fc5871
+            rnp_version = result.splitlines()[-1]
fc5871
+            rnp_version = rnp_version.replace('"', "")
fc5871
+        else:
fc5871
+            raise FatalCheckError("Unable to determine RNP version string.")
fc5871
+        return rnp_version
fc5871
+
fc5871
+    set_config("MZLA_LIBRNP_FULL_VERSION", rnp_version_string)
fc5871
+
fc5871
     # JSON-C --with-system-json
fc5871
     system_lib_option(
fc5871
         "--with-system-jsonc",
fc5871
         help="Use system JSON-C for librnp (located with pkgconfig)",
fc5871
     )
fc5871
diff --git a/comm/third_party/rnp/moz.build b/third_party/rnp/moz.b/commuild
fc5871
--- a/comm/third_party/rnp/moz.build
fc5871
+++ b/comm/third_party/rnp/moz.build
fc5871
@@ -41,10 +41,12 @@ rnp_defines = {
fc5871
     "HAVE_ZLIB_H": True,
fc5871
     "CRYPTO_BACKEND_BOTAN": True,
fc5871
     "ENABLE_AEAD": True,
fc5871
     "ENABLE_TWOFISH": True,
fc5871
     "ENABLE_BRAINPOOL": True,
fc5871
+    "PACKAGE_BUGREPORT": '"https://bugzilla.mozilla.org/enter_bug.cgi?product=Thunderbird"',
fc5871
+    "PACKAGE_STRING": '"rnp {}"'.format(CONFIG["MZLA_LIBRNP_FULL_VERSION"])
fc5871
 }
fc5871
 GeneratedFile(
fc5871
     "src/lib/config.h",
fc5871
     script="/comm/python/rocbuild/process_cmake_define_files.py",
fc5871
     inputs=["src/lib/config.h.in"],