OLD | NEW |
---|---|
1 # Copyright (c) 2012 Google Inc. All rights reserved. | 1 # Copyright (c) 2012 Google Inc. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 from __future__ import with_statement | 5 from __future__ import with_statement |
6 | 6 |
7 import collections | 7 import collections |
8 import errno | 8 import errno |
9 import filecmp | 9 import filecmp |
10 import os.path | 10 import os.path |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
124 # "Qualified" means the file that a target was defined in and the target | 124 # "Qualified" means the file that a target was defined in and the target |
125 # name, separated by a colon, suffixed by a # and the toolset name: | 125 # name, separated by a colon, suffixed by a # and the toolset name: |
126 # /path/to/file.gyp:target_name#toolset | 126 # /path/to/file.gyp:target_name#toolset |
127 fully_qualified = build_file + ':' + target | 127 fully_qualified = build_file + ':' + target |
128 if toolset: | 128 if toolset: |
129 fully_qualified = fully_qualified + '#' + toolset | 129 fully_qualified = fully_qualified + '#' + toolset |
130 return fully_qualified | 130 return fully_qualified |
131 | 131 |
132 | 132 |
133 @memoize | 133 @memoize |
134 def RelativePath(path, relative_to): | 134 def RelativePath(path, relative_to, follow_path_symlink=True): |
scottmg
2015/09/24 21:30:51
could you add some explanation for this arg here?
lindleyf
2015/09/24 21:47:14
I've added a comment here and at the point of use.
| |
135 # Assuming both |path| and |relative_to| are relative to the current | 135 # Assuming both |path| and |relative_to| are relative to the current |
136 # directory, returns a relative path that identifies path relative to | 136 # directory, returns a relative path that identifies path relative to |
137 # relative_to. | 137 # relative_to. |
138 | 138 |
139 # Convert to normalized (and therefore absolute paths). | 139 # Convert to normalized (and therefore absolute paths). |
140 path = os.path.realpath(path) | 140 if follow_path_symlink: |
141 path = os.path.realpath(path) | |
142 else: | |
143 path = os.path.abspath(path) | |
141 relative_to = os.path.realpath(relative_to) | 144 relative_to = os.path.realpath(relative_to) |
142 | 145 |
143 # On Windows, we can't create a relative path to a different drive, so just | 146 # On Windows, we can't create a relative path to a different drive, so just |
144 # use the absolute path. | 147 # use the absolute path. |
145 if sys.platform == 'win32': | 148 if sys.platform == 'win32': |
146 if (os.path.splitdrive(path)[0].lower() != | 149 if (os.path.splitdrive(path)[0].lower() != |
147 os.path.splitdrive(relative_to)[0].lower()): | 150 os.path.splitdrive(relative_to)[0].lower()): |
148 return path | 151 return path |
149 | 152 |
150 # Split the paths into components. | 153 # Split the paths into components. |
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
590 def CrossCompileRequested(): | 593 def CrossCompileRequested(): |
591 # TODO: figure out how to not build extra host objects in the | 594 # TODO: figure out how to not build extra host objects in the |
592 # non-cross-compile case when this is enabled, and enable unconditionally. | 595 # non-cross-compile case when this is enabled, and enable unconditionally. |
593 return (os.environ.get('GYP_CROSSCOMPILE') or | 596 return (os.environ.get('GYP_CROSSCOMPILE') or |
594 os.environ.get('AR_host') or | 597 os.environ.get('AR_host') or |
595 os.environ.get('CC_host') or | 598 os.environ.get('CC_host') or |
596 os.environ.get('CXX_host') or | 599 os.environ.get('CXX_host') or |
597 os.environ.get('AR_target') or | 600 os.environ.get('AR_target') or |
598 os.environ.get('CC_target') or | 601 os.environ.get('CC_target') or |
599 os.environ.get('CXX_target')) | 602 os.environ.get('CXX_target')) |
OLD | NEW |