Skip to content

Commit 30a0d62

Browse files
committed
deps: float gyp patch for long filenames
Pulling in https://codereview.chromium.org/2019133002/ in its current state, as gyp seems to be largely abandoned as a project. Original commit message: Hash intermediate file name to avoid ENAMETOOLONG Hash the intermediate Makefile target used for multi-output rules so that it still works when the involved file names are very long. Since the intermediate file's name is effectively arbitrary, this does not come with notable behavioural changes. The `import hashlib` boilerplate is taken directly from `xcodeproj_file.py`. Concretely, this makes the V8 inspector build currently fail when long pathnames are involved, notably when using ecryptfs which has a lower file name length limit. Fixes: #7959 Ref: #7510
1 parent 29e49fc commit 30a0d62

File tree

1 file changed

+15
-1
lines changed
  • tools/gyp/pylib/gyp/generator

1 file changed

+15
-1
lines changed

tools/gyp/pylib/gyp/generator/make.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,17 @@
3131
from gyp.common import GetEnvironFallback
3232
from gyp.common import GypError
3333

34+
# hashlib is supplied as of Python 2.5 as the replacement interface for sha
35+
# and other secure hashes. In 2.6, sha is deprecated. Import hashlib if
36+
# available, avoiding a deprecation warning under 2.6. Import sha otherwise,
37+
# preserving 2.4 compatibility.
38+
try:
39+
import hashlib
40+
_new_sha1 = hashlib.sha1
41+
except ImportError:
42+
import sha
43+
_new_sha1 = sha.new
44+
3445
generator_default_variables = {
3546
'EXECUTABLE_PREFIX': '',
3647
'EXECUTABLE_SUFFIX': '',
@@ -1743,7 +1754,10 @@ def WriteMakeRule(self, outputs, inputs, actions=None, comment=None,
17431754
# actual command.
17441755
# - The intermediate recipe will 'touch' the intermediate file.
17451756
# - The multi-output rule will have an do-nothing recipe.
1746-
intermediate = "%s.intermediate" % (command if command else self.target)
1757+
1758+
# Hash the target name to avoid generating overlong filenames.
1759+
cmddigest = _new_sha1(command if command else self.target).hexdigest()
1760+
intermediate = "%s.intermediate" % (cmddigest)
17471761
self.WriteLn('%s: %s' % (' '.join(outputs), intermediate))
17481762
self.WriteLn('\t%s' % '@:');
17491763
self.WriteLn('%s: %s' % ('.INTERMEDIATE', intermediate))

0 commit comments

Comments
 (0)