|
9 | 9 | importre |
10 | 10 | importtempfile |
11 | 11 | importsys |
| 12 | +importsubprocess |
12 | 13 |
|
13 | 14 |
|
14 | 15 | # A minimal memoizing decorator. It'll blow up if the args aren't immutable, |
@@ -337,11 +338,16 @@ def WriteOnDiff(filename): |
337 | 338 | classWriter(object): |
338 | 339 | """Wrapper around file which only covers the target if it differs.""" |
339 | 340 | def__init__(self): |
| 341 | +# On Cygwin remove the "dir" argument because `C:` prefixed paths are treated as relative, |
| 342 | +# consequently ending up with current dir "/cygdrive/c/..." being prefixed to those, which was |
| 343 | +# obviously a non-existent path, for example: "/cygdrive/c/<some folder>/C:\<my win style abs path>". |
| 344 | +# See https://docs.python.org/2/library/tempfile.html#tempfile.mkstemp for more details |
| 345 | +base_temp_dir=""ifIsCygwin() elseos.path.dirname(filename) |
340 | 346 | # Pick temporary file. |
341 | 347 | tmp_fd, self.tmp_path=tempfile.mkstemp( |
342 | 348 | suffix='.tmp', |
343 | 349 | prefix=os.path.split(filename)[1] +'.gyp.', |
344 | | -dir=os.path.split(filename)[0]) |
| 350 | +dir=base_temp_dir) |
345 | 351 | try: |
346 | 352 | self.tmp_file=os.fdopen(tmp_fd, 'wb') |
347 | 353 | exceptException: |
@@ -611,3 +617,14 @@ def CrossCompileRequested(): |
611 | 617 | os.environ.get('AR_target') or |
612 | 618 | os.environ.get('CC_target') or |
613 | 619 | os.environ.get('CXX_target')) |
| 620 | + |
| 621 | +defIsCygwin(): |
| 622 | +try: |
| 623 | +out=subprocess.Popen("uname", |
| 624 | +stdout=subprocess.PIPE, |
| 625 | +stderr=subprocess.STDOUT) |
| 626 | +stdout,stderr=out.communicate() |
| 627 | +return"CYGWIN"instr(stdout) |
| 628 | +exceptException: |
| 629 | +returnFalse |
| 630 | + |
0 commit comments