Linux library loaders: use relative path for includes (for distcc).

BUG=163209, 162733

Review URL: https://codereview.chromium.org/11414271

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@170990 0039d316-1c4b-4281-b951-d872f2087c98
parent dffd2b76
...@@ -163,10 +163,12 @@ def main(): ...@@ -163,10 +163,12 @@ def main():
if not args: if not args:
parser.error('No function names specified') parser.error('No function names specified')
# Make sure we are always dealing with an absolute path # Make sure we are always dealing with paths relative to source tree root
# to avoid issues caused by different relative path roots. # to avoid issues caused by different relative path roots.
options.output_cc = os.path.abspath(options.output_cc) source_tree_root = os.path.abspath(
options.output_h = os.path.abspath(options.output_h) os.path.join(os.path.dirname(__file__), '..', '..'))
options.output_cc = os.path.relpath(options.output_cc, source_tree_root)
options.output_h = os.path.relpath(options.output_h, source_tree_root)
# Create a unique prefix, e.g. for header guards. # Create a unique prefix, e.g. for header guards.
# Stick a known string at the beginning to ensure this doesn't begin # Stick a known string at the beginning to ensure this doesn't begin
...@@ -215,7 +217,7 @@ def main(): ...@@ -215,7 +217,7 @@ def main():
# Make it easier for people to find the code generator just in case. # Make it easier for people to find the code generator just in case.
# Doing it this way is more maintainable, because it's going to work # Doing it this way is more maintainable, because it's going to work
# even if file gets moved without updating the contents. # even if file gets moved without updating the contents.
generator_path = os.path.abspath(__file__) generator_path = os.path.relpath(__file__, source_tree_root)
header_contents = HEADER_TEMPLATE % { header_contents = HEADER_TEMPLATE % {
'generator_path': generator_path, 'generator_path': generator_path,
...@@ -234,13 +236,13 @@ def main(): ...@@ -234,13 +236,13 @@ def main():
'member_cleanup': ''.join(member_cleanup), 'member_cleanup': ''.join(member_cleanup),
} }
header_file = open(options.output_h, 'w') header_file = open(os.path.join(source_tree_root, options.output_h), 'w')
try: try:
header_file.write(header_contents) header_file.write(header_contents)
finally: finally:
header_file.close() header_file.close()
impl_file = open(options.output_cc, 'w') impl_file = open(os.path.join(source_tree_root, options.output_cc), 'w')
try: try:
impl_file.write(impl_contents) impl_file.write(impl_contents)
finally: finally:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment