Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a run SCons option to run the engine binary after a build #102550

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Calinou
Copy link
Member

@Calinou Calinou commented Feb 7, 2025

This makes the compile-test cycle faster for engine contributors, as you no longer need to manually run the engine binary after it's done compiling. This can also avoid distractions that occur when you leave the engine building in the background and forget to run the project/editor afterwards.

Examples

# Run project manager.
scons run=-p

# This passes "yes" as a positional argument to Godot, which Godot won't do anything about, so it'll act the same as above unless CWD is a project folder.
scons run=yes

# Open a project in the editor.
# You can use `~` as a standin for the `$HOME` environment variable.
# This works on all platforms regardless of shell as this PR handles `~` specifically.
scons run=/path/to/project.godot

# Run a project directly.
scons run="--path /path/to/project"

Preview

$ scons run="--path ~/Documents/Godot/test-tablet --quit"
scons: Reading SConscript files ...
Using SCons-detected MSVC version 14.3, arch x86_64
Building for platform "windows", architecture "x86_64", target "editor".
Checking for C header file mntent.h... (cached) no
scons: done reading SConscript files.
scons: Building targets ...
scons: `.' is up to date.
scons: done building targets.
--------------------------------------------------------------------------------
Build successful, running: bin\godot.windows.editor.x86_64.exe --path ~/Documents/Godot/test-tablet --quit
--------------------------------------------------------------------------------
Godot Engine v4.4.beta.custom_build.eee01066b (2025-02-07 17:57:42 UTC) - https://godotengine.org
Requested V-Sync mode: Disabled
OpenGL API 3.3.0 NVIDIA 566.36 - Compatibility - Using Device: NVIDIA - NVIDIA GeForce RTX 4090

INFO: Time elapsed: 00:00:09.72

TODO

  • Figure out if it's possible to move the Time elapsed calculation and text to be printed before the engine starts. This way, we don't take the engine runtime into account.

@Calinou Calinou added this to the 4.x milestone Feb 7, 2025
@Calinou Calinou requested review from a team as code owners February 7, 2025 18:12
@Calinou Calinou force-pushed the scons-add-run-option branch 6 times, most recently from 0a0ee5c to cdb6d53 Compare February 7, 2025 18:18
print("-" * 80 + f"\nBuild successful, running: {env['bin_path']} {env['run']}\n" + "-" * 80)
try:
# Allow using `~` as a shorthand for `$HOME` on all platforms.
subprocess.run([env["bin_path"], *env["run"].replace("~", os.environ["HOME"]).split()], shell=True)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be possible to run a detached process; this would solve your "Time elapsed" problem. I don't know if it's possible to make it automatically attach to the current terminal session though.

Copy link
Member Author

@Calinou Calinou Feb 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was my original idea, but I've often witnessed subpar UX with detached processes. For instance, if you press Ctrl + C in the terminal, it won't close the detached process like you'd expect.

@Calinou Calinou force-pushed the scons-add-run-option branch from cdb6d53 to e6c5234 Compare February 7, 2025 19:29
This makes the compile-test cycle faster for engine contributors,
as you no longer need to manually run the engine binary after it's
done compiling. This can also avoid distractions that occur when
you leave the engine building in the background and forget to run
the project/editor afterwards.
@Calinou Calinou force-pushed the scons-add-run-option branch from e6c5234 to e232d1b Compare February 8, 2025 16:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a run option to SCons to automatically run an engine binary after it was compiled
2 participants