Merge bug 579178 to mozilla-central. reviews by Mossop/khuey/jwalden/ted

This commit is contained in:
Benjamin Smedberg 2010-08-09 10:04:10 -04:00
Родитель 985c3faf1d b3e54c80b8
Коммит 7c3e8bf65e
25 изменённых файлов: 245 добавлений и 389 удалений

Просмотреть файл

@ -207,6 +207,7 @@ repackage-win32-installer: $(WIN32_INSTALLER_IN) $(SUBMAKEFILES)
# those are just for language packs
cp -r $(DIST)/xpi-stage/locale-$(AB_CD) l10n-stage/localized
$(RM) l10n-stage/localized/install.rdf l10n-stage/localized/chrome.manifest
mv l10n-stage/localized/chrome/$(AB_CD).manifest l10n-stage/localized/chrome/localized.manifest
$(MAKE) -C ../installer/windows CONFIG_DIR=l10ngen l10ngen/setup.exe l10ngen/7zSD.sfx
cp ../installer/windows/l10ngen/setup.exe l10n-stage
$(NSINSTALL) -D l10n-stage/localized/uninstall

Просмотреть файл

@ -186,7 +186,7 @@ check::
mkdir unify-sort-test unify-sort-test/a unify-sort-test/b
printf "lmn\nabc\nxyz\n" > unify-sort-test/a/file.foo
printf "xyz\nlmn\nabc" > unify-sort-test/b/file.foo
printf "abc\nlmn\nxyz\n" > unify-sort-test/expected-result
printf "lmn\nabc\nxyz\n" > unify-sort-test/expected-result
@if ! $(srcdir)/macosx/universal/unify --unify-with-sort "\.foo$$" \
./unify-sort-test/a ./unify-sort-test/b \
./unify-sort-test/c; then \

Просмотреть файл

@ -201,7 +201,6 @@ sub copyIfIdentical($$$);
sub slurp($);
sub get_sorted($);
sub compare_sorted($$);
sub copy_sorted($$);
sub copyIfIdenticalWhenSorted($$$);
sub createUniqueFile($$);
sub makeUniversal($$$);
@ -541,21 +540,6 @@ sub compare_sorted($$) {
return 0;
}
# copy_sorted($source, $destination)
#
# $source and $destination are filenames. Read the contents of $source
# into an array, sort it, and then write the sorted contents to $destination.
# Returns 1 on success, and undef on failure.
sub copy_sorted($$) {
my ($src, $dest) = @_;
my @lines = get_sorted($src);
return undef unless @lines;
open FILE, "> $dest" or return undef;
print FILE @lines;
close FILE;
return 1;
}
# copyIfIdenticalWhenSorted($source1, $source2, $target)
#
# $source1 and $source2 are FileAttrCache objects that are compared, and if
@ -605,8 +589,8 @@ sub copyIfIdenticalWhenSorted($$$) {
return 0;
}
if (!copy_sorted($source1->path(), $target)) {
complain(1, 'copyIfIdenticalWhenSorted: copy_sorted: '.$!
if (!copy($source1->path(), $target)) {
complain(1, 'copyIfIdenticalWhenSorted: copy: '.$!
.' while copying',
$source1->path(),
$target);

Просмотреть файл

@ -52,8 +52,9 @@ from MozZipFile import ZipFile
from cStringIO import StringIO
from datetime import datetime
from utils import pushback_iter
from utils import pushback_iter, lockFile
from Preprocessor import Preprocessor
from buildlist import addEntriesToListFile
__all__ = ['JarMaker']
@ -164,7 +165,7 @@ class JarMaker(object):
pass
def finalizeJar(self, jarPath, chromebasepath, register,
doZip=True):
doZip=True):
'''Helper method to write out the chrome registration entries to
jarfile.manifest or chrome.manifest, or both.
@ -173,35 +174,42 @@ class JarMaker(object):
# rewrite the manifest, if entries given
if not register:
return
chromeManifest = os.path.join(os.path.dirname(jarPath),
'..', 'chrome.manifest')
if self.useJarfileManifest:
self.updateManifest(jarPath + '.manifest', chromebasepath % '',
register)
addEntriesToListFile(chromeManifest, ['manifest chrome/%s.manifest' % (os.path.basename(jarPath),)])
if self.useChromeManifest:
manifestPath = os.path.join(os.path.dirname(jarPath),
'..', 'chrome.manifest')
self.updateManifest(manifestPath, chromebasepath % 'chrome/',
self.updateManifest(chromeManifest, chromebasepath % 'chrome/',
register)
def updateManifest(self, manifestPath, chromebasepath, register):
'''updateManifest replaces the % in the chrome registration entries
with the given chrome base path, and updates the given manifest file.
'''
myregister = dict.fromkeys(map(lambda s: s.replace('%', chromebasepath),
register.iterkeys()))
manifestExists = os.path.isfile(manifestPath)
mode = (manifestExists and 'r+b') or 'wb'
mf = open(manifestPath, mode)
if manifestExists:
# import previous content into hash, ignoring empty ones and comments
imf = re.compile('(#.*)?$')
for l in re.split('[\r\n]+', mf.read()):
if imf.match(l):
continue
myregister[l] = None
mf.seek(0)
for k in myregister.iterkeys():
mf.write(k + os.linesep)
mf.close()
lock = lockFile(manifestPath + '.lck')
try:
myregister = dict.fromkeys(map(lambda s: s.replace('%', chromebasepath),
register.iterkeys()))
manifestExists = os.path.isfile(manifestPath)
mode = (manifestExists and 'r+b') or 'wb'
mf = open(manifestPath, mode)
if manifestExists:
# import previous content into hash, ignoring empty ones and comments
imf = re.compile('(#.*)?$')
for l in re.split('[\r\n]+', mf.read()):
if imf.match(l):
continue
myregister[l] = None
mf.seek(0)
for k in myregister.iterkeys():
mf.write(k + os.linesep)
mf.close()
finally:
lock = None
def makeJar(self, infile=None,
jardir='',

Просмотреть файл

@ -908,6 +908,7 @@ ifdef IS_COMPONENT
$(INSTALL) $(IFLAGS2) $(SHARED_LIBRARY) $(FINAL_TARGET)/components
$(ELF_DYNSTR_GC) $(FINAL_TARGET)/components/$(SHARED_LIBRARY)
ifndef NO_COMPONENTS_MANIFEST
@$(PYTHON) $(MOZILLA_DIR)/config/buildlist.py $(FINAL_TARGET)/chrome.manifest "manifest components/components.manifest"
@$(PYTHON) $(MOZILLA_DIR)/config/buildlist.py $(FINAL_TARGET)/components/components.manifest "binary-component $(SHARED_LIBRARY)"
endif
ifdef BEOS_ADDON_WORKAROUND
@ -1782,6 +1783,7 @@ ifndef NO_DIST_INSTALL
$(INSTALL) $(IFLAGS1) $(XPIDL_GEN_DIR)/$(XPIDL_MODULE).xpt $(FINAL_TARGET)/components
ifndef NO_INTERFACES_MANIFEST
@$(PYTHON) $(MOZILLA_DIR)/config/buildlist.py $(FINAL_TARGET)/components/interfaces.manifest "interfaces $(XPIDL_MODULE).xpt"
@$(PYTHON) $(MOZILLA_DIR)/config/buildlist.py $(FINAL_TARGET)/chrome.manifest "manifest components/interfaces.manifest"
endif
endif
@ -1897,7 +1899,12 @@ ifndef NO_DIST_INSTALL
$(PYTHON) $(topsrcdir)/config/Preprocessor.py $(DEFINES) $(ACDEFINES) $(XULPPFLAGS) $$i > $$dest; \
done
endif
endif
EXTRA_MANIFESTS = $(filter %.manifest,$(EXTRA_COMPONENTS) $(EXTRA_PP_COMPONENTS))
ifneq (,$(EXTRA_MANIFESTS))
libs::
$(PYTHON) $(MOZILLA_DIR)/config/buildlist.py $(FINAL_TARGET)/chrome.manifest $(patsubst %,"manifest components/%",$(notdir $(EXTRA_MANIFESTS)))
endif
################################################################################
@ -2338,6 +2345,8 @@ FREEZE_VARIABLES = \
REQUIRES \
SHORT_LIBNAME \
TIERS \
EXTRA_COMPONENTS \
EXTRA_PP_COMPONENTS \
$(NULL)
$(foreach var,$(FREEZE_VARIABLES),$(eval $(var)_FROZEN := '$($(var))'))

Просмотреть файл

@ -43,7 +43,7 @@ class TestJarMaker(unittest.TestCase):
"""
Unit tests for JarMaker.py
"""
debug = False # set to True to debug failing tests on disk
debug = True # set to True to debug failing tests on disk
def setUp(self):
self.tmpdir = mkdtemp()
self.srcdir = os.path.join(self.tmpdir, 'src')
@ -142,6 +142,10 @@ class TestJarMaker(unittest.TestCase):
os.mkdir(ldir)
open(os.path.join(ldir, relpath), 'w').write(relpath+" content\n")
# create reference
mf = open(os.path.join(self.refdir, 'chrome.manifest'), 'w')
mf.write('manifest chrome/ab-CD.manifest\n')
mf.close()
chrome_ref = os.path.join(self.refdir, 'chrome')
os.mkdir(chrome_ref)
mf = open(os.path.join(chrome_ref, 'ab-CD.manifest'), 'wb')

Просмотреть файл

@ -908,6 +908,7 @@ ifdef IS_COMPONENT
$(INSTALL) $(IFLAGS2) $(SHARED_LIBRARY) $(FINAL_TARGET)/components
$(ELF_DYNSTR_GC) $(FINAL_TARGET)/components/$(SHARED_LIBRARY)
ifndef NO_COMPONENTS_MANIFEST
@$(PYTHON) $(MOZILLA_DIR)/config/buildlist.py $(FINAL_TARGET)/chrome.manifest "manifest components/components.manifest"
@$(PYTHON) $(MOZILLA_DIR)/config/buildlist.py $(FINAL_TARGET)/components/components.manifest "binary-component $(SHARED_LIBRARY)"
endif
ifdef BEOS_ADDON_WORKAROUND
@ -1782,6 +1783,7 @@ ifndef NO_DIST_INSTALL
$(INSTALL) $(IFLAGS1) $(XPIDL_GEN_DIR)/$(XPIDL_MODULE).xpt $(FINAL_TARGET)/components
ifndef NO_INTERFACES_MANIFEST
@$(PYTHON) $(MOZILLA_DIR)/config/buildlist.py $(FINAL_TARGET)/components/interfaces.manifest "interfaces $(XPIDL_MODULE).xpt"
@$(PYTHON) $(MOZILLA_DIR)/config/buildlist.py $(FINAL_TARGET)/chrome.manifest "manifest components/interfaces.manifest"
endif
endif
@ -1897,7 +1899,12 @@ ifndef NO_DIST_INSTALL
$(PYTHON) $(topsrcdir)/config/Preprocessor.py $(DEFINES) $(ACDEFINES) $(XULPPFLAGS) $$i > $$dest; \
done
endif
endif
EXTRA_MANIFESTS = $(filter %.manifest,$(EXTRA_COMPONENTS) $(EXTRA_PP_COMPONENTS))
ifneq (,$(EXTRA_MANIFESTS))
libs::
$(PYTHON) $(MOZILLA_DIR)/config/buildlist.py $(FINAL_TARGET)/chrome.manifest $(patsubst %,"manifest components/%",$(notdir $(EXTRA_MANIFESTS)))
endif
################################################################################
@ -2338,6 +2345,8 @@ FREEZE_VARIABLES = \
REQUIRES \
SHORT_LIBNAME \
TIERS \
EXTRA_COMPONENTS \
EXTRA_PP_COMPONENTS \
$(NULL)
$(foreach var,$(FREEZE_VARIABLES),$(eval $(var)_FROZEN := '$($(var))'))

Просмотреть файл

@ -1149,7 +1149,7 @@ static int
usage(void)
{
fprintf(gErrFile, "%s\n", JS_GetImplementationVersion());
fprintf(gErrFile, "usage: xpcshell [-g gredir] [-PsSwWxCij] [-v version] [-f scriptfile] [-e script] [scriptfile] [scriptarg...]\n");
fprintf(gErrFile, "usage: xpcshell [-g gredir] [-r manifest]... [-PsSwWxCij] [-v version] [-f scriptfile] [-e script] [scriptfile] [scriptarg...]\n");
return 2;
}
@ -1827,6 +1827,22 @@ main(int argc, char **argv)
argv += 2;
}
while (argc > 1 && !strcmp(argv[1], "-r")) {
if (argc < 3)
return usage();
nsCOMPtr<nsILocalFile> lf;
rv = XRE_GetFileFromPath(argv[2], getter_AddRefs(lf));
if (NS_FAILED(rv)) {
printf("Couldn't get manifest file.\n");
return 1;
}
XRE_AddManifestLocation(NS_COMPONENT_LOCATION, lf);
argc -= 2;
argv += 2;
}
{
nsCOMPtr<nsIServiceManager> servMan;
rv = NS_InitXPCOM2(getter_AddRefs(servMan), appDir, &dirprovider);

Просмотреть файл

@ -40,7 +40,6 @@ MODULES_LIBJAR_LCPPSRCS = \
nsJARInputStream.cpp \
nsJAR.cpp \
nsJARFactory.cpp \
nsManifestZIPLoader.cpp \
nsJARProtocolHandler.cpp \
nsJARChannel.cpp \
nsJARURI.cpp \
@ -49,7 +48,6 @@ MODULES_LIBJAR_LCPPSRCS = \
MODULES_LIBJAR_LEXPORTS = \
zipstruct.h \
nsZipArchive.h \
nsManifestZIPLoader.h \
$(NULL)
MODULES_LIBJAR_LXPIDLSRCS = \

Просмотреть файл

@ -689,9 +689,11 @@ overlay chrome://browser/content/browser.xul chrome://mochikit/content/browser-t
return self.installChromeFile(temp_file, options)
def installChromeFile(self, filename, options):
(p, file) = os.path.split(filename)
(path, leaf) = os.path.split(options.app)
manifest = os.path.join(path, "chrome", file)
manifestdir = os.path.join(path, "distribution", "bundles", "mochitest")
if not os.path.exists(manifestdir):
os.makedirs(manifestdir)
manifest = os.path.join(manifestdir, "chrome.manifest")
shutil.copy(filename, manifest)
return manifest

Просмотреть файл

@ -139,6 +139,9 @@ class XPCShellTests(object):
self.httpdJSPath = os.path.join(os.path.dirname(self.xpcshell), 'components', 'httpd.js')
self.httpdJSPath = replaceBackSlashes(self.httpdJSPath)
self.httpdManifest = os.path.join(os.path.dirname(self.xpcshell), 'components', 'httpd.manifest')
self.httpdManifest = replaceBackSlashes(self.httpdManifest)
if self.xrePath is None:
self.xrePath = os.path.dirname(self.xpcshell)
else:
@ -204,7 +207,7 @@ class XPCShellTests(object):
"""
# - NOTE: if you rename/add any of the constants set here, update
# do_load_child_test_harness() in head.js
self.xpcsCmd = [self.xpcshell, '-g', self.xrePath, '-j', '-s'] + \
self.xpcsCmd = [self.xpcshell, '-g', self.xrePath, '-r', self.httpdManifest, '-j', '-s'] + \
['-e', 'const _HTTPD_JS_PATH = "%s";' % self.httpdJSPath,
'-e', 'const _HEAD_JS_PATH = "%s";' % self.headJSPath,
'-f', os.path.join(self.testharnessdir, 'head.js')]

Просмотреть файл

@ -9,6 +9,7 @@ crashReporter.enabled = true;
crashReporter.minidumpPath = cwd;
let cd = cwd.clone();
cd.append("components");
cd.append("testcrasher.manifest");
Components.manager instanceof Components.interfaces.nsIComponentRegistrar;
Components.manager.autoRegister(cd);
let crashType = Components.interfaces.nsITestCrasher.CRASH_INVALID_POINTER_DEREF;

Просмотреть файл

@ -132,6 +132,7 @@ repackage-zip:
# those are just for language packs
cd $(DIST)/xpi-stage/locale-$(AB_CD) && \
tar --exclude=install.rdf --exclude=chrome.manifest $(TAR_CREATE_FLAGS) - * | ( cd $(STAGEDIST) && tar -xf - )
mv $(STAGEDIST)/chrome/$(AB_CD).manifest $(STAGEDIST)/chrome/localized.manifest
ifneq (en,$(AB))
ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
mv $(_ABS_DIST)/l10n-stage/$(MOZ_PKG_APPNAME)/$(_APPNAME)/Contents/Resources/en.lproj $(_ABS_DIST)/l10n-stage/$(MOZ_PKG_APPNAME)/$(_APPNAME)/Contents/Resources/$(AB).lproj

Просмотреть файл

@ -1,19 +1,15 @@
import sys, os
manifestsdir, distdir = sys.argv[1:]
outmanifest = sys.argv[1]
manifestdirs = sys.argv[2:]
if not os.path.exists(manifestsdir):
print >>sys.stderr, "Warning: %s does not exist." % manifestsdir
sys.exit(0)
outfd = open(outmanifest, 'w')
for name in os.listdir(manifestsdir):
manifestdir = os.path.join(manifestsdir, name)
for manifestdir in manifestdirs:
if not os.path.isdir(manifestdir):
print >>sys.stderr, "Warning: trying to link manifests in missing directory '%s'" % manifestdir
continue
manifestfile = os.path.join(distdir, 'components', name + '.manifest')
outfd = open(manifestfile, 'a')
for name in os.listdir(manifestdir):
infd = open(os.path.join(manifestdir, name))
print >>outfd, "# %s" % name
@ -21,4 +17,4 @@ for name in os.listdir(manifestsdir):
print >>outfd
infd.close()
outfd.close()
outfd.close()

Просмотреть файл

@ -364,8 +364,16 @@ ifdef MOZ_OPTIONAL_PKG_LIST
$(foreach pkg,$(MOZ_OPTIONAL_PKG_LIST),$(PKG_ARG)) )
endif
$(PERL) $(MOZILLA_DIR)/xpinstall/packager/xptlink.pl -s $(DIST) -d $(DIST)/xpt -f $(DEPTH)/installer-stage/nonlocalized/components -v -x "$(XPIDL_LINK)"
$(PYTHON) $(MOZILLA_DIR)/toolkit/mozapps/installer/link-manifests.py $(DIST)/manifests $(DEPTH)/installer-stage/nonlocalized
$(PYTHON) $(MOZILLA_DIR)/toolkit/mozapps/installer/link-manifests.py \
$(DEPTH)/installer-stage/nonlocalized/components/components.manifest \
$(patsubst %,$(DIST)/manifests/%/components,$(MOZ_NONLOCALIZED_PKG_LIST))
$(PYTHON) $(MOZILLA_DIR)/toolkit/mozapps/installer/link-manifests.py \
$(DEPTH)/installer-stage/nonlocalized/chrome/nonlocalized.manifest \
$(patsubst %,$(DIST)/manifests/%/chrome,$(MOZ_NONLOCALIZED_PKG_LIST))
$(PYTHON) $(MOZILLA_DIR)/toolkit/mozapps/installer/link-manifests.py \
$(DEPTH)/installer-stage/localized/chrome/localized.manifest \
$(patsubst %,$(DIST)/manifests/%/chrome,$(MOZ_LOCALIZED_PKG_LIST))
printf "manifest components/interfaces.manifest\nmanifest components/components.manifest\nmanifest chrome/nonlocalized.manifest\nmanifest chrome/localized.manifest\n" > $(DEPTH)/installer-stage/nonlocalized/chrome.manifest
stage-package: $(MOZ_PKG_MANIFEST) $(MOZ_PKG_REMOVALS_GEN)
@rm -rf $(DIST)/$(MOZ_PKG_DIR) $(DIST)/$(PKG_PATH)$(PKG_BASENAME).tar $(DIST)/$(PKG_PATH)$(PKG_BASENAME).dmg $@ $(EXCLUDE_LIST)
@ -382,7 +390,16 @@ ifdef MOZ_PKG_MANIFEST
"$(call core_abspath,$(DIST)/$(MOZ_PKG_DIR))", \
"$(MOZ_PKG_MANIFEST)", "$(PKGCP_OS)", 1, 0, 1)
$(PERL) $(MOZILLA_DIR)/xpinstall/packager/xptlink.pl -s $(DIST) -d $(DIST)/xpt -f $(DIST)/$(MOZ_PKG_DIR)/$(_BINPATH)/components -v -x "$(XPIDL_LINK)"
$(PYTHON) $(MOZILLA_DIR)/toolkit/mozapps/installer/link-manifests.py $(DIST)/manifests $(DIST)/$(MOZ_PKG_DIR)/$(_BINPATH)
$(PYTHON) $(MOZILLA_DIR)/toolkit/mozapps/installer/link-manifests.py \
$(DIST)/$(MOZ_PKG_DIR)/$(_BINPATH)/components/components.manifest \
$(patsubst %,$(DIST)/manifests/%/components,$(MOZ_NONLOCALIZED_PKG_LIST))
$(PYTHON) $(MOZILLA_DIR)/toolkit/mozapps/installer/link-manifests.py \
$(DIST)/$(MOZ_PKG_DIR)/$(_BINPATH)/chrome/nonlocalized.manifest \
$(patsubst %,$(DIST)/manifests/%/chrome,$(MOZ_NONLOCALIZED_PKG_LIST))
$(PYTHON) $(MOZILLA_DIR)/toolkit/mozapps/installer/link-manifests.py \
$(DIST)/$(MOZ_PKG_DIR)/$(_BINPATH)/chrome/localized.manifest \
$(patsubst %,$(DIST)/manifests/%/chrome,$(MOZ_LOCALIZED_PKG_LIST))
printf "manifest components/interfaces.manifest\nmanifest components/components.manifest\nmanifest chrome/nonlocalized.manifest\nmanifest chrome/localized.manifest\n" > $(DIST)/$(MOZ_PKG_DIR)/$(_BINPATH)/chrome.manifest
else # !MOZ_PKG_MANIFEST
ifeq ($(MOZ_PKG_FORMAT),DMG)
ifndef STAGE_SDK

Просмотреть файл

@ -68,6 +68,10 @@ CPPSRCS = \
nsNativeComponentLoader.cpp \
$(NULL)
ifdef MOZ_OMNIJAR
CPPSRCS += nsManifestZIPLoader.cpp
endif
SDK_XPIDLSRCS = \
nsIClassInfo.idl \
nsIComponentRegistrar.idl \
@ -76,7 +80,6 @@ SDK_XPIDLSRCS = \
nsIServiceManager.idl \
nsIComponentManager.idl \
nsICategoryManager.idl \
nsIManifestLoader.idl \
$(NULL)
LOCAL_INCLUDES = \
@ -87,6 +90,7 @@ LOCAL_INCLUDES = \
-I$(srcdir)/../build \
-I.. \
-I$(topsrcdir)/chrome/src \
-I$(topsrcdir)/modules/libjar \
$(NULL)
# we don't want the shared lib, but we want to force the creation of a static lib.

Просмотреть файл

@ -88,6 +88,8 @@ struct ManifestDirective
bool isContract;
};
static const ManifestDirective kParsingTable[] = {
{ "manifest", 1, false, true, false,
&nsComponentManagerImpl::ManifestManifest, NULL },
{ "binary-component", 1, true, false, false,
&nsComponentManagerImpl::ManifestBinaryComponent, NULL },
{ "interfaces", 1, true, false, false,
@ -600,7 +602,7 @@ ParseManifestCommon(NSLocationType aType, nsILocalFile* aFile,
stABI == eBad)
continue;
if (directive->ischrome) {
if (directive->regfunc) {
#ifdef MOZ_IPC
if (GeckoProcessType_Default != XRE_GetProcessType())
continue;
@ -619,7 +621,7 @@ ParseManifestCommon(NSLocationType aType, nsILocalFile* aFile,
(nsChromeRegistry::gChromeRegistry->*(directive->regfunc))
(chromecx, line, argv, platform, contentAccessible);
}
else if (!aChromeOnly) {
else if (directive->ischrome || !aChromeOnly) {
if (directive->isContract) {
CachedDirective* cd = contracts.AppendElement();
cd->lineno = line;
@ -643,7 +645,7 @@ void
ParseManifest(NSLocationType type, nsILocalFile* file,
char* buf, bool aChromeOnly)
{
nsComponentManagerImpl::ManifestProcessingContext mgrcx(type, file);
nsComponentManagerImpl::ManifestProcessingContext mgrcx(type, file, aChromeOnly);
nsChromeRegistry::ManifestProcessingContext chromecx(type, file);
ParseManifestCommon(type, file, mgrcx, chromecx, NULL, buf, aChromeOnly);
}
@ -653,7 +655,7 @@ void
ParseManifest(NSLocationType type, const char* jarPath,
char* buf, bool aChromeOnly)
{
nsComponentManagerImpl::ManifestProcessingContext mgrcx(type, jarPath);
nsComponentManagerImpl::ManifestProcessingContext mgrcx(type, jarPath, aChromeOnly);
nsChromeRegistry::ManifestProcessingContext chromecx(type, jarPath);
ParseManifestCommon(type, mozilla::OmnijarPath(), mgrcx, chromecx, jarPath,
buf, aChromeOnly);

Просмотреть файл

@ -107,7 +107,6 @@
#endif
#ifdef MOZ_OMNIJAR
#include "nsManifestZIPLoader.h"
#include "mozilla/Omnijar.h"
static NS_DEFINE_CID(kZipReaderCID, NS_ZIPREADER_CID);
#endif
@ -370,25 +369,16 @@ nsresult nsComponentManagerImpl::Init()
InitializeStaticModules();
InitializeModuleLocations();
NS_NAMED_LITERAL_CSTRING(strComponents, "components");
NS_NAMED_LITERAL_CSTRING(strChrome, "chrome");
ComponentLocation appLocations[2] = {
{ NS_COMPONENT_LOCATION, CloneAndAppend(appDir, strComponents) },
{ NS_COMPONENT_LOCATION, CloneAndAppend(appDir, strChrome) },
};
sModuleLocations->
InsertElementsAt(0, appLocations, NS_ARRAY_LENGTH(appLocations));
ComponentLocation* cl = sModuleLocations->InsertElementAt(0);
cl->type = NS_COMPONENT_LOCATION;
cl->location = CloneAndAppend(appDir, NS_LITERAL_CSTRING("chrome.manifest"));
PRBool equals = PR_FALSE;
appDir->Equals(greDir, &equals);
if (!equals) {
ComponentLocation greLocations[2] = {
{ NS_COMPONENT_LOCATION, CloneAndAppend(greDir, strComponents) },
{ NS_COMPONENT_LOCATION, CloneAndAppend(greDir, strChrome) },
};
sModuleLocations->
InsertElementsAt(0, greLocations, NS_ARRAY_LENGTH(greLocations));
cl = sModuleLocations->InsertElementAt(0);
cl->type = NS_COMPONENT_LOCATION;
cl->location = CloneAndAppend(greDir, NS_LITERAL_CSTRING("chrome.manifest"));
}
PR_LOG(nsComponentManagerLog, PR_LOG_DEBUG,
@ -407,12 +397,14 @@ nsresult nsComponentManagerImpl::Init()
RegisterModule((*sStaticModules)[i], NULL);
#ifdef MOZ_OMNIJAR
RegisterOmnijar(false);
mManifestLoader = new nsManifestZIPLoader();
RegisterOmnijar("chrome.manifest", false);
#endif
for (PRUint32 i = 0; i < sModuleLocations->Length(); ++i) {
ComponentLocation& l = sModuleLocations->ElementAt(i);
RegisterLocation(l.type, l.location, false);
RegisterManifestFile(l.type, l.location, false);
}
nsCategoryManager::GetSingleton()->SuppressNotifications(false);
@ -530,97 +522,41 @@ GetExtension(nsILocalFile* file)
return extension;
}
void
nsComponentManagerImpl::RegisterLocation(NSLocationType aType,
nsILocalFile* aLocation,
bool aChromeOnly)
{
nsCOMArray<nsILocalFile> manifests;
PRBool directory = PR_FALSE;
aLocation->IsDirectory(&directory);
if (directory)
GetManifestsInDirectory(aLocation, manifests);
else if (GetExtension(aLocation).LowerCaseEqualsLiteral("manifest"))
manifests.AppendObject(aLocation);
for (PRInt32 i = 0; i < manifests.Count(); ++i)
RegisterManifestFile(aType, manifests[i], aChromeOnly);
}
#ifdef MOZ_OMNIJAR
void
nsComponentManagerImpl::RegisterOmnijar(bool aChromeOnly)
nsComponentManagerImpl::RegisterOmnijar(const char* aPath, bool aChromeOnly)
{
nsCOMPtr<nsIManifestLoader> loader = new nsManifestZIPLoader();
mManifestLoader = loader;
mRegisterJARChromeOnly = aChromeOnly;
loader->EnumerateEntries(mozilla::OmnijarPath(), this);
mManifestLoader = NULL;
}
NS_IMETHODIMP
nsComponentManagerImpl::FoundEntry(const char* aPath,
PRInt32 aIndex,
nsIInputStream* aStream)
{
NS_ASSERTION(mManifestLoader, "Not registering a JAR.");
nsCOMPtr<nsIInputStream> is = mManifestLoader->LoadEntry(aPath);
PRUint32 flen;
aStream->Available(&flen);
is->Available(&flen);
nsAutoArrayPtr<char> whole(new char[flen + 1]);
if (!whole)
return NS_ERROR_OUT_OF_MEMORY;
return;
for (PRUint32 totalRead = 0; totalRead < flen; ) {
PRUint32 avail;
PRUint32 read;
if (NS_FAILED(aStream->Available(&avail)))
return NS_ERROR_FAILURE;
if (NS_FAILED(is->Available(&avail)))
return;
if (avail > flen)
return NS_ERROR_FAILURE;
return;
if (NS_FAILED(aStream->Read(whole + totalRead, avail, &read)))
return NS_ERROR_FAILURE;
if (NS_FAILED(is->Read(whole + totalRead, avail, &read)))
return;
totalRead += read;
}
whole[flen] = '\0';
ParseManifest(NS_COMPONENT_LOCATION, aPath, whole, mRegisterJARChromeOnly);
return NS_OK;
ParseManifest(NS_COMPONENT_LOCATION, aPath, whole, aChromeOnly);
}
#endif // MOZ_OMNIJAR
void
nsComponentManagerImpl::GetManifestsInDirectory(nsILocalFile* aDirectory,
nsCOMArray<nsILocalFile>& aManifests)
{
nsCOMPtr<nsISimpleEnumerator> entries;
aDirectory->GetDirectoryEntries(getter_AddRefs(entries));
if (!entries)
return;
PRBool more;
while (NS_SUCCEEDED(entries->HasMoreElements(&more)) && more) {
nsCOMPtr<nsISupports> supp;
entries->GetNext(getter_AddRefs(supp));
nsCOMPtr<nsILocalFile> f = do_QueryInterface(supp);
if (!f)
continue;
if (GetExtension(f).LowerCaseEqualsLiteral("manifest"))
aManifests.AppendObject(f);
}
}
namespace {
struct AutoCloseFD
{
@ -654,8 +590,12 @@ nsComponentManagerImpl::RegisterManifestFile(NSLocationType aType,
AutoCloseFD fd;
rv = aFile->OpenNSPRFileDesc(PR_RDONLY, 0444, &fd);
if (NS_FAILED(rv))
if (NS_FAILED(rv)) {
nsCAutoString path;
aFile->GetNativePath(path);
LogMessage("Could not read chrome manifest file '%s'.", path.get());
return;
}
PRFileInfo64 fileInfo;
if (PR_SUCCESS != PR_GetOpenFileInfo64(fd, &fileInfo))
@ -689,6 +629,54 @@ TranslateSlashes(char* path)
}
#endif
#ifdef MOZ_OMNIJAR
static void
AppendFileToManifestPath(nsCString& path,
const char* file)
{
PRInt32 i = path.RFindChar('/');
if (kNotFound == i)
path.Truncate(0);
else
path.Truncate(i + 1);
path.Append(file);
}
#endif
void
nsComponentManagerImpl::ManifestManifest(ManifestProcessingContext& cx, int lineno, char *const * argv)
{
char* file = argv[0];
#ifdef TRANSLATE_SLASHES
TranslateSlashes(file);
#endif
#ifdef MOZ_OMNIJAR
if (cx.mPath) {
nsCAutoString manifest(cx.mPath);
AppendFileToManifestPath(manifest, file);
RegisterOmnijar(manifest.get(), cx.mChromeOnly);
}
else
#endif
{
nsCOMPtr<nsIFile> cfile;
cx.mFile->GetParent(getter_AddRefs(cfile));
nsCOMPtr<nsILocalFile> clfile = do_QueryInterface(cfile);
nsresult rv = clfile->AppendRelativeNativePath(nsDependentCString(file));
if (NS_FAILED(rv)) {
NS_WARNING("Couldn't append relative path?");
return;
}
RegisterManifestFile(cx.mType, clfile, cx.mChromeOnly);
}
}
void
nsComponentManagerImpl::ManifestBinaryComponent(ManifestProcessingContext& cx, int lineno, char *const * argv)
{
@ -724,21 +712,6 @@ nsComponentManagerImpl::ManifestBinaryComponent(ManifestProcessingContext& cx, i
RegisterModule(m, clfile);
}
#ifdef MOZ_OMNIJAR
static void
AppendFileToManifestPath(nsCString& path,
const char* file)
{
PRInt32 i = path.RFindChar('/');
if (kNotFound == i)
path.Truncate(0);
else
path.Truncate(i + 1);
path.Append(file);
}
#endif
void
nsComponentManagerImpl::ManifestXPT(ManifestProcessingContext& cx, int lineno, char *const * argv)
{
@ -753,10 +726,9 @@ nsComponentManagerImpl::ManifestXPT(ManifestProcessingContext& cx, int lineno, c
nsCAutoString manifest(cx.mPath);
AppendFileToManifestPath(manifest, file);
nsCOMPtr<nsIInputStream> stream;
nsresult rv = mManifestLoader->LoadEntry(cx.mFile, manifest.get(),
getter_AddRefs(stream));
if (NS_FAILED(rv)) {
nsCOMPtr<nsIInputStream> stream =
mManifestLoader->LoadEntry(manifest.get());
if (!stream) {
NS_WARNING("Failed to load omnijar XPT file.");
return;
}
@ -906,12 +878,12 @@ void
nsComponentManagerImpl::RereadChromeManifests()
{
#ifdef MOZ_OMNIJAR
RegisterOmnijar(true);
RegisterOmnijar("chrome.manifest", true);
#endif
for (PRUint32 i = 0; i < sModuleLocations->Length(); ++i) {
ComponentLocation& l = sModuleLocations->ElementAt(i);
RegisterLocation(l.type, l.location, true);
RegisterManifestFile(l.type, l.location, true);
}
}
@ -2019,7 +1991,7 @@ XRE_AddManifestLocation(NSLocationType aType, nsILocalFile* aLocation)
if (nsComponentManagerImpl::gComponentManager &&
nsComponentManagerImpl::NORMAL == nsComponentManagerImpl::gComponentManager->mStatus)
nsComponentManagerImpl::gComponentManager->RegisterLocation(aType, aLocation, false);
nsComponentManagerImpl::gComponentManager->RegisterManifestFile(aType, aLocation, false);
return NS_OK;
}

Просмотреть файл

@ -68,7 +68,7 @@
#ifdef MOZ_OMNIJAR
#include "mozilla/Omnijar.h"
#include "nsIManifestLoader.h"
#include "nsManifestZIPLoader.h"
#endif
struct nsFactoryEntry;
@ -118,18 +118,12 @@ class nsComponentManagerImpl
, public nsSupportsWeakReference
, public nsIComponentRegistrar
, public nsIInterfaceRequestor
#ifdef MOZ_OMNIJAR
, public nsIManifestLoaderSink
#endif
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIINTERFACEREQUESTOR
NS_DECL_NSICOMPONENTMANAGER
NS_DECL_NSICOMPONENTREGISTRAR
#ifdef MOZ_OMNIJAR
NS_DECL_NSIMANIFESTLOADERSINK
#endif
static nsresult Create(nsISupports* aOuter, REFNSIID aIID, void** aResult);
@ -259,32 +253,28 @@ public:
KnownModule* aModule);
void RegisterContractID(const mozilla::Module::ContractIDEntry* aEntry);
void RegisterLocation(NSLocationType aType, nsILocalFile* aLocation,
bool aChromeOnly);
#ifdef MOZ_OMNIJAR
void RegisterOmnijar(bool aChromeOnly);
void RegisterOmnijar(const char* aPath, bool aChromeOnly);
#endif
void GetManifestsInDirectory(nsILocalFile* aDirectory,
nsCOMArray<nsILocalFile>& aManifests);
void RegisterManifestFile(NSLocationType aType, nsILocalFile* aFile,
bool aChromeOnly);
struct ManifestProcessingContext
{
ManifestProcessingContext(NSLocationType aType, nsILocalFile* aFile)
ManifestProcessingContext(NSLocationType aType, nsILocalFile* aFile, bool aChromeOnly)
: mType(aType)
, mFile(aFile)
, mPath(NULL)
, mChromeOnly(aChromeOnly)
{ }
#ifdef MOZ_OMNIJAR
ManifestProcessingContext(NSLocationType aType, const char* aPath)
ManifestProcessingContext(NSLocationType aType, const char* aPath, bool aChromeOnly)
: mType(aType)
, mFile(mozilla::OmnijarPath())
, mPath(aPath)
, mChromeOnly(aChromeOnly)
{ }
#endif
@ -293,8 +283,10 @@ public:
NSLocationType mType;
nsILocalFile* mFile;
const char* mPath;
bool mChromeOnly;
};
void ManifestManifest(ManifestProcessingContext& cx, int lineno, char *const * argv);
void ManifestBinaryComponent(ManifestProcessingContext& cx, int lineno, char *const * argv);
void ManifestXPT(ManifestProcessingContext& cx, int lineno, char *const * argv);
void ManifestComponent(ManifestProcessingContext& cx, int lineno, char *const * argv);
@ -331,8 +323,7 @@ private:
~nsComponentManagerImpl();
#ifdef MOZ_OMNIJAR
nsIManifestLoader* mManifestLoader;
bool mRegisterJARChromeOnly;
nsAutoPtr<nsManifestZIPLoader> mManifestLoader;
#endif
};

Просмотреть файл

@ -1,91 +0,0 @@
/* -*- Mode: IDL; 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 the external XPT loader interface.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corp.
* Portions created by the Initial Developer are Copyright (C) 2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* John Bandhauer <jband@netscape.com>
* Alec Flett <alecf@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either of 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 "nsISupports.idl"
#include "nsILocalFile.idl"
#include "nsIInputStream.idl"
/**
* Implement nsIXPTLoaderSink if you want to enumerate the entries in
* an XPT archive of some kind
*/
[scriptable, uuid(6E48C500-8682-4730-ADD6-7DB693B9E7BA)]
interface nsIManifestLoaderSink : nsISupports
{
/**
* Called by the loader for each components / *.manifest and
* chrome / *.manifest in the archive.
* @param itemName the name of this particular item in the archive
* @param index the index of the item inthe archive
* @param stream contains the contents of the xpt file
*/
void foundEntry(in string itemName,
in long index,
in nsIInputStream xptData);
};
/**
* The XPT loader interface: implemented by a loader to grab an input
* stream which will be consumed by the interface loader.
*/
[scriptable, uuid(368A15D9-17A9-4c2b-AC3D-A35B3A22B876)]
interface nsIManifestLoader : nsISupports {
/**
* enumerate entries in the given archive
* for each entry found, the loader will call the sink's
* foundEntry() method with the appropriate information and a
* stream that the consumer can read from
* @param file the file to read from
* @param sink an object which will be called with each file found
* in the file
*/
void enumerateEntries(in nsILocalFile file,
in nsIManifestLoaderSink sink );
/**
* Load a specific entry from the archive
* @param file the file to read from
* @param name the name of the xpt within the file
* @return an input stream that will read the raw xpt data from
* the file
*/
nsIInputStream loadEntry(in nsILocalFile file,
in string name);
};

Просмотреть файл

@ -40,79 +40,30 @@
#include "nsManifestZIPLoader.h"
#include "nsJAR.h"
#include "nsString.h"
#include "nsStringEnumerator.h"
#include "mozilla/Omnijar.h"
nsManifestZIPLoader::nsManifestZIPLoader() {
nsManifestZIPLoader::nsManifestZIPLoader()
: mZipReader(new nsJAR())
{
nsresult rv = mZipReader->Open(mozilla::OmnijarPath());
if (NS_FAILED(rv))
mZipReader = NULL;
}
NS_IMPL_ISUPPORTS1(nsManifestZIPLoader, nsIManifestLoader)
nsresult
nsManifestZIPLoader::LoadEntry(nsILocalFile* aFile,
const char* aName,
nsIInputStream** aResult)
nsManifestZIPLoader::~nsManifestZIPLoader()
{
nsCOMPtr<nsIZipReader> zip = dont_AddRef(GetZipReader(aFile));
if (!zip)
return NS_OK;
return zip->GetInputStream(aName, aResult);
}
static void
EnumerateEntriesForPattern(nsIZipReader* zip, const char* pattern,
nsIManifestLoaderSink* aSink)
already_AddRefed<nsIInputStream>
nsManifestZIPLoader::LoadEntry(const char* aName)
{
nsCOMPtr<nsIUTF8StringEnumerator> entries;
if (NS_FAILED(zip->FindEntries(pattern, getter_AddRefs(entries))) ||
!entries) {
return;
}
if (!mZipReader)
return NULL;
PRBool hasMore;
int index = 0;
while (NS_SUCCEEDED(entries->HasMore(&hasMore)) && hasMore) {
nsCAutoString itemName;
if (NS_FAILED(entries->GetNext(itemName)))
return;
nsCOMPtr<nsIInputStream> stream;
if (NS_FAILED(zip->GetInputStream(itemName.get(), getter_AddRefs(stream))))
continue;
// ignore the result
aSink->FoundEntry(itemName.get(), index++, stream);
}
}
nsresult
nsManifestZIPLoader::EnumerateEntries(nsILocalFile* aFile,
nsIManifestLoaderSink* aSink)
{
nsCOMPtr<nsIZipReader> zip = dont_AddRef(GetZipReader(aFile));
if (!zip) {
NS_WARNING("Could not get Zip Reader");
return NS_OK;
}
EnumerateEntriesForPattern(zip, "components/*.manifest$", aSink);
EnumerateEntriesForPattern(zip, "chrome/*.manifest$", aSink);
return NS_OK;
}
already_AddRefed<nsIZipReader>
nsManifestZIPLoader::GetZipReader(nsILocalFile* file)
{
NS_ASSERTION(file, "bad file");
nsCOMPtr<nsIZipReader> reader = new nsJAR();
nsresult rv = reader->Open(file);
nsCOMPtr<nsIInputStream> is;
nsresult rv = mZipReader->GetInputStream(aName, getter_AddRefs(is));
if (NS_FAILED(rv))
return NULL;
return reader.forget();
return is.forget();
}

Просмотреть файл

@ -37,21 +37,20 @@
*
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.h"
#include "nsIManifestLoader.h"
#include "nsCOMPtr.h"
#include "nsIZipReader.h"
#include "nsIInputStream.h"
class nsManifestZIPLoader : public nsIManifestLoader
class nsManifestZIPLoader
{
public:
nsManifestZIPLoader();
virtual ~nsManifestZIPLoader() {}
NS_DECL_ISUPPORTS
NS_DECL_NSIMANIFESTLOADER
~nsManifestZIPLoader();
already_AddRefed<nsIInputStream> LoadEntry(const char* name);
private:
already_AddRefed<nsIZipReader> GetZipReader(nsILocalFile* aFile);
nsCOMPtr<nsIZipReader> mZipReader;
};

Просмотреть файл

@ -158,7 +158,7 @@ bool TestContractFirst()
}
static already_AddRefed<nsILocalFile>
GetRegDirectory(const char* basename, const char* dirname)
GetRegDirectory(const char* basename, const char* dirname, const char* leafname)
{
nsCOMPtr<nsILocalFile> f;
nsresult rv = NS_NewNativeLocalFile(nsDependentCString(basename), PR_TRUE,
@ -167,6 +167,7 @@ GetRegDirectory(const char* basename, const char* dirname)
return NULL;
f->AppendNative(nsDependentCString(dirname));
f->AppendNative(nsDependentCString(leafname));
return f.forget();
}
@ -184,9 +185,9 @@ int main(int argc, char** argv)
const char *regPath = argv[1];
XRE_AddManifestLocation(NS_COMPONENT_LOCATION,
nsCOMPtr<nsILocalFile>(GetRegDirectory(regPath, "core")));
nsCOMPtr<nsILocalFile>(GetRegDirectory(regPath, "core", "component.manifest")));
XRE_AddManifestLocation(NS_COMPONENT_LOCATION,
nsCOMPtr<nsILocalFile>(GetRegDirectory(regPath, "extension")));
nsCOMPtr<nsILocalFile>(GetRegDirectory(regPath, "extension", "extComponent.manifest")));
ScopedXPCOM xpcom("RegistrationOrder");
if (xpcom.failed())
return 1;

Просмотреть файл

@ -230,12 +230,13 @@ sub do_copyfile
# set the destination path, if alternate destination given, use it.
if ($flat) {
if ($srcsuffix eq ".manifest" && $srcpath =~ m|/components/$|) {
if ($srcsuffix eq ".manifest" && $srcpath =~ m'/(chrome|components)/$') {
my $subdir = $1;
if ($component eq "") {
die ("Manifest file was not part of a component.");
}
$destpathcomp = "$srcdir/manifests/$component";
$destpathcomp = "$srcdir/manifests/$component/$subdir";
$altdest = "$srcname$srcsuffix";
}
elsif ($srcsuffix eq ".xpt" && $srcpath =~ m|/components/$|) {

Просмотреть файл

@ -67,13 +67,12 @@ $return = GetOptions( "source|s=s", \$srcdir,
"<>", \&do_badargument
);
if ($finaldir ne "") {
$bindir = "";
}
else {
$bindir = "bin/";
if ($finaldir eq "") {
die "Error: -f is required";
}
my $bindir = "";
# remove extra slashes from $destdir
$destdir =~ s:/+:/:g;
@ -133,16 +132,9 @@ foreach my $component (@xptdirs) {
# merge .xpt files into one if we found any in the dir
if ( scalar(@xptfiles) ) {
my ($merged, $fmerged, $manifest);
if ($finaldir ne "") {
$merged = "$finaldir/$component.xpt";
$manifest = "$finaldir/$component.manifest";
}
else {
$fmerged = "$destdir/$component/$bindir"."components/$component.xpt";
$merged = $fmerged.".new";
$manifest = "$destdir/$component/$bindir"."components/$component.manifest";
}
my ($merged, $manifest);
$merged = "$finaldir/$component.xpt";
$manifest = "$finaldir/interfaces.manifest";
my @realxptfiles;
my $realmerged;
@ -166,23 +158,8 @@ foreach my $component (@xptdirs) {
open MANIFEST, '>>', $manifest;
print MANIFEST "interfaces $component.xpt\n";
close MANIFEST;
if ($finaldir eq "") {
# remove old .xpt files in the component directory.
($debug >= 2) && print "Deleting individual xpt files.\n";
for my $file (@xptfiles) {
($debug >= 4) && print "\t$file";
unlink ($file) ||
die "Couldn't unlink file $file.\n";
($debug >= 4) && print "\t\tdeleted\n\n";
}
($debug >= 2) && print "Renaming $merged as $fmerged\n";
rename ($merged, $fmerged) ||
die "Rename of '$merged' to '$fmerged' failed.\n";
}
}
}
}
}
($debug >= 1) && print "Linking .xpt files completed.\n";