mirror of
https://github.com/zellij-org/zellij.git
synced 2024-11-22 22:26:54 +03:00
155 lines
4.5 KiB
TOML
155 lines
4.5 KiB
TOML
# Global Settings
|
|
[env]
|
|
CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = true
|
|
SKIP_TEST = false
|
|
|
|
# Patching the default flows to skip testing of wasm32-wasi targets
|
|
[tasks.pre-test]
|
|
condition = { env = { "CARGO_MAKE_CRATE_TARGET_TRIPLE" = "wasm32-wasi" } }
|
|
env = { "SKIP_TEST" = true }
|
|
|
|
[tasks.test]
|
|
condition = { env_false = ["SKIP_TEST"] }
|
|
dependencies = ["pre-test"]
|
|
|
|
[tasks.post-test]
|
|
env = { "SKIP_TEST" = false }
|
|
|
|
# Running Zellij using patched layouts
|
|
[tasks.run]
|
|
workspace = false
|
|
dependencies = ["build-workspace", "patch-layouts"]
|
|
run_task = "launch"
|
|
|
|
[tasks.build-workspace]
|
|
run_task = { name = "build", fork = true }
|
|
|
|
[tasks.patch-layouts]
|
|
script_runner = "@rust"
|
|
script = '''
|
|
//! ```cargo
|
|
//! [dependencies]
|
|
//! yaml-rust = "0.4"
|
|
//! ```
|
|
use std::{env, error::Error, fs, path::Path};
|
|
use yaml_rust::{Yaml, YamlEmitter, YamlLoader};
|
|
|
|
fn main() -> Result<(), Box<dyn Error>> {
|
|
let root = env::var("CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY")?;
|
|
let layout_path = Path::new(&root).join("assets/layouts");
|
|
for layout in fs::read_dir(layout_path)? {
|
|
let layout = layout?.path();
|
|
let yaml = fs::read_to_string(&layout)?;
|
|
let yaml = YamlLoader::load_from_str(&yaml)?.remove(0);
|
|
let yaml = patch_plugins(&root, yaml);
|
|
let new_layout = Path::new(&root)
|
|
.join("target")
|
|
.join(layout.file_name().unwrap());
|
|
let mut new_yaml = String::new();
|
|
let mut emitter = YamlEmitter::new(&mut new_yaml);
|
|
emitter.dump(&yaml)?;
|
|
fs::write(new_layout, new_yaml)?;
|
|
}
|
|
Ok(())
|
|
}
|
|
|
|
fn patch_plugins(root: &str, part: Yaml) -> Yaml {
|
|
let mut map = part.into_hash().unwrap();
|
|
if let Some(plugin) = map.get_mut(&Yaml::from_str("plugin")) {
|
|
let new_plugin = Path::new(root)
|
|
.join("target/wasm32-wasi/debug")
|
|
.join(plugin.as_str().unwrap());
|
|
*plugin = Yaml::String(new_plugin.to_string_lossy().into_owned());
|
|
}
|
|
if let Some(parts) = map.get_mut(&Yaml::from_str("parts")) {
|
|
let new_parts = parts
|
|
.clone()
|
|
.into_iter()
|
|
.map(|p| patch_plugins(root, p))
|
|
.collect();
|
|
*parts = Yaml::Array(new_parts);
|
|
}
|
|
Yaml::Hash(map)
|
|
}
|
|
'''
|
|
|
|
[tasks.pre-launch]
|
|
script_runner = "@duckscript"
|
|
script = '''
|
|
if is_empty ${CARGO_MAKE_TASK_ARGS}
|
|
set_env CARGO_MAKE_TASK_ARGS default
|
|
end
|
|
'''
|
|
|
|
[tasks.launch]
|
|
dependencies = ["pre-launch"]
|
|
command = "cargo"
|
|
args = ["run", "--", "-l", "${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/target/${CARGO_MAKE_TASK_ARGS}.yaml"]
|
|
|
|
# Simple clippy tweak
|
|
[tasks.clippy]
|
|
args = ["clippy", "--", "@@split(CARGO_MAKE_TASK_ARGS,;)"]
|
|
|
|
# Release building and installing Zellij
|
|
[tasks.install]
|
|
workspace = false
|
|
dependencies = ["build-tiles-release", "wasm-opt-tiles", "build-release", "clear-data-directory"]
|
|
script_runner = "@duckscript"
|
|
script = '''
|
|
cp ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/target/release/${CARGO_MAKE_CRATE_NAME} ${CARGO_MAKE_TASK_ARGS}
|
|
'''
|
|
|
|
[tasks.build-tiles-release]
|
|
env = { "CARGO_MAKE_WORKSPACE_SKIP_MEMBERS" = ["."] }
|
|
run_task = { name = "build-release", fork = true }
|
|
|
|
[tasks.wasm-opt-tiles]
|
|
script_runner = "@duckscript"
|
|
script = '''
|
|
tiles = glob_array ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/target/wasm32-wasi/release/*.wasm
|
|
|
|
for tile in ${tiles}
|
|
tile_name = basename ${tile}
|
|
tile_out = set ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/assets/plugins/${tile_name}
|
|
if is_path_newer ${tile} ${tile_out}
|
|
exec wasm-opt -O ${tile} -o ${tile_out}
|
|
end
|
|
end
|
|
'''
|
|
|
|
# FIXME: Maybe this should be more generic? Or just blow away the whole directory?
|
|
[tasks.clear-data-directory]
|
|
script_runner = "@rust"
|
|
script = '''
|
|
//! ```cargo
|
|
//! [dependencies]
|
|
//! directories-next = "2.0"
|
|
//! ```
|
|
use directories_next::ProjectDirs;
|
|
use std::fs;
|
|
|
|
fn main() {
|
|
let project_dirs = ProjectDirs::from("org", "Zellij Contributors", "Zellij").unwrap();
|
|
let data_dir = project_dirs.data_dir();
|
|
drop(fs::remove_file(data_dir.join("plugins/status-bar.wasm")));
|
|
drop(fs::remove_file(data_dir.join("plugins/tab-bar.wasm")));
|
|
drop(fs::remove_file(data_dir.join("plugins/strider.wasm")));
|
|
drop(fs::remove_file(data_dir.join("layouts/default.yaml")));
|
|
drop(fs::remove_file(data_dir.join("layouts/strider.yaml")));
|
|
}
|
|
'''
|
|
|
|
# Publishing Zellij
|
|
[tasks.publish]
|
|
clear = true
|
|
workspace = false
|
|
dependencies = ["build-tiles-release", "wasm-opt-tiles", "build-release", "publish-zellij-tile", "publish-zellij"]
|
|
|
|
[tasks.publish-zellij-tile]
|
|
cwd = "zellij-tile"
|
|
command = "cargo"
|
|
args = ["publish"]
|
|
|
|
[tasks.publish-zellij]
|
|
command = "cargo"
|
|
args = ["publish"] |