зеркало из https://github.com/mozilla/pjs.git
Enable building a library of Gecko components that can be linked against directly and then registered using the static component loader (bug 207407). This enables us to do full prebinding on Mac OS X. Also, don't force libjar to be standalone if not building an installer. r=ccarlen, sr=sfraser.
This commit is contained in:
Родитель
fe7ecce15d
Коммит
6741cba995
|
@ -0,0 +1 @@
|
|||
Makefile
|
|
@ -0,0 +1,154 @@
|
|||
#
|
||||
# The contents of this file are subject to the Netscape 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/NPL/
|
||||
#
|
||||
# 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 Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
DEPTH = ../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
REQUIRES = xpcom \
|
||||
$(NULL)
|
||||
|
||||
LOCAL_INCLUDES = -I$(srcdir)
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
_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
|
||||
|
||||
LIBRARY_NAME = mozcomps
|
||||
CPPSRCS = nsMetaModule_mozcomps.cpp
|
||||
|
||||
include $(topsrcdir)/config/static-config.mk
|
||||
|
||||
EXTRA_DSO_LIBS = $(STATIC_EXTRA_DSO_LIBS)
|
||||
|
||||
# See explanation below.
|
||||
ifeq ($(OS_ARCH),Darwin)
|
||||
EXTRA_DEPS = force_data_segment.o exported_symbols
|
||||
endif
|
||||
|
||||
FORCE_SHARED_LIB = 1
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
include $(topsrcdir)/config/static-rules.mk
|
||||
|
||||
# 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
|
||||
|
||||
# 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)
|
||||
|
||||
ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
|
||||
OS_LIBS += -framework QuickTime
|
||||
endif
|
||||
|
||||
ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
|
||||
OS_LIBS += -framework Cocoa
|
||||
endif
|
||||
|
||||
ifeq ($(OS_ARCH),Darwin)
|
||||
|
||||
# A limitation exists in the Mach-O format which causes "scattered" relocation
|
||||
# entries in shared libraries to be limited to a 24-bit address space (16 MB).
|
||||
# The high 8 bits of the address are dropped. This can cause problems in
|
||||
# a mozcomps build, particularly non-optimized builds. To avoid the problem,
|
||||
# we move the data segment before the code segment in the libraray. The data
|
||||
# segment is relatively small, and all of the relocations in question
|
||||
# (which are pointers to construction vtables) reside in the
|
||||
# (__DATA,__const) section.
|
||||
#
|
||||
# See also the 5th item in the TODO section of:
|
||||
# http://www.opensource.apple.com/darwinsource/10.2.6/cctools/ld/notes
|
||||
# (free APSL registration required)
|
||||
|
||||
|
||||
# Generate a .o file with only a data segment, which we'll link as the first
|
||||
# object file in the library. That will cause the data segment to be first.
|
||||
|
||||
force_data_segment.o:
|
||||
ld -sectcreate __DATA __const /dev/null -noseglinkedit -arch ppc -o $@
|
||||
|
||||
exported_symbols:
|
||||
echo _nsMetaModule_nsGetModule > $@
|
||||
|
||||
# We have to invoke ld directly so that force_data_segment.o can be linked
|
||||
# before dylib1.o
|
||||
MKSHLIB = $(LD) $(DSO_LDOPTS) -o $@
|
||||
|
||||
# force it to be first
|
||||
SHLIB_LDSTARTFILE = force_data_segment.o -ldylib1.o
|
||||
|
||||
# translate gcc link options to corresponding ld options
|
||||
EXTRA_DSO_LDOPTS := $(subst -dynamiclib,-dylib,$(EXTRA_DSO_LDOPTS))
|
||||
EXTRA_DSO_LDOPTS := $(subst install_name,dylib_install_name,$(EXTRA_DSO_LDOPTS))
|
||||
EXTRA_DSO_LDOPTS := $(subst compatibility_version,dylib_compatibility_version,$(EXTRA_DSO_LDOPTS))
|
||||
EXTRA_DSO_LDOPTS := $(subst current_version,dylib_current_version,$(EXTRA_DSO_LDOPTS))
|
||||
|
||||
# It would be nice to limit the exported symbols here, but doing so exposes a
|
||||
# bug in the linker that causes some C++ static initializers not to run after
|
||||
# prebinding is updated at runtime (reported as Radar bug 3268595).
|
||||
#EXTRA_DSO_LDOPTS += -exported_symbols_list exported_symbols
|
||||
|
||||
OS_LIBS := -lstdc++ $(OS_LIBS)
|
||||
SHLIB_LDENDFILE = -lgcc
|
||||
|
||||
endif # darwin
|
||||
|
||||
ifeq ($(OS_ARCH),WINNT)
|
||||
OS_LIBS += ole32.lib shell32.lib
|
||||
endif
|
||||
|
||||
GARBAGE += $(CPPSRCS)
|
||||
|
||||
ifdef _NO_AUTO_VARS
|
||||
_TARGET = $(srcdir)/$(@F)
|
||||
GARBAGE += $(addprefix $(srcdir)/,$(CPPSRCS))
|
||||
else
|
||||
_TARGET = $@
|
||||
endif
|
||||
|
||||
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)
|
||||
|
|
@ -0,0 +1,120 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Christopher Seawood <cls@seawood.org>
|
||||
* Doug Turner <dougt@netscape.com>
|
||||
* Chris Waterson <waterson@netscape.com>
|
||||
*/
|
||||
|
||||
#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
|
||||
nsMetaModule_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);
|
||||
}
|
||||
|
Загрузка…
Ссылка в новой задаче