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

Unified Diff: build/win/reorder-imports.py

Issue 109483003: Make sure Chrome_elf.dll imports are correct and that it the first import of chrome.exe (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use swapimports.exe for maintaining import order instead of gyp twiddling Created 6 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/chrome_exe.gypi » ('j') | chrome/chrome_exe.gypi » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/win/reorder-imports.py
diff --git a/build/win/reorder-imports.py b/build/win/reorder-imports.py
new file mode 100755
index 0000000000000000000000000000000000000000..0b8e122b0923156fcd1225e609a2f81be075bd64
--- /dev/null
+++ b/build/win/reorder-imports.py
@@ -0,0 +1,49 @@
+#!/usr/bin/env python
+# Copyright 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 shutil
csharp 2014/01/09 21:07:54 alphabetize imports
Cait (Slow) 2014/01/10 22:00:54 Done.
+import sys
+import os
+import getopt
+import subprocess
+import glob
+
+def reorder_imports(input_dir, output_dir):
+ """Run swapimports.exe on the initial chrome.exe, and write to the output
+ directory. Also copy over any related files that might be needed
+ (pdbs, manifests etc.)."""
csharp 2014/01/09 21:07:54 Nit: move the ending """ to a newline
Cait (Slow) 2014/01/10 22:00:54 Done.
+
+ input_image = '--input-image=%s' % (os.path.join(input_dir, 'chrome.exe'))
+ output_image = '--output-image=%s' % (os.path.join(output_dir, 'chrome.exe'))
+
+ swap_exe = os.path.join(
+ __file__, '..\\..\\..\\third_party\\syzygy\\binaries\\exe\\swapimport.exe')
+ subprocess.call(
+ [swap_exe, input_image, output_image, '--overwrite', 'chrome_elf.dll'])
+
+ for fname in glob.glob(os.path.join(input_dir, 'chrome.exe.*')):
csharp 2014/01/09 21:07:54 use glob.iglob so we use an iterator (less memory)
Cait (Slow) 2014/01/10 22:00:54 Done.
+ shutil.copy(fname, os.path.join(output_dir, os.path.basename(fname)))
+ return 0
+
csharp 2014/01/09 21:07:54 Nit: 2 blank lines
Cait (Slow) 2014/01/10 22:00:54 Done.
+def main(argv):
+ input_dir = ''
+ output_dir = ''
+ try:
+ opts, args = getopt.getopt(argv,"hi:o:",["idir=","odir="])
csharp 2014/01/09 21:07:54 optparse is easier to use (and more pythonic)
Cait (Slow) 2014/01/10 22:00:54 Done.
+ except getopt.GetoptError:
+ print 'reorder_imports.py -i <input_dir> -o <output_dir>'
+ sys.exit(2)
+ for opt, arg in opts:
+ if opt == '-h':
+ print 'test.py -i <input_dir> -o <output_dir>'
+ sys.exit()
+ elif opt in ("-i", "--idir"):
+ input_dir = arg
+ elif opt in ("-o", "--odir"):
+ output_dir = arg
+ return reorder_imports(input_dir, output_dir)
+
+if __name__ == "__main__":
+ sys.exit(main(sys.argv[1:]))
« no previous file with comments | « no previous file | chrome/chrome_exe.gypi » ('j') | chrome/chrome_exe.gypi » ('J')

Powered by Google App Engine
This is Rietveld 408576698