feat(misc): add make task to build universal mac bundle

This commit is contained in:
Federico Terzi 2021-08-14 10:08:25 +02:00
parent c8887fdee0
commit de8879e03c
4 changed files with 39 additions and 1 deletions

View File

@ -7,7 +7,7 @@ RELEASE = false
NO_X11 = false NO_X11 = false
NO_MODULO = false NO_MODULO = false
EXEC_PATH = "target/debug/espanso" EXEC_PATH = "target/debug/espanso"
BUILD_ARCH = "x86_64" # TODO: do something with this BUILD_ARCH = "current"
[env.release] [env.release]
DEBUG = false DEBUG = false
@ -48,10 +48,31 @@ dependencies = ["build-windows-portable", "build-windows-installer"]
# macOS # macOS
[tasks.build-macos-arm-binary]
env = { "BUILD_ARCH" = "aarch64-apple-darwin" }
run_task = [
{ name = "build-binary" }
]
[tasks.build-macos-x86-binary]
env = { "BUILD_ARCH" = "x86_64-apple-darwin" }
run_task = [
{ name = "build-binary" }
]
[tasks.build-universal-binary]
script = { file = "scripts/join_universal_binary.sh"}
dependencies=["build-macos-arm-binary", "build-macos-x86-binary"]
[tasks.create-bundle] [tasks.create-bundle]
script = { file = "scripts/create_bundle.sh" } script = { file = "scripts/create_bundle.sh" }
dependencies=["build-binary"] dependencies=["build-binary"]
[tasks.create-universal-bundle]
env = { "EXEC_PATH" = "target/universal/espanso" }
script = { file = "scripts/create_bundle.sh" }
dependencies=["build-universal-binary"]
[tasks.run-bundle] [tasks.run-bundle]
command="target/mac/Espanso.app/Contents/MacOS/espanso" command="target/mac/Espanso.app/Contents/MacOS/espanso"
args=["${@}"] args=["${@}"]

View File

@ -37,6 +37,12 @@ fn main() {
args.push("--release"); args.push("--release");
} }
let override_target_arch = envmnt::get_or("BUILD_ARCH", "current");
if override_target_arch != "current" {
args.push("--target");
args.push(&override_target_arch);
}
args.push("--manifest-path"); args.push("--manifest-path");
args.push("espanso/Cargo.toml"); args.push("espanso/Cargo.toml");

View File

@ -1,3 +1,5 @@
set -e
TARGET_DIR=target/mac/Espanso.app TARGET_DIR=target/mac/Espanso.app
rm -Rf $TARGET_DIR rm -Rf $TARGET_DIR

View File

@ -0,0 +1,9 @@
set -e
TARGET_DIR=target/universal
rm -Rf $TARGET_DIR
mkdir -p $TARGET_DIR
lipo -create -output "$TARGET_DIR/espanso" ./target/x86_64-apple-darwin/release/espanso ./target/aarch64-apple-darwin/release/espanso