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 option to import resources using a command line argument #1362

Closed
qarmin opened this issue Aug 13, 2020 · 13 comments · Fixed by godotengine/godot#90431
Closed

Add option to import resources using a command line argument #1362

qarmin opened this issue Aug 13, 2020 · 13 comments · Fixed by godotengine/godot#90431

Comments

@qarmin
Copy link

qarmin commented Aug 13, 2020

Describe the project you are working on:
I'm working on PR which import and check project to test PR - godotengine/godot#40994

Describe the problem or limitation you are having in your project:
I can't find(because probably doesn't exists) any flag, that would only import all files(scenes, resources, images etc...)

Describe the feature / enhancement and how it helps to overcome the problem or limitation:
Now I use timeout to prevent godot from quiting during importing, which sadly doesn't always work in CI

timeout 25s godot -e

but this isn't also universal solution, because a lot of projects have a lot of assets which is impossible to measure time which is needed to import all files.

So better idea is to add new flag e.g. --import-only which would import files and after that just close Godot.
It would be great if the editor wasn't even running.

godot --import-only

Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams:
The best if it would work without needing initializing all graphics editor components, but I know that this isn't now possible, because code which imports resources exists in EditorFileSystem

The easiest way to do this is to save to variable if user used --import-only option and check it in EditorFileSystem::_notification inside NOTIFICATION_EXIT_TREE if is set, so it may wait until all files will be imported.

If this enhancement will not be used often, can it be worked around with a few lines of script?:
Like I wrote, it can be used timeout but it is really really really bad solution for any project greater than 1 image.

Is there a reason why this should be core and not an add-on in the asset library?:
It would be very helpful for all people wanting to integrate their projects into CI

@Calinou
Copy link
Member

Calinou commented Aug 13, 2020

godot --editor --quit should do the job in theory. (--quit exits the engine after one iteration has finished running.)

@qarmin
Copy link
Author

qarmin commented Aug 13, 2020

In smaller project it usually works, but with https://github.com/godotengine/tps-demo it close after 2/3 second, which is impossible import all files because normal importing take ~30 minutes.

@Xrayez
Copy link
Contributor

Xrayez commented Aug 13, 2020

I vote yes! My legit use case godotengine/godot#39396 (comment).

@Calinou Calinou changed the title Add option to import scenes/resources by command Add option to import scenes/resources using a command line argument Sep 13, 2020
@Calinou Calinou changed the title Add option to import scenes/resources using a command line argument Add option to import resources using a command line argument Sep 13, 2020
@realkotob
Copy link

realkotob commented Oct 22, 2020

I support this.

I've worked the headless godot a lot and I found that godot --editor --quit is very unreliable.

Additionally, on gitlab the community CI runners don't cache pipelines when it's told to because the runners are shared and don't share their caches together. If there was an import CLI argument then at least I could try to have the cache be shared across jobs within the same pipeline.

@knightofiam
Copy link

I would like to see this implemented to avoid spurious CI errors when exporting via Godot headless:

ERROR: get_dependencies: Cannot open file 'res://.import/blahblahblahblah.sample At: core/io/resource_format_binary.cpp:1048

It reports an error because it can't find the .import folder (not under source control), but then it auto-generates it after the so-called "error" before exporting.

@Yazir
Copy link

Yazir commented May 18, 2022

I second @knightofiam 's comment.

Projects using build pipelines, without ./.import in repo are facing this issue. Build works, but with an error for each asset.

@aaronfranke
Copy link
Member

I ran into this issue today. I tried ./godot --headless --editor --quit but then a later CI step has many errors like this:

ERROR: Failed loading resource: res://whatever. Make sure resources have been imported by opening the project in the editor at least once.
   at: _load (core/io/resource_loader.cpp:221)

So, as mentioned above, --editor --quit doesn't seem to be working as expected.

@PoolloverNathan

This comment was marked as off-topic.

@Calinou
Copy link
Member

Calinou commented Jan 11, 2023

@PoolloverNathan Please don't bump issues without contributing significant new information. Use the 👍 reaction button on the first post instead.

@mogoh
Copy link

mogoh commented Dec 21, 2023

What is the best workaround for this issue for now?
The best that I came up with is commit .godot/imported/* and *.translation.

timeout 25s godot -e does not work in CI because it requries XServer which is not available in CI.

@Calinou
Copy link
Member

Calinou commented Dec 21, 2023

timeout 25s godot -e does not work in CI because it requries XServer which is not available in CI.

With Godot 4, timeout 25s godot --headless -e will work 🙂

With Godot 3, use a Linux headless editor binary which can be downloaded from the official website.

@juse4pro
Copy link

We had the same problem and opening the project via command line in editor mode with --quit-after 2 was solving it.
--quit-after 1 quits too early. Related to this: godotengine/godot#77508 (which is closed but has to be re-opened)

@mogoh
Copy link

mogoh commented Dec 21, 2023

@Calinou

With Godot 4, timeout 25s godot --headless -e will work 🙂

I did not test it right.
Yes, --headless generally works.
Thanks.

However, I noticed, that rebuilding the cache can cause other problems.
A font gets reimported which leads to a new UID, deleted fallbacks, and reference problems.
However, this might be topic for another issue.
I keep committing the cache for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.