mirror of
https://github.com/FyroxEngine/Fyrox.git
synced 2026-10-12 02:02:20 +00:00
ability to disable optimizations when exporting the project
This commit is contained in:
@@ -30,7 +30,11 @@ use std::{
|
||||
process::Stdio,
|
||||
};
|
||||
|
||||
pub fn build_package(package_name: &str, build_target: &str) -> std::process::Command {
|
||||
pub fn build_package(
|
||||
package_name: &str,
|
||||
build_target: &str,
|
||||
enable_optimization: bool,
|
||||
) -> std::process::Command {
|
||||
let mut process = utils::make_command("cargo-apk");
|
||||
process
|
||||
.stderr(Stdio::piped())
|
||||
@@ -39,8 +43,10 @@ pub fn build_package(package_name: &str, build_target: &str) -> std::process::Co
|
||||
.arg("--package")
|
||||
.arg(package_name)
|
||||
.arg("--target")
|
||||
.arg(build_target)
|
||||
.arg("--release");
|
||||
.arg(build_target);
|
||||
if enable_optimization {
|
||||
process.arg("--release");
|
||||
}
|
||||
process
|
||||
}
|
||||
|
||||
|
||||
@@ -91,6 +91,7 @@ struct ExportOptions {
|
||||
run_after_build: bool,
|
||||
open_destination_folder: bool,
|
||||
convert_assets: bool,
|
||||
enable_optimization: bool,
|
||||
}
|
||||
|
||||
impl Default for ExportOptions {
|
||||
@@ -106,6 +107,7 @@ impl Default for ExportOptions {
|
||||
run_after_build: false,
|
||||
open_destination_folder: true,
|
||||
convert_assets: true,
|
||||
enable_optimization: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -131,13 +133,16 @@ fn build_package(
|
||||
package_dir_path: &Utf8Path,
|
||||
target_platform: TargetPlatform,
|
||||
cancel_flag: Arc<AtomicBool>,
|
||||
enable_optimization: bool,
|
||||
) -> Result<(), String> {
|
||||
utils::configure_build_environment(target_platform, build_target)?;
|
||||
|
||||
let mut process = match target_platform {
|
||||
TargetPlatform::PC => pc::build_package(package_name),
|
||||
TargetPlatform::WebAssembly => wasm::build_package(package_dir_path),
|
||||
TargetPlatform::Android => android::build_package(package_name, build_target),
|
||||
TargetPlatform::PC => pc::build_package(package_name, enable_optimization),
|
||||
TargetPlatform::WebAssembly => wasm::build_package(package_dir_path, enable_optimization),
|
||||
TargetPlatform::Android => {
|
||||
android::build_package(package_name, build_target, enable_optimization)
|
||||
}
|
||||
};
|
||||
|
||||
let mut handle = match process.spawn() {
|
||||
@@ -252,6 +257,7 @@ fn export(
|
||||
package_dir_path,
|
||||
export_options.target_platform,
|
||||
cancel_flag,
|
||||
export_options.enable_optimization,
|
||||
)?;
|
||||
|
||||
match export_options.target_platform {
|
||||
|
||||
@@ -23,14 +23,16 @@ use cargo_metadata::Metadata;
|
||||
use fyrox::core::log::Log;
|
||||
use std::{ffi::OsStr, fs, path::Path, process::Stdio};
|
||||
|
||||
pub fn build_package(package_name: &str) -> std::process::Command {
|
||||
pub fn build_package(package_name: &str, enable_optimization: bool) -> std::process::Command {
|
||||
let mut process = utils::make_command("cargo");
|
||||
process
|
||||
.stderr(Stdio::piped())
|
||||
.arg("build")
|
||||
.arg("--package")
|
||||
.arg(package_name)
|
||||
.arg("--release");
|
||||
.arg(package_name);
|
||||
if enable_optimization {
|
||||
process.arg("--release");
|
||||
}
|
||||
process
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,10 @@ use cargo_metadata::camino::Utf8Path;
|
||||
use fyrox::core::log::Log;
|
||||
use std::{ffi::OsStr, path::Path, process::Stdio};
|
||||
|
||||
pub fn build_package(package_dir_path: &Utf8Path) -> std::process::Command {
|
||||
pub fn build_package(
|
||||
package_dir_path: &Utf8Path,
|
||||
enable_optimization: bool,
|
||||
) -> std::process::Command {
|
||||
let mut process = utils::make_command("wasm-pack");
|
||||
process
|
||||
.stderr(Stdio::piped())
|
||||
@@ -31,6 +34,11 @@ pub fn build_package(package_dir_path: &Utf8Path) -> std::process::Command {
|
||||
.arg(package_dir_path)
|
||||
.arg("--target")
|
||||
.arg("web");
|
||||
if enable_optimization {
|
||||
process.arg("--release");
|
||||
} else {
|
||||
process.arg("--dev");
|
||||
}
|
||||
process
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user