Zylann / godot_voxel

Voxel module for Godot Engine
MIT License
2.72k stars 251 forks source link

Building templates for mono version #573

Open stevenpi opened 1 year ago

stevenpi commented 1 year ago

Hi there!

I've recently started to play around with this plugin and fell in love with it. There is currently only one dealbreaker to me. The export template for the mono version is missing, therefore I cannot export the project (btw, i'm using windows).

At first I tried to get one of the prebuilt templates for the mono version, but unfortunately it's missing with the note "(likely not available, they broke in Godot 4, help is needed to fix them" in the docs. Therefore I wanted to build the template by myself with the latest version of this repo.

So I installed visual studio community, installed scons with python (version 3.11.4) and tried the command scons platform=windows target=template_debug arch=x86_32 in powershell. This returns me the error

scons: Reading SConscript files ...

scons: warning: Calling missing SConscript without error is deprecated.
Transition by adding must_exist=False to SConscript calls.
Missing SConscript 'D:\PROJETS\INFO\GODOT\Engine\godot_cpp_fork\SConstruct'
File "D:\GitProjectsOtherSources\godot_voxel\SConstruct", line 22, in <module>
TypeError: 'NoneType' object does not support item assignment:
  File "D:\GitProjectsOtherSources\godot_voxel\SConstruct", line 36:
    env_vars.Update(env)
  File "C:\Users\Link\AppData\Roaming\Python\Python311\site-packages\SCons\Variables\__init__.py", line 210:
    env[option.key] = values[option.key]

Judging from the error I'm guessing, that I'm missing some kind of env file or something alike.

Could anyone point me into the right direction? Also, is it even possible to build export templates for the monoversion, as the documentation states that it broke in godot 4?

Zylann commented 1 year ago

Regarding export templates missing, the reason is indeed this: https://github.com/Zylann/godot_voxel/blob/master/doc/source/getting_the_module.md#c-suppport

Regarding the error you get, I have never seen this before. I have no idea how you are getting this, it doesnt look related to the module. Maybe you could ask on Godot's RocketChat for more information?

Missing SConscript 'D:\PROJETS\INFO\GODOT\Engine\godot_cpp_fork\SConstruct'
File "D:\GitProjectsOtherSources\godot_voxel\SConstruct", line 22, in <module>
TypeError: 'NoneType' object does not support item assignment:
  File "D:\GitProjectsOtherSources\godot_voxel\SConstruct", line 36:

From seeing this, I can only assume you have put the module in the wrong place? Usually modules should be under the modules/ folder. In the case of the voxel module, its folder must be named voxel. But what's really weird is D:\PROJETS\INFO\GODOT\Engine\godot_cpp_fork\SConstruct, I dont know where you got that path from, but this is folders on my own computer xD

Edit: ok looks like you got it from the SConstruct file at the root of the module. This file is not supposed to be run like this:

# This is the entry point for SCons to build this engine as a GDExtension.
# To build as a module, see `SCsub`.

You're building a module, not a GDExtension, so don't run scons from within this folder. You have to recompile Godot itself. You must follow these steps: https://voxel-tools.readthedocs.io/en/latest/getting_the_module/#building-yourself Download the Godot source code at the version branch you want, then put the module under the modules/ folder and rename it voxel. Then you should be able to use SCons from the root directory of the Godot repo. But since you also want C# you also need to follow the steps specific to it https://github.com/Zylann/godot_voxel/blob/master/doc/source/getting_the_module.md#c-suppport

stevenpi commented 1 year ago

I see, thanks for the clarification. now I built godot from source with the module, and also built the .NET assemblies as well as the export template binary. I got it working now even with accessible c# classes, which is more than I asked for :D Also the project exports now, after i've compiled the templates as well from source. There still seems to be an issue in the export itself, but I think this is an error on my side which I can resolve (the generated map is not showing up in the exported project).

If this becomes a bigger problem, i'll open a new issue.

Since I will probably forget what I did and will need to do it again, here is what i did:

# Build editor binary
scons p=windows target=editor module_mono_enabled=yes
# Build export templates
scons p=windows target=template_debug module_mono_enabled=yes
scons p=windows target=template_release module_mono_enabled=yes

# Generate glue sources
bin/godot.windows.editor.x86_64.mono --generate-mono-glue modules/mono/glue
# Build .NET assemblies
./modules/mono/build_scripts/build_assemblies.py --godot-output-dir=./bin --godot-platform=windows

NOTE: might have to setup a custom nuget source. Which is creating a folder in %APPDATA%/nuget. Also need to copy the compiled .nupkg files godot repo\bin\GodotSharp\Tools\nupkgs and follow the nuget source section in the docs.