Skip to content

Commit

Permalink
HOTFIX: utils: Move plugins into new assets folder
Browse files Browse the repository at this point in the history
that is included in the utils to make builds pass.
  • Loading branch information
har7an committed Dec 9, 2022
1 parent 3623343 commit 0cbbe0b
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ description = "A terminal workspace with batteries included"
license = "MIT"
repository = "https://github.com/zellij-org/zellij"
homepage = "https://zellij.dev"
include = ["src/**/*", "assets/plugins/*", "assets/layouts/*", "assets/config/*", "LICENSE.md", "README.md", "!**/*_test.*", "!**/tests/**/*"]
include = ["src/**/*", "assets/layouts/*", "assets/config/*", "LICENSE.md", "README.md", "!**/*_test.*", "!**/tests/**/*"]
rust-version = "1.60"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
8 changes: 7 additions & 1 deletion Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ workspace = false
script_runner = "@duckscript"
script = '''
plugins = glob_array ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/default-plugins/*
out_dir = set ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/assets/plugins/
out_dir = set ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/zellij-utils/assets/plugins/
mkdir ${out_dir}
for plugin in ${plugins}
Expand All @@ -111,10 +111,16 @@ workspace = false
script_runner = "@duckscript"
script = '''
plugins = glob_array ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/default-plugins/*
out_dir = set ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/zellij-utils/assets/plugins/
mkdir ${out_dir}
for plugin in ${plugins}
cd ${plugin}
exec cargo build
plugin_name = basename ${plugin}
plugin_in = set ${CARGO_TARGET_DIR}/wasm32-wasi/debug/${plugin_name}.wasm
plugin_out = set ${out_dir}/${plugin_name}.wasm
cp ${plugin_in} ${plugin_out}
cd ..
end
'''
Expand Down
Binary file removed assets/plugins/compact-bar.wasm
Binary file not shown.
Binary file removed assets/plugins/status-bar.wasm
Binary file not shown.
Binary file removed assets/plugins/strider.wasm
Binary file not shown.
Binary file removed assets/plugins/tab-bar.wasm
Binary file not shown.
1 change: 1 addition & 0 deletions zellij-utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ authors = ["Kunal Mohan <kunalmohan99@gmail.com>"]
edition = "2021"
description = "A utility library for Zellij client and server"
license = "MIT"
include = ["src/**/*", "assets/"]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand Down
14 changes: 3 additions & 11 deletions zellij-utils/src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ pub const FEATURES: &[&str] = &[
"disable_automatic_asset_installation",
];

#[cfg(all(not(target_family = "wasm"), feature = "asset_map"))]
#[cfg(not(target_family = "wasm"))]
pub use not_wasm::*;

#[cfg(all(not(target_family = "wasm"), feature = "asset_map"))]
#[cfg(not(target_family = "wasm"))]
mod not_wasm {
use lazy_static::lazy_static;
use std::collections::HashMap;
Expand All @@ -49,17 +49,9 @@ mod not_wasm {
($assets:expr, $plugin:literal) => {
$assets.insert(
PathBuf::from("plugins").join($plugin),
#[cfg(debug_assertions)]
include_bytes!(concat!(
env!("CARGO_MANIFEST_DIR"),
"/../target/wasm32-wasi/debug/",
$plugin
))
.to_vec(),
#[cfg(not(debug_assertions))]
include_bytes!(concat!(
env!("CARGO_MANIFEST_DIR"),
"/../assets/plugins/",
"/assets/plugins/",
$plugin
))
.to_vec(),
Expand Down
6 changes: 3 additions & 3 deletions zellij-utils/src/input/plugins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use serde::{Deserialize, Serialize};
use url::Url;

use super::layout::{RunPlugin, RunPluginLocation};
#[cfg(all(not(target_family = "wasm"), feature = "asset_map"))]
#[cfg(not(target_family = "wasm"))]
use crate::consts::ASSET_MAP;
pub use crate::data::PluginTag;
use crate::errors::prelude::*;
Expand Down Expand Up @@ -129,7 +129,7 @@ impl PluginConfig {
for path in paths {
// 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.
#[cfg(all(not(target_family = "wasm"), feature = "asset_map"))]
#[cfg(not(target_family = "wasm"))]
if !cfg!(feature = "disable_automatic_asset_installation") && self.is_builtin() {
let asset_path = PathBuf::from("plugins").join(path);
if let Some(bytes) = ASSET_MAP.get(&asset_path) {
Expand Down Expand Up @@ -160,7 +160,7 @@ impl PluginConfig {
}

// Not reached if a plugin is found!
#[cfg(all(not(target_family = "wasm"), feature = "asset_map"))]
#[cfg(not(target_family = "wasm"))]
if self.is_builtin() {
// Layout requested a builtin plugin that wasn't found
let plugin_path = self.path.with_extension("wasm");
Expand Down
6 changes: 3 additions & 3 deletions zellij-utils/src/setup.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#[cfg(all(not(target_family = "wasm"), feature = "asset_map"))]
#[cfg(not(target_family = "wasm"))]
use crate::consts::ASSET_MAP;
use crate::input::theme::Themes;
use crate::{
Expand Down Expand Up @@ -175,7 +175,7 @@ pub fn dump_specified_layout(layout: &str) -> std::io::Result<()> {
}
}

#[cfg(all(not(target_family = "wasm"), feature = "asset_map"))]
#[cfg(not(target_family = "wasm"))]
pub fn dump_builtin_plugins(path: &PathBuf) -> Result<()> {
for (asset_path, bytes) in ASSET_MAP.iter() {
let plugin_path = path.join(asset_path);
Expand Down Expand Up @@ -205,7 +205,7 @@ pub fn dump_builtin_plugins(path: &PathBuf) -> Result<()> {
Ok(())
}

#[cfg(any(target_family = "wasm", not(feature = "asset_map")))]
#[cfg(target_family = "wasm")]
pub fn dump_builtin_plugins(_path: &PathBuf) -> Result<()> {
Ok(())
}
Expand Down

0 comments on commit 0cbbe0b

Please sign in to comment.