mirror of
https://chromium.googlesource.com/chromium/tools/depot_tools.git
synced 2026-01-11 18:51:29 +00:00
Make python build/vs_toolchain.py update mostly work on non-Windows.
1. GetFileList() returns a list of path\names on Windows but of path/names on
non-Windows. To not perturb existing hashes, I guess the hashing code should do
path.replace('/', '\\') before hashing.
2. GetFileList() returns a sorted list of filenames, and \ compares pretty
different than / (the former is less than all numbers while the latter
is greater, for example). So replace / with \\ for sorting too.
With this change, OS X produces the same file hash as Windows.
The script still early-exits on non-Windows, so no visible change yet.
BUG=495204
Review URL: https://codereview.chromium.org/1287543005
git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@296271 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
@@ -57,7 +57,7 @@ def GetFileList(root):
|
||||
for base, _, files in os.walk(root):
|
||||
paths = [os.path.join(base, f) for f in files]
|
||||
file_list.extend(x.lower() for x in paths)
|
||||
return sorted(file_list)
|
||||
return sorted(file_list, key=lambda s: s.replace('/', '\\'))
|
||||
|
||||
|
||||
def MakeTimestampsFileName(root):
|
||||
@@ -93,7 +93,7 @@ def CalculateHash(root):
|
||||
|
||||
digest = hashlib.sha1()
|
||||
for path in file_list:
|
||||
digest.update(path)
|
||||
digest.update(str(path).replace('/', '\\'))
|
||||
with open(path, 'rb') as f:
|
||||
digest.update(f.read())
|
||||
return digest.hexdigest()
|
||||
|
||||
Reference in New Issue
Block a user