Add another way to load .60 files from a build script

This commit is contained in:
Olivier Goffart 2020-06-05 13:32:56 +02:00
parent 0553ab8b1a
commit 9fc60e104f
10 changed files with 219 additions and 2 deletions

View file

@ -1,6 +1,72 @@
/*!
# SixtyFPS
This create is the main entry point for project using SixtyFPS UI in rust.
## How to use:
There are two ways to use this crate.
- The `.60` code inline in a macro.
- The `.60` code in external files compiled with `build.rs`
### The .60 code in a macro
This is the simpler way, just put the
```rust
sixtyfps::sixtyfps!{
HelloWolrd := Text { text: "hello world"; }
}
fn main() {
# return; // Don't run a window in an example
HelloWolrd::default().run()
}
```
### The .60 file in external files compiled with `build.rs`
In your Cargo.toml:
FIXME! set the version
```toml
[package]
...
build = "build.rs"
[dependencies]
sixtyfps = "*"
...
[build-dependencies]
sixtyfps-build = "*"
```
In the `build.rs` file:
```ignore
fn main() {
sixtyfps_build::compile("ui/hello.60");
}
```
Then in your main file
```ignore
sixtyfps::include_modules!();
fn main() {
HelloWolrd::default().run()
}
```
*/
#![warn(missing_docs)]
pub use sixtyfps_rs_macro::sixtyfps;
/// internal re_exports used by the macro generated
#[doc(hidden)]
pub mod re_exports {
pub use const_field_offset::{self, FieldOffsets};
pub use corelib::abi::datastructures::{Component, ComponentTO, ComponentVTable, ItemTreeNode};
@ -17,3 +83,11 @@ pub mod re_exports {
#[cfg(doctest)]
mod compile_fail_tests;
/// Include the code generated with the sixtyfps-build crate from the build script
#[macro_export]
macro_rules! include_modules {
() => {
include!(env!("SIXTYFPS_INCLUDE_GENERATED"));
};
}