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): |
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 # If |follow_symlink_path| is true (default) and |path| is a symlink, then |
| 139 # this method returns a path to the real file represented by |path|. If it is |
| 140 # false, this method returns a path to the symlink. If |path| is not a |
| 141 # symlink, this option has no effect. |
138 | 142 |
139 # Convert to normalized (and therefore absolute paths). | 143 # Convert to normalized (and therefore absolute paths). |
140 path = os.path.realpath(path) | 144 if follow_path_symlink: |
| 145 path = os.path.realpath(path) |
| 146 else: |
| 147 path = os.path.abspath(path) |
141 relative_to = os.path.realpath(relative_to) | 148 relative_to = os.path.realpath(relative_to) |
142 | 149 |
143 # On Windows, we can't create a relative path to a different drive, so just | 150 # On Windows, we can't create a relative path to a different drive, so just |
144 # use the absolute path. | 151 # use the absolute path. |
145 if sys.platform == 'win32': | 152 if sys.platform == 'win32': |
146 if (os.path.splitdrive(path)[0].lower() != | 153 if (os.path.splitdrive(path)[0].lower() != |
147 os.path.splitdrive(relative_to)[0].lower()): | 154 os.path.splitdrive(relative_to)[0].lower()): |
148 return path | 155 return path |
149 | 156 |
150 # Split the paths into components. | 157 # Split the paths into components. |
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
590 def CrossCompileRequested(): | 597 def CrossCompileRequested(): |
591 # TODO: figure out how to not build extra host objects in the | 598 # TODO: figure out how to not build extra host objects in the |
592 # non-cross-compile case when this is enabled, and enable unconditionally. | 599 # non-cross-compile case when this is enabled, and enable unconditionally. |
593 return (os.environ.get('GYP_CROSSCOMPILE') or | 600 return (os.environ.get('GYP_CROSSCOMPILE') or |
594 os.environ.get('AR_host') or | 601 os.environ.get('AR_host') or |
595 os.environ.get('CC_host') or | 602 os.environ.get('CC_host') or |
596 os.environ.get('CXX_host') or | 603 os.environ.get('CXX_host') or |
597 os.environ.get('AR_target') or | 604 os.environ.get('AR_target') or |
598 os.environ.get('CC_target') or | 605 os.environ.get('CC_target') or |
599 os.environ.get('CXX_target')) | 606 os.environ.get('CXX_target')) |
OLD | NEW |