From d71b8097a41561f56a55a167fb303cb245211e77 Mon Sep 17 00:00:00 2001 From: Rafael Caricio Date: Fri, 10 Apr 2020 19:12:10 +0200 Subject: [PATCH] Compile lvgl using cargo --- .gitignore | 1 + .gitmodules | 6 ++++++ Cargo.toml | 3 +++ lvgl-sys/Cargo.toml | 17 +++++++++++++++++ lvgl-sys/build.rs | 23 +++++++++++++++++++++++ lvgl-sys/src/lib.rs | 7 +++++++ lvgl/Cargo.toml | 10 ++++++++++ lvgl/src/lib.rs | 7 +++++++ vendor/lv_sim_eclipse_sdl | 1 + vendor/lvgl | 1 + 10 files changed, 76 insertions(+) create mode 100644 .gitmodules create mode 100644 Cargo.toml create mode 100644 lvgl-sys/Cargo.toml create mode 100644 lvgl-sys/build.rs create mode 100644 lvgl-sys/src/lib.rs create mode 100644 lvgl/Cargo.toml create mode 100644 lvgl/src/lib.rs create mode 160000 vendor/lv_sim_eclipse_sdl create mode 160000 vendor/lvgl diff --git a/.gitignore b/.gitignore index 088ba6b..aa982cd 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ Cargo.lock # These are backup files generated by rustfmt **/*.rs.bk +.idea/ diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..80e4d39 --- /dev/null +++ b/.gitmodules @@ -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 diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..8ee457c --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,3 @@ +[workspace] +members = ["lvgl-sys", "lvgl"] + diff --git a/lvgl-sys/Cargo.toml b/lvgl-sys/Cargo.toml new file mode 100644 index 0000000..f17ac67 --- /dev/null +++ b/lvgl-sys/Cargo.toml @@ -0,0 +1,17 @@ +[package] +name = "lvgl-sys" +version = "0.1.0" +authors = ["Rafael Caricio "] +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" diff --git a/lvgl-sys/build.rs b/lvgl-sys/build.rs new file mode 100644 index 0000000..8e3f84d --- /dev/null +++ b/lvgl-sys/build.rs @@ -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"); +} diff --git a/lvgl-sys/src/lib.rs b/lvgl-sys/src/lib.rs new file mode 100644 index 0000000..31e1bb2 --- /dev/null +++ b/lvgl-sys/src/lib.rs @@ -0,0 +1,7 @@ +#[cfg(test)] +mod tests { + #[test] + fn it_works() { + assert_eq!(2 + 2, 4); + } +} diff --git a/lvgl/Cargo.toml b/lvgl/Cargo.toml new file mode 100644 index 0000000..acf5836 --- /dev/null +++ b/lvgl/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "lvgl" +version = "0.1.0" +authors = ["Rafael Caricio "] +edition = "2018" +license = "MIT" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/lvgl/src/lib.rs b/lvgl/src/lib.rs new file mode 100644 index 0000000..31e1bb2 --- /dev/null +++ b/lvgl/src/lib.rs @@ -0,0 +1,7 @@ +#[cfg(test)] +mod tests { + #[test] + fn it_works() { + assert_eq!(2 + 2, 4); + } +} diff --git a/vendor/lv_sim_eclipse_sdl b/vendor/lv_sim_eclipse_sdl new file mode 160000 index 0000000..3899fd0 --- /dev/null +++ b/vendor/lv_sim_eclipse_sdl @@ -0,0 +1 @@ +Subproject commit 3899fd06c5a44c67e02dce6cde0d234dc04ba8cb diff --git a/vendor/lvgl b/vendor/lvgl new file mode 160000 index 0000000..9eeaf61 --- /dev/null +++ b/vendor/lvgl @@ -0,0 +1 @@ +Subproject commit 9eeaf61fa7ec2b5ea151374b135b85f15438938c