87 lines
No EOL
2.6 KiB
TOML
87 lines
No EOL
2.6 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.launch]
|
|
command = "cargo"
|
|
args = ["run", "--", "-l", "${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/target/default.yaml"]
|
|
|
|
|
|
# Running Zellij (need to add a run-release option and multi-layout support!)
|
|
|
|
# Have a publish flow that triggers wasm-opt and updates the assets
|
|
|
|
# Have an install flow that deletes the zellij data directory (using a rust script)
|
|
|
|
# Add a clippy flow that uses the nightly options |