[Pkg-mozext-commits] [adblock-plus] 341/464: Chrome: Automatically convert Firefox JavaScript files on build

David Prévot taffit at moszumanska.debian.org
Tue Jul 22 20:44:31 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository adblock-plus.

commit 38482802047e3964b816563b078fae407634304c
Author: Wladimir Palant <trev at adblockplus.org>
Date:   Mon Dec 17 14:28:22 2012 +0100

    Chrome: Automatically convert Firefox JavaScript files on build
---
 packagerChrome.py | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/packagerChrome.py b/packagerChrome.py
index ad46469..17204ce 100644
--- a/packagerChrome.py
+++ b/packagerChrome.py
@@ -133,6 +133,34 @@ def readFile(params, files, path):
     name = os.path.relpath(path, params['baseDir']).replace('\\', '/')
     files[name] = data
 
+def convertJS(params, files):
+  baseDir = params['baseDir']
+  hydraDir = os.path.join(baseDir, 'jshydra')
+  sys.path.append(hydraDir)
+  try:
+    import abp_rewrite
+    for file, sources in params['metadata'].items('convert_js'):
+      dirsep = file.find('/')
+      if dirsep >= 0:
+        # Not a top-level file, make sure it is inside an included director
+        dirname = file[0:dirsep]
+        if os.path.join(baseDir, dirname) not in getPackageFiles(params):
+          continue
+
+      sourceFiles = re.split(r'\s+', sources)
+      args = []
+      try:
+        argsStart = sourceFiles.index('--arg')
+        args = sourceFiles[argsStart + 1:]
+        sourceFiles = sourceFiles[0:argsStart]
+      except ValueError:
+        pass
+
+      sourceFiles = map(lambda f: os.path.abspath(os.path.join(baseDir, f)), sourceFiles)
+      files[file] = abp_rewrite.doRewrite(sourceFiles, args)
+  finally:
+    sys.path.remove(hydraDir)
+
 def packFiles(files):
   buffer = StringIO()
   zip = ZipFile(buffer, 'w', ZIP_DEFLATED)
@@ -194,6 +222,9 @@ def createBuild(baseDir, outFile=None, buildNum=None, releaseBuild=False, keyFil
     if os.path.exists(path):
       readFile(params, files, path)
 
+  if metadata.has_section('convert_js') and os.path.isdir(os.path.join(baseDir, 'jshydra')):
+    convertJS(params, files)
+
   zipdata = packFiles(files)
   signature = None
   pubkey = None

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/adblock-plus.git



More information about the Pkg-mozext-commits mailing list