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

Document how the Godot binary loads projects, and how to load external Godot projects from a Godot launcher with OS.execute #3593

Open
tx350z opened this issue May 25, 2020 · 6 comments
Labels
area:manual Issues and PRs related to the Manual/Tutorials section of the documentation content:new page Issues and PRs related to creation of new documentation pages for new or undocumented features enhancement

Comments

@tx350z
Copy link

tx350z commented May 25, 2020

Godot version:

v3.2.stable.official

OS/device including version:

N/A

Issue description:

Running "app1" in the Godot editor. App1 calls OS.execute to launch "app2.exe" which is another Godot app created using Windows Desktop export template with debug turned off. Instead of running app2.exe, a second instance of app1 ran.

When I export app1 using the Windows Desktop export template and run the app1.exe, OS.execute launches the correct app (app2.exe)

Steps to reproduce:

  1. Create a simple project and export to "path/app2.exe" using Windows Desktop export template with debug turned off. Verify this app runs correctly when launched manually.

  2. Create a second simple projected called "app1" with a button that when clicked calls OS.execute("path/app2.exe",[],false).

  3. Run app1 in the editor, click the button. A second instance of app1 appears.

  4. Export app1 to "path/app1.exe" using the Windows Desktop export template with debug turned off.

  5. Launch app1.exe and click the button. app2.exe is executed correctly.

Minimal reproduction project:

@Calinou
Copy link
Member

Calinou commented May 25, 2020

If you exported both executables in the project root folder, maybe this is because the project data takes priority over the PCK file?

Also, did you check the "embed PCK in executable" option in the export dialog? This is a known bug which has been fixed in the 3.2.2 betas.

@tx350z
Copy link
Author

tx350z commented May 25, 2020

Thanks. Embedding the PCK is a good idea but did not solve the problem. The interesting thing is if the target app is not a Godot app, the correct binary is run. The correct binary is also run if I export both apps to Windows and run the exe. So it has to be a bug in the editor/debugger.

I'm putting together very simple projects to demonstrate the problem. Will add the zips when I can.

@akien-mga
Copy link
Member

The correct binary is properly run, but Godot binaries are all the same, it's the presence of a .pck or project.godot file in the current folder which determines which project will run.

If you want to start a different project from your current Godot project, you can even reuse the current Godot binary (OS.get_executable_path() -- provided it's a project for the same Godot version), but you need to give it the --main-pack argument pointing to the .pck you want to load. Otherwise it will load your current project's project.godot from your current working directory.

@akien-mga akien-mga transferred this issue from godotengine/godot May 25, 2020
@akien-mga
Copy link
Member

Moving this to godot-docs as we should add a page or section related to the behavior of the Godot binary when loading projects, and how to run external Godot-based projects from a Godot application (e.g. game launcher).

@akien-mga akien-mga changed the title OS.execute run in the editor executes the wrong binary target if the target is another Godot app Document how the Godot binary loads projects, and how to load external Godot projects from a Godot launcher with OS.execute May 25, 2020
@akien-mga
Copy link
Member

@tx350z
Copy link
Author

tx350z commented May 26, 2020

I'm not trying to disagree, just understand why OS.execute() behaves differently when called by an app run in the editor and when called by the same app once compiled.

Attached is a zip containing three folders; two Godot project folders, and a folder for holding exported Windows binaries.

  1. Unzip to a folder of your choosing.
  2. Import osexec_child project into Godot.
  3. Do a Windows export (note Embed PCK is checked). Verify ../osexec_bins/osexec_child.exe runs correctly.
  4. Click Project/Exit to Project List.
  5. Import osexec_parent project into Godot and run it (F5)
  6. Clicking the button launches a second instance of oexec_parent, not ../osexec_bin/osexec_child.exe
  7. Do a Windows export of osexec_parent (Embed PCK is checked)
  8. Run ../osexec_bins/osexec_parent.exe
  9. Clicking the button correctly launches osexec_child.exe

Many thanks for all the great work you folks do.

osexec_oddness.zip

@skyace65 skyace65 added content:new page Issues and PRs related to creation of new documentation pages for new or undocumented features area:manual Issues and PRs related to the Manual/Tutorials section of the documentation labels Dec 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:manual Issues and PRs related to the Manual/Tutorials section of the documentation content:new page Issues and PRs related to creation of new documentation pages for new or undocumented features enhancement
Projects
None yet
Development

No branches or pull requests

4 participants