-
-
Notifications
You must be signed in to change notification settings - Fork 19.5k
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
Ignore Godot Engine source from Godot projects by default #28343
Conversation
When Godot Engine is added as a submodule of a game project, various engine's build related obj files are falsely treated as assets, leading to a spam of errors related to importing. Rationale: adding Godot as a submodule allows to keep track the exact Godot version used by the project at the moment of development, and allows to symlink any custom C++ modules associated with the project for compiling.
I don't think that's a common use case to add the engine code inside the project folder. For your use case, you can just have this structure:
|
Hmm yes this is what I've been doing so far, the problem with such structure is that I have to sync the Godot version (commit hash) with the project. So far I've done this via #!/bin/sh
#
# Appends Godot Engine version in each commit
#
GODOT_VERSION=$(godot --version)
BUILD_NAME="Xrayez"
# Ensure that version contains build name
if [[ $GODOT_VERSION = *"$BUILD_NAME"* ]]; then
# Append only if not already present in the commit message
grep -qs $BUILD_NAME "$1" || printf "\n$GODOT_VERSION" >> "$1"
else
# Build name is not configured
exit -1
fi So that each game project commit "keeps track" of what Godot version was used during developing:
But now I've figured that I could actually add the whole godot as a submodule, and this should already track the commit hash that way, plus there's a bonus to easily link custom modules to the engine inside game project. Plus adding a simple and empty |
Checking out other commits within a game project would also force to checkout associated Godot version, and this even can be done automatically depending on the git configuration. |
Your git repository can be initialized in the parent folder in the structure I exemplified, so you can have access to the commit hash from the Godot submodule. |
Ok if you say that's possible I'll try that... but there's just another layer of usability with this... I was thinking that maybe a game project could have it's own env = Environment()
# Compile Godot (with custom modules)
env.SConscript(['godot/SConstruct'])
# Compile GDNative plugins/modules
env.SConscript('modules/gdnative/a/SConstruct')
env.SConscript('modules/gdnative/b/SConstruct')
env.SConscript('modules/gdnative/c/SConstruct') See Scons Hierarchical builds. Would you say that I also need to keep GDNative modules outside game project source? Doesn't seem intuitive to me. And with setup like this it would be really, really convenient to compile it all from within a game project root folder with a regular scons command:
Btw, I haven't managed compiling godot that way yet, seems like some paths are absolute there in Godot's |
I think I misread your message, I thought you suggested that having an ability to initialize Godot as a submodule outside the project is possible (which wouldn't make sense though):
Having a simple direct access to commit hash in the parent directory is very similar to what I've been doing so far, so this defeats the purpose for me. Anyways I think I've come up with another structure that would allow the editor to ignore Godot's build files while still benefiting from having godot as a submodule:
I still think such a simple enhancement wouldn't hurt anything. This is probably the smallest PR in Godot with such a lengthy discussion. 😄 |
Ok, the workaround is the following (assuming the above structure and within game project's root): git submodule add --name godot https://github.com/godotengine/godot godot/engine` Notice Now, all you have to do is to create #!/usr/bin/env python3
import os
MODULES_DIR = "modules/"
TARGET_DIR = "godot/engine/modules/"
for module in os.listdir(MODULES_DIR):
# Relative path to module(s)
path_to_module = os.path.relpath(os.path.join(MODULES_DIR, module), TARGET_DIR)
path_to_target = os.path.join(TARGET_DIR, module)
os.symlink(path_to_module, path_to_target, True) Benefits:
I feel like this could be part of documentation. Closing this as I've found the solution to my problem and so far it works, thanks for reading. 😛 |
FWIW, I interpreted @akien-mga's structure suggestion as:
(i.e. the |
@follower yeah this could work too, yet with the Game folder being already initialized as git repository this would involve moving files around and could turn out a lot of work to fix a simple nuance. 😅 |
Ok, I got this structure now, given all the suggestions: So all files related to the actual build process are at the root, this allowed me to clean up the project itself and get rid of many There's one inconvenience with this, namely if you symlink the modules from
|
Jump To Workaround
When Godot Engine is added as a submodule of a game project, various engine's build related obj files are falsely treated as assets, leading to a spam of errors related to importing.
Rationale: adding Godot as a submodule allows to keep track the exact Godot version used by the project at the moment of development, and allows to symlink any custom C++ modules associated with the project for compiling.