环境
- 安装rust
- 安装msvc
- 安装cmake
- 安装 Git
设计工具
cargo install fltk-fluid fl2rust
use std::path::PathBuf;
use std::env;
fn main() {
println!("cargo:rerun-if-changed=src/myui.fl");
let g = fl2rust::Generator::default();
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
g.in_out("src/myui.fl", out_path.join("myui.rs").to_str().unwrap()).expect("Failed to generate rust from fl file!");
}
myui.rs
#![allow(unused_variables)]
#![allow(unused_mut)]
#![allow(unused_imports)]
#![allow(dead_code)]
#![allow(clippy::needless_update)]
include!(concat!(env!("OUT_DIR"), "/myui.rs"));
main.rs
use fltk::{prelude::*, *};
mod myui;
fn main() {
let app = app::App::default();
let mut ui = myui::UserInterface::make_window();
ui.but.set_callback(move |_| {
println!("Works!");
});
app.run().unwrap();
}
Cargo.toml
[profile.release]
opt-level = 'z' # 根据尺寸进行优化
lto = true # 启用链接时间优化
codegen-units = 1 # 减少代码生成单元的数量以增加优化.
panic = 'abort' # Abort on panic
strip = true # 从二进制中删除符号
[dependencies]
fltk = "1.4.13"
[build-dependencies]
fl2rust = "0.5.17"
评论区