Skip to content

Commit 77e5061

Browse files
committed
Merge remote-tracking branch 'machtan/master'
2 parents f6bbcb8 + 032aa2b commit 77e5061

File tree

3 files changed

+45
-9
lines changed

3 files changed

+45
-9
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
ui-sys/target
2+
ui-sys/Cargo.lock
3+
ui/target
4+
ui/Cargo.lock
5+
.DS_Store
6+
*.bk

ui-sys/build.rs

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,52 @@
11
extern crate make_cmd;
22

33
use std::env;
4-
use std::path::Path;
4+
use std::path::{Path, PathBuf};
55
use std::process::Command;
6+
use std::fs::{self, File};
7+
use std::io::Write;
68

79
fn main() {
10+
println!("cargo:rerun-if-changed=libui");
811
if !Path::new("libui/.git").exists() {
9-
Command::new("git").args(&["submodule", "update", "--init"]).status().unwrap();
12+
Command::new("git").args(&["submodule", "update", "--init"]).status().expect("Could not update libui submodule");
1013
}
11-
14+
15+
let cwd = env::current_dir().unwrap();
16+
17+
let libui_path = cwd.join("libui");
18+
env::set_current_dir(&libui_path).expect("Could not change dir");
19+
20+
// Run CMake
21+
//let cmake_cache_path = (&libui_path).join("CMakeCache.txt");
22+
//if cmake_cache_path.exists() {
23+
// fs::remove_file(cmake_cache_path).expect("Could not remove cmake cache");
24+
//}
25+
Command::new("cmake").arg(".").output().expect("cmake failed");
26+
27+
// Run Make
28+
let libui_out_path = (&libui_path).join("out");
29+
if ! libui_out_path.exists() {
30+
println!("Creating out dir");
31+
fs::create_dir(&libui_out_path).expect("Could not create out dir");
32+
}
33+
make_cmd::gnu_make().status().expect("Make failed");
34+
35+
// Copy the output to the build folder
1236
let out_dir = env::var("OUT_DIR").unwrap();
13-
let outdir_argument = format!("OUTDIR={}", out_dir);
14-
let objdir_argument = format!("OBJDIR={}/obj", out_dir);
15-
make_cmd::gnu_make().args(&["-C", "libui", &*outdir_argument, &*objdir_argument])
16-
.status()
17-
.unwrap();
37+
let out_path = Path::new(&out_dir);
38+
for entry in fs::read_dir(&libui_out_path).unwrap() {
39+
let entry = entry.expect("IO error while reading");
40+
let name = entry.file_name();
41+
let target = out_path.join(name);
42+
fs::copy(&entry.path(), &target).expect("Could not copy file");
43+
println!("Copying file from {} to {}", entry.path().display(), target.display());
44+
}
45+
1846

47+
// Configure cargo
1948
println!("cargo:rustc-link-lib=dylib=ui");
2049
println!("cargo:rustc-link-search={}", out_dir);
50+
//panic!();
2151
}
2252

ui-sys/libui

Submodule libui updated 115 files

0 commit comments

Comments
 (0)