Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1116)

Unified Diff: build/linux/rewrite_dirs.py

Issue 5105005: Improve pkg-config-wrapper to support ChromiumOS sysroots (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add copyright+license notice, add some description Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « build/linux/pkg-config-wrapper ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/linux/rewrite_dirs.py
diff --git a/build/linux/rewrite_dirs.py b/build/linux/rewrite_dirs.py
index 5c41cf9474cbce9f962b1f428d0a05cb90fe2b75..9e166d0efd1b3d889ae689b3a2f7777c05e88613 100755
--- a/build/linux/rewrite_dirs.py
+++ b/build/linux/rewrite_dirs.py
@@ -7,6 +7,7 @@
import sys
import os
+import optparse
REWRITE_PREFIX = ['-I',
'-idirafter',
@@ -18,15 +19,19 @@ REWRITE_PREFIX = ['-I',
'-isystem',
'-L']
-def RewritePath(path, sysroot):
- """Rewrites a path by prefixing it with the sysroot if it is absolute."""
+def RewritePath(path, opts):
+ """Rewrites a path by stripping the prefix and prepending the sysroot."""
+ sysroot = opts.sysroot
+ prefix = opts.strip_prefix
if os.path.isabs(path) and not path.startswith(sysroot):
+ if path.startswith(prefix):
+ path = path[len(prefix):]
path = path.lstrip('/')
return os.path.join(sysroot, path)
else:
return path
-def RewriteLine(line, sysroot):
+def RewriteLine(line, opts):
"""Rewrites all the paths in recognized options."""
args = line.split()
count = len(args)
@@ -38,25 +43,24 @@ def RewriteLine(line, sysroot):
if args[i] == prefix:
i += 1
try:
- args[i] = RewritePath(args[i], sysroot)
+ args[i] = RewritePath(args[i], opts)
except IndexError:
sys.stderr.write('Missing argument following %s\n' % prefix)
break
elif args[i].startswith(prefix):
- args[i] = prefix + RewritePath(args[i][len(prefix):], sysroot)
+ args[i] = prefix + RewritePath(args[i][len(prefix):], opts)
i += 1
return ' '.join(args)
def main(argv):
- try:
- sysroot = argv[1]
- except IndexError:
- sys.stderr.write('usage: %s /path/to/sysroot\n' % argv[0])
- return 1
+ parser = optparse.OptionParser()
+ parser.add_option('-s', '--sysroot', default='/', help='sysroot to prepend')
+ parser.add_option('-p', '--strip-prefix', default='', help='prefix to strip')
+ opts, args = parser.parse_args(argv[1:])
for line in sys.stdin.readlines():
- line = RewriteLine(line.strip(), sysroot)
+ line = RewriteLine(line.strip(), opts)
print line
return 0
« no previous file with comments | « build/linux/pkg-config-wrapper ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698