forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
linux: improve support for cross-compiling
This CL adds support for a 'sysroot' GYP define, that should point to the target root filesystem for cross-compilation. It passes that argument to the compiler and linker which uses it to prefix its hard-coded path (e.g. /usr/include) It also points pkg-config to look for package configs there, and rewrite the paths to be prefixed by 'sysroot' (since pkg-config doesn't do it itself) Review URL: http://codereview.chromium.org/199016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25418 0039d316-1c4b-4281-b951-d872f2087c98
- Loading branch information
piman@chromium.org
committed
Sep 4, 2009
1 parent
60f2ea2
commit ee28c9f
Showing
4 changed files
with
126 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/sh | ||
|
||
root="$1" | ||
if [ -z "$root" ] | ||
then | ||
echo "usage: $0 /path/to/sysroot [pkg-config-arguments]" >&2 | ||
exit 1 | ||
fi | ||
|
||
rewrite=`dirname $0`/rewrite_dirs.py | ||
|
||
shift | ||
config_path=$root/usr/lib/pkgconfig:$root/usr/share/pkgconfig | ||
PKG_CONFIG_PATH=$config_path pkg-config "$@" | $rewrite $root |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#!/usr/bin/python | ||
|
||
"""Rewrites paths in -I, -L and other option to be relative to a sysroot.""" | ||
|
||
import sys | ||
import os | ||
|
||
REWRITE_PREFIX = ['-I', | ||
'-idirafter', | ||
'-imacros', | ||
'-imultilib', | ||
'-include', | ||
'-iprefix', | ||
'-iquote', | ||
'-isystem', | ||
'-L'] | ||
|
||
def RewritePath(path, sysroot): | ||
"""Rewrites a path by prefixing it with the sysroot if it is absolute.""" | ||
if os.path.isabs(path): | ||
path = path.lstrip('/') | ||
return os.path.join(sysroot, path) | ||
else: | ||
return path | ||
|
||
def RewriteLine(line, sysroot): | ||
"""Rewrites all the paths in recognized options.""" | ||
args = line.split() | ||
count = len(args) | ||
i = 0 | ||
while i < count: | ||
for prefix in REWRITE_PREFIX: | ||
# The option can be either in the form "-I /path/to/dir" or | ||
# "-I/path/to/dir" so handle both. | ||
if args[i] == prefix: | ||
i += 1 | ||
try: | ||
args[i] = RewritePath(args[i], sysroot) | ||
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) | ||
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 | ||
|
||
for line in sys.stdin.readlines(): | ||
line = RewriteLine(line.strip(), sysroot) | ||
print line | ||
return 0 | ||
|
||
if __name__ == '__main__': | ||
sys.exit(main(sys.argv)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters