briansemrau / godot_box2d

A C++ module that integrates the Box2D library with the Godot game engine by providing nodes for standard Box2D objects.
MIT License
44 stars 4 forks source link

Rebuilding the module is slow #24

Open briansemrau opened 3 years ago

briansemrau commented 3 years ago

Using VS 2019 on Windows 10.

Right now, making changes and rebuilding to test takes just enough time to be annoying.

It might be possible to speed this process up following documentation here: https://docs.godotengine.org/en/latest/development/cpp/custom_modules_in_cpp.html#improving-the-build-system-for-development

Box2D claims to not work as a shared library, but I don't know why. We build Box2D with SCons as part of this module so maybe it will be fine.

jordo commented 3 years ago

Box2D should work as a shared library, I have used it fine dynamically in other projects so I'm not sure why they would claim otherwise? I dunno, maybe something has changed.

In general, build time is something that's also being worked on as well by a few godot devs (there's a side effort to port scons to meson). But most of my build time is scons scanning dependencies.

I have tried https://docs.godotengine.org/en/latest/development/cpp/custom_modules_in_cpp.html#improving-the-build-system-for-development to just build a module as a shared library, but eventually gave up and just included it statically in the engine. My build time for a module change is about 10s, which is slightly underneath my own threshhold to optimize further. But ya i hear ya.

jordo commented 3 years ago

also make sure to pass "-j", "X" to scons, cause i dont think scons picks up cpu core's automatically

Xrayez commented 3 years ago

Yeah, compiling statically is known to be slow (especially on Windows at parse-time due to Python I/O slowness), but I wouldn't say it's that slow to my taste (I take more time to think about my algorithm's correctness before I decide to compile, and I use VSCode C++ features that report problems beforehand).

Otherwise, there's GDNative approach to use Box2D as a dynamic library, but now you'll have to think about writing your own build scripts and deal with initialization steps like setting up GDNative library in the editor.

Pick your own poison, as they say. This is why I prefer to use C++ modules because they are much easier to maintain, slow compilation times are quite negligible in comparison.

Also, if you ever plan to integrate Box2D as a physics backend, then I don't think it's possible to use GDNative to achieve this.

In general, build time is something that's also being worked on as well by a few godot devs (there's a side effort to port scons to meson). But most of my build time is scons scanning dependencies.

This is because SCons's main principle is correctness rather than performance. I rarely see a build borked by SCons, and I like the flexibility of it because everything is Python. 🙂