зеркало из 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
|
# TODO: If this ever goes from relocatable package to system-installed, this may need to be
|
||||||
# a configured-in path.
|
# 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|$)')
|
_simpleopts = re.compile(r'^[a-zA-Z]+(\s|$)')
|
||||||
def parsemakeflags(env):
|
def parsemakeflags(env):
|
||||||
|
@ -221,7 +221,7 @@ def main(args, env, cwd, cb):
|
||||||
if options.directory is None:
|
if options.directory is None:
|
||||||
workdir = cwd
|
workdir = cwd
|
||||||
else:
|
else:
|
||||||
workdir = os.path.join(cwd, options.directory)
|
workdir = util.normaljoin(cwd, options.directory)
|
||||||
|
|
||||||
if options.jobcount != 1:
|
if options.jobcount != 1:
|
||||||
longflags.append('-j%i' % (options.jobcount,))
|
longflags.append('-j%i' % (options.jobcount,))
|
||||||
|
@ -239,7 +239,7 @@ def main(args, env, cwd, cb):
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
|
|
||||||
if len(options.makefiles) == 0:
|
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')
|
options.makefiles.append('Makefile')
|
||||||
else:
|
else:
|
||||||
print "No makefile found"
|
print "No makefile found"
|
||||||
|
|
|
@ -961,8 +961,8 @@ class Target(object):
|
||||||
libname = lp.resolve('', stem)
|
libname = lp.resolve('', stem)
|
||||||
|
|
||||||
for dir in searchdirs:
|
for dir in searchdirs:
|
||||||
libpath = os.path.join(dir, libname).replace('\\', '/')
|
libpath = util.normaljoin(dir, libname).replace('\\', '/')
|
||||||
fspath = os.path.join(makefile.workdir, libpath)
|
fspath = util.normaljoin(makefile.workdir, libpath)
|
||||||
mtime = getmtime(fspath)
|
mtime = getmtime(fspath)
|
||||||
if mtime is not None:
|
if mtime is not None:
|
||||||
self.vpathtarget = libpath
|
self.vpathtarget = libpath
|
||||||
|
@ -975,12 +975,13 @@ class Target(object):
|
||||||
|
|
||||||
search = [self.target]
|
search = [self.target]
|
||||||
if not os.path.isabs(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 dir in makefile.getvpath(self.target)]
|
||||||
|
|
||||||
for t in search:
|
for t in search:
|
||||||
fspath = os.path.join(makefile.workdir, t).replace('\\', '/')
|
fspath = util.normaljoin(makefile.workdir, t).replace('\\', '/')
|
||||||
mtime = getmtime(fspath)
|
mtime = getmtime(fspath)
|
||||||
|
# _log.info("Searching %s ... checking %s ... mtime %r" % (t, fspath, mtime))
|
||||||
if mtime is not None:
|
if mtime is not None:
|
||||||
self.vpathtarget = t
|
self.vpathtarget = t
|
||||||
self.mtime = mtime
|
self.mtime = mtime
|
||||||
|
@ -1321,7 +1322,7 @@ class _RemakeContext(object):
|
||||||
self.cb(remade=True)
|
self.cb(remade=True)
|
||||||
return
|
return
|
||||||
elif required and t.mtime is None:
|
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
|
return
|
||||||
|
|
||||||
self.cb(remade=False)
|
self.cb(remade=False)
|
||||||
|
@ -1482,7 +1483,7 @@ class Makefile(object):
|
||||||
Include the makefile at `path`.
|
Include the makefile at `path`.
|
||||||
"""
|
"""
|
||||||
self.included.append((path, required))
|
self.included.append((path, required))
|
||||||
fspath = os.path.join(self.workdir, path)
|
fspath = util.normaljoin(self.workdir, path)
|
||||||
if os.path.exists(fspath):
|
if os.path.exists(fspath):
|
||||||
stmts = parser.parsefile(fspath)
|
stmts = parser.parsefile(fspath)
|
||||||
self.variables.append('MAKEFILE_LIST', Variables.SOURCE_AUTOMATIC, path, None, self)
|
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):
|
def resolve(self, makefile, variables, fd, setting):
|
||||||
assert os.path.isabs(makefile.workdir)
|
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)]))
|
for path in self._arguments[0].resolvesplit(makefile, variables, setting)]))
|
||||||
|
|
||||||
class IfFunction(Function):
|
class IfFunction(Function):
|
||||||
|
|
|
@ -7,6 +7,7 @@ Filename globbing like the python glob module with minor differences:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import os, re, fnmatch
|
import os, re, fnmatch
|
||||||
|
import util
|
||||||
|
|
||||||
_globcheck = re.compile('[[*?]')
|
_globcheck = re.compile('[[*?]')
|
||||||
|
|
||||||
|
@ -30,11 +31,11 @@ def glob(fsdir, path):
|
||||||
r = []
|
r = []
|
||||||
|
|
||||||
for dir in dirsfound:
|
for dir in dirsfound:
|
||||||
fspath = os.path.join(fsdir, dir)
|
fspath = util.normaljoin(fsdir, dir)
|
||||||
if not os.path.isdir(fspath):
|
if not os.path.isdir(fspath):
|
||||||
continue
|
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
|
return r
|
||||||
|
|
||||||
|
@ -49,7 +50,7 @@ def globpattern(dir, pattern):
|
||||||
return ['']
|
return ['']
|
||||||
return []
|
return []
|
||||||
|
|
||||||
if os.path.exists(os.path.join(dir, pattern)):
|
if os.path.exists(util.normaljoin(dir, pattern)):
|
||||||
return [pattern]
|
return [pattern]
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
@ -61,7 +62,7 @@ def globpattern(dir, pattern):
|
||||||
if not leaf.startswith('.')]
|
if not leaf.startswith('.')]
|
||||||
|
|
||||||
leaves = fnmatch.filter(leaves, pattern)
|
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()
|
leaves.sort()
|
||||||
return leaves
|
return leaves
|
||||||
|
|
|
@ -73,7 +73,7 @@ def call(cline, env, cwd, loc, cb, context, echo):
|
||||||
return
|
return
|
||||||
|
|
||||||
if argv[0].find('/') != -1:
|
if argv[0].find('/') != -1:
|
||||||
executable = os.path.join(cwd, argv[0])
|
executable = util.normaljoin(cwd, argv[0])
|
||||||
else:
|
else:
|
||||||
executable = None
|
executable = None
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,15 @@ class MakeError(Exception):
|
||||||
|
|
||||||
return "%s%s" % (locstr, self.msg)
|
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):
|
def joiniter(fd, it):
|
||||||
"""
|
"""
|
||||||
Given an iterator that returns strings, write the words with a space in between each.
|
Given an iterator that returns strings, write the words with a space in between each.
|
||||||
|
|
Загрузка…
Ссылка в новой задаче