Skip to content

Commit

Permalink
feat: always build in release mode by default (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
knopp authored Aug 14, 2024
1 parent 301d148 commit 7b3c533
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions native_toolchain_rust/lib/src/builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down Expand Up @@ -139,6 +140,9 @@ class RustBuilder {
/// dependencies. Default value adds `hook/build.dart` as dependency.
final List<String> 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`
Expand Down Expand Up @@ -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(
[
Expand All @@ -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,
Expand All @@ -215,7 +221,7 @@ class RustBuilder {

final effectiveOutDir = outDir
.resolve('${target.triple}/')
.resolve('${buildConfig.buildMode.name}/');
.resolve('${effectiveBuildMode.name}/');

final asset = NativeCodeAsset(
package: package,
Expand Down

0 comments on commit 7b3c533

Please sign in to comment.