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 additional comments Created May 18, 2015, 7:42 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__))
+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:
+ print >>sys.stderr, "Usage: %s XPI_PATH" % os.path.basename(sys.argv[0])
+ sys.exit(1)
+
+ xpi_path = sys.argv[1]
+ patched_abp_dir = tempfile.NamedTemporaryFile().name
+
+ shutil.copytree(ABP_DIR, patched_abp_dir)
+ try:
+ subprocess.check_call(["hg", "import", "-q", "-R",
+ os.path.join(patched_abp_dir, "buildtools"),
+ os.path.join(BASE_DIR, "issue-2509.patch")]),
+ subprocess.check_call(["hg", "import", "-q", "-R", patched_abp_dir,
+ os.path.join(BASE_DIR, "issue-2510.patch")]),
+ 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