HOTFIX: Feature/ignore asset map (#2002)

* utils: feature-gate asset map

to make publishing on crates.io possible without compile errors.

* setup: Fix asset_map feature
This commit is contained in:
har7an 2022-12-09 09:17:28 +00:00 committed by GitHub
parent 66593ec41a
commit 36233439f9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 10 additions and 8 deletions

View file

@ -69,5 +69,6 @@ pkg-fmt = "tgz"
[features] [features]
# See remarks in zellij_utils/Cargo.toml # See remarks in zellij_utils/Cargo.toml
default = [ "zellij-utils/asset_map" ]
disable_automatic_asset_installation = [ "zellij-utils/disable_automatic_asset_installation" ] disable_automatic_asset_installation = [ "zellij-utils/disable_automatic_asset_installation" ]
unstable = [ "zellij-client/unstable", "zellij-utils/unstable" ] unstable = [ "zellij-client/unstable", "zellij-utils/unstable" ]

View file

@ -56,3 +56,4 @@ insta = { version = "1.6.0", features = ["backtrace"] }
# - builtin plugins MUST be available from whatever is configured as `PLUGIN_DIR` # - builtin plugins MUST be available from whatever is configured as `PLUGIN_DIR`
disable_automatic_asset_installation = [] disable_automatic_asset_installation = []
unstable = [] unstable = []
asset_map = []

View file

@ -35,10 +35,10 @@ pub const FEATURES: &[&str] = &[
"disable_automatic_asset_installation", "disable_automatic_asset_installation",
]; ];
#[cfg(not(target_family = "wasm"))] #[cfg(all(not(target_family = "wasm"), feature = "asset_map"))]
pub use not_wasm::*; pub use not_wasm::*;
#[cfg(not(target_family = "wasm"))] #[cfg(all(not(target_family = "wasm"), feature = "asset_map"))]
mod not_wasm { mod not_wasm {
use lazy_static::lazy_static; use lazy_static::lazy_static;
use std::collections::HashMap; use std::collections::HashMap;

View file

@ -9,7 +9,7 @@ use serde::{Deserialize, Serialize};
use url::Url; use url::Url;
use super::layout::{RunPlugin, RunPluginLocation}; use super::layout::{RunPlugin, RunPluginLocation};
#[cfg(not(target_family = "wasm"))] #[cfg(all(not(target_family = "wasm"), feature = "asset_map"))]
use crate::consts::ASSET_MAP; use crate::consts::ASSET_MAP;
pub use crate::data::PluginTag; pub use crate::data::PluginTag;
use crate::errors::prelude::*; use crate::errors::prelude::*;
@ -129,7 +129,7 @@ impl PluginConfig {
for path in paths { for path in paths {
// Check if the plugin path matches an entry in the asset map. If so, load it directly // Check if the plugin path matches an entry in the asset map. If so, load it directly
// from memory, don't bother with the disk. // from memory, don't bother with the disk.
#[cfg(not(target_family = "wasm"))] #[cfg(all(not(target_family = "wasm"), feature = "asset_map"))]
if !cfg!(feature = "disable_automatic_asset_installation") && self.is_builtin() { if !cfg!(feature = "disable_automatic_asset_installation") && self.is_builtin() {
let asset_path = PathBuf::from("plugins").join(path); let asset_path = PathBuf::from("plugins").join(path);
if let Some(bytes) = ASSET_MAP.get(&asset_path) { if let Some(bytes) = ASSET_MAP.get(&asset_path) {
@ -160,7 +160,7 @@ impl PluginConfig {
} }
// Not reached if a plugin is found! // Not reached if a plugin is found!
#[cfg(not(target_family = "wasm"))] #[cfg(all(not(target_family = "wasm"), feature = "asset_map"))]
if self.is_builtin() { if self.is_builtin() {
// Layout requested a builtin plugin that wasn't found // Layout requested a builtin plugin that wasn't found
let plugin_path = self.path.with_extension("wasm"); let plugin_path = self.path.with_extension("wasm");

View file

@ -1,4 +1,4 @@
#[cfg(not(target_family = "wasm"))] #[cfg(all(not(target_family = "wasm"), feature = "asset_map"))]
use crate::consts::ASSET_MAP; use crate::consts::ASSET_MAP;
use crate::input::theme::Themes; use crate::input::theme::Themes;
use crate::{ use crate::{
@ -175,7 +175,7 @@ pub fn dump_specified_layout(layout: &str) -> std::io::Result<()> {
} }
} }
#[cfg(not(target_family = "wasm"))] #[cfg(all(not(target_family = "wasm"), feature = "asset_map"))]
pub fn dump_builtin_plugins(path: &PathBuf) -> Result<()> { pub fn dump_builtin_plugins(path: &PathBuf) -> Result<()> {
for (asset_path, bytes) in ASSET_MAP.iter() { for (asset_path, bytes) in ASSET_MAP.iter() {
let plugin_path = path.join(asset_path); let plugin_path = path.join(asset_path);
@ -205,7 +205,7 @@ pub fn dump_builtin_plugins(path: &PathBuf) -> Result<()> {
Ok(()) Ok(())
} }
#[cfg(target_family = "wasm")] #[cfg(any(target_family = "wasm", not(feature = "asset_map")))]
pub fn dump_builtin_plugins(_path: &PathBuf) -> Result<()> { pub fn dump_builtin_plugins(_path: &PathBuf) -> Result<()> {
Ok(()) Ok(())
} }