Compile lvgl using cargo

This commit is contained in:
Rafael Caricio 2020-04-10 19:12:10 +02:00
parent 1d94ebd29d
commit d71b8097a4
10 changed files with 76 additions and 0 deletions

1
.gitignore vendored
View file

@ -8,3 +8,4 @@ Cargo.lock
# These are backup files generated by rustfmt
**/*.rs.bk
.idea/

6
.gitmodules vendored Normal file
View file

@ -0,0 +1,6 @@
[submodule "vendor/lvgl"]
path = vendor/lvgl
url = https://github.com/littlevgl/lvgl.git
[submodule "vendor/lv_sim_eclipse_sdl"]
path = vendor/lv_sim_eclipse_sdl
url = https://github.com/rafaelcaricio/lv_sim_eclipse_sdl.git

3
Cargo.toml Normal file
View file

@ -0,0 +1,3 @@
[workspace]
members = ["lvgl-sys", "lvgl"]

17
lvgl-sys/Cargo.toml Normal file
View file

@ -0,0 +1,17 @@
[package]
name = "lvgl-sys"
version = "0.1.0"
authors = ["Rafael Caricio <crates.lvgl-sys@caric.io>"]
edition = "2018"
license = "MIT"
repository = "https://github.com/rafaelcaricio/lvgl-rs"
build = "build.rs"
links = "lvgl"
[lib]
name = "lvgl_sys"
[dependencies]
[build-dependencies]
cc = "1.0.50"

23
lvgl-sys/build.rs Normal file
View file

@ -0,0 +1,23 @@
use std::{env, path::PathBuf};
use cc::Build;
fn main() {
let project_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap())
.canonicalize()
.unwrap();
let root_dir = project_dir.parent().unwrap();
let vendor = root_dir.join("vendor");
let src = vendor.join("lvgl").join("src");
let mut cfg = Build::new();
cfg.file(src.parent().unwrap().join("lvgl.h"))
.define("LV_CONF_INCLUDE_SIMPLE", Some("1"))
.include(&src)
.warnings(false);
// TODO: Make it configurable! Needs to be linked to final proj defs, define as an env var.
cfg.include(vendor.join("lv_sim_eclipse_sdl"));
cfg.compile("lvgl");
}

7
lvgl-sys/src/lib.rs Normal file
View file

@ -0,0 +1,7 @@
#[cfg(test)]
mod tests {
#[test]
fn it_works() {
assert_eq!(2 + 2, 4);
}
}

10
lvgl/Cargo.toml Normal file
View file

@ -0,0 +1,10 @@
[package]
name = "lvgl"
version = "0.1.0"
authors = ["Rafael Caricio <crates.lvgl@caric.io>"]
edition = "2018"
license = "MIT"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]

7
lvgl/src/lib.rs Normal file
View file

@ -0,0 +1,7 @@
#[cfg(test)]
mod tests {
#[test]
fn it_works() {
assert_eq!(2 + 2, 4);
}
}

1
vendor/lv_sim_eclipse_sdl vendored Submodule

@ -0,0 +1 @@
Subproject commit 3899fd06c5a44c67e02dce6cde0d234dc04ba8cb

1
vendor/lvgl vendored Submodule

@ -0,0 +1 @@
Subproject commit 9eeaf61fa7ec2b5ea151374b135b85f15438938c