зеркало из https://github.com/mozilla/pjs.git
Bug 536524. Normalize paths when possible/necessary to keep them under MAX_PATH limits. r=bsmedberg
This commit is contained in:
Родитель
3c80bf049d
Коммит
3a8b722289
|
@ -13,7 +13,7 @@ import data, parserdata, process, util
|
|||
# TODO: If this ever goes from relocatable package to system-installed, this may need to be
|
||||
# a configured-in path.
|
||||
|
||||
makepypath = os.path.normpath(os.path.join(os.path.dirname(__file__), '../make.py'))
|
||||
makepypath = util.normaljoin(os.path.dirname(__file__), '../make.py')
|
||||
|
||||
_simpleopts = re.compile(r'^[a-zA-Z]+(\s|$)')
|
||||
def parsemakeflags(env):
|
||||
|
@ -221,7 +221,7 @@ def main(args, env, cwd, cb):
|
|||
if options.directory is None:
|
||||
workdir = cwd
|
||||
else:
|
||||
workdir = os.path.join(cwd, options.directory)
|
||||
workdir = util.normaljoin(cwd, options.directory)
|
||||
|
||||
if options.jobcount != 1:
|
||||
longflags.append('-j%i' % (options.jobcount,))
|
||||
|
@ -239,7 +239,7 @@ def main(args, env, cwd, cb):
|
|||
sys.stdout.flush()
|
||||
|
||||
if len(options.makefiles) == 0:
|
||||
if os.path.exists(os.path.join(workdir, 'Makefile')):
|
||||
if os.path.exists(util.normaljoin(workdir, 'Makefile')):
|
||||
options.makefiles.append('Makefile')
|
||||
else:
|
||||
print "No makefile found"
|
||||
|
|
|
@ -961,8 +961,8 @@ class Target(object):
|
|||
libname = lp.resolve('', stem)
|
||||
|
||||
for dir in searchdirs:
|
||||
libpath = os.path.join(dir, libname).replace('\\', '/')
|
||||
fspath = os.path.join(makefile.workdir, libpath)
|
||||
libpath = util.normaljoin(dir, libname).replace('\\', '/')
|
||||
fspath = util.normaljoin(makefile.workdir, libpath)
|
||||
mtime = getmtime(fspath)
|
||||
if mtime is not None:
|
||||
self.vpathtarget = libpath
|
||||
|
@ -975,12 +975,13 @@ class Target(object):
|
|||
|
||||
search = [self.target]
|
||||
if not os.path.isabs(self.target):
|
||||
search += [os.path.join(dir, self.target).replace('\\', '/')
|
||||
search += [util.normaljoin(dir, self.target).replace('\\', '/')
|
||||
for dir in makefile.getvpath(self.target)]
|
||||
|
||||
for t in search:
|
||||
fspath = os.path.join(makefile.workdir, t).replace('\\', '/')
|
||||
fspath = util.normaljoin(makefile.workdir, t).replace('\\', '/')
|
||||
mtime = getmtime(fspath)
|
||||
# _log.info("Searching %s ... checking %s ... mtime %r" % (t, fspath, mtime))
|
||||
if mtime is not None:
|
||||
self.vpathtarget = t
|
||||
self.mtime = mtime
|
||||
|
@ -1321,7 +1322,7 @@ class _RemakeContext(object):
|
|||
self.cb(remade=True)
|
||||
return
|
||||
elif required and t.mtime is None:
|
||||
self.cb(remade=False, error=DataError("No rule to remaking missing include file %s", t.target))
|
||||
self.cb(remade=False, error=DataError("No rule to remake missing include file %s" % t.target))
|
||||
return
|
||||
|
||||
self.cb(remade=False)
|
||||
|
@ -1482,7 +1483,7 @@ class Makefile(object):
|
|||
Include the makefile at `path`.
|
||||
"""
|
||||
self.included.append((path, required))
|
||||
fspath = os.path.join(self.workdir, path)
|
||||
fspath = util.normaljoin(self.workdir, path)
|
||||
if os.path.exists(fspath):
|
||||
stmts = parser.parsefile(fspath)
|
||||
self.variables.append('MAKEFILE_LIST', Variables.SOURCE_AUTOMATIC, path, None, self)
|
||||
|
|
|
@ -415,7 +415,7 @@ class AbspathFunction(Function):
|
|||
|
||||
def resolve(self, makefile, variables, fd, setting):
|
||||
assert os.path.isabs(makefile.workdir)
|
||||
fd.write(' '.join([os.path.join(makefile.workdir, path).replace('\\', '/')
|
||||
fd.write(' '.join([util.normaljoin(makefile.workdir, path).replace('\\', '/')
|
||||
for path in self._arguments[0].resolvesplit(makefile, variables, setting)]))
|
||||
|
||||
class IfFunction(Function):
|
||||
|
|
|
@ -7,6 +7,7 @@ Filename globbing like the python glob module with minor differences:
|
|||
"""
|
||||
|
||||
import os, re, fnmatch
|
||||
import util
|
||||
|
||||
_globcheck = re.compile('[[*?]')
|
||||
|
||||
|
@ -30,11 +31,11 @@ def glob(fsdir, path):
|
|||
r = []
|
||||
|
||||
for dir in dirsfound:
|
||||
fspath = os.path.join(fsdir, dir)
|
||||
fspath = util.normaljoin(fsdir, dir)
|
||||
if not os.path.isdir(fspath):
|
||||
continue
|
||||
|
||||
r.extend((os.path.join(dir, found) for found in globpattern(fspath, leaf)))
|
||||
r.extend((util.normaljoin(dir, found) for found in globpattern(fspath, leaf)))
|
||||
|
||||
return r
|
||||
|
||||
|
@ -49,7 +50,7 @@ def globpattern(dir, pattern):
|
|||
return ['']
|
||||
return []
|
||||
|
||||
if os.path.exists(os.path.join(dir, pattern)):
|
||||
if os.path.exists(util.normaljoin(dir, pattern)):
|
||||
return [pattern]
|
||||
return []
|
||||
|
||||
|
@ -61,7 +62,7 @@ def globpattern(dir, pattern):
|
|||
if not leaf.startswith('.')]
|
||||
|
||||
leaves = fnmatch.filter(leaves, pattern)
|
||||
leaves = filter(lambda l: os.path.exists(os.path.join(dir, l)), leaves)
|
||||
leaves = filter(lambda l: os.path.exists(util.normaljoin(dir, l)), leaves)
|
||||
|
||||
leaves.sort()
|
||||
return leaves
|
||||
|
|
|
@ -73,7 +73,7 @@ def call(cline, env, cwd, loc, cb, context, echo):
|
|||
return
|
||||
|
||||
if argv[0].find('/') != -1:
|
||||
executable = os.path.join(cwd, argv[0])
|
||||
executable = util.normaljoin(cwd, argv[0])
|
||||
else:
|
||||
executable = None
|
||||
|
||||
|
|
|
@ -12,6 +12,15 @@ class MakeError(Exception):
|
|||
|
||||
return "%s%s" % (locstr, self.msg)
|
||||
|
||||
def normaljoin(path, suffix):
|
||||
"""
|
||||
Combine the given path with the suffix, and normalize if necessary to shrink the path to avoid hitting path length limits
|
||||
"""
|
||||
result = os.path.join(path, suffix)
|
||||
if len(result) > 255:
|
||||
result = os.path.normpath(result)
|
||||
return result
|
||||
|
||||
def joiniter(fd, it):
|
||||
"""
|
||||
Given an iterator that returns strings, write the words with a space in between each.
|
||||
|
|
Загрузка…
Ссылка в новой задаче