Skip to content
This repository has been archived by the owner on Jan 19, 2022. It is now read-only.

Convert to packed add-on #40

Merged
merged 3 commits into from
Feb 23, 2018
Merged

Convert to packed add-on #40

merged 3 commits into from
Feb 23, 2018

Conversation

jryans
Copy link
Contributor

@jryans jryans commented Feb 23, 2018

Firefox 59 and later require packed add-ons, so we convert to that mode here. (Some ESLint changes included as well in separate commits.)

Seems to work well on macOS. Still need to test the others.

Copy link
Contributor

@juliandescottes juliandescottes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks very good. Only small nits, questions and potential follow ups. I tested it on the latest Nightly on both OSX and Win10.

@@ -0,0 +1,7 @@
{
"version": "0.12",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice if those versions were not hardcoded. I guess we can either:

  • change unpack() update the files with current addon version when unpacking
  • change the MAKEFILE to set the version at build time

Can be addressed in a follow up though. Will the addon version be bumped to 0.12 during the next release or should we do it right now? I think it's not technically necessary to have those version numbers aligned with the addon version, but I guess it would be easier to have them in sync.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My main thinking here is that the manifest only has to change if these binaries change, and that's quite rare. (Most changes are in the JS layer of the add-on.) By leaving this number untouched until needed, we avoid extra unpacking for add-on upgrade where the binaries don't actually change.

But yes, that means there's an extra step to update these files when we do change the binaries. I'll file a bug to think more about it.

Yes, I am planning to bump the add-on to 0.12 after merging this, so that's why I used that number here. I filed a bug.


const { Cu } = require("chrome");
const { OS } = require("resource://gre/modules/osfile.jsm");
const { Services } = Cu.import("resource://gre/modules/Services.jsm", {});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Followup: we recently updated the DevTools codebase to get rid of Cu.import calls:

https://bugzilla.mozilla.org/show_bug.cgi?id=1434374

We should probably think about doing the same in adbhelper.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right! Unfortunately, we can't do that here yet, since this add-on might be loaded be older versions of Firefox, at least back to release (maybe ESR too...?). So, we'd need to wait for ChromeUtils to exist in all those places first. I filed a bug for this.

*
* @param {string} file
* The base name of the file, such as "adb".
* @param {boolean} exec
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: the param is an object, which contains a boolean exec

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, good call, I'll update it.

device.js Outdated
}
return false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: weird indentation and extra blank line

Copy link
Contributor Author

@jryans jryans Feb 23, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, curious! I need to watch out for eslint --fix more closely! 😅 Fixed.

Services.io.newURI("jar:" + file.path + "!/", null, null);
let fileURI = Services.io.newFileURI(file);
if (!file.isDirectory()) {
fileURI = Services.io.newURI("jar:" + fileURI.spec + "!/");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious about this: is there a reason to prefer fileURI.spec rather than file.path here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we need the file:// prefix here, which only exists in fileURI.spec.

Firefox 59 no longer supports unpacked add-ons, which we relied on for launching
the included binaries.  Packed mode is now enabled and we manually unpack the
binaries as needed to the local profile directory.
@jryans
Copy link
Contributor Author

jryans commented Feb 23, 2018

Thanks for the review! I have now tested across all 3 desktop platforms, and I think we're good to go.

@jryans jryans merged commit 364b1fc into mozilla:master Feb 23, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants