From 7b3c533d4222cdece633856151230ea2d3a9dda1 Mon Sep 17 00:00:00 2001 From: Matej Knopp Date: Wed, 14 Aug 2024 22:46:43 +0200 Subject: [PATCH] feat: always build in release mode by default (#19) --- native_toolchain_rust/lib/src/builder.dart | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/native_toolchain_rust/lib/src/builder.dart b/native_toolchain_rust/lib/src/builder.dart index 1763fee..d253e09 100644 --- a/native_toolchain_rust/lib/src/builder.dart +++ b/native_toolchain_rust/lib/src/builder.dart @@ -107,6 +107,7 @@ class RustBuilder { this.toolchain, required this.cratePath, required this.buildConfig, + this.release = true, this.assetName, this.useNativeManifest = true, this.dartBuildFiles = const ['hook/build.dart'], @@ -139,6 +140,9 @@ class RustBuilder { /// dependencies. Default value adds `hook/build.dart` as dependency. final List dartBuildFiles; + /// Whether to build in release mode. Default is `true` even for debug builds. + final bool release; + /// By default `native_toolchain_rust` expects `native_manifest.yaml` in /// package root in order to check for the required Rust version and also for /// `native_doctor` to work. If you don't want to include `native_manifest.yaml` @@ -186,6 +190,8 @@ class RustBuilder { await toolchain._checkNativeManifest(buildConfig: buildConfig); } + final effectiveBuildMode = release ? BuildMode.release : BuildMode.debug; + if (!buildConfig.dryRun) { await toolchain.toolchain.rustup.runCommand( [ @@ -197,7 +203,7 @@ class RustBuilder { manifestPath.toFilePath(), '-p', manifestInfo.packageName, - if (buildConfig.buildMode == BuildMode.release) '--release', + if (effectiveBuildMode == BuildMode.release) '--release', '--verbose', '--target', target.triple, @@ -215,7 +221,7 @@ class RustBuilder { final effectiveOutDir = outDir .resolve('${target.triple}/') - .resolve('${buildConfig.buildMode.name}/'); + .resolve('${effectiveBuildMode.name}/'); final asset = NativeCodeAsset( package: package,