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_MODULO = false
EXEC_PATH = "target/debug/espanso"
BUILD_ARCH = "x86_64" # TODO: do something with this
BUILD_ARCH = "current"
[env.release]
DEBUG = false
@ -48,10 +48,31 @@ dependencies = ["build-windows-portable", "build-windows-installer"]
# 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]
script = { file = "scripts/create_bundle.sh" }
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]
command="target/mac/Espanso.app/Contents/MacOS/espanso"
args=["${@}"]

View File

@ -37,6 +37,12 @@ fn main() {
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("espanso/Cargo.toml");

View File

@ -1,3 +1,5 @@
set -e
TARGET_DIR=target/mac/Espanso.app
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