@@ -11,6 +11,7 @@ struct RawPackageOptions {
1111 targets : Array [String ]
1212 output : String?
1313 build : Bool
14+ release : Bool
1415 dry_run : Bool
1516 sign : Bool
1617 notarize : Bool
@@ -32,6 +33,7 @@ struct PackagePlan {
3233 targets : Array [String ]
3334 output : String
3435 build : Bool
36+ release : Bool
3537 base_dir : String
3638 frontend_dist : String?
3739 entry_paths : Array [String ]
@@ -72,7 +74,8 @@ pub fn command() -> @argparse.Command {
7274 "package",
7375 about="Package a Proton application",
7476 flags=[
75- FlagArg ("no-build", about="Reuse an existing release build"),
77+ FlagArg ("no-build", about="Reuse an existing package build"),
78+ FlagArg ("release", about="Build and package the release output"),
7679 FlagArg ("dry-run", about="Print the resolved package plan"),
7780 FlagArg ("sign", about="Sign the packaged application"),
7881 FlagArg (
@@ -201,6 +204,8 @@ fn package_options_from_matches(
201204 | (None with notarize = false ),
202205 "no-build"? : Some (no_build)
203206 | (None with no_build = false ),
207+ "release"? : Some (release)
208+ | (None with release = false ),
204209 "dry-run"? : Some (dry_run)
205210 | (None with dry_run = false ),
206211 "sign"? : Some (sign)
@@ -216,6 +221,7 @@ fn package_options_from_matches(
216221 targets,
217222 output: output.get(0),
218223 build: !no_build,
224+ release,
219225 dry_run,
220226 sign: sign || notarize,
221227 notarize,
@@ -386,6 +392,7 @@ async fn build_package_plan(
386392 targets,
387393 output,
388394 build: raw.build,
395+ release: raw.release,
389396 base_dir,
390397 frontend_dist,
391398 entry_paths,
@@ -618,6 +625,8 @@ fn print_package_plan(plan : PackagePlan, dry_run : Bool) -> Unit {
618625 println(" sign binaries: " + sign_binaries)
619626 let build = if plan.build { "yes" } else { "no" }
620627 println(" build: " + build)
628+ let build_mode = if plan.release { "release" } else { "debug" }
629+ println(" build mode: " + build_mode)
621630 println(" sign: " + bool_text(plan.sign))
622631 println(" notarize: " + bool_text(plan.notarize))
623632}
@@ -634,12 +643,12 @@ fn bool_text(value : Bool) -> String {
634643///|
635644async fn execute_package_plan(plan : PackagePlan ) -> Unit {
636645 // Resolve the active runtime before any build work so a missing
637- // `proton_cli cef setup` fails fast instead of after a full release build.
646+ // `proton_cli cef setup` fails fast instead of after a full application build.
638647 let runtime = read_active_runtime(plan.workspace_root)
639648 if plan.build {
640- run_release_build (plan)
649+ run_package_build (plan)
641650 }
642- let executable = match find_release_executable (plan) {
651+ let executable = match find_package_executable (plan) {
643652 Some (path) => path
644653 None =>
645654 raise PackagePlanError ::MissingExecutable (path=plan.build_target_dir)
@@ -657,8 +666,15 @@ async fn is_macos_host() -> Bool {
657666}
658667
659668///|
660- async fn run_release_build(plan : PackagePlan ) -> Unit {
661- let moon_args = ["--release", "--target-dir", plan.build_target_dir]
669+ async fn run_package_build(plan : PackagePlan ) -> Unit {
670+ // Keep local packaging fast by default. Distribution builds opt into the
671+ // Moon release mode explicitly through `proton_cli package --release`.
672+ let moon_args : Array [String ] = []
673+ if plan.release {
674+ moon_args.push("--release")
675+ }
676+ moon_args.push("--target-dir")
677+ moon_args.push(plan.build_target_dir)
662678 let old_rpath = @env.get_env_var("PROTON_PACKAGE_RPATH ")
663679 // Mach-O only. The link config reads this on darwin; the Linux branch
664680 // ignores it and keeps the absolute runtime rpath, which is what a
@@ -683,8 +699,13 @@ fn restore_package_env(name : String, value : String?) -> Unit {
683699}
684700
685701///|
686- async fn find_release_executable(plan : PackagePlan ) -> String? {
687- let root = @fsutil.resolve_path(plan.build_target_dir, "native/release/build")
702+ async fn find_package_executable(plan : PackagePlan ) -> String? {
703+ // `--no-build` must reuse the same build mode selected for this command.
704+ let build_mode = if plan.release { "release" } else { "debug" }
705+ let root = @fsutil.resolve_path(
706+ plan.build_target_dir,
707+ "native/" + build_mode + "/build",
708+ )
688709 let package_name = path_basename(plan.app_package)
689710 find_named_file(root, package_name + ".exe")
690711}
0 commit comments