Skip to content

Commit 6a45a7c

Browse files
committed
Use aot-shared-library-name arg.
1 parent d1c27b6 commit 6a45a7c

File tree

3 files changed

+35
-56
lines changed

3 files changed

+35
-56
lines changed

Cargo.lock

+23-40
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ edition = "2018"
66

77
[dependencies]
88
env_logger = "0.7.1"
9-
flutter-engine = { git = "https://github.com/flutter-rs/flutter-rs", features = ["loader"] }
9+
flutter-engine = { git = "https://github.com/flutter-rs/flutter-rs" }
1010
flutter-winit = { git = "https://github.com/flutter-rs/flutter-rs" }
1111
glutin = { git = "https://github.com/dvc94ch/glutin", branch = "android" }
1212
log = "0.4.8"

src/main.rs

+11-15
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,26 @@
1-
use flutter_engine::loader::load_snapshot;
21
use flutter_winit::FlutterWindow;
32
use glutin::window::WindowBuilder;
4-
use std::path::PathBuf;
3+
use std::path::Path;
54

65
fn main() {
76
env_logger::init();
87

9-
let asset_dir = std::env::var("FLUTTER_ASSET_DIR").expect("FLUTTER_ASSET_DIR");
8+
let assets_dir = std::env::var("FLUTTER_ASSET_DIR")
9+
.expect("FLUTTER_ASSET_DIR");
1010

11-
let (_lib, snapshot) = std::env::var("FLUTTER_AOT_SNAPSHOT")
12-
.ok()
13-
.map(|aot_path| {
14-
unsafe { load_snapshot(&PathBuf::from(aot_path)) }
15-
.ok()
16-
.map(|(lib, snapshot)| (Some(lib), Some(snapshot)))
17-
.unwrap_or_default()
18-
})
19-
.unwrap_or_default();
11+
let mut args = Vec::with_capacity(1);
12+
13+
if let Some(snapshot) = std::env::var("FLUTTER_AOT_SNAPSHOT").ok() {
14+
if Path::new(&snapshot).exists() {
15+
args.push(format!("--aot-shared-library-name={}", snapshot));
16+
}
17+
}
2018

2119
let window = WindowBuilder::new().with_title("Flutter App Demo");
2220
let flutter = FlutterWindow::new(window).unwrap();
2321
let flutter = flutter.with_resource_context().unwrap();
2422

25-
flutter
26-
.start_engine(&PathBuf::from(asset_dir), &[], snapshot)
27-
.unwrap();
23+
flutter.start_engine(Path::new(&assets_dir), &args).unwrap();
2824

2925
flutter.run();
3026
}

0 commit comments

Comments
 (0)