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

Side by Side Diff: toolchain_build/substituter.py

Issue 355883002: The toolchain_build git cache is now referenced as a git-alternate. (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: rebase Created 6 years, 6 months 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « toolchain_build/command.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # Copyright (c) 2013 The Native Client Authors. All rights reserved. 2 # Copyright (c) 2013 The Native Client Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 import multiprocessing 6 import multiprocessing
7 import os 7 import os
8 import sys 8 import sys
9 9
10 10
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 self.SetUpPathVariables() 66 self.SetUpPathVariables()
67 67
68 def SetUpPathVariables(self): 68 def SetUpPathVariables(self):
69 """Create the internal mappings for all path variables. 69 """Create the internal mappings for all path variables.
70 70
71 Paths are calculated relative to the current working directory. 71 Paths are calculated relative to the current working directory.
72 """ 72 """
73 self._variables = self._nonpaths.copy() 73 self._variables = self._nonpaths.copy()
74 self._variables['cwd'] = FixPath(os.path.abspath(self._cwd)) 74 self._variables['cwd'] = FixPath(os.path.abspath(self._cwd))
75 for key, value in self._paths.iteritems(): 75 for key, value in self._paths.iteritems():
76 self._variables['abs_' + key] = FixPath(os.path.abspath(value)) 76 if value:
77 self._variables[key] = FixPath(os.path.relpath(value, self._cwd)) 77 abs_path = FixPath(os.path.abspath(value))
78 key_path = FixPath(os.path.relpath(value, self._cwd))
79 else:
80 abs_path = value
81 key_path = value
82
83 self._variables['abs_' + key] = abs_path
84 self._variables[key] = key_path
78 85
79 def Substitute(self, template): 86 def Substitute(self, template):
80 """ Substitute the %-variables in 'template' """ 87 """ Substitute the %-variables in 'template' """
81 return template % self._variables 88 return template % self._variables
82 89
83 def SubstituteAbsPaths(self, template): 90 def SubstituteAbsPaths(self, template):
84 """Substitute the %-variables in 'template'. 91 """Substitute the %-variables in 'template'.
85 92
86 All variables in the template must be paths, and if the values are relative 93 All variables in the template must be paths, and if the values are relative
87 paths, they are resolved relative to cwd and returned as absolute paths. 94 paths, they are resolved relative to cwd and returned as absolute paths.
88 """ 95 """
89 return AbsPath(self.Substitute(template), self._cwd) 96 path = self.Substitute(template)
97 if path:
98 path = AbsPath(path, self._cwd)
99 return path
90 100
91 def _SetUpCommonNonPaths(self): 101 def _SetUpCommonNonPaths(self):
92 try: 102 try:
93 self._nonpaths['cores'] = multiprocessing.cpu_count() 103 self._nonpaths['cores'] = multiprocessing.cpu_count()
94 except NotImplementedError: 104 except NotImplementedError:
95 self._nonpaths['cores'] = 4 # Assume 4 if we can't measure. 105 self._nonpaths['cores'] = 4 # Assume 4 if we can't measure.
OLDNEW
« no previous file with comments | « toolchain_build/command.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698