Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: build_release.py

Issue 11370206: Make it possible to create release builds (Closed)
Patch Set: Created Aug. 13, 2013, 2:43 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | 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/env python 1 #!/usr/bin/env python
2 2
3 import sys, os, re, subprocess 3 import sys, os, re, subprocess
4 4
5 if len(sys.argv) < 2: 5 def print_usage():
6 print >>sys.stderr, "Please add a command line parameter with the path of the signing key file" 6 print >>sys.stderr, "Usage: %s release|devbuild SIGNING_KEY_FILE" % (os.path.b asename(sys.argv[0]))
7
8 if len(sys.argv) < 3:
9 print_usage()
7 sys.exit(1) 10 sys.exit(1)
8 11
9 basedir = os.path.dirname(os.path.abspath(sys.argv[0])) 12 basedir = os.path.dirname(os.path.abspath(sys.argv[0]))
10 key = sys.argv[1] 13 build_type = sys.argv[1]
14
15 if not build_type in ["release", "devbuild"]:
16 print_usage()
17 sys.exit(2)
18
19 key = sys.argv[2]
11 20
12 def sign(*argv): 21 def sign(*argv):
13 subprocess.check_call([ 22 subprocess.check_call([
14 "signtool", 23 "signtool",
15 "sign", "/v", 24 "sign", "/v",
16 "/d", "Adblock Plus", 25 "/d", "Adblock Plus",
17 "/du", "http://adblockplus.org/", 26 "/du", "http://adblockplus.org/",
18 "/f", key, 27 "/f", key,
19 "/tr", "http://www.startssl.com/timestamp" 28 "/tr", "http://www.startssl.com/timestamp"
20 ] + list(argv)) 29 ] + list(argv))
21 30
22 def read_macro_value(file, macro): 31 def read_macro_value(file, macro):
23 handle = open(file, 'rb') 32 handle = open(file, 'rb')
24 for line in handle: 33 for line in handle:
25 match = re.search(r"^\s*#define\s+%s\s+\w?\"(.*?)\"" % macro, line) 34 match = re.search(r"^\s*#define\s+%s\s+\w?\"(.*?)\"" % macro, line)
26 if match: 35 if match:
27 return match.group(1) 36 return match.group(1)
28 raise Exception("Macro %s not found in file %s" % (macro, file)) 37 raise Exception("Macro %s not found in file %s" % (macro, file))
29 38
30 version = read_macro_value(os.path.join(basedir, "src", "shared", "Version.h"), "IEPLUGIN_VERSION"); 39 version = read_macro_value(os.path.join(basedir, "src", "shared", "Version.h"), "IEPLUGIN_VERSION");
31 buildnum = subprocess.check_output(['hg', 'id', '-R', basedir, '-n'])
32 buildnum = re.sub(r'\D', '', buildnum)
33 while version.count(".") < 1: 40 while version.count(".") < 1:
34 version += ".0" 41 version += ".0"
Wladimir Palant 2013/08/13 14:46:59 Normally we don't do that for releases, not that i
35 version += ".%s" % buildnum
36 42
37 subprocess.check_call([os.path.join(basedir, "createsolution.bat"), version, "de vbuild"]) 43 if build_type == "devbuild":
44 buildnum = subprocess.check_output(['hg', 'id', '-R', basedir, '-n'])
45 buildnum = re.sub(r'\D', '', buildnum)
46 version += ".%s" % buildnum
47
48 subprocess.check_call([os.path.join(basedir, "createsolution.bat"), version, bui ld_type])
38 49
39 for arch in ("ia32", "x64"): 50 for arch in ("ia32", "x64"):
40 subprocess.check_call([ 51 subprocess.check_call([
41 "msbuild", 52 "msbuild",
42 os.path.join(basedir, "build", arch, "adblockplus.sln"), 53 os.path.join(basedir, "build", arch, "adblockplus.sln"),
43 "/p:Configuration=Release", "/target:AdblockPlus;AdblockPlusEngine", 54 "/p:Configuration=Release", "/target:AdblockPlus;AdblockPlusEngine",
44 ]) 55 ])
45 56
46 sign(os.path.join(basedir, "build", arch, "Release", "AdblockPlus.dll"), 57 sign(os.path.join(basedir, "build", arch, "Release", "AdblockPlus.dll"),
47 os.path.join(basedir, "build", arch, "Release", "AdblockPlusEngine.exe")) 58 os.path.join(basedir, "build", arch, "Release", "AdblockPlusEngine.exe"))
48 59
49 installerParams = os.environ.copy() 60 installerParams = os.environ.copy()
50 installerParams["VERSION"] = version 61 installerParams["VERSION"] = version
51 subprocess.check_call(["nmake", "/A", "ia32", "x64"], env=installerParams, cwd=o s.path.join(basedir, "installer")) 62 subprocess.check_call(["nmake", "/A", "ia32", "x64"], env=installerParams, cwd=o s.path.join(basedir, "installer"))
52 sign(os.path.join(basedir, "build", "ia32", "adblockplusie-%s-en-us-ia32.msi" % version), 63 sign(os.path.join(basedir, "build", "ia32", "adblockplusie-%s-en-us-ia32.msi" % version),
53 os.path.join(basedir, "build", "x64", "adblockplusie-%s-en-us-x64.msi" % ver sion)) 64 os.path.join(basedir, "build", "x64", "adblockplusie-%s-en-us-x64.msi" % ver sion))
54 65
55 subprocess.check_call(["nmake", "/A", "setup"], env=installerParams, cwd=os.path .join(basedir, "installer")) 66 subprocess.check_call(["nmake", "/A", "setup"], env=installerParams, cwd=os.path .join(basedir, "installer"))
56 67
57 # Do the signing dance described on http://wix.sourceforge.net/manual-wix3/insig nia.htm 68 # Do the signing dance described on http://wix.sourceforge.net/manual-wix3/insig nia.htm
58 bundle = os.path.join(basedir, "build", "adblockplusie-%s.exe" % version) 69 bundle = os.path.join(basedir, "build", "adblockplusie-%s.exe" % version)
59 engine = os.path.join(basedir, "build", "engine-%s.exe" % version) 70 engine = os.path.join(basedir, "build", "engine-%s.exe" % version)
60 subprocess.check_call(["insignia", "-ib", bundle, "-o", engine]) 71 subprocess.check_call(["insignia", "-ib", bundle, "-o", engine])
61 sign(engine) 72 sign(engine)
62 subprocess.check_call(["insignia", "-ab", engine, bundle, "-o", bundle]) 73 subprocess.check_call(["insignia", "-ab", engine, bundle, "-o", bundle])
63 sign(bundle) 74 sign(bundle)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld