From a4aced69dc814befcbb57ff1cc04bee307f2c131 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Fri, 16 Jul 2021 10:06:58 -0400 Subject: [PATCH] Reorganize platform directory to avoid Chromium-centric appearance Though Firefox shares a lot of WebExtensions code with Chromium, these platforms have their own specific code paths, for various reasons. The reorganization here makes it clear that Chromium platform is just one flavor of WebExtensions, and as such all Chromium-specific code paths should no longer be automatically pulled by other platforms where these code paths are not needed. Given that the filepath of many files changed, here is the parent commit to quickly browse back to the previous directory layout: https://github.com/gorhill/uBlock/commit/ec7db30b2f4ff492ebc2a87ded28afa74aa50948 --- ...i-webrequest.js => vapi-background-ext.js} | 0 .../{chromium => common}/managed_storage.json | 0 .../{chromium => common}/vapi-background.js | 0 .../{chromium => common}/vapi-client-extra.js | 0 platform/{chromium => common}/vapi-client.js | 0 platform/{chromium => common}/vapi-common.js | 0 platform/{chromium => common}/vapi.js | 0 ...i-webrequest.js => vapi-background-ext.js} | 0 platform/webext/README.md | 3 - platform/webext/manifest.json | 113 ------------------ src/background.html | 2 +- tools/copy-common-files.sh | 5 +- tools/make-chromium.sh | 8 +- tools/make-firefox.sh | 12 +- tools/make-opera.sh | 11 +- tools/make-thunderbird.sh | 11 +- 16 files changed, 33 insertions(+), 132 deletions(-) rename platform/chromium/{vapi-webrequest.js => vapi-background-ext.js} (100%) rename platform/{chromium => common}/managed_storage.json (100%) rename platform/{chromium => common}/vapi-background.js (100%) rename platform/{chromium => common}/vapi-client-extra.js (100%) rename platform/{chromium => common}/vapi-client.js (100%) rename platform/{chromium => common}/vapi-common.js (100%) rename platform/{chromium => common}/vapi.js (100%) rename platform/firefox/{vapi-webrequest.js => vapi-background-ext.js} (100%) delete mode 100644 platform/webext/README.md delete mode 100644 platform/webext/manifest.json diff --git a/platform/chromium/vapi-webrequest.js b/platform/chromium/vapi-background-ext.js similarity index 100% rename from platform/chromium/vapi-webrequest.js rename to platform/chromium/vapi-background-ext.js diff --git a/platform/chromium/managed_storage.json b/platform/common/managed_storage.json similarity index 100% rename from platform/chromium/managed_storage.json rename to platform/common/managed_storage.json diff --git a/platform/chromium/vapi-background.js b/platform/common/vapi-background.js similarity index 100% rename from platform/chromium/vapi-background.js rename to platform/common/vapi-background.js diff --git a/platform/chromium/vapi-client-extra.js b/platform/common/vapi-client-extra.js similarity index 100% rename from platform/chromium/vapi-client-extra.js rename to platform/common/vapi-client-extra.js diff --git a/platform/chromium/vapi-client.js b/platform/common/vapi-client.js similarity index 100% rename from platform/chromium/vapi-client.js rename to platform/common/vapi-client.js diff --git a/platform/chromium/vapi-common.js b/platform/common/vapi-common.js similarity index 100% rename from platform/chromium/vapi-common.js rename to platform/common/vapi-common.js diff --git a/platform/chromium/vapi.js b/platform/common/vapi.js similarity index 100% rename from platform/chromium/vapi.js rename to platform/common/vapi.js diff --git a/platform/firefox/vapi-webrequest.js b/platform/firefox/vapi-background-ext.js similarity index 100% rename from platform/firefox/vapi-webrequest.js rename to platform/firefox/vapi-background-ext.js diff --git a/platform/webext/README.md b/platform/webext/README.md deleted file mode 100644 index ee03d100c4a2c..0000000000000 --- a/platform/webext/README.md +++ /dev/null @@ -1,3 +0,0 @@ -The purpose of the `webext` target is to create a single package which -can be used for both Chromium and Firefox. Such package is a requirement -to have uBlock Origin shipped in Debian. diff --git a/platform/webext/manifest.json b/platform/webext/manifest.json deleted file mode 100644 index 38166b9fb98c5..0000000000000 --- a/platform/webext/manifest.json +++ /dev/null @@ -1,113 +0,0 @@ -{ - "applications": { - "gecko": { - "id": "uBlock0@raymondhill.net", - "strict_min_version": "55.0" - } - }, - "author": "Raymond Hill & contributors", - "background": { - "page": "background.html" - }, - "browser_action": { - "browser_style": false, - "default_icon": { - "16": "img/icon_16.png", - "32": "img/icon_32.png" - }, - "default_title": "uBlock Origin", - "default_popup": "popup.html" - }, - "commands": { - "launch-element-zapper": { - "description": "__MSG_popupTipZapper__" - }, - "launch-element-picker": { - "description": "__MSG_popupTipPicker__" - }, - "launch-logger": { - "description": "__MSG_popupTipLog__" - }, - "relax-blocking-mode": { - "description": "__MSG_relaxBlockingMode__" - } - }, - "content_scripts": [ - { - "matches": [ - "http://*/*", - "https://*/*", - "file://*/*" - ], - "js": [ - "/js/vapi.js", - "/js/vapi-client.js", - "/js/contentscript.js" - ], - "run_at": "document_start", - "all_frames": true - }, - { - "matches": [ - "https://easylist.to/*", - "https://*.fanboy.co.nz/*", - "https://filterlists.com/*", - "https://forums.lanik.us/*", - "https://github.com/*", - "https://*.github.io/*" - ], - "js": [ - "/js/scriptlets/subscriber.js" - ], - "run_at": "document_idle", - "all_frames": false - } - ], - "default_locale": "en", - "description": "__MSG_extShortDesc__", - "icons": { - "16": "img/icon_16.png", - "32": "img/icon_32.png", - "64": "img/icon_64.png", - "128": "img/icon_128.png" - }, - "incognito": "split", - "manifest_version": 2, - "minimum_chrome_version": "51.0", - "name": "uBlock Origin", - "optional_permissions": [ - "file:///*" - ], - "options_ui": { - "page": "dashboard.html", - "open_in_tab": true - }, - "permissions": [ - "contextMenus", - "privacy", - "storage", - "tabs", - "unlimitedStorage", - "webNavigation", - "webRequest", - "webRequestBlocking", - "" - ], - "short_name": "uBlockâ‚€", - "sidebar_action": { - "default_title": "__MSG_statsPageName__", - "default_panel": "logger-ui.html", - "default_icon": { - "16": "img/ublock.svg", - "48": "img/ublock.svg" - }, - "open_at_install": false - }, - "storage": { - "managed_schema": "managed_storage.json" - }, - "version": "1.9.15.101", - "web_accessible_resources": [ - "/web_accessible_resources/*" - ] -} diff --git a/src/background.html b/src/background.html index 393b15024b8f4..078824442b7a6 100644 --- a/src/background.html +++ b/src/background.html @@ -14,7 +14,7 @@ - + diff --git a/tools/copy-common-files.sh b/tools/copy-common-files.sh index cb7d8bcf841a4..7500512ea4138 100644 --- a/tools/copy-common-files.sh +++ b/tools/copy-common-files.sh @@ -14,7 +14,6 @@ cp -R src/web_accessible_resources $DES/ cp -R src/_locales $DES/ cp src/*.html $DES/ -cp platform/chromium/*.js $DES/js/ -cp platform/chromium/*.html $DES/ -cp platform/chromium/*.json $DES/ +cp platform/common/*.js $DES/js/ +cp platform/common/*.json $DES/ cp LICENSE.txt $DES/ diff --git a/tools/make-chromium.sh b/tools/make-chromium.sh index e1f6e5c373518..f32bd233015cc 100755 --- a/tools/make-chromium.sh +++ b/tools/make-chromium.sh @@ -8,9 +8,15 @@ DES=dist/build/uBlock0.chromium rm -rf $DES mkdir -p $DES -echo "*** uBlock0.chromium: copying common files" +echo "*** uBlock0.chromium: Copying common files" bash ./tools/copy-common-files.sh $DES +# Chromium-specific +echo "*** uBlock0.chromium: Copying chromium-specific files" +cp platform/chromium/*.js $DES/js/ +cp platform/chromium/*.html $DES/ +cp platform/chromium/*.json $DES/ + # Chrome store-specific cp -R $DES/_locales/nb $DES/_locales/no diff --git a/tools/make-firefox.sh b/tools/make-firefox.sh index d1708cdd45973..31ec7ae20e2e2 100755 --- a/tools/make-firefox.sh +++ b/tools/make-firefox.sh @@ -9,14 +9,16 @@ DES="$BLDIR"/uBlock0.firefox rm -rf $DES mkdir -p $DES -echo "*** uBlock0.firefox: copying common files" +echo "*** uBlock0.firefox: Copying common files" bash ./tools/copy-common-files.sh $DES -cp -R $DES/_locales/nb $DES/_locales/no +# Firefox-specific +echo "*** uBlock0.firefox: Copying firefox-specific files" +cp platform/firefox/*.json $DES/ +cp platform/firefox/*.js $DES/js/ -cp platform/firefox/manifest.json $DES/ -cp platform/firefox/webext.js $DES/js/ -cp platform/firefox/vapi-webrequest.js $DES/js/ +# Firefox store-specific +cp -R $DES/_locales/nb $DES/_locales/no # Firefox/webext-specific rm $DES/img/icon_128.png diff --git a/tools/make-opera.sh b/tools/make-opera.sh index a963f3d68a53b..8a6c7443ab2fa 100755 --- a/tools/make-opera.sh +++ b/tools/make-opera.sh @@ -8,11 +8,18 @@ DES=dist/build/uBlock0.opera rm -rf $DES mkdir -p $DES -echo "*** uBlock0.opera: copying common files" +echo "*** uBlock0.opera: Copying common files" bash ./tools/copy-common-files.sh $DES +# Chromium-specific +echo "*** uBlock0.opera: Copying chromium-specific files" +cp platform/chromium/*.js $DES/js/ +cp platform/chromium/*.html $DES/ + # Opera-specific -cp platform/opera/manifest.json $DES/ +echo "*** uBlock0.opera: Copying opera-specific files" +cp platform/opera/manifest.json $DES/ + rm -r $DES/_locales/az rm -r $DES/_locales/cv rm -r $DES/_locales/hi diff --git a/tools/make-thunderbird.sh b/tools/make-thunderbird.sh index 5a8edd7c24434..16a17121f58ae 100755 --- a/tools/make-thunderbird.sh +++ b/tools/make-thunderbird.sh @@ -12,11 +12,14 @@ mkdir -p $DES echo "*** uBlock0.thunderbird: copying common files" bash ./tools/copy-common-files.sh $DES -cp -R $DES/_locales/nb $DES/_locales/no +echo "*** uBlock0.firefox: Copying firefox-specific files" +cp platform/firefox/*.js $DES/js/ -cp platform/thunderbird/manifest.json $DES/ -cp platform/firefox/webext.js $DES/js/ -cp platform/firefox/vapi-webrequest.js $DES/js/ +echo "*** uBlock0.firefox: Copying thunderbird-specific files" +cp platform/thunderbird/manifest.json $DES/ + +# Firefox store-specific +cp -R $DES/_locales/nb $DES/_locales/no # Firefox/webext-specific rm $DES/img/icon_128.png