Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow plugins when building static modules #813

Merged
merged 4 commits into from
Nov 5, 2024

Conversation

jeffcharles
Copy link
Collaborator

Description of the change

Add a -p or --plugin flag to javy build to support using a user-provided plugin. I've disabled allowing plugins on dynamically linked modules in this PR since I want to make that a required parameter and that would represent a breaking change. I also don't want a version of Javy shipped where it is an optional parameter.

I've also added a test-plugin crate for use by the CLI tests so the tests can verify the plugin is being actually used by the generated Wasm module.

Why am I making this change?

Part of #768. This enables using plugins for statically linked modules.

I opted to compile the test plugin as part of the Makefile and CI steps but I'm open to switching it so we commit the final artifact if that would be preferrable.

Checklist

  • I've updated the relevant CHANGELOG files if necessary. Changes to javy-cli and javy-plugin do not require updating CHANGELOG files.
  • I've updated the relevant crate versions if necessary. Versioning policy for library crates
  • I've updated documentation including crate documentation if necessary.

// Using `assert!` instead of `debug_assert!` because integration
// tests are executed with Javy built with the release profile so
// `debug_assert!`s are stripped out.
assert!(
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

My plan is to relax this assertion a bit after we have released a new version of javy_quickjs_provider_v3.

@jeffcharles jeffcharles force-pushed the jc.allow-static-plugins branch from 900a5cc to e8f8452 Compare November 4, 2024 21:38
@jeffcharles jeffcharles marked this pull request as ready for review November 4, 2024 21:38
Copy link
Member

@saulecabrera saulecabrera left a comment

Choose a reason for hiding this comment

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

Looking good, left a few comments.

Comment on lines 361 to 365
// `eval_bytecode` is not present in user plugins and `remove`
// returns an error if the export is not present.
if module.exports.get_func("eval_bytecode").is_ok() {
module.exports.remove("eval_bytecode")?;
}
Copy link
Member

Choose a reason for hiding this comment

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

This is true because we know the plugin API surface, however, I don't think anything is preventing a plugin from exporting a function named eval_bytecode for their own purposes. Probably unlikely, but not impossible. I'd suggest checking if the plugin is not a user provided plugin before removing this export.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've updated the check


#[arg(short, long)]
/// Path of the plugin.
pub plugin: Option<PathBuf>,
Copy link
Member

Choose a reason for hiding this comment

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

Any reason why the plugin flag is not scoped? In the What are the changes? section of the RFC, the plugin handling is scoped under the -C option group, which is what I think makes most sense, since it's easier to validate the semantic meaning of the group as a whole (e.g., -C pluing=.. is required with -C dynamic)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That was an oversight on my part

Copy link
Member

@saulecabrera saulecabrera left a comment

Choose a reason for hiding this comment

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

Thanks!

@jeffcharles jeffcharles merged commit 947dceb into main Nov 5, 2024
7 checks passed
@jeffcharles jeffcharles deleted the jc.allow-static-plugins branch November 5, 2024 17:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants