Merge pull request #311724 from malt3/espanso-2-2-1

espanso: 2.1.8 -> 2.2-unstable-2024-05-14
This commit is contained in:
Paul Meyer 2024-05-23 08:39:27 +02:00 committed by GitHub
commit 223760324f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 785 additions and 625 deletions

File diff suppressed because it is too large Load Diff

View File

@ -28,6 +28,7 @@
, QTKit
, AVKit
, WebKit
, System
, waylandSupport ? false
, x11Support ? stdenv.isLinux
, testers
@ -39,13 +40,13 @@ assert stdenv.isDarwin -> !x11Support;
assert stdenv.isDarwin -> !waylandSupport;
rustPlatform.buildRustPackage rec {
pname = "espanso";
version = "2.1.8";
version = "2.2-unstable-2024-05-14";
src = fetchFromGitHub {
owner = "espanso";
repo = "espanso";
rev = "v${version}";
hash = "sha256-5TUo5B1UZZARgTHbK2+520e3mGZkZ5tTez1qvZvMnxs=";
rev = "8daadcc949c35a7b7aa20b7f544fdcff83e2c5f7";
hash = "sha256-4MArENBmX6tDVLZE1O8cuJe7A0R+sLZoxBkDvIwIVZ4=";
};
cargoLock = {
@ -55,10 +56,6 @@ rustPlatform.buildRustPackage rec {
};
};
cargoPatches = lib.optionals stdenv.isDarwin [
./inject-wx-on-darwin.patch
];
nativeBuildInputs = [
extra-cmake-modules
pkg-config
@ -70,7 +67,7 @@ rustPlatform.buildRustPackage rec {
buildNoDefaultFeatures = true;
buildFeatures = [
"modulo"
] ++ lib.optionals waylandSupport[
] ++ lib.optionals waylandSupport [
"wayland"
] ++ lib.optionals stdenv.isLinux [
"vendored-tls"
@ -96,6 +93,7 @@ rustPlatform.buildRustPackage rec {
QTKit
AVKit
WebKit
System
] ++ lib.optionals waylandSupport [
wl-clipboard
] ++ lib.optionals x11Support [
@ -108,39 +106,39 @@ rustPlatform.buildRustPackage rec {
postPatch = lib.optionalString stdenv.isDarwin ''
substituteInPlace scripts/create_bundle.sh \
--replace target/mac/ $out/Applications/ \
--replace /bin/echo ${coreutils}/bin/echo
--replace-fail target/mac/ $out/Applications/ \
--replace-fail /bin/echo ${coreutils}/bin/echo
patchShebangs scripts/create_bundle.sh
substituteInPlace espanso/src/res/macos/Info.plist \
--replace "<string>espanso</string>" "<string>${placeholder "out"}/Applications/Espanso.app/Contents/MacOS/espanso</string>"
substituteInPlace espanso/src/res/macos/com.federicoterzi.espanso.plist \
--replace "<string>/Applications/Espanso.app/Contents/MacOS/espanso</string>" "<string>${placeholder "out"}/Applications/Espanso.app/Contents/MacOS/espanso</string>" \
--replace "<string>/usr/bin" "<string>${placeholder "out"}/bin:/usr/bin"
--replace-fail "<string>espanso</string>" "<string>${placeholder "out"}/Applications/Espanso.app/Contents/MacOS/espanso</string>"
substituteInPlace espanso/src/path/macos.rs espanso/src/path/linux.rs \
--replace '"/usr/local/bin/espanso"' '"${placeholder "out"}/bin/espanso"'
--replace-fail '"/usr/local/bin/espanso"' '"${placeholder "out"}/bin/espanso"'
'';
# Some tests require networking
doCheck = false;
postInstall = if stdenv.isDarwin then ''
EXEC_PATH=$out/bin/espanso BUILD_ARCH=current ${stdenv.shell} ./scripts/create_bundle.sh
'' else ''
wrapProgram $out/bin/espanso \
--prefix PATH : ${lib.makeBinPath (
lib.optionals stdenv.isLinux [
libnotify
setxkbmap
] ++ lib.optionals waylandSupport [
wl-clipboard
] ++ lib.optionals x11Support [
xclip
]
)}
'';
postInstall =
if stdenv.isDarwin then ''
EXEC_PATH=$out/bin/espanso BUILD_ARCH=current ${stdenv.shell} ./scripts/create_bundle.sh
'' else ''
wrapProgram $out/bin/espanso \
--prefix PATH : ${lib.makeBinPath (
lib.optionals stdenv.isLinux [
libnotify
setxkbmap
] ++ lib.optionals waylandSupport [
wl-clipboard
] ++ lib.optionals x11Support [
xclip
]
)}
'';
passthru.tests.version = testers.testVersion {
package = espanso;
# remove when updating to a release version
version = "2.2.1";
};
meta = with lib; {
@ -148,8 +146,15 @@ rustPlatform.buildRustPackage rec {
mainProgram = "espanso";
homepage = "https://espanso.org";
license = licenses.gpl3Plus;
maintainers = with maintainers; [ kimat pyrox0 ];
maintainers = with maintainers; [ kimat pyrox0 n8henrie ];
platforms = platforms.unix;
# With apple_sdk_10_12,
# kCFURLVolumeAvailableCapacityForImportantUsageKey
# is undefined.
# With apple_sdk_11_0, there is an issue with
# kColorSyncGenericGrayProfile.
broken = stdenv.hostPlatform.system == "x86_64-darwin";
longDescription = ''
Espanso detects when you type a keyword and replaces it while you're typing.

View File

@ -1,223 +0,0 @@
From 6a7400c20831c5ff502c7336d6db2be743f156be Mon Sep 17 00:00:00 2001
From: Nikola Knezevic <nikola.knezevic@imc.com>
Date: Tue, 16 Aug 2022 22:28:46 +0200
Subject: [PATCH] Build using system wx on darwin
---
espanso-modulo/build.rs | 174 ++++------------------------------------
1 file changed, 17 insertions(+), 157 deletions(-)
diff --git a/espanso-modulo/build.rs b/espanso-modulo/build.rs
index b8b889a..5d972ec 100644
--- a/espanso-modulo/build.rs
+++ b/espanso-modulo/build.rs
@@ -156,161 +156,6 @@ fn build_native() {
);
}
-#[cfg(target_os = "macos")]
-fn build_native() {
- use std::process::Command;
-
- let project_dir =
- PathBuf::from(std::env::var("CARGO_MANIFEST_DIR").expect("missing CARGO_MANIFEST_DIR"));
- let wx_archive = project_dir.join("vendor").join(WX_WIDGETS_ARCHIVE_NAME);
- if !wx_archive.is_file() {
- panic!("could not find wxWidgets archive!");
- }
-
- let out_dir = if let Ok(out_path) = std::env::var(WX_WIDGETS_BUILD_OUT_DIR_ENV_NAME) {
- println!(
- "detected wxWidgets build output directory override: {}",
- out_path
- );
- let path = PathBuf::from(out_path);
- std::fs::create_dir_all(&path).expect("unable to create wxWidgets out dir");
- path
- } else {
- PathBuf::from(std::env::var("OUT_DIR").expect("missing OUT_DIR"))
- };
- let out_wx_dir = out_dir.join("wx");
- println!("wxWidgets will be compiled into: {}", out_wx_dir.display());
-
- let target_arch = match std::env::var("CARGO_CFG_TARGET_ARCH")
- .expect("unable to read target arch")
- .as_str()
- {
- "x86_64" => "x86_64",
- "aarch64" => "arm64",
- arch => panic!("unsupported arch {}", arch),
- };
-
- let should_use_ci_m1_workaround =
- std::env::var("CI").unwrap_or_default() == "true" && target_arch == "arm64";
-
- if !out_wx_dir.is_dir() {
- // Extract the wxWidgets archive
- let wx_archive =
- std::fs::File::open(&wx_archive).expect("unable to open wxWidgets source archive");
- let mut archive = zip::ZipArchive::new(wx_archive).expect("unable to read wxWidgets archive");
- archive
- .extract(&out_wx_dir)
- .expect("unable to extract wxWidgets source dir");
-
- // Compile wxWidgets
- let build_dir = out_wx_dir.join("build-cocoa");
- std::fs::create_dir_all(&build_dir).expect("unable to create build-cocoa directory");
-
- let mut handle = if should_use_ci_m1_workaround {
- // Because of a configuration problem on the GitHub CI pipeline,
- // we need to use a series of workarounds to build for M1 machines.
- // See: https://github.com/actions/virtual-environments/issues/3288#issuecomment-830207746
- Command::new(out_wx_dir.join("configure"))
- .current_dir(build_dir.to_string_lossy().to_string())
- .args(&[
- "--disable-shared",
- "--without-libtiff",
- "--without-liblzma",
- "--with-libjpeg=builtin",
- "--with-libpng=builtin",
- "--enable-universal-binary=arm64,x86_64",
- ])
- .spawn()
- .expect("failed to execute configure")
- } else {
- Command::new(out_wx_dir.join("configure"))
- .current_dir(build_dir.to_string_lossy().to_string())
- .args(&[
- "--disable-shared",
- "--without-libtiff",
- "--without-liblzma",
- "--with-libjpeg=builtin",
- "--with-libpng=builtin",
- &format!("--enable-macosx_arch={}", target_arch),
- ])
- .spawn()
- .expect("failed to execute configure")
- };
-
- if !handle
- .wait()
- .expect("unable to wait for configure command")
- .success()
- {
- panic!("configure returned non-zero exit code!");
- }
-
- let mut handle = Command::new("make")
- .current_dir(build_dir.to_string_lossy().to_string())
- .args(&["-j8"])
- .spawn()
- .expect("failed to execute make");
- if !handle
- .wait()
- .expect("unable to wait for make command")
- .success()
- {
- panic!("make returned non-zero exit code!");
- }
- }
-
- // Make sure wxWidgets is compiled
- if !out_wx_dir.join("build-cocoa").is_dir() {
- panic!("wxWidgets is not compiled correctly, missing 'build-cocoa/' directory")
- }
-
- // If using the M1 CI workaround, convert all the universal libraries to arm64 ones
- // This is needed until https://github.com/rust-lang/rust/issues/55235 is fixed
- if should_use_ci_m1_workaround {
- convert_fat_libraries_to_arm(&out_wx_dir.join("build-cocoa").join("lib"));
- convert_fat_libraries_to_arm(&out_wx_dir.join("build-cocoa"));
- }
-
- let config_path = out_wx_dir.join("build-cocoa").join("wx-config");
- let cpp_flags = get_cpp_flags(&config_path);
-
- let mut build = cc::Build::new();
- build
- .cpp(true)
- .file("src/sys/form/form.cpp")
- .file("src/sys/common/common.cpp")
- .file("src/sys/search/search.cpp")
- .file("src/sys/wizard/wizard.cpp")
- .file("src/sys/wizard/wizard_gui.cpp")
- .file("src/sys/welcome/welcome.cpp")
- .file("src/sys/welcome/welcome_gui.cpp")
- .file("src/sys/textview/textview.cpp")
- .file("src/sys/textview/textview_gui.cpp")
- .file("src/sys/troubleshooting/troubleshooting.cpp")
- .file("src/sys/troubleshooting/troubleshooting_gui.cpp")
- .file("src/sys/common/mac.mm");
- build.flag("-std=c++17");
-
- for flag in cpp_flags {
- build.flag(&flag);
- }
-
- build.compile("espansomodulosys");
-
- // Render linker flags
-
- generate_linker_flags(&config_path);
-
- // On (older) OSX we need to link against the clang runtime,
- // which is hidden in some non-default path.
- //
- // More details at https://github.com/alexcrichton/curl-rust/issues/279.
- if let Some(path) = macos_link_search_path() {
- println!("cargo:rustc-link-lib=clang_rt.osx");
- println!("cargo:rustc-link-search={}", path);
- }
-}
-
#[cfg(target_os = "macos")]
fn convert_fat_libraries_to_arm(lib_dir: &Path) {
for entry in
@@ -440,12 +285,17 @@ fn macos_link_search_path() -> Option<String> {
None
}
+#[cfg(not(target_os = "macos"))]
+fn macos_link_search_path() -> Option<String> {
+ return None
+}
+
// TODO: add documentation for linux
// Install wxWidgets:
// sudo apt install libwxgtk3.0-0v5 libwxgtk3.0-dev
//
// cargo run
-#[cfg(target_os = "linux")]
+#[cfg(not(target_os = "windows"))]
fn build_native() {
// Make sure wxWidgets is installed
// Depending on the installation package, the 'wx-config' command might also be available as 'wx-config-gtk3',
@@ -483,7 +333,8 @@ fn build_native() {
.file("src/sys/textview/textview.cpp")
.file("src/sys/textview/textview_gui.cpp")
.file("src/sys/troubleshooting/troubleshooting.cpp")
- .file("src/sys/troubleshooting/troubleshooting_gui.cpp");
+ .file("src/sys/troubleshooting/troubleshooting_gui.cpp")
+ .file("src/sys/common/mac.mm");
build.flag("-std=c++17");
for flag in cpp_flags {
@@ -495,6 +346,15 @@ fn build_native() {
// Render linker flags
generate_linker_flags(&config_path);
+
+ // On (older) OSX we need to link against the clang runtime,
+ // which is hidden in some non-default path.
+ //
+ // More details at https://github.com/alexcrichton/curl-rust/issues/279.
+ if let Some(path) = macos_link_search_path() {
+ println!("cargo:rustc-link-lib=clang_rt.osx");
+ println!("cargo:rustc-link-search={}", path);
+ }
}
fn main() {
--
2.37.1

View File

@ -5119,7 +5119,7 @@ with pkgs;
eschalot = callPackage ../tools/security/eschalot { };
espanso = callPackage ../applications/office/espanso {
inherit (darwin.apple_sdk.frameworks) AppKit Cocoa Foundation IOKit Kernel AVFoundation Carbon QTKit AVKit WebKit;
inherit (darwin.apple_sdk_11_0.frameworks) AppKit Cocoa Foundation IOKit Kernel AVFoundation Carbon QTKit AVKit WebKit System;
};
espanso-wayland = espanso.override {
x11Support = false;