Readd shared library module compilation docs#11820
Readd shared library module compilation docs#11820dementive wants to merge 1 commit intogodotengine:masterfrom
Conversation
| and as a shared library when passing ``summator_shared=yes``. | ||
|
|
||
| Finally, you can even speed up the build further by explicitly specifying your | ||
| shared module as target in the SCons command: |
There was a problem hiding this comment.
| shared module as target in the SCons command: | |
| shared module as the target in the SCons command: |
| # Static compilation | ||
| module_env.add_source_files(env.modules_sources, sources) | ||
|
|
||
| Now by default ``scons`` command will build our module as part of Godot's binary |
There was a problem hiding this comment.
| Now by default ``scons`` command will build our module as part of Godot's binary | |
| Now by default the ``scons`` command will build our module as part of Godot's binary |
| ./bin/godot* | ||
|
|
||
| .. note:: | ||
| You have to ``export`` the environment variable. Otherwise, |
There was a problem hiding this comment.
| You have to ``export`` the environment variable. Otherwise, | |
| You have to ``export`` the environment variable. Otherwise, |
|
|
||
|
|
||
| On top of that, it would be nice to be able to select whether to compile our | ||
| module as shared library (for development) or as a part of the Godot binary |
There was a problem hiding this comment.
| module as shared library (for development) or as a part of the Godot binary | |
| module as a shared library (for development) or as a part of the Godot binary |
|
|
||
| # LIBPATH and LIBS need to be set on the real "env" (not the clone) | ||
| # to link the specified libraries to the Godot executable. | ||
|
|
|
|
||
| env.Append(LIBPATH=['#bin']) | ||
|
|
||
| # SCons wants the name of the library with it custom suffixes |
There was a problem hiding this comment.
| # SCons wants the name of the library with it custom suffixes | |
| # SCons wants the name of the library with its custom suffixes |
| # Don't inject Godot's dependencies into our shared library. | ||
| module_env['LIBS'] = [] | ||
|
|
||
| # Required for symbols from godot to link when rebuilding shared library. |
There was a problem hiding this comment.
| # Required for symbols from godot to link when rebuilding shared library. | |
| # Required for symbols from Godot to link when rebuilding shared library. |
|
|
||
|
|
||
| Once compiled, we should end up with a ``bin`` directory containing both the | ||
| ``godot*`` binary and our ``libsummator*.so``. However given the .so is not in | ||
| a standard directory (like ``/usr/lib``), we have to help our binary find it | ||
| during runtime with the ``LD_LIBRARY_PATH`` environment variable: |
There was a problem hiding this comment.
Remove extraneous blank line:
| Once compiled, we should end up with a ``bin`` directory containing both the | |
| ``godot*`` binary and our ``libsummator*.so``. However given the .so is not in | |
| a standard directory (like ``/usr/lib``), we have to help our binary find it | |
| during runtime with the ``LD_LIBRARY_PATH`` environment variable: | |
| Once compiled, we should end up with a ``bin`` directory containing both the | |
| ``godot*`` binary and our ``libsummator*.so``. However given the .so is not in | |
| a standard directory (like ``/usr/lib``), we have to help our binary find it | |
| during runtime with the ``LD_LIBRARY_PATH`` environment variable: |
|
|
||
|
|
||
| On top of that, it would be nice to be able to select whether to compile our |
There was a problem hiding this comment.
Remove extraneous blank line:
| On top of that, it would be nice to be able to select whether to compile our | |
| On top of that, it would be nice to be able to select whether to compile our |
Calinou
left a comment
There was a problem hiding this comment.
Should be good to merge after applying suggestions.
|
Closing this due to the lack of a response to reviews for over a month. If the original author wishes to update this please do so and @ me to re-open this PR. If another maintainer wishes to salvage this PR with another one, or commit to the branch, feel free to. I personally am not doing so due to my limited C++ experience, I wouldn't be able to update or maintain this in the future. |
Adds back the shared library custom module compilation documentation that was removed in 160aa37 and adds the missing parts that were making it not work.
The original documentation was flawed because it was missing the
-rdynamicflag (see: https://stackoverflow.com/a/24016413) but with it compiling as a shared library works as expected. I have been using this for about a year and a half now and it has continued to work the same without any problems.For me this is a core part of my workflow as it brings my compile times down to 0.5-2 seconds depending on the file but without it compiles take around 8-10 seconds because of the time it takes to link the full binary for every build. Would be great to have this documentation back up because hopefully someone smarter than me will see it in the future and work out how to get this to work on Windows too if that is even possible.