Index: tools/isolate/trace_inputs.py |
diff --git a/tools/isolate/trace_inputs.py b/tools/isolate/trace_inputs.py |
index f181946aefe1309105f02e68263e4d036a692a46..43cd6ea71ce6546c3531c8562d23a59fa70640bb 100755 |
--- a/tools/isolate/trace_inputs.py |
+++ b/tools/isolate/trace_inputs.py |
@@ -16,6 +16,7 @@ import csv |
import logging |
import optparse |
import os |
+import posixpath |
import re |
import subprocess |
import sys |
@@ -132,6 +133,14 @@ def fix_python_path(cmd): |
return out |
+def posix_relpath(path, root): |
+ """posix.relpath() that keeps trailing slash.""" |
+ out = posixpath.relpath(path, root) |
+ if path.endswith('/'): |
+ out += '/' |
+ return out |
+ |
+ |
class Strace(object): |
"""strace implies linux.""" |
IGNORED = ( |
@@ -1294,12 +1303,10 @@ def trace_inputs(logfile, cmd, root_dir, cwd_dir, product_dir, force_trace): |
if product_dir and f.startswith(product_dir): |
return '<(PRODUCT_DIR)/%s' % f[len(product_dir):] |
- elif cwd_dir and f.startswith(cwd_dir): |
+ else: |
# cwd_dir is usually the directory containing the gyp file. It may be |
# empty if the whole directory containing the gyp file is needed. |
- return f[len(cwd_dir):] or './' |
- else: |
- return '<(DEPTH)/%s' % f |
+ return posix_relpath(f, cwd_dir) or './' |
corrected = [fix(f) for f in simplified] |
tracked = [f for f in corrected if not f.endswith('/') and ' ' not in f] |