2021-03-26 19:01:22 +03:00
|
|
|
# Global Settings
|
|
|
|
[env]
|
|
|
|
CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = true
|
|
|
|
SKIP_TEST = false
|
|
|
|
|
2021-04-13 20:14:13 +03:00
|
|
|
# Add clippy to the default flow
|
|
|
|
[tasks.dev-test-flow]
|
|
|
|
dependencies = [
|
|
|
|
"format-flow",
|
|
|
|
"format-toml-conditioned-flow",
|
|
|
|
"pre-build",
|
|
|
|
"build",
|
|
|
|
"post-build",
|
|
|
|
"test-flow",
|
|
|
|
"clippy",
|
|
|
|
]
|
|
|
|
|
2021-03-26 19:01:22 +03:00
|
|
|
# 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 }
|
|
|
|
|
2021-04-01 14:18:05 +03:00
|
|
|
# Running Zellij using patched layouts
|
2021-03-30 14:49:42 +03:00
|
|
|
[tasks.run]
|
|
|
|
workspace = false
|
2021-04-01 14:18:05 +03:00
|
|
|
dependencies = ["build-workspace", "patch-layouts"]
|
|
|
|
run_task = "launch"
|
|
|
|
|
|
|
|
[tasks.build-workspace]
|
|
|
|
run_task = { name = "build", fork = true }
|
2021-03-30 14:49:42 +03:00
|
|
|
|
|
|
|
[tasks.patch-layouts]
|
|
|
|
script_runner = "@rust"
|
|
|
|
script = '''
|
|
|
|
//! ```cargo
|
|
|
|
//! [dependencies]
|
|
|
|
//! yaml-rust = "0.4"
|
|
|
|
//! ```
|
2021-04-01 14:18:05 +03:00
|
|
|
use std::{env, error::Error, fs, path::Path};
|
|
|
|
use yaml_rust::{Yaml, YamlEmitter, YamlLoader};
|
2021-03-30 14:49:42 +03:00
|
|
|
|
|
|
|
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)? {
|
2021-04-01 14:18:05 +03:00
|
|
|
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)?;
|
2021-03-30 14:49:42 +03:00
|
|
|
}
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
2021-04-01 14:18:05 +03:00
|
|
|
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)
|
|
|
|
}
|
|
|
|
'''
|
2021-03-30 14:49:42 +03:00
|
|
|
|
2021-04-13 17:35:37 +03:00
|
|
|
[tasks.pre-launch]
|
|
|
|
script_runner = "@duckscript"
|
|
|
|
script = '''
|
|
|
|
if is_empty ${CARGO_MAKE_TASK_ARGS}
|
|
|
|
set_env CARGO_MAKE_TASK_ARGS default
|
|
|
|
end
|
|
|
|
'''
|
|
|
|
|
2021-04-01 14:18:05 +03:00
|
|
|
[tasks.launch]
|
2021-04-13 17:35:37 +03:00
|
|
|
dependencies = ["pre-launch"]
|
2021-04-01 14:18:05 +03:00
|
|
|
command = "cargo"
|
2021-04-13 17:35:37 +03:00
|
|
|
args = ["run", "--", "-l", "${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/target/${CARGO_MAKE_TASK_ARGS}.yaml"]
|
2021-03-30 14:49:42 +03:00
|
|
|
|
2021-04-13 17:35:37 +03:00
|
|
|
# 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}
|
|
|
|
'''
|
2021-03-26 19:01:22 +03:00
|
|
|
|
2021-04-13 17:35:37 +03:00
|
|
|
[tasks.build-tiles-release]
|
|
|
|
env = { "CARGO_MAKE_WORKSPACE_SKIP_MEMBERS" = ["."] }
|
|
|
|
run_task = { name = "build-release", fork = true }
|
2021-03-26 19:01:22 +03:00
|
|
|
|
2021-04-13 17:35:37 +03:00
|
|
|
[tasks.wasm-opt-tiles]
|
|
|
|
script_runner = "@duckscript"
|
|
|
|
script = '''
|
|
|
|
tiles = glob_array ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/target/wasm32-wasi/release/*.wasm
|
2021-03-26 19:01:22 +03:00
|
|
|
|
2021-04-13 17:35:37 +03:00
|
|
|
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
|
|
|
|
'''
|
2021-03-26 19:01:22 +03:00
|
|
|
|
2021-04-13 17:35:37 +03:00
|
|
|
# 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"]
|