Browse Source

recover the files I accidentally ignored

translation2
Colin Reeder 3 years ago
parent
commit
5b280eea80
4 changed files with 75 additions and 3 deletions
  1. +1
    -1
      .gitignore
  2. +2
    -2
      build.rs
  3. +54
    -0
      src/build/build_qmo.rs
  4. +18
    -0
      src/build/build_translations.rs

+ 1
- 1
.gitignore View File

@@ -5,7 +5,7 @@ Cargo.lock

# Clickable
.clickable/
build/
/build

# JetBrains IDEs
.idea/

+ 2
- 2
build.rs View File

@@ -1,8 +1,8 @@
mod build_qmo {
include!("./build/build_qmo.rs");
include!("./src/build/build_qmo.rs");
}
mod build_translations {
include!("./build/build_translations.rs");
include!("./src/build/build_translations.rs");
}

fn main() {


+ 54
- 0
src/build/build_qmo.rs View File

@@ -0,0 +1,54 @@
/* Copyright (C) 2018 Olivier Goffart <ogoffart@woboq.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial
portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
extern crate cpp_build;
use std::process::Command;

fn qmake_query(var: &str) -> String {
String::from_utf8(
Command::new("qmake")
.args(&["-query", var])
.output()
.expect("Failed to execute qmake. Make sure 'qmake' is in your path")
.stdout,
).expect("UTF-8 conversion failed")
}

pub fn main() {
let qt_include_path = qmake_query("QT_INSTALL_HEADERS");
let qt_library_path = qmake_query("QT_INSTALL_LIBS");

cpp_build::Config::new()
.include(qt_include_path.trim())
.build("src/main.rs");

let macos_lib_search = if cfg!(target_os = "macos") {
"=framework"
} else {
""
};
let macos_lib_framework = if cfg!(target_os = "macos") { "" } else { "5" };

println!(
"cargo:rustc-link-search{}={}",
macos_lib_search,
qt_library_path.trim()
);
println!("cargo:rustc-link-lib{}=Qt{}Widgets", macos_lib_search, macos_lib_framework);
println!("cargo:rustc-link-lib{}=Qt{}Gui", macos_lib_search, macos_lib_framework);
println!("cargo:rustc-link-lib{}=Qt{}Core", macos_lib_search, macos_lib_framework);
println!("cargo:rustc-link-lib{}=Qt{}Quick", macos_lib_search, macos_lib_framework);
println!("cargo:rustc-link-lib{}=Qt{}Qml", macos_lib_search, macos_lib_framework);
println!("cargo:rustc-link-lib{}=Qt{}QuickControls2", macos_lib_search, macos_lib_framework);
}

+ 18
- 0
src/build/build_translations.rs View File

@@ -0,0 +1,18 @@
pub fn main() {
let target_dir = std::path::PathBuf::from(std::env::var("OUT_DIR").unwrap());
let translation_target_dir = target_dir.join("mo");
for entry in std::fs::read_dir("./po").expect("Failed to read po directory") {
let entry = entry.expect("Failed to read po directory");
let name = entry.file_name();
let name = name.to_string_lossy();
if name.ends_with(".po") {
println!("{}", name);
std::process::Command::new("msgfmt")
.arg(entry.path())
.arg("-o")
.arg(translation_target_dir.join(format!("{}.mo", &name[..(name.len() - 3)])))
.status()
.expect("Failed to compile po file");
}
}
}

Loading…
Cancel
Save