From e903752037f083eed592c5527a056f9a5f8cc0d6 Mon Sep 17 00:00:00 2001 From: gorhill Date: Fri, 4 Aug 2017 18:19:55 -0400 Subject: [PATCH] rename webext to webext-hybrid, add pure webext version --- tools/make-webext-hybrid-meta.py | 2 +- ...webext-hybrid.py => make-webext-hybrid.sh} | 14 +++---- tools/make-webext-meta.py | 29 ++++++++++++++ tools/make-webext.sh | 40 +++++++++++++++++++ 4 files changed, 77 insertions(+), 8 deletions(-) rename tools/{make-webext-hybrid.py => make-webext-hybrid.sh} (80%) create mode 100644 tools/make-webext-meta.py create mode 100755 tools/make-webext.sh diff --git a/tools/make-webext-hybrid-meta.py b/tools/make-webext-hybrid-meta.py index 694f63006..5e3a22b4c 100644 --- a/tools/make-webext-hybrid-meta.py +++ b/tools/make-webext-hybrid-meta.py @@ -43,7 +43,7 @@ for alpha2 in sorted(os.listdir(source_locale_dir)): descriptions[alpha2] = strings['extShortDesc']['message'] webext_manifest['author'] = chromium_manifest['author']; -webext_manifest['name'] = chromium_manifest['name'] + '/webext'; +webext_manifest['name'] = chromium_manifest['name'] + '/webext-hybrid' webext_manifest['homepage'] = 'https://github.com/gorhill/uBlock' webext_manifest['description'] = descriptions['en'] del descriptions['en'] diff --git a/tools/make-webext-hybrid.py b/tools/make-webext-hybrid.sh similarity index 80% rename from tools/make-webext-hybrid.py rename to tools/make-webext-hybrid.sh index 2f64bf926..b2282fafa 100755 --- a/tools/make-webext-hybrid.py +++ b/tools/make-webext-hybrid.sh @@ -2,10 +2,10 @@ # # This script assumes a linux environment -echo "*** uBlock0.webext: Creating web store package" -echo "*** uBlock0.webext: Copying files" +echo "*** uBlock0.webext-hybrid: Creating web store package" +echo "*** uBlock0.webext-hybrid: Copying files" -DES=dist/build/uBlock0.webext +DES=dist/build/uBlock0.webext-hybrid rm -rf $DES mkdir -p $DES/webextension @@ -34,14 +34,14 @@ cp platform/webext/chrome.manifest $DES/ cp platform/webext/install.rdf $DES/ mv $DES/webextension/img/icon_128.png $DES/icon.png -echo "*** uBlock0.webext: Generating meta..." -python tools/make-webext-meta.py $DES/ +echo "*** uBlock0.webext-hybrid: Generating meta..." +python tools/make-webext-hybrid-meta.py $DES/ if [ "$1" = all ]; then - echo "*** uBlock0.webext: Creating package..." + echo "*** uBlock0.webext-hybrid: Creating package..." pushd $DES > /dev/null zip ../$(basename $DES).xpi -qr * popd > /dev/null fi -echo "*** uBlock0.webext: Package done." +echo "*** uBlock0.webext-hybrid: Package done." diff --git a/tools/make-webext-meta.py b/tools/make-webext-meta.py new file mode 100644 index 000000000..15df315fb --- /dev/null +++ b/tools/make-webext-meta.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python3 + +import os +import json +import sys + +if len(sys.argv) == 1 or not sys.argv[1]: + raise SystemExit('Build dir missing.') + +proj_dir = os.path.join(os.path.split(os.path.abspath(__file__))[0], '..') +build_dir = os.path.abspath(sys.argv[1]) + +# Import version number from chromium platform +chromium_manifest = {} +webext_manifest = {} + +chromium_manifest_file = os.path.join(proj_dir, 'platform', 'chromium', 'manifest.json') +with open(chromium_manifest_file) as f1: + chromium_manifest = json.load(f1) + +webext_manifest_file = os.path.join(build_dir, 'manifest.json') +with open(webext_manifest_file) as f2: + webext_manifest = json.load(f2) + +webext_manifest['version'] = chromium_manifest['version'] + +with open(webext_manifest_file, 'w') as f2: + json.dump(webext_manifest, f2, indent=2, separators=(',', ': '), sort_keys=True) + f2.write('\n') diff --git a/tools/make-webext.sh b/tools/make-webext.sh new file mode 100755 index 000000000..1e5fdfcab --- /dev/null +++ b/tools/make-webext.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash +# +# This script assumes a linux environment + +echo "*** uBlock0.webext: Creating web store package" +echo "*** uBlock0.webext: Copying files" + +DES=dist/build/uBlock0.webext +rm -rf $DES +mkdir -p $DES + +bash ./tools/make-assets.sh $DES + +cp -R src/css $DES/ +cp -R src/img $DES/ +cp -R src/js $DES/ +cp -R src/lib $DES/ +cp -R src/_locales $DES/ +cp -R $DES/_locales/nb $DES/_locales/no +cp src/*.html $DES/ +cp platform/chromium/*.js $DES/js/ +cp -R platform/chromium/img $DES/ +cp platform/chromium/*.html $DES/ +cp platform/chromium/*.json $DES/ +cp platform/webext/polyfill.js $DES/js/ +cp platform/webext/vapi-usercss.js $DES/js/ +cp platform/webext/manifest.json $DES/ +cp LICENSE.txt $DES/ + +echo "*** uBlock0.webext: Generating meta..." +python tools/make-webext-meta.py $DES/ + +if [ "$1" = all ]; then + echo "*** uBlock0.webext: Creating package..." + pushd $DES > /dev/null + zip ../$(basename $DES).xpi -qr * + popd > /dev/null +fi + +echo "*** uBlock0.webext: Package done."