-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat(vfox): embed vfox plugin Lua code in binary #7369
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
Merged
Merged
Changes from 3 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
ec2c45b
feat(vfox): embed vfox plugin Lua code in binary
claude dd96499
ci: add submodules checkout for embedded vfox plugins
claude ac83d2b
fix(vfox): use forward slashes in include_str! paths for Windows
claude c2b8fd3
fix(vfox): add embedded plugin check to uninstall method
claude 5b749c0
feat(vfox): allow installed plugins to override embedded
claude b69bfec
chore(vfox): ignore embedded-plugins in prettier
claude ed00dea
ci: add submodules checkout to autofix and test-vfox workflows
claude 02aa695
fix(vfox): properly handle filesystem overrides of embedded plugins
claude ce162df
chore(release): auto-sync vfox embedded plugins from registry
claude 4a0870b
fix(vfox): accept any Lua type from embedded lib modules
claude 3af2503
fix(vfox): consistent filesystem-first priority in from_name
claude a14456e
fix(ci): add submodules checkout to remaining workflows
claude 744ab55
fix(vfox): multiple embedded plugin fixes
claude 849a871
fix(lint): ignore embedded-plugins in markdownlint
claude 2bae469
[autofix.ci] apply automated fixes
autofix-ci[bot] 8b36694
fix(release): use precise grep pattern for plugin matching
claude e3ef5f2
Merge branch 'main' into feat/embed-vfox-plugins
jdx File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| [submodule "crates/vfox/embedded-plugins/vfox-aapt2"] | ||
| path = crates/vfox/embedded-plugins/vfox-aapt2 | ||
| url = https://github.com/mise-plugins/vfox-aapt2.git | ||
| [submodule "crates/vfox/embedded-plugins/vfox-ag"] | ||
| path = crates/vfox/embedded-plugins/vfox-ag | ||
| url = https://github.com/mise-plugins/vfox-ag.git | ||
| [submodule "crates/vfox/embedded-plugins/vfox-android-sdk"] | ||
| path = crates/vfox/embedded-plugins/vfox-android-sdk | ||
| url = https://github.com/mise-plugins/vfox-android-sdk.git | ||
| [submodule "crates/vfox/embedded-plugins/vfox-ant"] | ||
| path = crates/vfox/embedded-plugins/vfox-ant | ||
| url = https://github.com/mise-plugins/vfox-ant.git | ||
| [submodule "crates/vfox/embedded-plugins/vfox-bfs"] | ||
| path = crates/vfox/embedded-plugins/vfox-bfs | ||
| url = https://github.com/mise-plugins/vfox-bfs.git | ||
| [submodule "crates/vfox/embedded-plugins/vfox-bpkg"] | ||
| path = crates/vfox/embedded-plugins/vfox-bpkg | ||
| url = https://github.com/mise-plugins/vfox-bpkg.git | ||
| [submodule "crates/vfox/embedded-plugins/vfox-chicken"] | ||
| path = crates/vfox/embedded-plugins/vfox-chicken | ||
| url = https://github.com/mise-plugins/vfox-chicken.git | ||
| [submodule "crates/vfox/embedded-plugins/vfox-vlang"] | ||
| path = crates/vfox/embedded-plugins/vfox-vlang | ||
| url = https://github.com/mise-plugins/vfox-vlang.git |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,197 @@ | ||
| use std::collections::BTreeMap; | ||
| use std::env; | ||
| use std::fs; | ||
| use std::path::Path; | ||
|
|
||
| fn main() { | ||
| codegen_embedded_plugins(); | ||
| } | ||
|
|
||
| /// Convert a path to a string with forward slashes (required for include_str! on Windows) | ||
| fn path_to_forward_slashes(path: &Path) -> String { | ||
| path.to_string_lossy().replace('\\', "/") | ||
| } | ||
|
|
||
| fn codegen_embedded_plugins() { | ||
| let out_dir = env::var_os("OUT_DIR").unwrap(); | ||
| let dest_path = Path::new(&out_dir).join("embedded_plugins.rs"); | ||
|
|
||
| let manifest_dir = env::var("CARGO_MANIFEST_DIR").unwrap(); | ||
| let embedded_dir = Path::new(&manifest_dir).join("embedded-plugins"); | ||
|
|
||
| // Tell Cargo to re-run if any embedded plugin files change | ||
| println!("cargo:rerun-if-changed=embedded-plugins"); | ||
|
|
||
| if !embedded_dir.exists() { | ||
| // Generate empty implementation if no embedded plugins | ||
| let code = r#" | ||
| #[derive(Debug)] | ||
| pub struct EmbeddedPlugin { | ||
| pub metadata: &'static str, | ||
| pub hooks: &'static [(&'static str, &'static str)], | ||
| pub lib: &'static [(&'static str, &'static str)], | ||
| } | ||
|
|
||
| pub fn get_embedded_plugin(_name: &str) -> Option<&'static EmbeddedPlugin> { | ||
| None | ||
| } | ||
|
|
||
| pub fn list_embedded_plugins() -> &'static [&'static str] { | ||
| &[] | ||
| } | ||
| "#; | ||
| fs::write(&dest_path, code).unwrap(); | ||
| return; | ||
| } | ||
|
|
||
| let mut plugins: BTreeMap<String, PluginFiles> = BTreeMap::new(); | ||
|
|
||
| // Scan for plugin directories | ||
| for entry in fs::read_dir(&embedded_dir).unwrap() { | ||
| let entry = entry.unwrap(); | ||
| let path = entry.path(); | ||
| if !path.is_dir() { | ||
| continue; | ||
| } | ||
|
|
||
| let dir_name = path.file_name().unwrap().to_string_lossy().to_string(); | ||
| if !dir_name.starts_with("vfox-") { | ||
| continue; | ||
| } | ||
|
|
||
| // Tell Cargo to re-run if this plugin directory changes | ||
| println!("cargo:rerun-if-changed={}", path.display()); | ||
|
|
||
| let plugin = collect_plugin_files(&path); | ||
| plugins.insert(dir_name, plugin); | ||
| } | ||
|
|
||
| // Generate Rust code | ||
| let mut code = String::new(); | ||
|
|
||
| // Struct definition | ||
| code.push_str( | ||
| r#" | ||
| #[derive(Debug)] | ||
| pub struct EmbeddedPlugin { | ||
| pub metadata: &'static str, | ||
| pub hooks: &'static [(&'static str, &'static str)], | ||
| pub lib: &'static [(&'static str, &'static str)], | ||
| } | ||
|
|
||
| "#, | ||
| ); | ||
|
|
||
| // Generate static instances for each plugin | ||
| for (name, files) in &plugins { | ||
| let var_name = name.replace('-', "_").to_uppercase(); | ||
| code.push_str(&format!( | ||
| "static {var_name}: EmbeddedPlugin = EmbeddedPlugin {{\n" | ||
| )); | ||
|
|
||
| // Metadata - use absolute path with forward slashes for cross-platform include_str! | ||
| let metadata_path = embedded_dir.join(name).join("metadata.lua"); | ||
| code.push_str(&format!( | ||
| " metadata: include_str!(\"{}\"),\n", | ||
| path_to_forward_slashes(&metadata_path) | ||
| )); | ||
|
|
||
| // Hooks | ||
| code.push_str(" hooks: &[\n"); | ||
| for hook in &files.hooks { | ||
| let hook_path = embedded_dir | ||
| .join(name) | ||
| .join("hooks") | ||
| .join(format!("{}.lua", hook)); | ||
| code.push_str(&format!( | ||
| " (\"{}\", include_str!(\"{}\")),\n", | ||
| hook, | ||
| path_to_forward_slashes(&hook_path) | ||
| )); | ||
| } | ||
| code.push_str(" ],\n"); | ||
|
|
||
| // Lib files | ||
| code.push_str(" lib: &[\n"); | ||
| for lib in &files.lib { | ||
| let lib_path = embedded_dir | ||
| .join(name) | ||
| .join("lib") | ||
| .join(format!("{}.lua", lib)); | ||
| code.push_str(&format!( | ||
| " (\"{}\", include_str!(\"{}\")),\n", | ||
| lib, | ||
| path_to_forward_slashes(&lib_path) | ||
| )); | ||
| } | ||
| code.push_str(" ],\n"); | ||
|
|
||
| code.push_str("};\n\n"); | ||
| } | ||
|
|
||
| // Generate lookup function | ||
| code.push_str("pub fn get_embedded_plugin(name: &str) -> Option<&'static EmbeddedPlugin> {\n"); | ||
| code.push_str(" match name {\n"); | ||
| for name in plugins.keys() { | ||
| let var_name = name.replace('-', "_").to_uppercase(); | ||
| let short_name = name.strip_prefix("vfox-").unwrap_or(name); | ||
| code.push_str(&format!( | ||
| " \"{}\" | \"{}\" => Some(&{}),\n", | ||
| name, short_name, var_name | ||
| )); | ||
| } | ||
| code.push_str(" _ => None,\n"); | ||
| code.push_str(" }\n"); | ||
| code.push_str("}\n\n"); | ||
|
|
||
| // Generate list function | ||
| code.push_str("pub fn list_embedded_plugins() -> &'static [&'static str] {\n"); | ||
| code.push_str(" &[\n"); | ||
| for name in plugins.keys() { | ||
| code.push_str(&format!(" \"{}\",\n", name)); | ||
| } | ||
| code.push_str(" ]\n"); | ||
| code.push_str("}\n"); | ||
|
|
||
| fs::write(&dest_path, code).unwrap(); | ||
| } | ||
|
|
||
| struct PluginFiles { | ||
| hooks: Vec<String>, | ||
| lib: Vec<String>, | ||
| } | ||
|
|
||
| fn collect_plugin_files(plugin_dir: &Path) -> PluginFiles { | ||
| let mut hooks = Vec::new(); | ||
| let mut lib = Vec::new(); | ||
|
|
||
| // Collect hooks | ||
| let hooks_dir = plugin_dir.join("hooks"); | ||
| if hooks_dir.exists() { | ||
| for entry in fs::read_dir(&hooks_dir).unwrap() { | ||
| let entry = entry.unwrap(); | ||
| let path = entry.path(); | ||
| if path.extension().is_some_and(|ext| ext == "lua") { | ||
|
||
| let name = path.file_stem().unwrap().to_string_lossy().to_string(); | ||
| hooks.push(name); | ||
| } | ||
| } | ||
| } | ||
| hooks.sort(); | ||
|
|
||
| // Collect lib files | ||
| let lib_dir = plugin_dir.join("lib"); | ||
| if lib_dir.exists() { | ||
| for entry in fs::read_dir(&lib_dir).unwrap() { | ||
| let entry = entry.unwrap(); | ||
| let path = entry.path(); | ||
| if path.extension().is_some_and(|ext| ext == "lua") { | ||
| let name = path.file_stem().unwrap().to_string_lossy().to_string(); | ||
| lib.push(name); | ||
| } | ||
| } | ||
| } | ||
| lib.sort(); | ||
|
|
||
| PluginFiles { hooks, lib } | ||
| } | ||
Submodule vfox-aapt2
added at
144a5e
Submodule vfox-android-sdk
added at
5f8b78
Submodule vfox-chicken
added at
85ce8f
Submodule vfox-vlang
added at
61dee7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| // This module provides access to embedded vfox plugin Lua code. | ||
| // The actual code is generated at build time by build.rs | ||
|
|
||
| include!(concat!(env!("OUT_DIR"), "/embedded_plugins.rs")); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.