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

Unified Diff: build_release.py

Issue 10879048: Use minor upgrade mechanism for updates, set installer versionautomatically (Closed)
Patch Set: Created June 11, 2013, 1:21 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: build_release.py
===================================================================
rename from build_release.bat
rename to build_release.py
--- a/build_release.bat
+++ b/build_release.py
@@ -1,30 +1,62 @@
-@echo off
+#!/usr/bin/env python
-if %1.==. goto NoKey
+import sys, os, re, subprocess
-pushd %~dp0
-call libadblockplus\createsolution.bat
-msbuild libadblockplus\build\ia32\libadblockplus.sln /p:Configuration=Release
-msbuild libadblockplus\build\x64\libadblockplus.sln /p:Configuration=Release
-msbuild AdblockPlus.sln "/p:Configuration=Release Test" /p:Platform=Win32
-msbuild AdblockPlus.sln "/p:Configuration=Release Test" /p:Platform=x64
-signtool.exe sign /v /d "Adblock Plus" /du "http://adblockplus.org/" /f %1 /tr "http://www.startssl.com/timestamp" "build\ia32\Release Test\AdblockPlus.dll"
-signtool.exe sign /v /d "Adblock Plus" /du "http://adblockplus.org/" /f %1 /tr "http://www.startssl.com/timestamp" "build\x64\Release Test\AdblockPlusx64.dll"
-signtool.exe sign /v /d "Adblock Plus" /du "http://adblockplus.org/" /f %1 /tr "http://www.startssl.com/timestamp" "build\ia32\Release Test\AdblockPlusEngine.exe"
-signtool.exe sign /v /d "Adblock Plus" /du "http://adblockplus.org/" /f %1 /tr "http://www.startssl.com/timestamp" "build\x64\Release Test\AdblockPlusEngine.exe"
+if len(sys.argv) < 2:
+ print >>sys.stderr, "Please add a command line parameter with the path of the signing key file"
+ sys.exit(1)
-pushd WixInstaller
-nmake
-popd
+basedir = os.path.dirname(os.path.abspath(sys.argv[0]))
+key = sys.argv[1]
-signtool.exe sign /v /d "Adblock Plus" /du "http://adblockplus.org/" /f %1 /tr "http://www.startssl.com/timestamp" "build\ia32\adblockplusie-en-us-ia32.msi"
-signtool.exe sign /v /d "Adblock Plus" /du "http://adblockplus.org/" /f %1 /tr "http://www.startssl.com/timestamp" "build\x64\adblockplusie-en-us-x64.msi"
+def sign(*argv):
+ subprocess.call([
+ "signtool",
+ "sign", "/v",
+ "/d", "Adblock Plus",
+ "/du", "http://adblockplus.org/",
+ "/f", key,
+ "/tr", "http://www.startssl.com/timestamp"
+ ] + list(argv))
-popd
-goto End
+def read_macro_value(file, macro):
+ handle = open(file, 'rb')
+ for line in handle:
+ match = re.search(r"^\s*#define\s+%s\s+\w?\"(.*?)\"" % macro, line)
+ if match:
+ return match.group(1)
+ raise Exception("Macro %s not found in file %s" % (macro, file))
-:NoKey
- echo Please add a command line parameter with the path of the signing key file
- goto End
+version = read_macro_value(os.path.join(basedir, "src", "shared", "Version.h"), "IEPLUGIN_VERSION");
+buildnum, dummy = subprocess.Popen(['hg', 'id', '-R', basedir, '-n'], stdout=subprocess.PIPE).communicate()
Felix Dahlke 2013/06/11 13:53:22 I'd consider buildnum = subprocess.Popen(...).comm
Wladimir Palant 2013/06/11 14:43:18 Seriously? [0] at the end of a long line is very n
+buildnum = re.sub(r'\D', '', buildnum)
+while version.count(".") < 1:
+ version += ".0"
+version += ".%s" % buildnum
-:End
+subprocess.call([os.path.join(basedir, "libadblockplus", "createsolution.bat")])
+
+for arch in ("ia32", "x64"):
+ platform = "/p:Platform=%s" % {"ia32": "Win32", "x64": "x64"}[arch]
+ subprocess.call([
+ "msbuild",
+ os.path.join(basedir, "libadblockplus", "build", arch, "libadblockplus.sln"),
+ "/p:Configuration=Release",
+ platform
+ ])
+
+ subprocess.call([
+ "msbuild",
+ os.path.join(basedir, "AdblockPlus.sln"),
+ "/p:Configuration=Release Test",
+ platform])
+
+ plugin = {"ia32": "AdblockPlus.dll", "x64": "AdblockPlusx64.dll"}[arch]
+ sign(os.path.join(basedir, "build", arch, "Release Test", plugin),
+ os.path.join(basedir, "build", arch, "Release Test", "AdblockPlusEngine.exe"))
+
+installerParams = os.environ.copy()
+installerParams["VERSION"] = version
+subprocess.call(["nmake"], env=installerParams, cwd=os.path.join(basedir, "WixInstaller"))
+sign(os.path.join(basedir, "build", "ia32", "adblockplusie-%s-en-us-ia32.msi" % version),
+ os.path.join(basedir, "build", "x64", "adblockplusie-%s-en-us-x64.msi" % version))
Eric 2013/06/11 15:41:46 I would redo the batch file as a Makefile rather t
Wladimir Palant 2013/06/12 09:46:34 I would definitely be opposed to that - a Makefile
Eric 2013/06/12 14:33:24 (as I mentioned in email) The incremental calculat

Powered by Google App Engine
This is Rietveld