Bug 1518166 - Include libotr and dependencies from build artifacts.
authorRob Lemley <rob@thunderbird.net>
Thu, 23 Jan 2020 17:20:44 -0500
changeset 28875 e0e05018f705af08c3b98472483c02c69d25d9ec
parent 28874 32b795794bfa328f78f81850686241e1bbae66bf
child 28876 77c269c63ddcf34fa4260cc4992433bd9b6a3817
push id17087
push userthunderbird@calypsoblue.org
push dateMon, 02 Mar 2020 20:11:30 +0000
treeherdercomm-central@e0e05018f705 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1518166
Bug 1518166 - Include libotr and dependencies from build artifacts. Copy libotr libraries from $MOZ_FETCHES_DIR to objdir/dist/bin during the libs phase of the build process. Update package-manifest.in accordingly do it's included in the final package. This step is configured so that it only runs when building on Taskcluster. It's expected that distributions packaging their own builds will have libotr own libotr package and will not need to have it bundled.
mail/installer/Makefile.in
mail/installer/package-manifest.in
mail/moz.build
mail/moz.configure
third_party/Makefile.in
third_party/moz.build
--- a/mail/installer/Makefile.in
+++ b/mail/installer/Makefile.in
@@ -165,16 +165,20 @@ endif
 
 ifdef CLANG_CXX
 DEFINES += -DCLANG_CXX
 endif
 ifdef CLANG_CL
 DEFINES += -DCLANG_CL
 endif
 
+ifdef TB_LIBOTR_PREBUILT
+DEFINES += -DTB_LIBOTR_PREBUILT
+endif
+
 libs::
 	$(MAKE) -C $(commtopobjdir)/mail/locales langpack
 
 ifeq (WINNT,$(OS_ARCH))
 PKGCOMP_FIND_OPTS =
 else
 PKGCOMP_FIND_OPTS = -L
 endif
--- a/mail/installer/package-manifest.in
+++ b/mail/installer/package-manifest.in
@@ -216,16 +216,34 @@
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 @RESPATH@/@PREF_DIR@/chat-prefs.js
 @RESPATH@/chrome/chat@JAREXT@
 @RESPATH@/chrome/chat.manifest
 
 ; Thunderbird specific
 @RESPATH@/@PREF_DIR@/all-im.js
 
+; OTR libraries
+#ifdef TB_LIBOTR_PREBUILT
+#ifdef XP_WIN
+@BINPATH@/libotr-5.dll
+@BINPATH@/libgcrypt-20.dll
+@BINPATH@/libssp-0.dll
+#ifdef _AMD64_
+@BINPATH@/libgpg-error6-0.dll
+#else
+@BINPATH@/libgpg-error-0.dll
+#endif
+#elif defined(XP_MACOSX)
+@BINPATH@/libotr.5.dylib
+#elif defined(XP_LINUX)
+@BINPATH@/libotr.so.5
+#endif
+#endif
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ; Chrome Files
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
 @RESPATH@/chrome/classic@JAREXT@
 @RESPATH@/chrome/classic.manifest
 
 ; [DevTools Startup Files]
--- a/mail/moz.build
+++ b/mail/moz.build
@@ -16,15 +16,17 @@ DIRS += [
 ]
 
 if CONFIG['MAKENSISU']:
     DIRS += ['installer/windows']
 
 if CONFIG['MOZ_BUNDLED_FONTS']:
     DIRS += ['/%s/browser/fonts' % CONFIG['mozreltopsrcdir']]
 
+DIRS += ['../third_party']
+
 TEST_DIRS += [
     'test/browser',
     'test/marionette',
     'test/static',
 ]
 
 FINAL_TARGET_FILES.defaults += ['app/permissions']
--- a/mail/moz.configure
+++ b/mail/moz.configure
@@ -75,16 +75,32 @@ imply_option('MOZ_BLOCK_PROFILE_DOWNGRAD
 
 with only_when(target_is_linux & compile_environment):
     option(env='MOZ_NO_PIE_COMPAT',
            help='Enable non-PIE wrapper')
 
     set_config('MOZ_NO_PIE_COMPAT',
                depends_if('MOZ_NO_PIE_COMPAT')(lambda _: True))
 
+
+@depends('MOZ_AUTOMATION')
+@imports(_from='os', _import='environ')
+@imports(_from='six', _import='ensure_text')
+def pkg_libotr(automation):
+    if automation:
+        fetch_dir = environ.get('MOZ_FETCHES_DIR', None)
+        if fetch_dir:
+            log.info('Including libotr from {}'.format(fetch_dir))
+            return ensure_text(fetch_dir)
+
+        log.info('TB_LIBOTR_PREBUILT is set, but MOZ_FETCHES_DIR is invalid.')
+
+set_config('TB_LIBOTR_PREBUILT', pkg_libotr)
+
+
 set_config('MOZ_TELEMETRY_EXTRA_HISTOGRAM_FILES', ['/comm/mail/components/telemetry/Histograms.json'])
 set_config('MOZ_TELEMETRY_EXTRA_SCALAR_FILES', ['/comm/mail/components/telemetry/Scalars.yaml'])
 set_config('MOZ_TELEMETRY_EXTRA_EVENT_FILES', ['/comm/mail/components/telemetry/Events.yaml'])
 
 include('../build/moz.configure/gecko_source.configure')
 
 include('../mailnews/moz.configure')
 
new file mode 100644
--- /dev/null
+++ b/third_party/Makefile.in
@@ -0,0 +1,38 @@
+# 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 $(moztopsrcdir)/config/rules.mk
+
+print-%: ; @echo $* is $($*)
+origin-%: ; @echo $* origin $(origin $*)
+
+ifdef TB_LIBOTR_PREBUILT
+
+ifeq (WINNT,$(OS_ARCH))
+ifdef HAVE_64BIT_BUILD
+OTR_LIBS := libgpg-error6-0.dll
+else
+OTR_LIBS := libgpg-error-0.dll
+endif
+OTR_LIBS += libgcrypt-20.dll \
+	libotr-5.dll \
+	libssp-0.dll
+endif
+
+ifeq (Darwin,$(OS_ARCH))
+OTR_LIBS := libotr.5.dylib
+endif
+
+ifeq (Linux,$(OS_ARCH))
+OTR_LIBS := libotr.so.5
+endif
+
+OTR_LIB_PATHS := $(foreach otrlib,$(OTR_LIBS),$(TB_LIBOTR_PREBUILT)/$(otrlib))
+
+libs:: $(OTR_LIB_PATHS)
+	$(NSINSTALL) -t -m 755 $(OTR_LIB_PATHS) $(DIST)/bin
+
+endif   ## TB_LIBOTR_PREBUILT
new file mode 100644
--- /dev/null
+++ b/third_party/moz.build
@@ -0,0 +1,10 @@
+# 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/.
+
+if CONFIG['TB_LIBOTR_PREBUILT']:
+    DEFINES['TB_LIBOTR_PREBUILT'] = CONFIG['TB_LIBOTR_PREBUILT']
+
+    if CONFIG['HAVE_64BIT_BUILD']:
+        DEFINES['HAVE_64BIT_BUILD'] = True