Bug 524659: allow JarMaker to process jar.mn files in objdirs that aren't within topsrcdir, r=Pike

This commit is contained in:
Gavin Sharp 2009-10-27 07:33:58 -04:00
Родитель 07a15f2ff7
Коммит 091bdca45e
1 изменённых файлов: 13 добавлений и 7 удалений

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

@ -250,6 +250,7 @@ class JarMaker(object):
that against the l10nbases. l10nbases can either be path strings, or that against the l10nbases. l10nbases can either be path strings, or
callables. In the latter case, that will be called with the callables. In the latter case, that will be called with the
relativesrcdir as argument, and is expected to return a path string. relativesrcdir as argument, and is expected to return a path string.
This logic is disabled if the jar.mn path is not inside the topsrcdir.
''' '''
topsourcedir = os.path.normpath(os.path.abspath(topsourcedir)) topsourcedir = os.path.normpath(os.path.abspath(topsourcedir))
def resolveL10nBase(relpath): def resolveL10nBase(relpath):
@ -265,13 +266,18 @@ class JarMaker(object):
l10ndir = srcdir l10ndir = srcdir
if os.path.basename(srcdir) == 'locales': if os.path.basename(srcdir) == 'locales':
l10ndir = os.path.dirname(l10ndir) l10ndir = os.path.dirname(l10ndir)
assert srcdir.startswith(topsourcedir), "src dir %s not in topsourcedir %s" % (srcdir, topsourcedir)
rell10ndir = l10ndir[len(topsourcedir):].lstrip(os.sep) l10ndirs = None
# srcdir may not be a child of topsourcedir, in which case
l10ndirs = map(resolveL10nBase(rell10ndir), l10nbases) # we assume that the caller passed in suitable sourcedirs,
if localedirs is not None: # and just skip passing in localedirs
l10ndirs += [os.path.normpath(os.path.abspath(s)) if srcdir.startswith(topsourcedir):
for s in localedirs] rell10ndir = l10ndir[len(topsourcedir):].lstrip(os.sep)
l10ndirs = map(resolveL10nBase(rell10ndir), l10nbases)
if localedirs is not None:
l10ndirs += [os.path.normpath(os.path.abspath(s))
for s in localedirs]
srcdirs = [os.path.normpath(os.path.abspath(s)) srcdirs = [os.path.normpath(os.path.abspath(s))
for s in sourcedirs] + [srcdir] for s in sourcedirs] + [srcdir]
self.makeJar(infile=infile, self.makeJar(infile=infile,