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

Side by Side Diff: tools/supalink/install_supalink.py

Issue 7792103: Install link wrapper in runhooks, and turn incremental on by default (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: more cases in link sim Created 9 years, 3 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
OLDNEW
(Empty)
1 # Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 import os
6 import shutil
7 import subprocess
8
9 VSVARS_PATH = "C:\\Program Files (x86)\\Microsoft Visual Studio 9.0\
10 \\Common7\\Tools\\vsvars32.bat"
11
12 def run_with_vsvars(cmd):
13 f = open("temp.bat", "w")
bradn 2011/09/06 23:56:19 Please match the python style guide.
14 f.write("@echo off\n")
15 f.write("call \"%s\"\n" % VSVARS_PATH)
16 f.write(cmd + "\n")
17 f.close()
18 p = subprocess.Popen(["temp.bat"], shell=True, stdout=subprocess.PIPE)
19 out, err = p.communicate()
20 os.unlink("temp.bat")
21 out = out.replace("\r", "")
22 return p.returncode, out
23
24
25 def get_vc_dir():
26 rc, out = run_with_vsvars("echo VCINSTALLDIR=%VCINSTALLDIR%")
27 for line in out.split("\n"):
28 if line.startswith("VCINSTALLDIR="):
29 return line[len("VCINSTALLDIR="):]
30 raise SystemExit("Couldn't get VCINSTALLDIR. Run vsvars32.bat?")
31
32 def main():
33 if "VCINSTALLDIR" not in os.environ:
34 vcdir = get_vc_dir()
35 os.environ["PATH"] += ";" + os.path.join(vcdir, "bin") + \
36 ";" + os.path.join(vcdir, "../Common7/IDE")
37 else:
38 vcdir = os.environ["VCINSTALLDIR"]
39
40 # Switch to our own dir.
41 os.chdir(os.path.dirname(os.path.abspath(__file__)))
42
43 # Verify that we can find link.exe.
44 link = os.path.join(vcdir, "bin", "link.exe")
45 link_backup = os.path.join(vcdir, "bin", "link.exe.supalink_orig.exe")
46 if not os.path.exists(link):
47 raise SystemExit("link.exe not found at %s" % link)
48
49 # Don't re-backup link.exe, so only copy link.exe to backup if it's
50 # not there already.
51 if not os.path.exists(link_backup):
52 try:
53 print "Saving original link.exe..."
54 shutil.copyfile(link, link_backup)
bradn 2011/09/06 23:56:19 The bots don't run with admin privs, so this won't
55 except IOError:
56 raise SystemExit("Wasn't able to back up %s to %s.\
57 Not running with Administrator privileges?" % (link, link_backup))
58
59 # Build supalink.exe but only if it's out of date.
60 cpptime = os.path.getmtime("supalink.cpp")
61 if (not os.path.exists("supalink.exe")
62 or cpptime > os.path.getmtime("supalink.exe")):
63 print "Building supalink.exe..."
64 rc, out = run_with_vsvars("cl /nologo /Ox /Zi /W4 /WX\
65 /D_CRT_SECURE_NO_WARNINGS /EHsc supalink.cpp\
bradn 2011/09/06 23:56:19 Can we just check this program in?
66 /link /out:supalink.exe")
67 if rc != 0:
68 print out
69 raise SystemExit("Failed to build supalink.exe")
70
71 # Copy supalink into place if it's been updated since last time we ran.
72 exetime = os.path.getmtime("supalink.exe")
73 if exetime > os.path.getmtime(link):
74 print "Copying supalink.exe over link.exe..."
75 try:
76 shutil.copyfile("supalink.exe", link)
77 except IOError:
78 raise SystemExit("Wasn't able to copy supalink.exe over %s.\
79 Not running with Administrator privileges?" % link)
80
81 if __name__ == "__main__":
82 main()
OLDNEW
« tools/supalink/README ('K') | « tools/supalink/README ('k') | tools/supalink/supalink.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698