diff options
author | scottmg@chromium.org <scottmg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-14 21:38:19 +0000 |
---|---|---|
committer | scottmg@chromium.org <scottmg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-14 21:38:19 +0000 |
commit | e5f7c33fd248ce3443645b9a2f7a25624ad75188 (patch) | |
tree | 57118f1dc237c20f21b5f7fe081effe2fc76b30e /tools/win | |
parent | 787286efd5569637b42d48abff5f72023a6a6a83 (diff) | |
download | chromium_src-e5f7c33fd248ce3443645b9a2f7a25624ad75188.zip chromium_src-e5f7c33fd248ce3443645b9a2f7a25624ad75188.tar.gz chromium_src-e5f7c33fd248ce3443645b9a2f7a25624ad75188.tar.bz2 |
fix line endings on split_link scripts
(otherwise, presubmit whines about copyright now matching because it
contains \r)
I'm not 100% sure this will fix the problem because something will
do line ending changes, but... we will see.
TBR=cpu@chromium.org
BUG=none
Review URL: https://codereview.chromium.org/14655021
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@200079 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/win')
-rw-r--r-- | tools/win/split_link/check_installed.py | 92 | ||||
-rw-r--r-- | tools/win/split_link/install_split_link.py | 190 |
2 files changed, 141 insertions, 141 deletions
diff --git a/tools/win/split_link/check_installed.py b/tools/win/split_link/check_installed.py index 2017021..31bf60f 100644 --- a/tools/win/split_link/check_installed.py +++ b/tools/win/split_link/check_installed.py @@ -1,46 +1,46 @@ -# Copyright (c) 2013 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-import os
-import sys
-
-
-def IsAvailable():
- _winreg = None
- if sys.platform == 'win32':
- import _winreg
- elif sys.platform == 'cygwin':
- try:
- import cygwinreg as _winreg
- except ImportError:
- pass # If not available, be safe and write 0.
-
- if not _winreg:
- return False
-
- try:
- val = _winreg.QueryValue(_winreg.HKEY_CURRENT_USER,
- 'Software\\Chromium\\split_link_installed')
- return os.path.exists(val)
- except WindowsError:
- pass
-
- return False
-
-
-def main():
- # Can be called from gyp to set variable.
- if IsAvailable():
- sys.stdout.write('1')
- else:
- print >> sys.stderr, "Couldn't find split_link installation."
- print >> sys.stderr, ('Run python tools\\win\\split_link\\'
- 'install_split_link.py from an elevated Visual '
- 'Studio Command Prompt to install.')
- sys.stdout.write('0')
- return 1
-
-
-if __name__ == '__main__':
- sys.exit(main())
+# Copyright (c) 2013 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import os +import sys + + +def IsAvailable(): + _winreg = None + if sys.platform == 'win32': + import _winreg + elif sys.platform == 'cygwin': + try: + import cygwinreg as _winreg + except ImportError: + pass # If not available, be safe and write 0. + + if not _winreg: + return False + + try: + val = _winreg.QueryValue(_winreg.HKEY_CURRENT_USER, + 'Software\\Chromium\\split_link_installed') + return os.path.exists(val) + except WindowsError: + pass + + return False + + +def main(): + # Can be called from gyp to set variable. + if IsAvailable(): + sys.stdout.write('1') + else: + print >> sys.stderr, "Couldn't find split_link installation." + print >> sys.stderr, ('Run python tools\\win\\split_link\\' + 'install_split_link.py from an elevated Visual ' + 'Studio Command Prompt to install.') + sys.stdout.write('0') + return 1 + + +if __name__ == '__main__': + sys.exit(main()) diff --git a/tools/win/split_link/install_split_link.py b/tools/win/split_link/install_split_link.py index 0841251..13ae448 100644 --- a/tools/win/split_link/install_split_link.py +++ b/tools/win/split_link/install_split_link.py @@ -1,95 +1,95 @@ -# Copyright (c) 2013 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-import _winreg
-import os
-import shutil
-import subprocess
-import sys
-
-
-BASE_DIR = os.path.dirname(os.path.abspath(__file__))
-
-
-def IsExe(fpath):
- return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
-
-
-def FindInPath(program):
- fpath, _ = os.path.split(program)
- if fpath:
- if IsExe(program):
- return program
- else:
- for path in os.environ['PATH'].split(os.pathsep):
- path = path.strip('"')
- exe_file = os.path.join(path, program)
- if not path or not os.path.isabs(path):
- continue
- if IsExe(exe_file):
- return exe_file
- return None
-
-
-def EscapeForCommandLineAndCString(path):
- """Quoted sufficiently to be passed on the compile command line as a define
- to be turned into a string in the target C program."""
- path = '"' + path + '"'
- return path.replace('\\', '\\\\').replace('"', '\\"')
-
-
-def main():
- # Switch to our own dir.
- os.chdir(BASE_DIR)
-
- link = FindInPath('link.exe')
- if not link:
- print("Couldn't find link.exe in PATH. Must run from Administrator "
- "Visual Studio Command Prompt.")
- return 1
-
- link_backup = os.path.join(os.path.split(link)[0], 'link.exe.split_link.exe')
-
- # Don't re-backup link.exe, so only copy link.exe to backup if it's
- # not there already.
- if not os.path.exists(link_backup):
- try:
- print 'Saving original link.exe...'
- shutil.copyfile(link, link_backup)
- except IOError:
- print(("Wasn't able to back up %s to %s. "
- "Not running with Administrator privileges?")
- % (link, link_backup))
- return 1
-
- # Build our linker shim.
- print 'Building split_link.exe...'
- split_link_py = os.path.abspath('split_link.py')
- script_path = EscapeForCommandLineAndCString(split_link_py)
- python = EscapeForCommandLineAndCString(sys.executable)
- subprocess.check_call('cl.exe /nologo /Ox /Zi /W4 /WX /D_UNICODE /DUNICODE'
- ' /D_CRT_SECURE_NO_WARNINGS /EHsc split_link.cc'
- ' /DPYTHON_PATH="%s"'
- ' /DSPLIT_LINK_SCRIPT_PATH="%s"'
- ' /link shell32.lib shlwapi.lib /out:split_link.exe' % (
- python, script_path))
-
- # Copy shim into place.
- print 'Copying split_link.exe over link.exe...'
- try:
- shutil.copyfile('split_link.exe', link)
- _winreg.SetValue(_winreg.HKEY_CURRENT_USER,
- 'Software\\Chromium\\split_link_installed',
- _winreg.REG_SZ,
- link_backup)
- except IOError:
- print("Wasn't able to copy split_link.exe over %s. "
- "Not running with Administrator privileges?" % link)
- return 1
-
- return 0
-
-
-if __name__ == '__main__':
- sys.exit(main())
+# Copyright (c) 2013 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import _winreg +import os +import shutil +import subprocess +import sys + + +BASE_DIR = os.path.dirname(os.path.abspath(__file__)) + + +def IsExe(fpath): + return os.path.isfile(fpath) and os.access(fpath, os.X_OK) + + +def FindInPath(program): + fpath, _ = os.path.split(program) + if fpath: + if IsExe(program): + return program + else: + for path in os.environ['PATH'].split(os.pathsep): + path = path.strip('"') + exe_file = os.path.join(path, program) + if not path or not os.path.isabs(path): + continue + if IsExe(exe_file): + return exe_file + return None + + +def EscapeForCommandLineAndCString(path): + """Quoted sufficiently to be passed on the compile command line as a define + to be turned into a string in the target C program.""" + path = '"' + path + '"' + return path.replace('\\', '\\\\').replace('"', '\\"') + + +def main(): + # Switch to our own dir. + os.chdir(BASE_DIR) + + link = FindInPath('link.exe') + if not link: + print("Couldn't find link.exe in PATH. Must run from Administrator " + "Visual Studio Command Prompt.") + return 1 + + link_backup = os.path.join(os.path.split(link)[0], 'link.exe.split_link.exe') + + # Don't re-backup link.exe, so only copy link.exe to backup if it's + # not there already. + if not os.path.exists(link_backup): + try: + print 'Saving original link.exe...' + shutil.copyfile(link, link_backup) + except IOError: + print(("Wasn't able to back up %s to %s. " + "Not running with Administrator privileges?") + % (link, link_backup)) + return 1 + + # Build our linker shim. + print 'Building split_link.exe...' + split_link_py = os.path.abspath('split_link.py') + script_path = EscapeForCommandLineAndCString(split_link_py) + python = EscapeForCommandLineAndCString(sys.executable) + subprocess.check_call('cl.exe /nologo /Ox /Zi /W4 /WX /D_UNICODE /DUNICODE' + ' /D_CRT_SECURE_NO_WARNINGS /EHsc split_link.cc' + ' /DPYTHON_PATH="%s"' + ' /DSPLIT_LINK_SCRIPT_PATH="%s"' + ' /link shell32.lib shlwapi.lib /out:split_link.exe' % ( + python, script_path)) + + # Copy shim into place. + print 'Copying split_link.exe over link.exe...' + try: + shutil.copyfile('split_link.exe', link) + _winreg.SetValue(_winreg.HKEY_CURRENT_USER, + 'Software\\Chromium\\split_link_installed', + _winreg.REG_SZ, + link_backup) + except IOError: + print("Wasn't able to copy split_link.exe over %s. " + "Not running with Administrator privileges?" % link) + return 1 + + return 0 + + +if __name__ == '__main__': + sys.exit(main()) |