From 0470f05c0786c39e38e3fb1e10e3e7789e54f8d6 Mon Sep 17 00:00:00 2001 From: Ayush Singh Date: Wed, 1 Dec 2021 07:32:07 +0530 Subject: [PATCH] Can now specify Include and Lib path. Using KF5_I18n_INCLUDE_PATH and KF5_I18n_LIBREARY_PATH. Maybe can improve default detection later. --- build.rs | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/build.rs b/build.rs index b636cce..fcd7856 100644 --- a/build.rs +++ b/build.rs @@ -68,9 +68,24 @@ fn qt_setup(config: &mut cpp_build::Config) -> Version { } fn ki18n_setup(config: &mut cpp_build::Config) { - let kf5_i18n_path = "/usr/include/KF5/KI18n"; + println!("cargo:rerun-if-env-changed=KF5_I18n_INCLUDE_PATH"); + println!("cargo:rerun-if-env-changed=KF5_I18n_LIBRARY_PATH"); - config.include(kf5_i18n_path); + let (kf5i18n_include_path, kf5i18n_library_path) = match ( + std::env::var("KF5_I18n_INCLUDE_PATH").ok(), + std::env::var("KF5_I18n_LIBRARY_PATH").ok(), + ) { + (Some(include_path), Some(library_path)) => (include_path, library_path), + (None, None) => { + const DEFAULT_INCLUDE_PATH: &str = "/usr/include/KF5/KI18n"; + (DEFAULT_INCLUDE_PATH.to_string(), "KF5I18n".to_string()) + } + (Some(_), None) | (None, Some(_)) => { + panic!("KF5_KI18n_INCLUDE_PATH and KF5_KI18n_LIBRARY_PATH env variable must be either both empty or both set.") + } + }; - println!("cargo:rustc-link-lib=KF5I18n"); + config.include(kf5i18n_include_path); + + println!("cargo:rustc-link-lib={}", kf5i18n_library_path); }