Building a godot game using a build-server?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Smetad_Anarkist

The documentation suggests ignoring the .import folder when checking in code in your version control system. But when I do that i get the error ERROR: Cannot open file 'res://.import/jingles_SAX02.ogg-d9c47f76611e11c44f637c07534d8749.oggstr'. when I build my game using a CI/CD pipeline.

What am I doing wrong?

:bust_in_silhouette: Reply From: Lopy

What am I doing wrong?

Your mistake, is that you believe the documentation. The documentation can, and will sometimes, be wrong, or at least misleading.


In all seriousness tho. The .import folder contains cache files, and can be considered part of the compilation process for your game. You could simply add it to the version control system, or add a command to regenerate it on your build server.

To do so, you will need to open the Editor on your project in your build server, with something like ./engine --editor --path ./folder/containing/project.godot./ --no-window.

This should be enough to generate the imports. If it isn’t, you can use get_editor_interface().get_resource_filesystem().scan() inside an EditorScript with the tool keyword, run from a Node with the tool keyword in the main scene of your project (the one that the Editor will open on launch).

To close the Editor, you can kill the process, or do a Engine.get_main_loop().quit() inside a/the Node with tool inside your main scene. In that case, use custom program arguments to avoid soft locking yourself out of the project.


Example:

tool
extends Node
# To be placed in the main scene of the project

func _ready():
    if !OS.has_feature("standalone"): # The Editor
        if "--custom-arg-compile-import" in OS.get_cmdline_args():
            # Force load if necessary
            #var force_load_script: EditorScript= load(...)
            #force_load_script.new()._run()
            
            # Quit
            Engine.get_main_loop().quit()

The loaded script (probably not necessary):

tool
extends EditorScript


func _run():
    get_editor_interface().get_resource_filesystem().scan()

The make target:

.PHONY: import

import:
	./engine --editor --path ./path/to/project.godot/folder/ --no-window --custom-arg-compile-import 2> /dev/null

Your mistake, is that you believe the documentation. The documentation can, and will sometimes, be wrong, or at least misleading.

You have a point, the documentation does also suggest that export_presets.cfg should be excluded from version control, and that would make building your game with a build server very challenging.

Smetad_Anarkist | 2022-09-18 07:44