Fix build in Docs.rs #41
2 changed files with 29 additions and 7 deletions
14
README.md
14
README.md
|
@ -19,6 +19,20 @@ LittlevGL is compatible with <samp>#![no_std]</samp> environments by default.
|
||||||
|
|
||||||
![Rust bindings usage demo code.](demo.png)
|
![Rust bindings usage demo code.](demo.png)
|
||||||
|
|
||||||
|
## System Build Dependencies
|
||||||
|
|
||||||
|
In order to build the `lvgl` project you will need the following system dependencies to be installed:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ sudo apt install build-essential llvm clang
|
||||||
|
```
|
||||||
|
|
||||||
|
If you want to build the examples, then you will need to install SDL2 as well.
|
||||||
|
|
||||||
|
```
|
||||||
|
$ sudo apt install libsdl2-dev
|
||||||
|
```
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
Edit your `Cargo.toml` file dependencies with:
|
Edit your `Cargo.toml` file dependencies with:
|
||||||
|
|
|
@ -12,17 +12,24 @@ fn main() {
|
||||||
let vendor_src = vendor.join("lvgl").join("src");
|
let vendor_src = vendor.join("lvgl").join("src");
|
||||||
|
|
||||||
let lv_config_dir = {
|
let lv_config_dir = {
|
||||||
let raw_path = env::var(CONFIG_NAME).unwrap_or_else(|_| {
|
let conf_path = env::var(CONFIG_NAME).map(|raw_path| PathBuf::from(raw_path)).unwrap_or_else(|_| {
|
||||||
panic!(
|
match std::env::var("DOCS_RS") {
|
||||||
"The environment variable {} is required to be defined",
|
Ok(_) => {
|
||||||
CONFIG_NAME
|
// We've detected that we are building for docs.rs
|
||||||
);
|
// so let's set the examples `lv_conf.h` file.
|
||||||
|
project_dir.join("..").join("examples").join("include")
|
||||||
|
}
|
||||||
|
Err(_) => panic!(
|
||||||
|
"The environment variable {} is required to be defined",
|
||||||
|
CONFIG_NAME
|
||||||
|
)
|
||||||
|
}
|
||||||
});
|
});
|
||||||
let conf_path = PathBuf::from(raw_path);
|
|
||||||
|
|
||||||
if !conf_path.exists() {
|
if !conf_path.exists() {
|
||||||
panic!(format!(
|
panic!(format!(
|
||||||
"Directory referenced by {} needs to exist",
|
"Directory {} referenced by {} needs to exist",
|
||||||
|
conf_path.to_string_lossy(),
|
||||||
CONFIG_NAME
|
CONFIG_NAME
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -94,6 +101,7 @@ fn main() {
|
||||||
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
|
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
|
||||||
let bindings = bindgen::Builder::default()
|
let bindings = bindgen::Builder::default()
|
||||||
.header(shims_dir.join("lvgl_sys.h").to_str().unwrap())
|
.header(shims_dir.join("lvgl_sys.h").to_str().unwrap())
|
||||||
|
.generate_comments(false)
|
||||||
.layout_tests(false)
|
.layout_tests(false)
|
||||||
.use_core()
|
.use_core()
|
||||||
.rustfmt_bindings(true)
|
.rustfmt_bindings(true)
|
||||||
|
|
Loading…
Reference in a new issue