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