Now Linking and Including KF5I18nLocaleData.
Required for KCountry.
This commit is contained in:
parent
2cdd13d145
commit
10f1b9ab50
45
build.rs
45
build.rs
|
@ -17,6 +17,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use semver::Version;
|
use semver::Version;
|
||||||
|
use std::path::PathBuf;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
eprintln!("cargo:warning={:?}", std::env::vars().collect::<Vec<_>>());
|
eprintln!("cargo:warning={:?}", std::env::vars().collect::<Vec<_>>());
|
||||||
|
@ -68,24 +69,42 @@ fn qt_setup(config: &mut cpp_build::Config) -> Version {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ki18n_setup(config: &mut cpp_build::Config) {
|
fn ki18n_setup(config: &mut cpp_build::Config) {
|
||||||
println!("cargo:rerun-if-env-changed=KF5_I18n_INCLUDE_PATH");
|
let (kf5_include_path, kf5_library_path) = probe_kf5();
|
||||||
println!("cargo:rerun-if-env-changed=KF5_I18n_LIBRARY_PATH");
|
|
||||||
|
|
||||||
let (kf5i18n_include_path, kf5i18n_library_path) = match (
|
config
|
||||||
std::env::var("KF5_I18n_INCLUDE_PATH").ok(),
|
.include(kf5_include_path.join("KI18n"))
|
||||||
std::env::var("KF5_I18n_LIBRARY_PATH").ok(),
|
.include(kf5_include_path.join("KI18nLocaleData"));
|
||||||
|
|
||||||
|
println!(
|
||||||
|
"cargo:rustc-link-search={}",
|
||||||
|
kf5_library_path.to_str().unwrap()
|
||||||
|
);
|
||||||
|
|
||||||
|
println!("cargo:rustc-link-lib={}", "KF5I18n");
|
||||||
|
println!("cargo:rustc-link-lib={}", "KF5I18nLocaleData");
|
||||||
|
}
|
||||||
|
|
||||||
|
fn probe_kf5() -> (PathBuf, PathBuf) {
|
||||||
|
println!("cargo:rerun-if-env-changed=KF5_INCLUDE_PATH");
|
||||||
|
println!("cargo:rerun-if-env-changed=KF5_LIBRARY_PATH");
|
||||||
|
|
||||||
|
match (
|
||||||
|
std::env::var("KF5_INCLUDE_PATH").ok(),
|
||||||
|
std::env::var("KF5_LIBRARY_PATH").ok(),
|
||||||
) {
|
) {
|
||||||
(Some(include_path), Some(library_path)) => (include_path, library_path),
|
(Some(include_path), Some(library_path)) => {
|
||||||
|
(PathBuf::from(include_path), PathBuf::from(library_path))
|
||||||
|
}
|
||||||
(None, None) => {
|
(None, None) => {
|
||||||
const DEFAULT_INCLUDE_PATH: &str = "/usr/include/KF5/KI18n";
|
const DEFAULT_INCLUDE_PATH: &str = "/usr/include/KF5";
|
||||||
(DEFAULT_INCLUDE_PATH.to_string(), "KF5I18n".to_string())
|
const DEFAULT_LIBRARY_PATH: &str = "/usr/lib";
|
||||||
|
(
|
||||||
|
PathBuf::from(DEFAULT_INCLUDE_PATH),
|
||||||
|
PathBuf::from(DEFAULT_LIBRARY_PATH),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
(Some(_), None) | (None, Some(_)) => {
|
(Some(_), None) | (None, Some(_)) => {
|
||||||
panic!("KF5_KI18n_INCLUDE_PATH and KF5_KI18n_LIBRARY_PATH env variable must be either both empty or both set.")
|
panic!("KF5_KI18n_INCLUDE_PATH and KF5_KI18n_LIBRARY_PATH env variable must be either both empty or both set.")
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
config.include(kf5i18n_include_path);
|
|
||||||
|
|
||||||
println!("cargo:rustc-link-lib={}", kf5i18n_library_path);
|
|
||||||
}
|
}
|
||||||
|
|
10
src/kcountry.rs
Normal file
10
src/kcountry.rs
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
use cpp::{cpp, cpp_class};
|
||||||
|
|
||||||
|
cpp! {{
|
||||||
|
#include <KCountry>
|
||||||
|
}}
|
||||||
|
|
||||||
|
cpp_class!(
|
||||||
|
#[derive(Default, Clone, Eq, PartialEq)]
|
||||||
|
pub unsafe struct KCountry as "KCountry"
|
||||||
|
);
|
|
@ -47,8 +47,8 @@
|
||||||
|
|
||||||
pub mod klocalizedcontext;
|
pub mod klocalizedcontext;
|
||||||
pub mod klocalizedstring;
|
pub mod klocalizedstring;
|
||||||
|
pub mod kcountry;
|
||||||
|
|
||||||
pub mod prelude {
|
pub mod prelude {
|
||||||
pub use crate::klocalizedcontext::KLocalizedContext;
|
|
||||||
pub use crate::klocalizedstring::KLocalizedString;
|
pub use crate::klocalizedstring::KLocalizedString;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue