aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrooks Rady <b.j.rady@gmail.com>2021-02-17 12:24:13 +0000
committerGitHub <noreply@github.com>2021-02-17 12:24:13 +0000
commit8be470fbc0f39bb493678e1cff9b71950ff6e60b (patch)
treedf0cb7cac90380aef4f54184caf1192151fb089f
parentfeat(input): new keybindings and persistent mode as default (#181) (diff)
parentFix a silly bug in the build! (diff)
downloadsl0ppij-8be470fbc0f39bb493678e1cff9b71950ff6e60b.tar.gz
sl0ppij-8be470fbc0f39bb493678e1cff9b71950ff6e60b.tar.xz
sl0ppij-8be470fbc0f39bb493678e1cff9b71950ff6e60b.zip
infra(simplify build and install)
Merge pull request #186 from zellij-org/simplify-build-and-install
-rw-r--r--CONTRIBUTING.md10
-rw-r--r--Cargo.toml2
-rw-r--r--assets/plugins/status-bar.wasmbin4544837 -> 436470 bytes
-rw-r--r--assets/plugins/strider.wasmbin6006435 -> 527289 bytes
-rwxr-xr-xbuild-all.sh19
-rw-r--r--build.rs137
-rw-r--r--src/client/mod.rs2
-rw-r--r--src/common/install.rs12
-rw-r--r--src/common/ipc.rs2
-rw-r--r--src/common/mod.rs4
-rw-r--r--src/main.rs21
-rw-r--r--src/tests/integration/snapshots/zellij__tests__integration__layouts__accepts_basic_layout-3.snap4
12 files changed, 81 insertions, 132 deletions
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 7aa359f3..a58d52f9 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -13,6 +13,16 @@ of contributions, and don't want a wall of rules to get in the way of that.
Before contributing please read our [Code of Conduct](CODE_OF_CONDUCT.md) which
all contributors are expected to adhere to.
+## Building
+To work around a [Cargo bug][https://github.com/rust-lang/cargo/issues/7004], you'll need to use the included `build-all.sh` script.
+
+```sh
+# An unoptimized debug build
+./build-all.sh
+# A fully optimized release build
+./build-all.sh --release
+```
+
## Looking for something to work on?
If you are new contributor to `Zellij` going through [beginners][good-first-issue]
diff --git a/Cargo.toml b/Cargo.toml
index 1b658e60..f237d455 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -3,6 +3,8 @@ name = "zellij"
version = "0.1.0"
authors = ["Aram Drevekenin <aram@poor.dev>"]
edition = "2018"
+description = "Terminal workspace (WIP)"
+license = "MIT"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
diff --git a/assets/plugins/status-bar.wasm b/assets/plugins/status-bar.wasm
index f9c32980..1b82a5c0 100644
--- a/assets/plugins/status-bar.wasm
+++ b/assets/plugins/status-bar.wasm
Binary files differ
diff --git a/assets/plugins/strider.wasm b/assets/plugins/strider.wasm
index d82b57ca..46f272eb 100644
--- a/assets/plugins/strider.wasm
+++ b/assets/plugins/strider.wasm
Binary files differ
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 2bea2727..05cbe8d4 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");
@@ -135,19 +23,16 @@ fn main() {
clap_app.gen_completions(BIN_NAME, Shell::Zsh, &out_dir);
clap_app.gen_completions(BIN_NAME, Shell::Fish, &out_dir);
- // Install Default Plugins and Layouts
- let assets = vec![
- "plugins/status-bar.wasm",
- "plugins/strider.wasm",
- "layouts/default.yaml",
- "layouts/strider.yaml",
- ];
+ // Clear Default Plugins and Layouts
+ for entry in WalkDir::new("assets/") {
+ let entry = entry.unwrap();
+ 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();
- fs::create_dir_all(data_dir.join("plugins")).unwrap();
- fs::create_dir_all(data_dir.join("layouts")).unwrap();
- for asset in assets {
- fs::copy(Path::new("assets/").join(asset), data_dir.join(asset))
- .expect("Failed to copy asset files");
- }
+ 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/install.rs b/src/common/install.rs
new file mode 100644
index 00000000..4e3f5c5d
--- /dev/null
+++ b/src/common/install.rs
@@ -0,0 +1,12 @@
+#[macro_export]
+macro_rules! asset_map {
+ ($($path:literal),+) => {
+ {
+ let mut assets = std::collections::HashMap::new();
+ $(
+ assets.insert($path, include_bytes!(concat!("../assets/", $path)).to_vec());
+ )+
+ assets
+ }
+ }
+}
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 00ee64fd..d1133e27 100644
--- a/src/common/mod.rs
+++ b/src/common/mod.rs
@@ -1,6 +1,7 @@
pub mod command_is_executing;
pub mod errors;
pub mod input;
+pub mod install;
pub mod ipc;
pub mod os_input_output;
pub mod pty_bus;
@@ -416,6 +417,7 @@ pub fn start(mut os_input: Box<dyn OsApi>, 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")))
@@ -646,7 +648,7 @@ pub fn start(mut os_input: Box<dyn OsApi>, opts: CliArgs) {
let restore_snapshot = "\u{1b}[?1049l";
let goto_start_of_last_line = format!("\u{1b}[{};{}H", full_screen_ws.rows, 1);
let goodbye_message = format!(
- "{}\n{}{}{}Bye from Zellij!",
+ "{}\n{}{}{}Bye from Zellij!\n",
goto_start_of_last_line, restore_snapshot, reset_style, show_cursor
);
diff --git a/src/main.rs b/src/main.rs
index 50c0b6f3..27036e3d 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -11,9 +11,10 @@ use common::{
command_is_executing, errors, os_input_output, pty_bus, screen, start, utils, wasm_vm,
ApiCommand,
};
+use directories_next::ProjectDirs;
-use std::io::Write;
use std::os::unix::net::UnixStream;
+use std::{fs, io::Write};
use structopt::StructOpt;
@@ -27,6 +28,24 @@ use crate::utils::{
};
pub fn main() {
+ // First run installation of default plugins & layouts
+ let project_dirs = ProjectDirs::from("org", "Zellij Contributors", "Zellij").unwrap();
+ let data_dir = project_dirs.data_dir();
+ let assets = asset_map! {
+ "plugins/status-bar.wasm",
+ "plugins/strider.wasm",
+ "layouts/default.yaml",
+ "layouts/strider.yaml"
+ };
+
+ for (path, bytes) in assets {
+ let path = data_dir.join(path);
+ fs::create_dir_all(path.parent().unwrap()).unwrap();
+ if !path.exists() {
+ fs::write(path, bytes).expect("Failed to install default assets!");
+ }
+ }
+
let opts = CliArgs::from_args();
if let Some(split_dir) = opts.split {
match split_dir {
diff --git a/src/tests/integration/snapshots/zellij__tests__integration__layouts__accepts_basic_layout-3.snap b/src/tests/integration/snapshots/zellij__tests__integration__layouts__accepts_basic_layout-3.snap
index 0941f965..d506a47a 100644
--- a/src/tests/integration/snapshots/zellij__tests__integration__layouts__accepts_basic_layout-3.snap
+++ b/src/tests/integration/snapshots/zellij__tests__integration__layouts__accepts_basic_layout-3.snap
@@ -3,8 +3,8 @@ source: src/tests/integration/layouts.rs
expression: last_snapshot
---
-Bye from Zellij!█
-
+Bye from Zellij!
+ █