ardazishvili / Sota

Editable generator of discrete structures for Godot 4
MIT License
31 stars 2 forks source link

Static build option #25

Closed HKunogi closed 2 months ago

HKunogi commented 2 months ago

Would be nice to have an option to build this statically inside the engine, so all templates and editors we build from source using custom engine build would include this module directly, built-in.

ardazishvili commented 2 months ago

At the moment I see no application for this feature, but implementation doesn't look too difficult.

Also, we have docs via GDExtension only from 4.3. Who knows, maybe static build will be useful somehow.

ardazishvili commented 2 months ago

I compiled single file as a module just to test how it should work. I consider only option where module's sources are out of godot project. There are couple things to solve:

  1. Different structure of sources, e.g. name of directory matters. From docs:
    
    /* register_types.h */

include "modules/register_module_types.h"

void initialize_summator_module(ModuleInitializationLevel p_level); void uninitialize_summator_module(ModuleInitializationLevel p_level); / yes, the word in the middle must be the same as the module folder name /

Also, there should be SCsub file and not SConstruct, but that's not complicated at all.
2. Paths to godot headers differ from godot_cpp headers.
  - Naive solution is to use preprocessor `#ifdef`'s in existing sources.
  - Another solution is to make abstraction layer. Actually, for some time I have an idea to abstract from godot or from specific version of godot. E.g. in case of godot::Vector3D there would be some abstract Vector3D which _mostly_ is an adaptor. At first stage it may only include code like following:

/Vector3D header file of Sota, client code will include it and not Godot header/

if defined(GODOT_CPP)

include "godot_cpp/.../.hpp"

else

include "some_native_godot_header/.../.h"

// adaptor may be defined here


If you have ideas let me know.
HKunogi commented 2 months ago

I did some tests making the SCsub and such, but requires going on the files with engine includes and do the conditional preprocessor checks to include either the gdextension headers or the actual engine headers directly. An example that may be noted is this module for lua. Besides it being compiled as static module on the engine build time, on the external folder, it does have a reference to the godot-cpp repository used for gd-extensions modules.

ardazishvili commented 2 months ago

Main difference from GDExtension so far: native c++ structures have different constness. Some signatures are also different