2021-05-27 20:05:45 +00:00
|
|
|
[config]
|
|
|
|
default_to_workspace = false
|
|
|
|
|
2021-07-09 22:18:04 +00:00
|
|
|
[env]
|
|
|
|
DEBUG = true
|
|
|
|
RELEASE = false
|
|
|
|
NO_X11 = false
|
|
|
|
NO_MODULO = false
|
|
|
|
EXEC_PATH = "target/debug/espanso"
|
|
|
|
# TODO: flag to enable/disable modulo support
|
|
|
|
|
|
|
|
[env.release]
|
|
|
|
DEBUG = false
|
|
|
|
RELEASE = true
|
|
|
|
EXEC_PATH = "target/release/espanso"
|
|
|
|
|
|
|
|
# Build variants
|
|
|
|
|
|
|
|
# This one was written in Rust instead of bash because it has to run on Windows as well
|
|
|
|
[tasks.build-binary]
|
|
|
|
script_runner = "@rust"
|
|
|
|
script = '''
|
|
|
|
//! ```cargo
|
|
|
|
//! [dependencies]
|
|
|
|
//! envmnt = "*"
|
|
|
|
//! ```
|
|
|
|
|
|
|
|
use std::process::Command;
|
|
|
|
|
|
|
|
#[derive(Debug, PartialEq)]
|
|
|
|
enum Profile {
|
|
|
|
Debug,
|
|
|
|
Release,
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let profile = if envmnt::get_or_panic("RELEASE") == "true" {
|
|
|
|
Profile::Release
|
|
|
|
} else {
|
|
|
|
Profile::Debug
|
|
|
|
};
|
|
|
|
|
|
|
|
println!("Using profile: {:?}", profile);
|
|
|
|
|
|
|
|
let wayland = envmnt::get_or("NO_X11", "false") == "true";
|
|
|
|
if wayland {
|
|
|
|
println!("Using Wayland feature");
|
|
|
|
}
|
|
|
|
|
|
|
|
let avoid_modulo = envmnt::get_or("NO_MODULO", "false") == "true";
|
|
|
|
if avoid_modulo {
|
|
|
|
println!("Skipping modulo feature");
|
|
|
|
}
|
|
|
|
|
|
|
|
let mut args = Vec::new();
|
|
|
|
args.push("build");
|
|
|
|
|
|
|
|
if profile == Profile::Release {
|
|
|
|
args.push("--release");
|
|
|
|
}
|
|
|
|
|
|
|
|
let mut features = Vec::new();
|
|
|
|
if wayland {
|
|
|
|
features.push("wayland");
|
|
|
|
}
|
|
|
|
if !avoid_modulo {
|
|
|
|
features.push("modulo");
|
|
|
|
}
|
|
|
|
|
|
|
|
let features_flag = features.join(" ");
|
|
|
|
|
|
|
|
args.push("-p");
|
|
|
|
args.push("espanso");
|
2021-07-10 08:28:32 +00:00
|
|
|
args.push("--no-default-features");
|
2021-07-09 22:18:04 +00:00
|
|
|
args.push("--features");
|
|
|
|
args.push(&features_flag);
|
|
|
|
|
|
|
|
println!("Calling with args: {:?}", args);
|
|
|
|
|
|
|
|
let mut cmd = Command::new("cargo");
|
|
|
|
cmd.args(&args);
|
|
|
|
|
|
|
|
// Remove cargo/rust-specific env variables, as otherwise they mess up the
|
|
|
|
// nested cargo build call.
|
|
|
|
let all_vars = envmnt::vars();
|
|
|
|
for (key, _) in all_vars {
|
|
|
|
if key.starts_with("CARGO") || key.starts_with("RUST") {
|
|
|
|
//println!("Removing {}", key);
|
|
|
|
cmd.env_remove(key);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
let mut handle = cmd.spawn().expect("cargo build failed");
|
|
|
|
handle.wait();
|
|
|
|
}
|
|
|
|
'''
|
2021-06-05 17:10:31 +00:00
|
|
|
|
2021-07-10 08:45:39 +00:00
|
|
|
[tasks.run-binary]
|
|
|
|
command = "${EXEC_PATH}"
|
|
|
|
args = ["${@}"]
|
|
|
|
dependencies = ["build-binary"]
|
|
|
|
|
2021-06-05 17:10:31 +00:00
|
|
|
[tasks.create-bundle]
|
|
|
|
script = '''
|
|
|
|
TARGET_DIR=target/mac/Espanso.app
|
|
|
|
|
2021-06-05 20:26:08 +00:00
|
|
|
rm -Rf $TARGET_DIR
|
|
|
|
|
2021-06-05 17:10:31 +00:00
|
|
|
VERSION=$(cat espanso/Cargo.toml | grep version | head -1 | awk -F '"' '{ print $2 }')
|
|
|
|
|
|
|
|
mkdir -p $TARGET_DIR/Contents
|
|
|
|
mkdir -p $TARGET_DIR/Contents/MacOS
|
|
|
|
mkdir -p $TARGET_DIR/Contents/Resources
|
|
|
|
|
|
|
|
sed -e "s/VERSION/$VERSION/" espanso/src/res/macos/Info.plist > $TARGET_DIR/Contents/Info.plist
|
|
|
|
|
|
|
|
/bin/echo "APPL????" > $TARGET_DIR/Contents/PkgInfo
|
|
|
|
|
|
|
|
cp -f espanso/src/res/macos/icon.icns $TARGET_DIR/Contents/Resources/icon.icns
|
2021-07-09 22:18:04 +00:00
|
|
|
cp -f $EXEC_PATH $TARGET_DIR/Contents/MacOS/espanso
|
2021-06-05 17:10:31 +00:00
|
|
|
'''
|
2021-07-09 22:18:04 +00:00
|
|
|
dependencies=["build-binary"]
|
2021-06-05 17:10:31 +00:00
|
|
|
|
|
|
|
[tasks.run-debug-bundle]
|
|
|
|
command="target/mac/Espanso.app/Contents/MacOS/espanso"
|
|
|
|
args=["${@}"]
|
|
|
|
dependencies=["create-bundle"]
|
|
|
|
|
2021-07-09 22:18:04 +00:00
|
|
|
[tasks.create-app-image]
|
|
|
|
script = '''
|
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -e
|
|
|
|
TOOL_DIR=$(pwd)/target/linux/linuxdeploy
|
|
|
|
TARGET_DIR=$(pwd)/target/linux/AppImage
|
|
|
|
BUILD_DIR=$TARGET_DIR/build
|
|
|
|
OUTPUT_DIR=$TARGET_DIR/out
|
|
|
|
BASE_DIR=$(pwd)
|
|
|
|
|
|
|
|
mkdir -p $TOOL_DIR
|
|
|
|
|
|
|
|
if ls $TOOL_DIR/*.AppImage 1> /dev/null 2>&1; then
|
|
|
|
echo "Skipping download of linuxdeploy"
|
|
|
|
else
|
|
|
|
echo "Downloading linuxdeploy tool"
|
|
|
|
wget https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage -P "$TOOL_DIR"
|
|
|
|
chmod +x $TOOL_DIR/linuxdeploy*.AppImage
|
|
|
|
fi
|
|
|
|
|
|
|
|
rm -Rf "$TARGET_DIR"
|
|
|
|
mkdir -p $OUTPUT_DIR
|
|
|
|
mkdir -p $BUILD_DIR
|
|
|
|
|
|
|
|
echo Building AppImage into $OUTPUT_DIR
|
|
|
|
pushd $OUTPUT_DIR
|
|
|
|
$TOOL_DIR/linuxdeploy*.AppImage --appimage-extract-and-run -e "$BASE_DIR/$EXEC_PATH" -d "$BASE_DIR/espanso/src/res/linux/espanso.desktop" -i "$BASE_DIR/espanso/src/res/linux/icon.png" --appdir $BUILD_DIR --output appimage
|
|
|
|
chmod +x ./Espanso*.AppImage
|
|
|
|
popd
|
|
|
|
'''
|
|
|
|
dependencies=["build-binary"]
|
|
|
|
|
|
|
|
[tasks.run-app-image]
|
|
|
|
args=["${@}"]
|
|
|
|
script='''
|
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -e
|
|
|
|
echo Launching AppImage with args: "$@"
|
|
|
|
./target/linux/AppImage/out/Espanso-*.AppImage "$@"
|
|
|
|
'''
|
|
|
|
dependencies=["create-app-image"]
|
|
|
|
|
|
|
|
# Test runs
|
|
|
|
|
2021-05-27 20:05:45 +00:00
|
|
|
[tasks.test]
|
|
|
|
command = "cargo"
|
2021-06-25 16:57:17 +00:00
|
|
|
args = ["test", "--workspace", "--exclude", "espanso-modulo", "--exclude", "espanso-ipc", "--no-default-features"]
|
2021-06-02 19:52:08 +00:00
|
|
|
|
|
|
|
[tasks.test-output]
|
|
|
|
command = "cargo"
|
2021-06-25 16:57:17 +00:00
|
|
|
args = ["test", "--workspace", "--exclude", "espanso-modulo", "--exclude", "espanso-ipc", "--no-default-features", "--", "--nocapture"]
|