feat: commit code

This commit is contained in:
mrxiaozhuox committed 2022-02-11 16:54:35 +08:00
1 parent 9d8b95dfc4
commit 936fefbbf8
1 file changed
+20 -13
+20 -13
View File
@@ -5,6 +5,7 @@ use crate::{
}; };
use std::{ use std::{
fs::{copy, create_dir_all, remove_dir_all}, fs::{copy, create_dir_all, remove_dir_all},
panic,
path::PathBuf, path::PathBuf,
process::Command, process::Command,
}; };
@@ -62,9 +63,6 @@ pub fn build(config: &CrateConfig) -> Result<()> {
// [2] Establish the output directory structure // [2] Establish the output directory structure
let bindgen_outdir = out_dir.join("assets").join("dioxus"); let bindgen_outdir = out_dir.join("assets").join("dioxus");
// [3] Bindgen the final binary for use easy linking
let mut bindgen_builder = Bindgen::new();
let release_type = match config.release { let release_type = match config.release {
true => "release", true => "release",
false => "debug", false => "debug",
@@ -80,16 +78,25 @@ pub fn build(config: &CrateConfig) -> Result<()> {
.join(format!("{}.wasm", name)), .join(format!("{}.wasm", name)),
}; };
bindgen_builder let bindgen_result = panic::catch_unwind(move || {
.input_path(input_path) // [3] Bindgen the final binary for use easy linking
.web(true)? let mut bindgen_builder = Bindgen::new();
.debug(true)
.demangle(true) bindgen_builder
.keep_debug(true) .input_path(input_path)
.remove_name_section(false) .web(true).unwrap()
.remove_producers_section(false) .debug(true)
.out_name(&dioxus_config.application.name) .demangle(true)
.generate(&bindgen_outdir)?; .keep_debug(true)
.remove_name_section(false)
.remove_producers_section(false)
.out_name(&dioxus_config.application.name)
.generate(&bindgen_outdir).unwrap();
});
if bindgen_result.is_err() {
panic!("Bindgen build failed");
}
// this code will copy all public file to the output dir // this code will copy all public file to the output dir
let copy_options = fs_extra::dir::CopyOptions { let copy_options = fs_extra::dir::CopyOptions {