Bug 345517 - Build Firefox --enable-libxul by default, r=darin/mento
git-svn-id: svn://10.0.0.236/trunk@206971 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -35,6 +35,9 @@
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
# This makefile links all the static components which have EXPORT_LIBRARY
|
||||
# set into a single component DLL.
|
||||
|
||||
DEPTH = ../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
@@ -42,131 +45,32 @@ VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
ifdef MOZ_STATIC_COMPONENTS
|
||||
MODULE = staticmod
|
||||
LIBRARY_NAME = staticmod
|
||||
SHORT_LIBNAME = statcmod
|
||||
endif
|
||||
|
||||
LIBRARY_NAME = appmeta
|
||||
IS_COMPONENT = 1
|
||||
FORCE_SHARED_LIB = 1
|
||||
|
||||
CPPSRCS = nsMetaModule.cpp
|
||||
|
||||
REQUIRES = xpcom
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
REQUIRES = xpcom \
|
||||
$(NULL)
|
||||
FINAL_COMPONENT_LIBS := $(shell cat $(FINAL_LINK_COMPS))
|
||||
FINAL_LINK_LIBS := $(shell cat $(FINAL_LINK_LIBS))
|
||||
|
||||
ifdef MOZ_STATIC_COMPONENTS
|
||||
CPPSRCS = nsStaticModule.cpp
|
||||
endif
|
||||
|
||||
LOCAL_INCLUDES = -I$(srcdir)
|
||||
|
||||
#
|
||||
# _COMPONENT_BASE is the base name of the meta component library
|
||||
# that we are building in the current pass of this makefile
|
||||
#
|
||||
# mozcomps is a special name used to specify that we want to link all
|
||||
# of the non-meta components into this special meta component
|
||||
#
|
||||
ifdef _COMPONENT_BASE
|
||||
ifeq ($(_COMPONENT_BASE),mozcomps)
|
||||
_FINAL_COMPONENT_NAMES := $(shell cat $(FINAL_LINK_COMP_NAMES))
|
||||
_FINAL_COMPONENT_LIBS := $(shell cat $(FINAL_LINK_COMPS))
|
||||
_FINAL_LINK_LIBS := $(shell cat $(FINAL_LINK_LIBS))
|
||||
_META_COMPONENT_NAMES := _FINAL_COMPONENT_NAMES
|
||||
_META_COMPONENT_LIBS := _FINAL_COMPONENT_LIBS
|
||||
_META_DEP_LIBS := _FINAL_LINK_LIBS
|
||||
else
|
||||
_META_COMPONENT_NAMES := MOZ_META_COMPONENTS_$(_COMPONENT_BASE)
|
||||
_META_COMPONENT_LIBS := MOZ_META_COMPONENTS_$(_COMPONENT_BASE)_comps
|
||||
_META_DEP_LIBS := MOZ_META_COMPONENTS_$(_COMPONENT_BASE)_libs
|
||||
endif # mozcomps
|
||||
endif # _COMPONENT_BASE
|
||||
|
||||
ifdef MOZ_STATIC_COMPONENTS
|
||||
SHARED_LIBRARY_LIBS = \
|
||||
$(foreach m, $(MOZ_STATIC_COMPONENTS), $(DIST)/lib/components/$(LIB_PREFIX)$(m).$(LIB_SUFFIX))
|
||||
endif
|
||||
$(foreach c,$(FINAL_COMPONENT_LIBS),$(DIST)/lib/components/$(LIB_PREFIX)$(c).$(LIB_SUFFIX)) \
|
||||
$(foreach l,$(FINAL_LINK_LIBS),$(DIST)/lib/$(LIB_PREFIX)$(l).$(LIB_SUFFIX)) \
|
||||
$(NULL)
|
||||
|
||||
ifdef _COMPONENT_BASE
|
||||
ifneq ($(_COMPONENT_BASE),mozcomps)
|
||||
SHARED_LIBRARY_LIBS = $(foreach m,$($(_META_COMPONENT_LIBS)), $(DIST)/lib/components/$(LIB_PREFIX)$(m).$(LIB_SUFFIX))
|
||||
EXTRA_DSO_LDOPTS += $(foreach m,$($(_META_DEP_LIBS)), $(DIST)/lib/$(LIB_PREFIX)$(m).$(LIB_SUFFIX))
|
||||
endif
|
||||
endif
|
||||
|
||||
#
|
||||
# Create each meta component by calling this makefile recursively
|
||||
# and forcing it to built a shared library meta component library
|
||||
#
|
||||
ifndef NO_RECURSE
|
||||
libs clean distclean clobber realclean clobber_all::
|
||||
set -e; \
|
||||
for f in $(MOZ_META_COMPONENTS); do \
|
||||
$(MAKE) NO_RECURSE=1 BUILD_STATIC_LIBS= LIBRARY_NAME=meta_$$f CPPSRCS=nsMetaModule_$$f.cpp _COMPONENT_BASE=$$f $@ ; \
|
||||
done
|
||||
endif
|
||||
|
||||
ifeq ($(LIBRARY_NAME),meta_mozcomps)
|
||||
include $(topsrcdir)/config/static-config.mk
|
||||
EXTRA_DSO_LIBS = $(STATIC_EXTRA_DSO_LIBS)
|
||||
endif
|
||||
EXTRA_DSO_LDOPTS = \
|
||||
$(XPCOM_GLUE_LDOPTS) \
|
||||
$(NSPR_LIBS) \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
ifeq ($(LIBRARY_NAME),meta_mozcomps)
|
||||
include $(topsrcdir)/config/static-rules.mk
|
||||
endif
|
||||
|
||||
ifdef MOZ_STATIC_COMPONENTS
|
||||
EXTRA_DSO_LDOPTS += \
|
||||
$(ZLIB_LIBS) \
|
||||
$(XPCOM_LIBS) \
|
||||
$(MOZ_JS_LIBS) \
|
||||
$(NSPR_LIBS) \
|
||||
$(PNG_LIBS)
|
||||
endif
|
||||
|
||||
ifdef MOZ_META_COMPONENTS
|
||||
# Force XPCOM_TRANSLATE_NSGM_ENTRY_POINT to be defined so the macros
|
||||
# in nsIGenericFactory.h will come out in the wash.
|
||||
DEFINES += -DMETA_MODULE=\"$(LIBRARY_NAME)\" -DXPCOM_TRANSLATE_NSGM_ENTRY_POINT
|
||||
|
||||
ifeq ($(LIBRARY_NAME),meta_mail)
|
||||
EXTRA_DSO_LDOPTS += \
|
||||
$(LIBS_DIR) \
|
||||
$(call EXPAND_MOZLIBNAME,xpcom_compat gkgfx rdfutil_s) \
|
||||
$(MOZ_UNICHARUTIL_LIBS) \
|
||||
$(MOZ_COMPONENT_LIBS) \
|
||||
$(TK_LIBS) \
|
||||
$(NULL)
|
||||
endif # meta_mail
|
||||
|
||||
ifeq ($(LIBRARY_NAME),meta_crypto)
|
||||
EXTRA_DSO_LDOPTS += \
|
||||
$(MOZ_JS_LIBS) \
|
||||
$(NSS_LIBS) \
|
||||
$(MOZ_UNICHARUTIL_LIBS) \
|
||||
$(MOZ_COMPONENT_LIBS) \
|
||||
$(NULL)
|
||||
endif # meta_crypto
|
||||
|
||||
ifeq ($(LIBRARY_NAME),meta_mozcomps)
|
||||
|
||||
# We don't want to link mozcomps against NSS if not necessary
|
||||
ifneq (,$(findstring crypto,$(MOZ_META_COMPONENTS)))
|
||||
STATIC_EXTRA_LIBS := $(filter-out $(NSS_LIBS),$(STATIC_EXTRA_LIBS))
|
||||
endif
|
||||
|
||||
EXTRA_DSO_LDOPTS += \
|
||||
$(LIBS_DIR) \
|
||||
$(EXTRA_DSO_LIBS) \
|
||||
$(STATIC_EXTRA_LIBS) \
|
||||
$(MOZ_JS_LIBS) \
|
||||
$(MOZ_UNICHARUTIL_LIBS) \
|
||||
$(MOZ_COMPONENT_LIBS) \
|
||||
$(TK_LIBS) \
|
||||
$(NULL)
|
||||
DEFINES += -DXPCOM_TRANSLATE_NSGM_ENTRY_POINT
|
||||
|
||||
ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
|
||||
OS_LIBS += -framework QuickTime
|
||||
@@ -176,39 +80,32 @@ ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
|
||||
OS_LIBS += -framework Cocoa
|
||||
endif
|
||||
|
||||
endif # meta_mozcomps
|
||||
|
||||
endif # MOZ_META_COMPONENTS
|
||||
|
||||
ifeq ($(OS_ARCH),WINNT)
|
||||
OS_LIBS += ole32.lib shell32.lib
|
||||
OS_LIBS += $(call EXPAND_LIBNAME,comctl32 comdlg32 uuid shell32 ole32 oleaut32 version winspool imm32)
|
||||
# XXX temporary workaround until link ordering issue is solved
|
||||
ifdef GNU_CC
|
||||
OS_LIBS += $(call EXPAND_LIBNAME,winmm wsock32 gdi32)
|
||||
endif
|
||||
ifdef MOZ_ENABLE_CAIRO_GFX
|
||||
OS_LIBS += $(call EXPAND_LIBNAME, usp10)
|
||||
endif
|
||||
endif
|
||||
|
||||
GARBAGE += $(CPPSRCS)
|
||||
|
||||
list:
|
||||
echo $(MOZ_STATIC_COMPONENTS)
|
||||
|
||||
ifdef _NO_AUTO_VARS
|
||||
_TARGET = $(srcdir)/$(@F)
|
||||
GARBAGE += $(addprefix $(srcdir)/,$(CPPSRCS))
|
||||
else
|
||||
_TARGET = $@
|
||||
ifneq (,$(MOZ_ENABLE_GTK)$(MOZ_ENABLE_GTK2)$(MOZ_ENABLE_XLIB))
|
||||
OS_LIBS += $(XLDFLAGS) $(XT_LIBS)
|
||||
endif
|
||||
|
||||
ifdef MOZ_STATIC_COMPONENTS
|
||||
nsStaticModule.cpp: nsMetaModule.cpp.in Makefile Makefile.in $(DEPTH)/config/autoconf.mk
|
||||
rm -f $@
|
||||
cat $< | \
|
||||
sed -e "s|%DECLARE_SUBMODULE_INFOS%|$(foreach m, $(MOZ_STATIC_COMPONENTS), extern nsModuleInfo NSMODULEINFO($(m));)|" | \
|
||||
sed -e "s|%SUBMODULE_INFOS%|$(foreach m, $(MOZ_STATIC_COMPONENTS), \\& NSMODULEINFO($(m)),)|" \
|
||||
> $(_TARGET)
|
||||
endif
|
||||
OS_LIBS += $(TK_LIBS)
|
||||
|
||||
nsMetaModule_%.cpp: nsMetaModule.cpp.in Makefile Makefile.in $(topsrcdir)/config/config.mk
|
||||
rm -f $@
|
||||
cat $< | \
|
||||
sed -e "s|%DECLARE_SUBMODULE_INFOS%|$(foreach m, $($(_META_COMPONENT_NAMES)), extern nsModuleInfo NSMODULEINFO($(m));)|" | \
|
||||
sed -e "s|%SUBMODULE_INFOS%|$(foreach m, $($(_META_COMPONENT_NAMES)), \\& NSMODULEINFO($(m)),)|" \
|
||||
> $(_TARGET)
|
||||
GARBAGE += module_list.h
|
||||
|
||||
LOCAL_INCLUDES += -I.
|
||||
|
||||
FINAL_COMPONENT_NAMES := $(shell cat $(FINAL_LINK_COMP_NAMES))
|
||||
|
||||
nsMetaModule.$(OBJ_SUFFIX): module_list.h
|
||||
|
||||
module_list.h: Makefile Makefile.in $(DEPTH)/config/autoconf.mk
|
||||
echo '#define MODULES \' > $@
|
||||
awk '{ print "MODULE(" $$1 ") \\" }' < $(FINAL_LINK_COMP_NAMES) >> $@
|
||||
echo >> $@
|
||||
|
||||
@@ -1,164 +0,0 @@
|
||||
#!nmake
|
||||
#
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Netscape Communications Corporation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 1998
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
DEPTH=..\..
|
||||
|
||||
REQUIRES = xpcom
|
||||
|
||||
include <$(DEPTH)/config/config.mak>
|
||||
|
||||
MAKE_OBJ_TYPE = DLL
|
||||
DLLNAME = $(META_MODULE).dll
|
||||
DLL = .\$(OBJDIR)\$(DLLNAME)
|
||||
|
||||
LINK_COMP_NAMES = $(DIST)\$(META_MODULE)-link-comp-names
|
||||
LINK_COMPS = $(DIST)\$(META_MODULE)-link-comps
|
||||
LINK_LIBS = $(DIST)\$(META_MODULE)-link-libs
|
||||
SEDCMDS = nsMetaModule_$(META_MODULE).cpp.sed
|
||||
|
||||
EXTRA_LIBS_LIST_FILE = $(OBJDIR)\$(META_MODULE)-libs.txt
|
||||
|
||||
GARBAGE = $(GARBAGE) $(SEDCMDS) $(LIBFILE) nsMetaModule_$(META_MODULE).cpp
|
||||
|
||||
LCFLAGS = $(LCFLAGS) -DMETA_MODULE=\"$(META_MODULE)\"
|
||||
CPP_OBJS = .\$(OBJDIR)\nsMetaModule_$(META_MODULE).obj
|
||||
|
||||
# XXX Lame! This is currently the superset of all static libraries not
|
||||
# explicitly made part of the META_MODULE.
|
||||
LLIBS = $(DIST)\lib\gkgfx.lib \
|
||||
$(DIST)\lib\rdfutil_s.lib \
|
||||
$(DIST)\lib\js3250.lib \
|
||||
$(DIST)\lib\xpcom.lib \
|
||||
$(DIST)\lib\unicharutil_s.lib \
|
||||
$(LIBNSPR)
|
||||
|
||||
WIN_LIBS = rpcrt4.lib \
|
||||
ole32.lib \
|
||||
shell32.lib
|
||||
|
||||
|
||||
!ifdef MOZ_GECKO_DLL
|
||||
LLIBS = $(LLIBS) \
|
||||
$(DIST)\lib\png.lib \
|
||||
$(DIST)\lib\mng.lib \
|
||||
$(DIST)\lib\util.lib \
|
||||
$(DIST)\lib\mozexpat.lib \
|
||||
$(DIST)\lib\nsldap32v40.lib
|
||||
|
||||
WIN_LIBS = $(WIN_LIBS) \
|
||||
comctl32.lib \
|
||||
comdlg32.lib \
|
||||
uuid.lib \
|
||||
ole32.lib \
|
||||
shell32.lib \
|
||||
oleaut32.lib \
|
||||
version.lib \
|
||||
winspool.lib
|
||||
|
||||
!endif
|
||||
|
||||
include <$(DEPTH)/config/rules.mak>
|
||||
|
||||
#
|
||||
# Create the sed commands that are used translate nsMetaModule_(foo).cpp.in
|
||||
# into nsMetaModule_(foo).cpp, using the component names,
|
||||
#
|
||||
$(SEDCMDS): $(LINK_COMP_NAMES)
|
||||
echo +++make: Creating $@
|
||||
rm -f $@
|
||||
echo s/%DECLARE_SUBMODULE_INFOS%/\>> $@
|
||||
sed -e "s/\(.*\)/extern nsModuleInfo NSMODULEINFO(\1);\\\/" $(LINK_COMP_NAMES) >> $@
|
||||
echo />> $@
|
||||
echo s/%SUBMODULE_INFOS%/\>> $@
|
||||
sed -e "s/\(.*\)/\\\\\& NSMODULEINFO(\1),\\\/" $(LINK_COMP_NAMES) >> $@
|
||||
echo />> $@
|
||||
|
||||
#
|
||||
# Create nsMetaModule_(foo).cpp from nsMetaModule.cpp.in
|
||||
#
|
||||
nsMetaModule_$(META_MODULE).cpp: nsMetaModule.cpp.in $(SEDCMDS)
|
||||
echo +++make: Creating $@
|
||||
rm -f $@
|
||||
sed -f $(SEDCMDS) nsMetaModule.cpp.in > $@
|
||||
|
||||
#
|
||||
# If no link components file has been created, make an empty one now.
|
||||
#
|
||||
$(LINK_COMPS):
|
||||
echo +++ make: Creating empty link components file: $@
|
||||
touch $@
|
||||
|
||||
#
|
||||
# If no link libs file has been created, make an empty one now.
|
||||
#
|
||||
$(LINK_LIBS):
|
||||
echo +++ make: Creating empty link libraries file: $@
|
||||
touch $@
|
||||
|
||||
#
|
||||
# Create a list of libraries that we'll need to link against from the
|
||||
# component list and the ``export library'' list
|
||||
#
|
||||
$(EXTRA_LIBS_LIST_FILE): $(LINK_COMPS) $(LINK_LIBS)
|
||||
echo +++ make: Creating list of link libraries: $@
|
||||
rm -f $@
|
||||
sed -e "s/\(.*\)/$(DIST:\=\\\)\\\lib\\\\\1.lib/" $(LINK_COMPS) > $@
|
||||
sed -e "s/\(.*\)/$(DIST:\=\\\)\\\lib\\\\\1.lib/" $(LINK_LIBS) >> $@
|
||||
|
||||
|
||||
# XXX this is a hack. The ``gecko'' meta-module consists
|
||||
# of all the static components linked into a DLL instead
|
||||
# of an executable. To make this work, we'll copy the
|
||||
# statically linked libs, components, and component names
|
||||
# to the right file. This relies on the fact that the
|
||||
# modules/staticmod directory gets built after all the other
|
||||
# directories in the tree are processed.
|
||||
!if defined(MOZ_GECKO_DLL) && "$(META_MODULE)" == "gecko"
|
||||
export::
|
||||
copy $(FINAL_LINK_LIBS) $(DIST)\$(META_MODULE)-link-libs
|
||||
copy $(FINAL_LINK_COMPS) $(DIST)\$(META_MODULE)-link-comps
|
||||
copy $(FINAL_LINK_COMP_NAMES) $(DIST)\$(META_MODULE)-link-comp-names
|
||||
!endif
|
||||
|
||||
|
||||
libs:: $(DLL)
|
||||
$(MAKE_INSTALL) $(DLL) $(DIST)/bin/components
|
||||
|
||||
clobber::
|
||||
rm -f $(DIST)/bin/components/$(DLLNAME)
|
||||
|
||||
167
mozilla/modules/staticmod/nsMetaModule.cpp
Normal file
167
mozilla/modules/staticmod/nsMetaModule.cpp
Normal file
@@ -0,0 +1,167 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Christopher Seawood <cls@seawood.org>
|
||||
* Doug Turner <dougt@netscape.com>
|
||||
* Chris Waterson <waterson@netscape.com>
|
||||
* Benjamin Smedberg <benjamin@smedbergs.us>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsIGenericFactory.h"
|
||||
#include "nsXPCOM.h"
|
||||
#include "nsIModule.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsCOMArray.h"
|
||||
#include "nsMemory.h"
|
||||
#include "nsAutoPtr.h"
|
||||
|
||||
#include "module_list.h"
|
||||
|
||||
#define NSGETMODULE(_name) _name##_NSGetModule
|
||||
|
||||
#define MODULE(_name) \
|
||||
NSGETMODULE_ENTRY_POINT(_name) (nsIComponentManager*, nsIFile*, nsIModule**);
|
||||
|
||||
MODULES
|
||||
|
||||
#undef MODULE
|
||||
|
||||
#define MODULE(_name) NSGETMODULE(_name),
|
||||
|
||||
static const nsGetModuleProc kGetModules[] = {
|
||||
MODULES
|
||||
};
|
||||
|
||||
#undef MODULE
|
||||
|
||||
class MetaModule : public nsIModule
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIMODULE
|
||||
|
||||
MetaModule() { }
|
||||
nsresult Init(nsIComponentManager*, nsIFile*);
|
||||
|
||||
private:
|
||||
~MetaModule() { }
|
||||
|
||||
nsCOMArray<nsIModule> mModules;
|
||||
};
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS1(MetaModule, nsIModule)
|
||||
|
||||
nsresult
|
||||
MetaModule::Init(nsIComponentManager* aCompMgr, nsIFile* aLocation)
|
||||
{
|
||||
if (!mModules.SetCapacity(NS_ARRAY_LENGTH(kGetModules)))
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
// eat all errors
|
||||
nsGetModuleProc const *end = kGetModules + NS_ARRAY_LENGTH(kGetModules);
|
||||
|
||||
nsCOMPtr<nsIModule> module;
|
||||
for (nsGetModuleProc const *cur = kGetModules; cur < end; ++cur) {
|
||||
nsresult rv = (*cur)(aCompMgr, aLocation, getter_AddRefs(module));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
mModules.AppendObject(module);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MetaModule::GetClassObject(nsIComponentManager* aCompMgr, REFNSCID aCID,
|
||||
REFNSIID aIID, void **aResult)
|
||||
{
|
||||
for (PRInt32 i = mModules.Count() - 1; i >= 0; --i) {
|
||||
nsresult rv = mModules[i]->GetClassObject(aCompMgr, aCID,
|
||||
aIID, aResult);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
return rv;
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MetaModule::RegisterSelf(nsIComponentManager* aCompMgr, nsIFile* aLocation,
|
||||
const char *aStr, const char *aType)
|
||||
{
|
||||
for (PRInt32 i = mModules.Count() - 1; i >= 0; --i) {
|
||||
mModules[i]->RegisterSelf(aCompMgr, aLocation, aStr, aType);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MetaModule::UnregisterSelf(nsIComponentManager* aCompMgr, nsIFile* aLocation,
|
||||
const char *aStr)
|
||||
{
|
||||
for (PRInt32 i = mModules.Count() - 1; i >= 0; --i) {
|
||||
mModules[i]->UnregisterSelf(aCompMgr, aLocation, aStr);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MetaModule::CanUnload(nsIComponentManager* aCompMgr, PRBool *aResult)
|
||||
{
|
||||
for (PRInt32 i = mModules.Count() - 1; i >= 0; --i) {
|
||||
nsresult rv = mModules[i]->CanUnload(aCompMgr, aResult);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
// Any submodule may veto unloading
|
||||
if (!*aResult)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
extern "C" NS_EXPORT nsresult
|
||||
NSGetModule(nsIComponentManager *servMgr,
|
||||
nsIFile *location,
|
||||
nsIModule **result)
|
||||
{
|
||||
nsRefPtr<MetaModule> mmodule = new MetaModule();
|
||||
nsresult rv = mmodule->Init(servMgr, location);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
NS_ADDREF(*result = mmodule);
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -1,135 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Christopher Seawood <cls@seawood.org>
|
||||
* Doug Turner <dougt@netscape.com>
|
||||
* Chris Waterson <waterson@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#line 27 "nsMetaModule.cpp.in"
|
||||
#include "nsError.h"
|
||||
#include "nsIModule.h"
|
||||
#include "nsIFile.h"
|
||||
#include "nsIGenericFactory.h"
|
||||
#include "prmem.h"
|
||||
|
||||
%DECLARE_SUBMODULE_INFOS%
|
||||
#line 35 "nsMetaModule.cpp.in"
|
||||
|
||||
static nsModuleInfo* gSubModules[] = {
|
||||
%SUBMODULE_INFOS%
|
||||
#line 39 "nsMetaModule.cpp.in"
|
||||
};
|
||||
|
||||
#define NUM_SUB_MODULES (sizeof(gSubModules) / sizeof(gSubModules[0]))
|
||||
|
||||
static nsModuleComponentInfo* gComponentInfo;
|
||||
static PRBool gInitialized = PR_FALSE;
|
||||
|
||||
PR_STATIC_CALLBACK(nsresult)
|
||||
Initialize(nsIModule *self)
|
||||
{
|
||||
if (! gInitialized) {
|
||||
// Run the ctor for each sub-module
|
||||
gInitialized = PR_TRUE;
|
||||
|
||||
nsModuleInfo** module = gSubModules;
|
||||
nsModuleInfo** limit = module + NUM_SUB_MODULES;
|
||||
for ( ; module < limit; ++module) {
|
||||
if ((*module)->mCtor)
|
||||
((*module)->mCtor)(self);
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PR_STATIC_CALLBACK(void)
|
||||
Shutdown(nsIModule *self)
|
||||
{
|
||||
if (gInitialized) {
|
||||
// Run the dtor for each sub-module
|
||||
gInitialized = PR_FALSE;
|
||||
|
||||
nsModuleInfo** module = gSubModules;
|
||||
nsModuleInfo** limit = module + NUM_SUB_MODULES;
|
||||
for ( ; module < limit; ++module) {
|
||||
if ((*module)->mDtor)
|
||||
((*module)->mDtor)(self);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" NS_EXPORT nsresult
|
||||
NSGetModule(nsIComponentManager *servMgr,
|
||||
nsIFile *location,
|
||||
nsIModule **result)
|
||||
{
|
||||
// Count the number of components contained in all of the
|
||||
// sub-modules
|
||||
nsModuleInfo** info = gSubModules;
|
||||
nsModuleInfo** limit = info + NUM_SUB_MODULES;
|
||||
PRUint32 count = 0;
|
||||
for ( ; info < limit; ++info)
|
||||
count += (*info)->mCount;
|
||||
|
||||
// Allocate an nsModuleComponentInfo array large enough to contain
|
||||
// all of them. This will be permanently leaked.
|
||||
gComponentInfo = new nsModuleComponentInfo[count];
|
||||
if (! gComponentInfo)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
// Copy the module component info into the contiguous array
|
||||
nsModuleComponentInfo *comps = gComponentInfo;
|
||||
for (info = gSubModules; info < limit; ++info) {
|
||||
PRUint32 n = (*info)->mCount;
|
||||
::memcpy(comps, (*info)->mComponents, sizeof(nsModuleComponentInfo) * n);
|
||||
comps += n;
|
||||
}
|
||||
|
||||
// Dummy up an nsModuleInfo struct to register us as a generic
|
||||
// module that contains all our sub-module's components.
|
||||
nsModuleInfo metainfo;
|
||||
memset(&metainfo, 0, sizeof(metainfo));
|
||||
metainfo.mVersion = NS_MODULEINFO_VERSION;
|
||||
metainfo.mModuleName = META_MODULE " meta module";
|
||||
metainfo.mComponents = gComponentInfo;
|
||||
metainfo.mCount = count;
|
||||
metainfo.mCtor = Initialize;
|
||||
metainfo.mDtor = Shutdown;
|
||||
|
||||
return NS_NewGenericModule2(&metainfo, result);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user