Skip to content

Commit e121ccf

Browse files
committed
Make libui, ui-sys, and ui examples build properly
This involved actually invoking cmake to build the library rather than just running make on the build directory, so cmake is now a dependency.
1 parent 8acc55e commit e121ccf

File tree

4 files changed

+17
-3
lines changed

4 files changed

+17
-3
lines changed

.gitignore

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

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
These are work-in-progress Rust bindings to the minimalistic native UI library [libui][libui].
22

3+
They require GNU Make and CMake to build `libui` itself.
4+
35
Author: Patrick Walton (@pcwalton)
46

57
[libui]: https://github.com/andlabs/libui

ui-sys/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ libc = "0.2"
1111

1212
[build-dependencies]
1313
make-cmd = "0.1"
14+
cmake = "0.1"
1415

ui-sys/build.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,32 @@
11
extern crate make_cmd;
2+
extern crate cmake;
23

34
use std::env;
45
use std::path::Path;
56
use std::process::Command;
67

78
fn main() {
9+
// Update the submodule with libui if needed
810
if !Path::new("libui/.git").exists() {
911
Command::new("git").args(&["submodule", "update", "--init"]).status().unwrap();
1012
}
1113

14+
// Run cmake to build the project's makefiles
15+
let dst = cmake::Config::new("libui")
16+
.build_target("")
17+
.build();
18+
let dst = format!("{}/build", dst.display());
19+
20+
// Run make to build the actual library
1221
let out_dir = env::var("OUT_DIR").unwrap();
1322
let outdir_argument = format!("OUTDIR={}", out_dir);
1423
let objdir_argument = format!("OBJDIR={}/obj", out_dir);
15-
make_cmd::gnu_make().args(&["-C", "libui", &*outdir_argument, &*objdir_argument])
24+
make_cmd::gnu_make().args(&["-C", &dst, &*outdir_argument, &*objdir_argument])
1625
.status()
1726
.unwrap();
18-
Command::new("cp").args(&["-r", "libui/out/", &*out_dir]).status().unwrap();
27+
//Command::new("cp").args(&["-r", "libui/out/", &*out_dir]).status().unwrap();
1928

29+
println!("cargo:rustc-link-search=native={}/out/", dst);
2030
println!("cargo:rustc-link-lib=dylib=ui");
21-
println!("cargo:rustc-link-search=native={}", out_dir);
2231
}
2332

0 commit comments

Comments
 (0)