Merge pull request #231062 from bobvanderlinden/espanso-update-2.1.8

espanso: 0.7.3 -> 2.1.8
This commit is contained in:
Ryan Lahfa 2023-05-21 21:44:41 +02:00 committed by GitHub
commit 270dcda1e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 3845 additions and 17 deletions

View File

@ -343,6 +343,8 @@ In addition to numerous new and upgraded packages, this release has the followin
- The `pict-rs` package was updated from an 0.3 alpha release to 0.3 stable, and related environment variables now require two underscores instead of one.
- `espanso` has been updated to major version 2. Therefore, migration steps may need to be performed. See [the official migration instructions](https://espanso.org/docs/migration/overview/) for how to perform these migrations. Further, `espanso-wayland` can now be used for Wayland support.
## Other Notable Changes {#sec-release-23.05-notable-changes}
<!-- To avoid merge conflicts, consider adding your item at an arbitrary place in the list instead. -->

3532
pkgs/applications/office/espanso/Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -3,52 +3,106 @@
, rustPlatform
, pkg-config
, extra-cmake-modules
, dbus
, libX11
, libXi
, libXtst
, libnotify
, libxkbcommon
, openssl
, xclip
, xdotool
, setxkbmap
, wl-clipboard
, wxGTK32
, makeWrapper
, stdenv
, AppKit
, Cocoa
, Foundation
, IOKit
, Kernel
, AVFoundation
, Carbon
, QTKit
, AVKit
, WebKit
, waylandSupport ? false
, x11Support ? stdenv.isLinux
, testers
, espanso
}:
# espanso does not support building with both X11 and Wayland support at the same time
assert stdenv.isLinux -> x11Support != waylandSupport;
assert stdenv.isDarwin -> !x11Support;
assert stdenv.isDarwin -> !waylandSupport;
rustPlatform.buildRustPackage rec {
pname = "espanso";
version = "0.7.3";
version = "2.1.8";
src = fetchFromGitHub {
owner = "federico-terzi";
repo = pname;
owner = "espanso";
repo = "espanso";
rev = "v${version}";
sha256 = "1q47r43midkq9574gl8gdv3ylvrnbhdc39rrw4y4yk6jbdf5wwkm";
hash = "sha256-5TUo5B1UZZARgTHbK2+520e3mGZkZ5tTez1qvZvMnxs=";
};
cargoSha256 = "0ba5skn5s6qh0blf6bvivzvqc2l8v488l9n3x98pmf6nygrikfdb";
cargoLock = {
lockFile = ./Cargo.lock;
outputHashes = {
"yaml-rust-0.4.6" = "sha256-wXFy0/s4y6wB3UO19jsLwBdzMy7CGX4JoUt5V6cU7LU=";
};
};
cargoPatches = lib.optionals stdenv.isDarwin [
./inject-wx-on-darwin.patch
];
nativeBuildInputs = [
extra-cmake-modules
pkg-config
makeWrapper
wxGTK32
];
# Ref: https://github.com/espanso/espanso/blob/78df1b704fe2cc5ea26f88fdc443b6ae1df8a989/scripts/build_binary.rs#LL49C3-L62C4
buildNoDefaultFeatures = true;
buildFeatures = [
"modulo"
] ++ lib.optionals waylandSupport[
"wayland"
] ++ lib.optionals stdenv.isLinux [
"vendored-tls"
] ++ lib.optionals stdenv.isDarwin [
"native-tls"
];
buildInputs = [
libX11
libXtst
libXi
libnotify
xclip
openssl
wxGTK32
] ++ lib.optionals stdenv.isLinux [
xdotool
openssl
dbus
libnotify
libxkbcommon
] ++ lib.optionals stdenv.isDarwin [
AppKit
Cocoa
Foundation
IOKit
Kernel
AVFoundation
Carbon
QTKit
AVKit
WebKit
] ++ lib.optionals waylandSupport [
wl-clipboard
] ++ lib.optionals x11Support [
libXi
libXtst
libX11
xclip
xdotool
];
# Some tests require networking
@ -56,14 +110,27 @@ rustPlatform.buildRustPackage rec {
postInstall = ''
wrapProgram $out/bin/espanso \
--prefix PATH : ${lib.makeBinPath [ libnotify xclip ]}
--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;
};
meta = with lib; {
description = "Cross-platform Text Expander written in Rust";
homepage = "https://espanso.org";
license = licenses.gpl3Plus;
maintainers = with maintainers; [ kimat ];
maintainers = with maintainers; [ kimat thehedgeh0g ];
platforms = platforms.unix;
longDescription = ''

View File

@ -0,0 +1,223 @@
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

@ -4777,8 +4777,12 @@ with pkgs;
eschalot = callPackage ../tools/security/eschalot { };
espanso = callPackage ../applications/office/espanso {
inherit (darwin.apple_sdk.frameworks) AppKit Cocoa Foundation;
openssl = openssl_1_1;
inherit (darwin.apple_sdk.frameworks) AppKit Cocoa Foundation IOKit Kernel AVFoundation Carbon QTKit AVKit WebKit;
};
espanso-wayland = espanso.override {
x11Support = false;
waylandSupport = true;
espanso = espanso-wayland;
};
esphome = callPackage ../tools/misc/esphome { };