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

Unified Diff: pylib/gyp/common.py

Issue 11659002: Teach ninja to handle output directories outside the source dir. (Closed) Base URL: http://gyp.googlecode.com/svn/trunk/
Patch Set: Created 8 years 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 | « no previous file | pylib/gyp/generator/make.py » ('j') | test/generator-output/gyptest-relocate.py » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pylib/gyp/common.py
===================================================================
--- pylib/gyp/common.py (revision 1537)
+++ pylib/gyp/common.py (working copy)
@@ -128,8 +128,8 @@
# relative_to.
# Convert to absolute (and therefore normalized paths).
Nico 2012/12/21 22:52:08 Is the comment now out of date?
- path = os.path.abspath(path)
- relative_to = os.path.abspath(relative_to)
+ path = os.path.realpath(path)
+ relative_to = os.path.realpath(relative_to)
# Split the paths into components.
path_split = path.split(os.path.sep)
@@ -151,6 +151,20 @@
return os.path.join(*relative_split)
+@memoize
+def InvertRelativePath(path, toplevel_dir=None):
+ """Given a path like foo/bar that is relative to toplevel_dir, return
+ the inverse relative path back to the toplevel_dir.
+
+ E.g. os.path.normpath(os.path.join(path, InvertRelativePath(path)))
+ should always produce the empty string, unless the path contains symlinks.
+ """
+ if not path:
+ return path
+ toplevel_dir = '.' if toplevel_dir is None else toplevel_dir
+ return RelativePath(toplevel_dir, os.path.join(toplevel_dir, path))
+
+
def FixIfRelativePath(path, relative_to):
# Like RelativePath but returns |path| unchanged if it is absolute.
if os.path.isabs(path):
« no previous file with comments | « no previous file | pylib/gyp/generator/make.py » ('j') | test/generator-output/gyptest-relocate.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698