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

Unified Diff: adblockplus/build.py

Issue 6238034718621696: Issue 2483 - Give Adblock Browser its own app ID (Closed)
Patch Set: Address comments Created May 15, 2015, 10:06 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
« no previous file with comments | « no previous file | adblockplus/issue-2509.patch » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: adblockplus/build.py
===================================================================
--- a/adblockplus/build.py
+++ b/adblockplus/build.py
@@ -2,16 +2,42 @@
# coding: utf-8
import os
+import shutil
+import subprocess
import sys
+import tempfile
-import buildtools.build
-import buildtools.packager
+BASE_DIR = os.path.dirname(os.path.abspath(__file__))
Felix Dahlke 2015/05/15 22:09:08 Realised the naming here was inconsistent with our
+ABP_DIR = os.path.join(BASE_DIR, "adblockplus")
-BUILD_DIR = os.path.dirname(os.path.abspath(__file__))
-BASE_DIR = os.path.join(BUILD_DIR, "adblockplus")
+def build_abp(base_dir, xpi_path):
+ xpi_dir = os.path.dirname(os.path.abspath(xpi_path))
+ if not os.path.exists(xpi_dir):
+ os.makedirs(xpi_dir)
-def getMetadataPath(baseDir, type):
- return os.path.join(BUILD_DIR, "metadata.gecko")
+ sys.path.insert(0, base_dir)
+ import buildtools.build
+ import buildtools.packager
+ def get_metadata_path(base_dir, type):
+ return os.path.join(BASE_DIR, "metadata.gecko")
+ buildtools.packager.getMetadataPath = get_metadata_path
+ buildtools.build.processArgs(base_dir, ["", "build", xpi_path])
-buildtools.packager.getMetadataPath = getMetadataPath
-buildtools.build.processArgs(BASE_DIR, sys.argv)
+if __name__ == "__main__":
+ if len(sys.argv) < 2:
+ sys.exit(1)
Wladimir Palant 2015/05/18 11:01:22 Exiting without an error message is strange, why d
Felix Dahlke 2015/05/18 19:43:28 Oops, forgot that one.
+
+ xpi_path = sys.argv[1]
+ patched_abp_dir = tempfile.NamedTemporaryFile().name
+
+ shutil.copytree(ABP_DIR, patched_abp_dir)
+ try:
+ subprocess.call(
+ ["hg", "import", "-q", os.path.join(BASE_DIR, "issue-2509.patch")],
+ cwd=os.path.join(patched_abp_dir, "buildtools"))
Wladimir Palant 2015/05/18 11:01:22 I'd prefer -R parameter instead of cwd but doesn't
Felix Dahlke 2015/05/18 19:43:28 Yeah that's nicer, done.
+ subprocess.call(
+ ["hg", "import", "-q", os.path.join(BASE_DIR, "issue-2510.patch")],
+ cwd=patched_abp_dir)
+ build_abp(patched_abp_dir, xpi_path)
+ finally:
+ shutil.rmtree(patched_abp_dir)
« no previous file with comments | « no previous file | adblockplus/issue-2509.patch » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld