From bdfec65cfbd63012c3a7415abf620487009a1c8a Mon Sep 17 00:00:00 2001 From: Brooks J Rady Date: Tue, 16 Feb 2021 18:33:27 +0000 Subject: [PATCH] Switched to using a *much* simpler build-script --- build-all.sh | 19 +++++++ build.rs | 130 ++++++---------------------------------------- src/client/mod.rs | 2 +- src/common/ipc.rs | 2 +- src/common/mod.rs | 1 + 5 files changed, 39 insertions(+), 115 deletions(-) create mode 100755 build-all.sh diff --git a/build-all.sh b/build-all.sh new file mode 100755 index 00000000..41f90870 --- /dev/null +++ b/build-all.sh @@ -0,0 +1,19 @@ +#!/bin/sh + +# This is temporary while https://github.com/rust-lang/cargo/issues/7004 is open + +echo "Building zellij-tile (1/5)..." +cd zellij-tile +cargo build --release +echo "Building status-bar (2/5)..." +cd ../default-tiles/status-bar +cargo build --release +echo "Building strider (3/5)..." +cd ../strider +cargo build --release +echo "Optimising WASM executables (4/5)..." +cd ../.. +wasm-opt -O target/wasm32-wasi/release/status-bar.wasm -o assets/plugins/status-bar.wasm +wasm-opt -O target/wasm32-wasi/release/strider.wasm -o assets/plugins/strider.wasm +echo "Building zellij (5/5)..." +cargo build $@ \ No newline at end of file diff --git a/build.rs b/build.rs index 85e997a6..7d78a7f2 100644 --- a/build.rs +++ b/build.rs @@ -1,7 +1,6 @@ use directories_next::ProjectDirs; -use std::{env::*, fs, path::Path, process::Command}; +use std::fs; use structopt::clap::Shell; -use toml::Value; use walkdir::WalkDir; include!("src/cli.rs"); @@ -9,117 +8,6 @@ include!("src/cli.rs"); const BIN_NAME: &str = "zellij"; fn main() { - // Build Sub-Projects (Temporary?) - for entry in WalkDir::new(".") { - let entry = entry.unwrap(); - let ext = entry.path().extension(); - if ext.is_some() && ext.unwrap() == "rs" { - println!("cargo:rerun-if-changed={}", entry.path().to_string_lossy()); - } - } - - let manifest_dir = Path::new(env!("CARGO_MANIFEST_DIR")); - let manifest: Value = - toml::from_str(&fs::read_to_string(manifest_dir.join("Cargo.toml")).unwrap()).unwrap(); - let members = manifest - .get("workspace") - .unwrap() - .get("members") - .unwrap() - .as_array() - .unwrap(); - - let release = if var("PROFILE").unwrap() == "release" { - "--release" - } else { - "" - }; - let starting_dir = current_dir().unwrap(); - let alt_target = manifest_dir.join("target/tiles"); - for project in members { - let path = manifest_dir.join(project.as_str().unwrap()); - // Should be able to change directory to continue build process - set_current_dir(&path).unwrap(); - - // FIXME: This is soul-crushingly terrible, but I can't keep the values alive long enough - if var("PROFILE").unwrap() == "release" { - Command::new("cargo".to_string()) - .arg("build") - .arg("--target-dir") - .arg(&alt_target.as_os_str()) - .arg("--release") - .status() - .unwrap(); - } else { - Command::new("cargo") - .arg("build") - .arg("--target-dir") - .arg(&alt_target.as_os_str()) - .status() - .unwrap(); - } - } - // Should be able to change directory to continue build process - set_current_dir(&starting_dir).unwrap(); - - if var("PROFILE").unwrap() == "release" { - // FIXME: Deduplicate this with the initial walk all .rs pattern - for entry in fs::read_dir(alt_target.join("wasm32-wasi/release/")).unwrap() { - let entry = entry.unwrap().path(); - let ext = entry.extension(); - if ext.is_some() && ext.unwrap() == "wasm" { - dbg!(&entry); - Command::new("wasm-opt") - .arg("-O") - .arg(entry.as_os_str()) - .arg("-o") - .arg(format!( - "assets/plugins/{}", - entry.file_name().unwrap().to_string_lossy() - )) - .status() - .unwrap_or_else(|_| { - Command::new("cp") - .arg(entry.as_os_str()) - .arg(format!( - "assets/plugins/{}", - entry.file_name().unwrap().to_string_lossy() - )) - .status() - .unwrap() - }); - } - } - } else { - // FIXME: Deduplicate this with the initial walk all .rs pattern - for entry in fs::read_dir(alt_target.join("wasm32-wasi/debug/")).unwrap() { - let entry = entry.unwrap().path(); - let ext = entry.extension(); - if ext.is_some() && ext.unwrap() == "wasm" { - dbg!(&entry); - Command::new("wasm-opt") - .arg("-O") - .arg(entry.as_os_str()) - .arg("-o") - .arg(format!( - "assets/plugins/{}", - entry.file_name().unwrap().to_string_lossy() - )) - .status() - .unwrap_or_else(|_| { - Command::new("cp") - .arg(entry.as_os_str()) - .arg(format!( - "assets/plugins/{}", - entry.file_name().unwrap().to_string_lossy() - )) - .status() - .unwrap() - }); - } - } - } - // Generate Shell Completions let mut clap_app = CliArgs::clap(); println!("cargo:rerun-if-changed=src/cli.rs"); @@ -134,4 +22,20 @@ fn main() { clap_app.gen_completions(BIN_NAME, Shell::Bash, &out_dir); clap_app.gen_completions(BIN_NAME, Shell::Zsh, &out_dir); clap_app.gen_completions(BIN_NAME, Shell::Fish, &out_dir); + + // Clear Default Plugins and Layouts + for entry in WalkDir::new("assets/") { + let entry = entry.unwrap(); + let ext = entry.path().extension(); + if ext.is_some() && ext.unwrap() == "rs" { + println!("cargo:rerun-if-changed={}", entry.path().to_string_lossy()); + } + } + + 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/strider.wasm"))); + drop(fs::remove_file(data_dir.join("layouts/default.yaml"))); + drop(fs::remove_file(data_dir.join("layouts/strider.yaml"))); } diff --git a/src/client/mod.rs b/src/client/mod.rs index c8276253..93f35e06 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -3,4 +3,4 @@ pub mod layout; pub mod panes; pub mod tab; -pub fn start_client() {} +pub fn _start_client() {} diff --git a/src/common/ipc.rs b/src/common/ipc.rs index 425d81d6..3fa8c6b2 100644 --- a/src/common/ipc.rs +++ b/src/common/ipc.rs @@ -38,7 +38,7 @@ pub enum ClientToServerMsg { // Types of messages sent from the server to the client // @@@ Implement Serialize and Deserialize for this... -pub enum ServerToClientMsg { +pub enum _ServerToClientMsg { // Info about a particular session SessionInfo(Session), // A list of sessions diff --git a/src/common/mod.rs b/src/common/mod.rs index a256e3ef..9f942656 100644 --- a/src/common/mod.rs +++ b/src/common/mod.rs @@ -417,6 +417,7 @@ pub fn start(mut os_input: Box, opts: CliArgs) { let project_dirs = ProjectDirs::from("org", "Zellij Contributors", "Zellij").unwrap(); let plugin_dir = project_dirs.data_dir().join("plugins/"); + // FIXME: This really shouldn't need to exist anymore, let's get rid of it! let root_plugin_dir = Path::new(ZELLIJ_ROOT_PLUGIN_DIR); let wasm_bytes = fs::read(&path) .or_else(|_| fs::read(&path.with_extension("wasm")))