Bug 988168 - Better integrate gtest libxul in the build system. r=mshal
☠☠ backed out by 2db12b4898e2 ☠ ☠
authorMike Hommey <mh+mozilla@glandium.org>
Sat, 29 Mar 2014 07:50:08 +0900
changeset 194509 ca413634eba3d4b9d7c493a6da41c78ab869b2c0
parent 194508 05a22543378bacadca314c7e8d1603ab742df2ac
child 194510 b714220dd39d499d24d4955133332de267df84e4
push id3624
push userasasaki@mozilla.com
push dateMon, 09 Jun 2014 21:49:01 +0000
treeherdermozilla-beta@b1a5da15899a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmshal
bugs988168
milestone31.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 988168 - Better integrate gtest libxul in the build system. r=mshal
CLOBBER
config/config.mk
content/media/gtest/moz.build
gfx/tests/gtest/moz.build
security/manager/ssl/tests/gtest/moz.build
testing/gtest/moz.build
toolkit/library/Makefile.in
toolkit/library/build/Makefile.in
toolkit/library/build/moz.build
toolkit/library/gtest/Makefile.in
toolkit/library/gtest/moz.build
toolkit/library/libxul.mk
toolkit/library/libxul.mozbuild
toolkit/library/moz.build
xpcom/glue/tests/gtest/moz.build
--- a/CLOBBER
+++ b/CLOBBER
@@ -17,9 +17,9 @@
 #
 # Modifying this file will now automatically clobber the buildbot machines \o/
 #
 
 # Are you updating CLOBBER because you think it's needed for your WebIDL
 # changes to stick? As of bug 928195, this shouldn't be necessary! Please
 # don't change CLOBBER for WebIDL changes any more.
 
-Bug 957865 - Non-clobbered ASAN builds were failing all mochitests after the clang upgrade
+Bug 988168 requires a clobber because of the location change for the linked libxul.
--- a/config/config.mk
+++ b/config/config.mk
@@ -335,28 +335,28 @@ endif
 #
 # Build using PIC by default
 #
 _ENABLE_PIC=1
 
 # Determine if module being compiled is destined
 # to be merged into libxul
 
-ifneq (,$(filter xul,$(FINAL_LIBRARY) $(LIBRARY_NAME)))
+ifneq (,$(filter xul xul-%,$(FINAL_LIBRARY) $(LIBRARY_NAME)))
   ifdef LIBXUL_LIBRARY
     $(error LIBRARY_NAME or FINAL_LIBRARY is "xul", LIBXUL_LIBRARY is implied)
   endif
   LIBXUL_LIBRARY := 1
 endif
 
 ifdef LIBXUL_LIBRARY
 ifdef IS_COMPONENT
 $(error IS_COMPONENT is set, but is not compatible with LIBXUL_LIBRARY)
 endif
-ifneq (xul,$(LIBRARY_NAME))
+ifeq (,$(filter xul xul-%,$(LIBRARY_NAME)))
 FORCE_STATIC_LIB=1
 endif
 endif
 
 # If we are building this component into an extension/xulapp, it cannot be
 # statically linked. In the future we may want to add a xulapp meta-component
 # build option.
 
--- a/content/media/gtest/moz.build
+++ b/content/media/gtest/moz.build
@@ -6,18 +6,17 @@
 
 LIBRARY_NAME = 'media_gtest'
 
 UNIFIED_SOURCES += [
     'TestAudioCompactor.cpp',
     'TestTrackEncoder.cpp',
 ]
 
-LIBXUL_LIBRARY = True
-
 EXPORT_LIBRARY = True
 
 include('/ipc/chromium/chromium-config.mozbuild')
 
 LOCAL_INCLUDES += [
     '/content/media/encoder',
 ]
 
+FINAL_LIBRARY = 'xul-gtest'
--- a/gfx/tests/gtest/moz.build
+++ b/gfx/tests/gtest/moz.build
@@ -34,20 +34,19 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'wind
         'TestPoint.cpp',
         'TestScaling.cpp',
     ]]
     UNIFIED_SOURCES += [
         'TestMoz2D.cpp',
         'TestRect.cpp',
     ]
 
-LIBXUL_LIBRARY = True
-
 EXPORT_LIBRARY = True
 
 include('/ipc/chromium/chromium-config.mozbuild')
 
 LOCAL_INCLUDES += [
     '/gfx/2d',
     '/gfx/2d/unittest',
     '/gfx/layers',
 ]
 
+FINAL_LIBRARY = 'xul-gtest'
--- a/security/manager/ssl/tests/gtest/moz.build
+++ b/security/manager/ssl/tests/gtest/moz.build
@@ -1,22 +1,22 @@
 # -*- Mode: python; c-basic-offset: 4; 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/.
 
 LIBRARY_NAME = 'ssltest'
 
-LIBXUL_LIBRARY = True
-
 SOURCES += [
     'OCSPCacheTest.cpp',
     'TLSIntoleranceTest.cpp',
 ]
 
 LOCAL_INCLUDES += [
     '../../../../certverifier',
     '../../../../pkix/include',
     '/security/manager/ssl/src',
 ]
 
 include('/ipc/chromium/chromium-config.mozbuild')
+
+FINAL_LIBRARY = 'xul-gtest'
--- a/testing/gtest/moz.build
+++ b/testing/gtest/moz.build
@@ -58,19 +58,18 @@ SOURCES += [
 ]
 
 LIBRARY_NAME = 'gtest'
 
 SOURCES += [
     'mozilla/SanityTest.cpp',
 ]
 
-LIBXUL_LIBRARY = True
-
 EXPORT_LIBRARY = True
 
 LOCAL_INCLUDES += [
     'gmock',
     'gmock/include',
     'gtest',
     'gtest/include',
 ]
 
+FINAL_LIBRARY = 'xul-gtest'
--- a/toolkit/library/Makefile.in
+++ b/toolkit/library/Makefile.in
@@ -1,335 +1,29 @@
 # 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/.
 
-ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
-# This is going to be a framework named "XUL", not an ordinary library named
-# "libxul.dylib"
-SHARED_LIBRARY_NAME=XUL
-# Setting MAKE_FRAMEWORK makes DLL_PREFIX and DLL_SUFFIX be ignored when
-# setting SHARED_LIBRARY; we need to leave DLL_PREFIX and DLL_SUFFIX
-# as-is so that dependencies of the form -ltracemalloc still work.
-MAKE_FRAMEWORK=1
-endif
-
 ifdef MOZ_CONTENT_SANDBOX
 ifeq ($(OS_ARCH),WINNT)
   SHARED_LIBRARY_LIBS += ../../security/sandbox/win/src/sandboxbroker/$(LIB_PREFIX)sandboxbroker.$(LIB_SUFFIX)
 endif
 endif
 
 # COMPONENT_LIBS is mosly useless since bug 935881, but is kept for
 # MOZ_APP_COMPONENT_LIBS, used by comm-central, and gtest linking.
 SHARED_LIBRARY_LIBS += \
   $(foreach component,$(COMPONENT_LIBS),$(DEPTH)/staticlib/$(LIB_PREFIX)$(component).$(LIB_SUFFIX)) \
   $(NULL)
 
-# dependent libraries
-ifdef MOZ_B2G_BT_BLUEZ #{
-ifeq (gonk,$(MOZ_WIDGET_TOOLKIT))
-OS_LIBS += -ldbus
-endif
-endif #}
-
-ifdef MOZ_B2G_CAMERA #{
-OS_LIBS += -lstagefright -lstagefright_omx
-endif #}
-
-ifeq (Linux,$(OS_ARCH))
-ifneq (Android,$(OS_TARGET))
-OS_LIBS += -lrt
-EXTRA_DSO_LDOPTS += -Wl,-version-script,symverscript
-
-symverscript: symverscript.in
-	$(call py_action,preprocessor, \
-		-DVERSION='$(LIBRARY_NAME)$(MOZILLA_SYMBOLVERSION)' $< -o $@)
-
-EXTRA_DEPS += symverscript
-endif
-endif
-
 ifdef MOZ_APP_COMPONENT_LIBS
 COMPONENT_LIBS += $(MOZ_APP_COMPONENT_LIBS)
 endif
 
 ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
-OS_LIBS += -lcups
-endif
-
-EXTRA_DSO_LDOPTS += \
-  $(LIBS_DIR) \
-  $(MOZ_JS_LIBS) \
-  $(NSS_LIBS) \
-  $(MOZ_CAIRO_OSLIBS) \
-  $(MOZ_APP_EXTRA_LIBS) \
-  $(SQLITE_LIBS) \
-  $(NULL)
-
-ifdef ENABLE_INTL_API
-ifdef JS_SHARED_LIBRARY
-EXTRA_DSO_LDOPTS += $(MOZ_ICU_LIBS)
-endif
-endif
-
-ifdef MOZ_NATIVE_JPEG
-EXTRA_DSO_LDOPTS += $(MOZ_JPEG_LIBS)
-endif
-
-ifdef MOZ_NATIVE_PNG
-EXTRA_DSO_LDOPTS += $(MOZ_PNG_LIBS)
-endif
-
-ifndef ZLIB_IN_MOZGLUE
-EXTRA_DSO_LDOPTS += $(MOZ_ZLIB_LIBS)
-endif
-
-ifdef MOZ_NATIVE_HUNSPELL
-EXTRA_DSO_LDOPTS += $(MOZ_HUNSPELL_LIBS)
-endif
-
-ifdef MOZ_NATIVE_LIBEVENT
-EXTRA_DSO_LDOPTS += $(MOZ_LIBEVENT_LIBS)
-endif
-
-ifdef MOZ_NATIVE_LIBVPX
-EXTRA_DSO_LDOPTS += $(MOZ_LIBVPX_LIBS)
-endif
-
-ifndef MOZ_TREE_PIXMAN
-EXTRA_DSO_LDOPTS += $(MOZ_PIXMAN_LIBS)
-endif
-
-ifdef MOZ_DMD
-EXTRA_DSO_LDOPTS += $(call EXPAND_LIBNAME_PATH,dmd,$(DIST)/lib)
-endif
-
-EXTRA_DSO_LDOPTS += $(call EXPAND_LIBNAME_PATH,gkmedias,$(DIST)/lib)
-
-ifdef MOZ_WEBRTC
-ifeq (WINNT,$(OS_TARGET))
-ifndef MOZ_HAS_WINSDK_WITH_D3D
-EXTRA_DSO_LDOPTS += \
-  -LIBPATH:'$(MOZ_DIRECTX_SDK_PATH)/lib/$(MOZ_DIRECTX_SDK_CPU_SUFFIX)' \
-  $(NULL)
-endif
-OS_LIBS += $(call EXPAND_LIBNAME,secur32 crypt32 iphlpapi strmiids dmoguids wmcodecdspuuid amstrmid msdmo wininet)
-endif
-endif
-
-
-ifdef MOZ_ALSA
-EXTRA_DSO_LDOPTS += $(MOZ_ALSA_LIBS)
-endif
-
-ifdef HAVE_CLOCK_MONOTONIC
-EXTRA_DSO_LDOPTS += $(REALTIME_LIBS)
-endif
-
-ifeq (android,$(MOZ_WIDGET_TOOLKIT))
-OS_LIBS += -lGLESv2
-endif
-
-ifeq (gonk,$(MOZ_WIDGET_TOOLKIT))
-OS_LIBS += \
-  -lui \
-  -lmedia \
-  -lhardware_legacy \
-  -lhardware \
-  -lutils \
-  -lcutils \
-  -lsysutils \
-  -lcamera_client \
-  -lsensorservice \
-  -lstagefright \
-  -lstagefright_foundation \
-  -lstagefright_omx \
-  -lbinder \
-  -lgui \
-  $(NULL)
-endif
-
-ifneq (,$(filter rtsp,$(NECKO_PROTOCOLS)))
-OS_LIBS += -lstagefright_foundation
-endif
-
-ifdef MOZ_WMF
-OS_LIBS += $(call EXPAND_LIBNAME,mfuuid wmcodecdspuuid strmiids)
-endif
-
-ifdef MOZ_DIRECTSHOW
-OS_LIBS += $(call EXPAND_LIBNAME,dmoguids wmcodecdspuuid strmiids msdmo)
-endif
-
-ifneq (,$(filter WINNT,$(OS_ARCH)))
-SDK_LIBRARY = $(IMPORT_LIBRARY)
-else
-SDK_LIBRARY = $(SHARED_LIBRARY)
+CXXFLAGS += $(TK_CFLAGS)
 endif
 
-EXTRA_DSO_LDOPTS += $(LIBS_DIR)
-
-EXTRA_DSO_LDOPTS += $(NSPR_LIBS) $(MOZALLOC_LIB)
-
-ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
-CXXFLAGS += $(TK_CFLAGS)
-OS_LIBS += \
-  $(TK_LIBS) \
-  $(NULL)
-endif
-
-ifeq (OpenBSD,$(OS_ARCH))
-EXTRA_DSO_LDOPTS += -lsndio
-endif
-
-ifdef MOZ_ENABLE_DBUS
-EXTRA_DSO_LDOPTS += $(MOZ_DBUS_GLIB_LIBS)
-endif
-
-ifdef MOZ_WIDGET_GTK
-EXTRA_DSO_LDOPTS += $(TK_LIBS)
-EXTRA_DSO_LDOPTS += $(XLDFLAGS) $(XLIBS) $(XEXT_LIBS) $(XCOMPOSITE_LIBS) $(MOZ_PANGO_LIBS) $(XT_LIBS) -lgthread-2.0
-EXTRA_DSO_LDOPTS += $(FT2_LIBS)
-endif
-
-ifeq (qt,$(MOZ_WIDGET_TOOLKIT))
-EXTRA_DSO_LDOPTS += $(XLDFLAGS) $(XLIBS) $(XT_LIBS) $(MOZ_QT_LIBS)
-EXTRA_DSO_LDOPTS += $(FT2_LIBS) $(MOZ_PANGO_LIBS)
-endif
-
-ifdef MOZ_TREE_FREETYPE
-EXTRA_DSO_LDOPTS += $(FT2_LIBS)
-endif
-
-ifdef MOZ_ENABLE_STARTUP_NOTIFICATION
-EXTRA_DSO_LDOPTS += $(MOZ_STARTUP_NOTIFICATION_LIBS)
-endif
-
-ifdef MOZ_ENABLE_LIBPROXY
-EXTRA_DSO_LDOPTS += $(MOZ_LIBPROXY_LIBS)
-endif
-
-ifeq ($(OS_ARCH),SunOS)
-ifdef GNU_CC
-EXTRA_DSO_LDOPTS += -lelf
-else
-EXTRA_DSO_LDOPTS += -lelf -ldemangle
-endif
-endif
-
-ifneq (,$(filter DragonFly FreeBSD NetBSD OpenBSD,$(OS_ARCH)))
-OS_LIBS += $(call EXPAND_LIBNAME,kvm)
-endif
-
-ifeq ($(OS_ARCH),FreeBSD)
-OS_LIBS += $(call EXPAND_LIBNAME,util)
-endif
-
-ifeq ($(OS_ARCH),WINNT)
-OS_LIBS += $(call EXPAND_LIBNAME,shell32 ole32 version winspool comdlg32 imm32 msimg32 shlwapi psapi ws2_32 dbghelp rasapi32 rasdlg iphlpapi uxtheme setupapi secur32 sensorsapi portabledeviceguids windowscodecs wininet wbemuuid wintrust)
-ifdef ACCESSIBILITY
-OS_LIBS += $(call EXPAND_LIBNAME,oleacc)
-endif
-ifdef MOZ_METRO
-OS_LIBS += $(call EXPAND_LIBNAME,uiautomationcore runtimeobject)
-endif
-ifdef MOZ_GAMEPAD
-ifndef GNU_CC
-ifdef MOZ_HAS_WINSDK_WITH_D3D
-OS_LIBS += dxguid.lib dinput8.lib
-else
-DXSDK := $(subst \,/,$(MOZ_DIRECTX_SDK_PATH))/Lib/$(MOZ_DIRECTX_SDK_CPU_SUFFIX)
-OS_LIBS += \
-  '$(DXSDK)/dxguid.lib' \
-  '$(DXSDK)/dinput8.lib' \
-  $(NULL)
-endif
-else
-OS_LIBS += $(call EXPAND_LIBNAME,dxguid dinput8)
-endif
-endif
-endif # WINNT
-
-ifdef MOZ_JPROF
-EXTRA_DSO_LDOPTS += -ljprof
-endif
-
-ifdef MOZ_ENABLE_QT
-EXTRA_DSO_LDOPTS += $(MOZ_QT_LDFLAGS) $(XEXT_LIBS)
-endif
-
-ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
-ifdef MOZ_GSTREAMER
-EXTRA_DSO_LDOPTS += $(GSTREAMER_LIBS)
-endif
-endif
-
-# 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'.
-ifeq (Linux,$(OS_ARCH))
-# Create a GDB Python auto-load file alongside the libxul shared library in
-# the build directory.
-PP_TARGETS += LIBXUL_AUTOLOAD
-LIBXUL_AUTOLOAD = libxul.so-gdb.py.in
-LIBXUL_AUTOLOAD_FLAGS := -Dtopsrcdir=$(abspath $(topsrcdir))
-endif
-
-ifdef MAKE_FRAMEWORK
-EFFECTIVE_LIB_PREFIX=
-EFFECTIVE_LIB_SUFFIX=
-else
-EFFECTIVE_LIB_PREFIX=$(DLL_PREFIX)
-EFFECTIVE_LIB_SUFFIX=$(DLL_SUFFIX)
-endif
-
-GTEST_LIB = $(EFFECTIVE_LIB_PREFIX)gtest/$(EFFECTIVE_LIB_PREFIX)$(SHARED_LIBRARY_NAME)$(EFFECTIVE_LIB_SUFFIX)
-EXTRA_MDDEPEND_FILES = $(GTEST_LIB).pp
-
 include $(topsrcdir)/config/rules.mk
 
-OS_LIBS += $(LIBICONV)
-
-ifeq ($(MOZ_WIDGET_TOOLKIT),windows)
-OS_LIBS += $(call EXPAND_LIBNAME,usp10 oleaut32)
-endif
-
-ifeq (WINNT_1,$(OS_TARGET)_$(MOZ_PROFILE_USE))
-# Wrap linker to measure peak virtual memory usage.
-LD := $(PYTHON) $(topsrcdir)/build/link.py $(CURDIR)/linker-vsize $(LD)
-endif
-
-ifndef LINK_GTEST
-ifdef COMPILE_ENVIRONMENT
-libs:: $(FINAL_TARGET)/dependentlibs.list
-endif
-endif
-
 .PHONY: gtestxul
-
-$(FINAL_TARGET)/dependentlibs.list.gtest: $(FINAL_TARGET)/dependentlibs.list
-	sed -e 's|$(SHARED_LIBRARY)|gtest/$(SHARED_LIBRARY)|' $< > $@
-
-# Remove this target when actually linking gtest to prevent redefining
-# the implicit rules.mk target
-ifndef LINK_GTEST
-
-gtestxul: $(GTEST_LIB)
-
-$(GTEST_LIB): $(FINAL_TARGET)/dependentlibs.list.gtest
-	$(MKDIR) -p $(EFFECTIVE_LIB_PREFIX)gtest
-	$(MAKE) libs SHARED_LIBRARY_NAME=gtest/$(EFFECTIVE_LIB_PREFIX)$(LIBRARY_NAME) FINAL_TARGET=$(FINAL_TARGET)/gtest SDK_LIBRARY= IMPORT_LIB_DEST=$(IMPORT_LIB_DEST)/gtest LINK_GTEST=true
-endif
-
-ifdef LINK_GTEST
-
-COMPONENT_LIBS += \
-  gtest \
-  gfxtest \
-  ssltest \
-  xpcom_glue_gtest \
-  media_gtest \
-  $(NULL)
-endif
-
-$(FINAL_TARGET)/dependentlibs.list: dependentlibs.py $(SHARED_LIBRARY) $(wildcard $(if $(wildcard $(FINAL_TARGET)/dependentlibs.list),$(addprefix $(FINAL_TARGET)/,$(shell cat $(FINAL_TARGET)/dependentlibs.list))))
-	$(PYTHON) $< $(SHARED_LIBRARY) -L $(FINAL_TARGET) $(if $(TOOLCHAIN_PREFIX),$(addprefix -p ,$(TOOLCHAIN_PREFIX))) > $@
+gtestxul:
+	$(MAKE) -C gtest libs LINK_GTEST=1
new file mode 100644
--- /dev/null
+++ b/toolkit/library/build/Makefile.in
@@ -0,0 +1,20 @@
+# 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 $(topsrcdir)/toolkit/library/libxul.mk
+
+ifneq (,$(filter WINNT,$(OS_ARCH)))
+SDK_LIBRARY = $(IMPORT_LIBRARY)
+else
+SDK_LIBRARY = $(SHARED_LIBRARY)
+endif
+
+include $(topsrcdir)/config/rules.mk
+
+ifdef COMPILE_ENVIRONMENT
+libs:: $(FINAL_TARGET)/dependentlibs.list
+endif
+
+$(FINAL_TARGET)/dependentlibs.list: $(topsrcdir)/toolkit/library/dependentlibs.py $(SHARED_LIBRARY) $(wildcard $(if $(wildcard $(FINAL_TARGET)/dependentlibs.list),$(addprefix $(FINAL_TARGET)/,$(shell cat $(FINAL_TARGET)/dependentlibs.list))))
+	$(PYTHON) $< $(SHARED_LIBRARY) -L $(FINAL_TARGET) $(if $(TOOLCHAIN_PREFIX),$(addprefix -p ,$(TOOLCHAIN_PREFIX))) > $@
new file mode 100644
--- /dev/null
+++ b/toolkit/library/build/moz.build
@@ -0,0 +1,9 @@
+# -*- Mode: python; c-basic-offset: 4; 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/.
+
+LIBRARY_NAME = 'xul-shared'
+
+include('../libxul.mozbuild')
new file mode 100644
--- /dev/null
+++ b/toolkit/library/gtest/Makefile.in
@@ -0,0 +1,21 @@
+# 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/.
+
+ifndef LINK_GTEST
+# Force to not include backend.mk unless LINK_GTEST is defined.
+# Not including backend.mk makes traversing this directory do nothing.
+STANDALONE_MAKEFILE = 1
+
+else
+
+include $(topsrcdir)/toolkit/library/libxul.mk
+
+ifdef COMPILE_ENVIRONMENT
+libs:: $(DIST)/bin/dependentlibs.list.gtest
+endif
+
+$(DIST)/bin/dependentlibs.list.gtest: $(DIST)/bin/dependentlibs.list
+	sed -e 's|$(SHARED_LIBRARY)|gtest/$(SHARED_LIBRARY)|' $< > $@
+
+endif
new file mode 100644
--- /dev/null
+++ b/toolkit/library/gtest/moz.build
@@ -0,0 +1,11 @@
+# -*- Mode: python; c-basic-offset: 4; 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/.
+
+LIBRARY_NAME = 'xul-gtest'
+
+FINAL_TARGET = 'dist/bin/gtest'
+
+include('../libxul.mozbuild')
copy from toolkit/library/Makefile.in
copy to toolkit/library/libxul.mk
--- a/toolkit/library/Makefile.in
+++ b/toolkit/library/libxul.mk
@@ -5,29 +5,23 @@
 ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
 # This is going to be a framework named "XUL", not an ordinary library named
 # "libxul.dylib"
 SHARED_LIBRARY_NAME=XUL
 # Setting MAKE_FRAMEWORK makes DLL_PREFIX and DLL_SUFFIX be ignored when
 # setting SHARED_LIBRARY; we need to leave DLL_PREFIX and DLL_SUFFIX
 # as-is so that dependencies of the form -ltracemalloc still work.
 MAKE_FRAMEWORK=1
+else
+SHARED_LIBRARY_NAME=xul
 endif
 
-ifdef MOZ_CONTENT_SANDBOX
-ifeq ($(OS_ARCH),WINNT)
-  SHARED_LIBRARY_LIBS += ../../security/sandbox/win/src/sandboxbroker/$(LIB_PREFIX)sandboxbroker.$(LIB_SUFFIX)
-endif
-endif
+SHARED_LIBRARY_LIBS += $(call EXPAND_LIBNAME_PATH,xul,$(DEPTH)/toolkit/library)
 
-# COMPONENT_LIBS is mosly useless since bug 935881, but is kept for
-# MOZ_APP_COMPONENT_LIBS, used by comm-central, and gtest linking.
-SHARED_LIBRARY_LIBS += \
-  $(foreach component,$(COMPONENT_LIBS),$(DEPTH)/staticlib/$(LIB_PREFIX)$(component).$(LIB_SUFFIX)) \
-  $(NULL)
+EXTRA_DEPS += $(topsrcdir)/toolkit/library/libxul.mk
 
 # dependent libraries
 ifdef MOZ_B2G_BT_BLUEZ #{
 ifeq (gonk,$(MOZ_WIDGET_TOOLKIT))
 OS_LIBS += -ldbus
 endif
 endif #}
 
@@ -35,28 +29,24 @@ ifdef MOZ_B2G_CAMERA #{
 OS_LIBS += -lstagefright -lstagefright_omx
 endif #}
 
 ifeq (Linux,$(OS_ARCH))
 ifneq (Android,$(OS_TARGET))
 OS_LIBS += -lrt
 EXTRA_DSO_LDOPTS += -Wl,-version-script,symverscript
 
-symverscript: symverscript.in
+symverscript: $(topsrcdir)/toolkit/library/symverscript.in
 	$(call py_action,preprocessor, \
-		-DVERSION='$(LIBRARY_NAME)$(MOZILLA_SYMBOLVERSION)' $< -o $@)
+		-DVERSION='$(SHARED_LIBRARY_NAME)$(MOZILLA_SYMBOLVERSION)' $< -o $@)
 
 EXTRA_DEPS += symverscript
 endif
 endif
 
-ifdef MOZ_APP_COMPONENT_LIBS
-COMPONENT_LIBS += $(MOZ_APP_COMPONENT_LIBS)
-endif
-
 ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
 OS_LIBS += -lcups
 endif
 
 EXTRA_DSO_LDOPTS += \
   $(LIBS_DIR) \
   $(MOZ_JS_LIBS) \
   $(NSS_LIBS) \
@@ -111,17 +101,16 @@ ifndef MOZ_HAS_WINSDK_WITH_D3D
 EXTRA_DSO_LDOPTS += \
   -LIBPATH:'$(MOZ_DIRECTX_SDK_PATH)/lib/$(MOZ_DIRECTX_SDK_CPU_SUFFIX)' \
   $(NULL)
 endif
 OS_LIBS += $(call EXPAND_LIBNAME,secur32 crypt32 iphlpapi strmiids dmoguids wmcodecdspuuid amstrmid msdmo wininet)
 endif
 endif
 
-
 ifdef MOZ_ALSA
 EXTRA_DSO_LDOPTS += $(MOZ_ALSA_LIBS)
 endif
 
 ifdef HAVE_CLOCK_MONOTONIC
 EXTRA_DSO_LDOPTS += $(REALTIME_LIBS)
 endif
 
@@ -155,28 +144,21 @@ endif
 ifdef MOZ_WMF
 OS_LIBS += $(call EXPAND_LIBNAME,mfuuid wmcodecdspuuid strmiids)
 endif
 
 ifdef MOZ_DIRECTSHOW
 OS_LIBS += $(call EXPAND_LIBNAME,dmoguids wmcodecdspuuid strmiids msdmo)
 endif
 
-ifneq (,$(filter WINNT,$(OS_ARCH)))
-SDK_LIBRARY = $(IMPORT_LIBRARY)
-else
-SDK_LIBRARY = $(SHARED_LIBRARY)
-endif
-
 EXTRA_DSO_LDOPTS += $(LIBS_DIR)
 
 EXTRA_DSO_LDOPTS += $(NSPR_LIBS) $(MOZALLOC_LIB)
 
 ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
-CXXFLAGS += $(TK_CFLAGS)
 OS_LIBS += \
   $(TK_LIBS) \
   $(NULL)
 endif
 
 ifeq (OpenBSD,$(OS_ARCH))
 EXTRA_DSO_LDOPTS += -lsndio
 endif
@@ -265,71 +247,22 @@ endif
 
 # 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'.
 ifeq (Linux,$(OS_ARCH))
 # Create a GDB Python auto-load file alongside the libxul shared library in
 # the build directory.
 PP_TARGETS += LIBXUL_AUTOLOAD
-LIBXUL_AUTOLOAD = libxul.so-gdb.py.in
+LIBXUL_AUTOLOAD = $(topsrcdir)/toolkit/library/libxul.so-gdb.py.in
 LIBXUL_AUTOLOAD_FLAGS := -Dtopsrcdir=$(abspath $(topsrcdir))
 endif
 
-ifdef MAKE_FRAMEWORK
-EFFECTIVE_LIB_PREFIX=
-EFFECTIVE_LIB_SUFFIX=
-else
-EFFECTIVE_LIB_PREFIX=$(DLL_PREFIX)
-EFFECTIVE_LIB_SUFFIX=$(DLL_SUFFIX)
-endif
-
-GTEST_LIB = $(EFFECTIVE_LIB_PREFIX)gtest/$(EFFECTIVE_LIB_PREFIX)$(SHARED_LIBRARY_NAME)$(EFFECTIVE_LIB_SUFFIX)
-EXTRA_MDDEPEND_FILES = $(GTEST_LIB).pp
-
-include $(topsrcdir)/config/rules.mk
-
 OS_LIBS += $(LIBICONV)
 
 ifeq ($(MOZ_WIDGET_TOOLKIT),windows)
 OS_LIBS += $(call EXPAND_LIBNAME,usp10 oleaut32)
 endif
 
 ifeq (WINNT_1,$(OS_TARGET)_$(MOZ_PROFILE_USE))
 # Wrap linker to measure peak virtual memory usage.
 LD := $(PYTHON) $(topsrcdir)/build/link.py $(CURDIR)/linker-vsize $(LD)
 endif
-
-ifndef LINK_GTEST
-ifdef COMPILE_ENVIRONMENT
-libs:: $(FINAL_TARGET)/dependentlibs.list
-endif
-endif
-
-.PHONY: gtestxul
-
-$(FINAL_TARGET)/dependentlibs.list.gtest: $(FINAL_TARGET)/dependentlibs.list
-	sed -e 's|$(SHARED_LIBRARY)|gtest/$(SHARED_LIBRARY)|' $< > $@
-
-# Remove this target when actually linking gtest to prevent redefining
-# the implicit rules.mk target
-ifndef LINK_GTEST
-
-gtestxul: $(GTEST_LIB)
-
-$(GTEST_LIB): $(FINAL_TARGET)/dependentlibs.list.gtest
-	$(MKDIR) -p $(EFFECTIVE_LIB_PREFIX)gtest
-	$(MAKE) libs SHARED_LIBRARY_NAME=gtest/$(EFFECTIVE_LIB_PREFIX)$(LIBRARY_NAME) FINAL_TARGET=$(FINAL_TARGET)/gtest SDK_LIBRARY= IMPORT_LIB_DEST=$(IMPORT_LIB_DEST)/gtest LINK_GTEST=true
-endif
-
-ifdef LINK_GTEST
-
-COMPONENT_LIBS += \
-  gtest \
-  gfxtest \
-  ssltest \
-  xpcom_glue_gtest \
-  media_gtest \
-  $(NULL)
-endif
-
-$(FINAL_TARGET)/dependentlibs.list: dependentlibs.py $(SHARED_LIBRARY) $(wildcard $(if $(wildcard $(FINAL_TARGET)/dependentlibs.list),$(addprefix $(FINAL_TARGET)/,$(shell cat $(FINAL_TARGET)/dependentlibs.list))))
-	$(PYTHON) $< $(SHARED_LIBRARY) -L $(FINAL_TARGET) $(if $(TOOLCHAIN_PREFIX),$(addprefix -p ,$(TOOLCHAIN_PREFIX))) > $@
copy from toolkit/library/moz.build
copy to toolkit/library/libxul.mozbuild
--- a/toolkit/library/moz.build
+++ b/toolkit/library/libxul.mozbuild
@@ -1,75 +1,14 @@
 # -*- Mode: python; c-basic-offset: 4; 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/.
 
-LIBRARY_NAME = 'xul'
-
-SOURCES += [
-    'nsStaticXULComponents.cpp',
-]
-
-if CONFIG['OS_ARCH'] == 'WINNT':
-    SOURCES += [
-        'nsDllMain.cpp',
-    ]
-    if not CONFIG['GNU_CC']:
-        LOCAL_INCLUDES += [
-            '/widget/windows',
-            '/xpcom/base',
-        ]
-        RCINCLUDE = 'xulrunner.rc'
-
-# component libraries
-additional_defines = (
-    'MOZ_AUTH_EXTENSION',
-    'MOZ_GIO_COMPONENT',
-    'MOZ_JSDEBUGGER',
-    'MOZ_PERMISSIONS',
-    'MOZ_PREF_EXTENSIONS',
-    'MOZ_SPELLCHECK',
-    'MOZ_UNIVERSALCHARDET',
-    'MOZ_ZIPWRITER',
-)
-
-for var in additional_defines:
-    if CONFIG[var]:
-        DEFINES[var] = True
-
-if CONFIG['MOZ_DEBUG'] and CONFIG['ENABLE_TESTS']:
-    DEFINES['ENABLE_LAYOUTDEBUG'] = True
-
-if CONFIG['MOZ_WIDGET_TOOLKIT'] not in ('android', 'gonk', 'qt',
-                                        'cocoa', 'windows') and \
-   CONFIG['MOZ_XUL']:
-    DEFINES['MOZ_FILEVIEW'] = True
-
-# Platform-specific icon channel stuff - supported mostly-everywhere
-if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('windows', 'mac', 'cocoa',
-                                    'gtk2', 'gtk3', 'qt', 'android'):
-    DEFINES['ICON_DECODER'] = True
-
-LOCAL_INCLUDES += [
-    '/config',
-    # need widget/windows for resource.h (included from widget.rc)
-    '/widget/windows',
-]
-
-if CONFIG['OS_ARCH'] == 'WINNT' and not CONFIG['GNU_CC']:
-    LOCAL_INCLUDES += [
-        '/xpcom/base',
-    ]
-
-FAIL_ON_WARNINGS = True
-
-MSVC_ENABLE_PGO = True
-
 FORCE_SHARED_LIB = True
 
 DELAYLOAD_DLLS += [
     'comdlg32.dll',
     'dbghelp.dll',
     'psapi.dll',
     'rasapi32.dll',
     'rasdlg.dll',
--- a/toolkit/library/moz.build
+++ b/toolkit/library/moz.build
@@ -60,43 +60,9 @@ if CONFIG['OS_ARCH'] == 'WINNT' and not 
     LOCAL_INCLUDES += [
         '/xpcom/base',
     ]
 
 FAIL_ON_WARNINGS = True
 
 MSVC_ENABLE_PGO = True
 
-FORCE_SHARED_LIB = True
-
-DELAYLOAD_DLLS += [
-    'comdlg32.dll',
-    'dbghelp.dll',
-    'psapi.dll',
-    'rasapi32.dll',
-    'rasdlg.dll',
-    'secur32.dll',
-    'wininet.dll',
-    'winspool.drv'
-]
-
-if CONFIG['MOZ_METRO']:
-    DELAYLOAD_DLLS += [
-        'API-MS-WIN-CORE-WINRT-L' + CONFIG['CRTEXPDLLVERSION'] + '.DLL',
-        'API-MS-WIN-CORE-WINRT-STRING-L' + CONFIG['CRTEXPDLLVERSION'] + '.DLL',
-        'uiautomationcore.dll'
-    ]
-
-if CONFIG['ACCESSIBILITY']:
-    DELAYLOAD_DLLS += ['oleacc.dll']
-
-if CONFIG['MOZ_WEBRTC']:
-    DELAYLOAD_DLLS += ['msdmo.dll']
-
-if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
-    LDFLAGS += [
-        '-framework OpenGL',
-        '-framework SystemConfiguration',
-        '-framework QTKit',
-        '-framework IOKit',
-        '-F%s' % CONFIG['MACOS_PRIVATE_FRAMEWORKS_DIR'],
-        '-framework CoreUI',
-    ]
+DIRS += ['build', 'gtest']
--- a/xpcom/glue/tests/gtest/moz.build
+++ b/xpcom/glue/tests/gtest/moz.build
@@ -10,12 +10,11 @@ UNIFIED_SOURCES += [
 ]
 
 LOCAL_INCLUDES = [
     '../..',
 ]
 
 LIBRARY_NAME = 'xpcom_glue_gtest'
 
-LIBXUL_LIBRARY = True
-
 EXPORT_LIBRARY = True
 
+FINAL_LIBRARY = 'xul-gtest'