Bug 1573566 - Move the real libxul definition in a subdirectory. r=froydnj
authorMike Hommey <mh+mozilla@glandium.org>
Fri, 16 Aug 2019 21:44:10 +0000
changeset 488603 14329e051f16ca0f31b85c9ee093114b1c7c82f7
parent 488602 d7b5e712bf67506589579e37c162590064e5d950
child 488604 295a5e78ed1ea7ace9d1f10fb9192cb819f76b2f
push id92848
push usermh@glandium.org
push dateFri, 16 Aug 2019 22:01:44 +0000
treeherderautoland@c51ba76790c0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1573566
milestone70.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1573566 - Move the real libxul definition in a subdirectory. r=froydnj The current setup, where gtest/libxul uses the static library in the same directory as the shared libxul, and somehow the backend ignores gkrust for gtest/libxul, is fragile. Differential Revision: https://phabricator.services.mozilla.com/D42246
.flake8
build/gecko_templates.mozbuild
toolkit/library/build/dependentlibs.py
toolkit/library/build/moz.build
toolkit/library/dependentlibs.py
toolkit/library/gtest/moz.build
toolkit/library/moz.build
--- a/.flake8
+++ b/.flake8
@@ -40,17 +40,17 @@ exclude =
     testing/tools/iceserver/iceserver.py,
     testing/tools/view_gecko_profile/view_gecko_profile.py,
     testing/tools/websocketprocessbridge/websocketprocessbridge.py,
     testing/web-platform,
     toolkit/components/featuregates,
     toolkit/content/tests/chrome/file_about_networking_wsh.py,
     toolkit/crashreporter/tools/symbolstore.py,
     toolkit/crashreporter/tools/unit-symbolstore.py,
-    toolkit/library/dependentlibs.py,
+    toolkit/library/build/dependentlibs.py,
     toolkit/locales/generate_update_locale.py,
     toolkit/mozapps,
     toolkit/moz.configure,
     toolkit/nss.configure,
 
     # These paths are intentionally excluded (not necessarily for good reason).
     build/build-infer/build-infer.py,
     build/moz.configure/*.configure,
--- a/build/gecko_templates.mozbuild
+++ b/build/gecko_templates.mozbuild
@@ -20,17 +20,17 @@ def GeckoBinary(linkage='dependent', moz
     `mozglue` indicates whether to link against the mozglue library, and if
     so, what linkage to apply. Valid values are None (mozglue not linked),
     'program' (mozglue linked to an executable program), or 'library' (mozglue
     linked to a shared library).
     '''
     if linkage == 'dependent':
         USE_LIBS += [
             'nspr',
-            'xul',
+            'xul-real',
         ]
     elif linkage == 'standalone':
         DEFINES['XPCOM_GLUE'] = True
 
         USE_LIBS += [
             'xpcomglue',
         ]
     elif linkage != None:
rename from toolkit/library/dependentlibs.py
rename to toolkit/library/build/dependentlibs.py
new file mode 100644
--- /dev/null
+++ b/toolkit/library/build/moz.build
@@ -0,0 +1,32 @@
+# -*- 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/.
+
+USE_LIBS += [
+    'static:xul',
+]
+
+# This library is entirely composed of Rust code, and needs to come after
+# all the C++ code so any possible C++ -> Rust calls can be resolved.
+USE_LIBS += ['gkrust']
+
+Libxul('xul-real')
+
+if CONFIG['COMPILE_ENVIRONMENT']:
+    if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('cocoa', 'uikit'):
+        full_libname = SHARED_LIBRARY_NAME
+    else:
+        full_libname = '%s%s%s' % (
+            CONFIG['DLL_PREFIX'],
+            SHARED_LIBRARY_NAME,
+            CONFIG['DLL_SUFFIX']
+        )
+    GENERATED_FILES += [('dependentlibs.list', 'dependentlibs.list.gtest')]
+    dep_libs_list = GENERATED_FILES[('dependentlibs.list', 'dependentlibs.list.gtest')]
+    dep_libs_list.script = 'dependentlibs.py:gen_list'
+    dep_libs_list.inputs = [
+        '!%s' % full_libname,
+    ]
+    FINAL_TARGET_FILES += ['!dependentlibs.list', '!dependentlibs.list.gtest']
--- a/toolkit/library/gtest/moz.build
+++ b/toolkit/library/gtest/moz.build
@@ -15,28 +15,10 @@ if CONFIG['ENABLE_TESTS']:
         UNIFIED_SOURCES += [
             'TestUCRTDepends.cpp',
         ]
 
 USE_LIBS += [
     'static:xul',
 ]
 
-if CONFIG['OS_ARCH'] == 'Linux' and CONFIG['OS_TARGET'] != 'Android':
-    GENERATED_FILES += ['symverscript']
-    GENERATED_FILES['symverscript'].script = '/build/gen_symverscript.py'
-    GENERATED_FILES['symverscript'].inputs = ['../symverscript.in']
-    GENERATED_FILES['symverscript'].flags = [
-        'xul%s' % CONFIG['MOZILLA_SYMBOLVERSION']
-    ]
-    SYMBOLS_FILE = '!symverscript'
-
-# Generate GDB pretty printer-autoload files only on Linux. OSX's GDB is
-# too old to support Python pretty-printers; if this changes, we could
-# make this 'ifdef GNU_CC'.
-if CONFIG['OS_ARCH'] == 'Linux':
-    # Create a GDB Python auto-load file alongside the libxul shared library
-    # in the build directory.
-    DEFINES['topsrcdir'] = TOPSRCDIR
-    OBJDIR_PP_FILES.toolkit.library.gtest += ['../libxul.so-gdb.py.in']
-
 Libxul('xul-gtest',
        output_category=None if CONFIG['LINK_GTEST_DURING_COMPILE'] else 'gtest')
--- a/toolkit/library/moz.build
+++ b/toolkit/library/moz.build
@@ -79,39 +79,66 @@ def Libxul(name, output_category=None):
         LDFLAGS += ['-Wl,-U,_OBJC_CLASS_$_NSCustomTouchBarItem']
         LDFLAGS += ['-lresolv']
 
     if CONFIG['MOZ_DEBUG_SYMBOLS'] and CONFIG['CC_TYPE'] == 'clang-cl':
         LDFLAGS += ['-NATVIS:%s/toolkit/library/gecko.natvis' % TOPSRCDIR]
     if CONFIG['RUSTC_NATVIS_LDFLAGS']:
         LDFLAGS += CONFIG['RUSTC_NATVIS_LDFLAGS']
 
-Libxul('xul')
+    if CONFIG['OS_ARCH'] == 'Linux' and CONFIG['OS_TARGET'] != 'Android':
+        GENERATED_FILES += ['symverscript']
+        GENERATED_FILES['symverscript'].script = '/build/gen_symverscript.py'
+        GENERATED_FILES['symverscript'].inputs = ['../symverscript.in']
+        GENERATED_FILES['symverscript'].flags = [
+            'xul%s' % CONFIG['MOZILLA_SYMBOLVERSION']
+        ]
+        SYMBOLS_FILE = '!symverscript'
 
-FORCE_STATIC_LIB = True
+    # Generate GDB pretty printer-autoload files only on Linux. OSX's GDB is
+    # too old to support Python pretty-printers; if this changes, we could
+    # make this 'ifdef GNU_CC'.
+    if CONFIG['OS_ARCH'] == 'Linux':
+        # Create a GDB Python auto-load file alongside the libxul shared library
+        # in the build directory.
+        DEFINES['topsrcdir'] = TOPSRCDIR
+        OBJDIR_PP_FILES.toolkit.library.gtest += ['../libxul.so-gdb.py.in']
+
+
+# The real libxul definition is in ./build/moz.build, but we define a
+# xul library here such that # FINAL_LIBRARY = 'xul' refers to here, which
+# is then linked to both build/libxul and gtest/libxul.
+Library('xul')
 
 STATIC_LIBRARY_NAME = 'xul_s'
 
+# Use a FINAL_LIBRARY for Libxul_defines to propagate from there. They wouldn't
+# propagate from here.
+FINAL_LIBRARY = 'xul-real'
+
 if CONFIG['OS_ARCH'] == 'WINNT':
     SOURCES += [
         'nsDllMain.cpp',
     ]
 
 LOCAL_INCLUDES += [
     '/config',
     # need widget/windows for resource.h (included from widget.rc)
     '/widget/windows',
 ]
 
 if CONFIG['OS_ARCH'] == 'WINNT' and CONFIG['CC_TYPE'] not in ('clang', 'gcc'):
     LOCAL_INCLUDES += [
         '/xpcom/base',
     ]
 
-DIRS += ['gtest']
+DIRS += [
+    'build',
+    'gtest',
+]
 
 if CONFIG['OS_ARCH'] == 'WINNT':
   DIRS += ['dummydll']
 
 # js needs to come after xul for now, because it is an archive and its content
 # is discarded when it comes first.
 USE_LIBS += [
     'js',
@@ -329,63 +356,24 @@ if CONFIG['OS_ARCH'] == 'WINNT':
         ]
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':
     OS_LIBS += [
         'usp10',
         'oleaut32',
     ]
 
-if CONFIG['COMPILE_ENVIRONMENT']:
-    if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('cocoa', 'uikit'):
-        full_libname = SHARED_LIBRARY_NAME
-    else:
-        full_libname = '%s%s%s' % (
-            CONFIG['DLL_PREFIX'],
-            LIBRARY_NAME,
-            CONFIG['DLL_SUFFIX']
-        )
-    GENERATED_FILES += [('dependentlibs.list', 'dependentlibs.list.gtest')]
-    dep_libs_list = GENERATED_FILES[('dependentlibs.list', 'dependentlibs.list.gtest')]
-    dep_libs_list.script = 'dependentlibs.py:gen_list'
-    dep_libs_list.inputs = [
-        '!%s' % full_libname,
-    ]
-    FINAL_TARGET_FILES += ['!dependentlibs.list', '!dependentlibs.list.gtest']
-
-    if CONFIG['OS_ARCH'] == 'Linux' and CONFIG['OS_TARGET'] != 'Android':
-        GENERATED_FILES += ['symverscript']
-        GENERATED_FILES['symverscript'].script = '/build/gen_symverscript.py'
-        GENERATED_FILES['symverscript'].inputs = ['symverscript.in']
-        GENERATED_FILES['symverscript'].flags = [
-            'xul%s' % CONFIG['MOZILLA_SYMBOLVERSION']
-        ]
-        SYMBOLS_FILE = '!symverscript'
-
-    # Generate GDB pretty printer-autoload files only on Linux. OSX's GDB is
-    # too old to support Python pretty-printers; if this changes, we could
-    # make this 'ifdef GNU_CC'.
-    if CONFIG['OS_ARCH'] == 'Linux':
-        # Create a GDB Python auto-load file alongside the libxul shared library
-        # in the build directory.
-        DEFINES['topsrcdir'] = TOPSRCDIR
-        OBJDIR_PP_FILES.toolkit.library += ['libxul.so-gdb.py.in']
-
-# This library is entirely composed of Rust code, and needs to come after
-# all the C++ code so any possible C++ -> Rust calls can be resolved.
-USE_LIBS += ['gkrust']
-
 # The buildid is refreshed on every (incremental) build. But we want to avoid
 # rebuilding libxul every time, so instead of having a source file that
 # #include's buildid.h, which would have a dependency on it, and that would
 # thus trigger make to rebuild everything, we generate a source with the
 # buildid hard coded in it. Then we make that source file depend on all the
 # objects files that constitute libxul, so that if any of the files linked into
 # libxul is rebuilt, we refresh the buildid and link it into libxul.
 SOURCES += ['!buildid.cpp']
 GENERATED_FILES += ['buildid.cpp']
 GENERATED_FILES['buildid.cpp'].script = 'gen_buildid.py'
 if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('cocoa', 'uikit'):
     libxul_list = 'XUL'
 else:
     libxul_list = '%sxul_%s' % (
         CONFIG['DLL_PREFIX'], CONFIG['DLL_SUFFIX'].lstrip('.'))
-GENERATED_FILES['buildid.cpp'].inputs = ['!%s.list' % libxul_list]
+GENERATED_FILES['buildid.cpp'].inputs = ['!build/%s.list' % libxul_list]