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

Side by Side Diff: adblockplus/build.py

Issue 29863604: Issue 6865 - Update ABP dependency to version 3.2 (Closed)
Patch Set: Adjusting build script and removing extension first run page Created Jan. 8, 2019, 2:54 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 | adblockplus/extensionBridge.js » ('j') | adblockplus/extensionBridge.js » ('J')
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 # coding: utf-8 2 # coding: utf-8
3 3
4 # This file is part of Adblock Plus <https://adblockplus.org/>, 4 # This file is part of Adblock Plus <https://adblockplus.org/>,
5 # Copyright (C) 2006-present eyeo GmbH 5 # Copyright (C) 2006-present eyeo GmbH
6 # 6 #
7 # Adblock Plus is free software: you can redistribute it and/or modify 7 # Adblock Plus is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License version 3 as 8 # it under the terms of the GNU General Public License version 3 as
9 # published by the Free Software Foundation. 9 # published by the Free Software Foundation.
10 # 10 #
11 # Adblock Plus is distributed in the hope that it will be useful, 11 # Adblock Plus is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details. 14 # GNU General Public License for more details.
15 # 15 #
16 # You should have received a copy of the GNU General Public License 16 # You should have received a copy of the GNU General Public License
17 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 17 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
18 18
19 import os 19 import os
20 import shutil 20 import shutil
21 import subprocess 21 import subprocess
22 import sys 22 import sys
23 import tempfile 23 import tempfile
24 24
25 _BASE_DIR = os.path.dirname(os.path.abspath(__file__)) 25 _BASE_DIR_PATH = os.path.dirname(os.path.abspath(__file__))
26 _ABP_DIR = "adblockplus" 26 _ABP_DIR = "adblockpluschrome"
27 _ABP_CORE_DIR = "adblockpluscore" 27 _ABP_CORE_DIR = "adblockpluscore"
28 _SUBSCRIPTIONS_PATH = os.path.join(_BASE_DIR_PATH, _ABP_DIR, _ABP_CORE_DIR,
29 "chrome", "content", "ui",
30 "subscriptions.xml")
28 31
29 32
30 def _build_abp(base_dir, xpi_path): 33 def _import_issue_patch(src_path, patched_path, issue_name):
31 xpi_dir = os.path.dirname(os.path.abspath(xpi_path)) 34 patch_filename = "issue-%s.patch" % issue_name
32 if not os.path.exists(xpi_dir): 35 subprocess.check_call(["hg", "import", "-q", "-R", src_path,
33 os.makedirs(xpi_dir) 36 os.path.join(patched_path, patch_filename)])
34 37
35 abp_dir = os.path.join(base_dir, _ABP_DIR) 38
36 sys.path.insert(0, abp_dir) 39 def _patch_abp(patched_path):
37 import buildtools.build 40 shutil.copytree(_BASE_DIR_PATH, patched_path)
38 import buildtools.packager 41 abp_path = os.path.join(patched_path, _ABP_DIR)
42 abp_core_path = os.path.join(abp_path, _ABP_CORE_DIR)
43 _import_issue_patch(abp_core_path, patched_path, "6070")
44 _import_issue_patch(abp_path, patched_path, "6865")
45
46
47 def _build_abp(base_path, xpi_path):
48 xpi_dir_path = os.path.dirname(xpi_path)
49 if not os.path.exists(xpi_dir_path):
50 os.makedirs(xpi_dir_path)
51
52 abp_dir_path = os.path.join(base_path, _ABP_DIR)
53 sys.path.insert(0, abp_dir_path)
54 import buildtools.build as tools_build
55 import buildtools.packager as tools_packager
39 56
40 def get_metadata_path(dir, type): 57 def get_metadata_path(dir, type):
41 return os.path.join(base_dir, "metadata.gecko") 58 return os.path.join(base_path, "metadata.gecko")
42 59
43 buildtools.packager.getMetadataPath = get_metadata_path 60 tools_packager.getMetadataPath = get_metadata_path
44 buildtools.build.processArgs(abp_dir, ["", "build", xpi_path]) 61 tools_build.process_args(abp_dir_path, "build", "-t", "gecko", "-r",
62 xpi_path)
45 63
46 64
47 def _patch_abp(patched_dir): 65 def _copy_subscriptions(xpi_path):
48 shutil.copytree(_BASE_DIR, patched_dir) 66 xpi_dir_path = os.path.dirname(xpi_path)
49 abp_dir = os.path.join(patched_dir, _ABP_DIR) 67 shutil.copy2(_SUBSCRIPTIONS_PATH, xpi_dir_path)
50 abp_core_dir = os.path.join(abp_dir, _ABP_CORE_DIR)
51 subprocess.check_call(["hg", "import", "-q", "-R", abp_core_dir,
52 os.path.join(patched_dir, "issue-6070.patch")])
53 68
54 subprocess.check_call(["hg", "import", "-q", "-R", abp_core_dir,
55 os.path.join(patched_dir, "issue-6108.patch")])
56 69
57 if __name__ == "__main__": 70 if __name__ == "__main__":
58 if len(sys.argv) < 2: 71 if len(sys.argv) < 2:
59 error_message = "Usage: %s XPI_PATH" % os.path.basename(sys.argv[0]) 72 error_message = "Usage: %s XPI_PATH" % os.path.basename(sys.argv[0])
60 print >>sys.stderr, error_message 73 print >>sys.stderr, error_message
61 sys.exit(1) 74 sys.exit(1)
62 75
63 xpi_path = sys.argv[1] 76 xpi_path = os.path.abspath(sys.argv[1])
64 patched_dir = tempfile.NamedTemporaryFile().name 77 patched_path = tempfile.NamedTemporaryFile().name
65 try: 78 try:
66 _patch_abp(patched_dir) 79 _patch_abp(patched_path)
67 _build_abp(patched_dir, xpi_path) 80 _build_abp(patched_path, xpi_path)
81 _copy_subscriptions(xpi_path)
68 finally: 82 finally:
69 shutil.rmtree(patched_dir) 83 shutil.rmtree(patched_path)
OLDNEW
« no previous file with comments | « no previous file | adblockplus/extensionBridge.js » ('j') | adblockplus/extensionBridge.js » ('J')

Powered by Google App Engine
This is Rietveld