Skip to content

Allow searching LIBRARY_PATH with build_library=no #1807

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

vilhalmer
Copy link

Currently when building a downstream project with build_library=no, the library is still assumed to be present in godot-cpp/bin/ from a previous build. With this change, allow the linker to search the system (LIBRARY_PATH) for it. When build_library=yes, the current behavior of passing the entire path to the linker is retained, since in that case you definitely intended to use the newly-built version.

This change allows more flexibility in the build process of downstream projects: while they still need to have the godot-cpp submodule present for the SConscript, the library can more easily be built as part of a previous step or even preinstalled into the build environment. My specific goal is to save build time in CI with multiple GDExtensions that all use the same version of godot-cpp.

>> scons verbose=yes build_library=no
scons: Reading SConscript files ...
Auto-detected 16 CPU cores available for build parallelism. Using 15 cores by default. You can override it with the -j argument.
Building for architecture x86_64 on platform linux
scons: done reading SConscript files.
…
g++ -o demo/addons/mylib/bin/linux64/libmyliblinux.template_debug.x86_64.so -Wl,-R,'$ORIGIN' -m64 -march=x86-64 -fvisibility=hidden -s -shared -Wl,-rpath=\$ORIGIN src/register_types.os src/mylib.os src/gen/doc_data.gen.os -Lgodot-cpp/bin -lgodot-cpp.linux.template_debug.x86_64
scons: done building targets.

I'm no scons expert so there may be a more idiomatic approach to this. It does technically have a side effect: if a shared library version of godot-cpp somehow existed on the system, it would be preferred because scons has no way to force a given library to be used statically. In practice, this will never happen.

@vilhalmer vilhalmer requested a review from a team as a code owner June 25, 2025 17:04
Instead of assuming the library is already present in bin/ when asking
not to build it, allow the linker to search the system for it as well.
@vilhalmer vilhalmer force-pushed the allow-library-search-path branch from b2df774 to f0e0986 Compare June 26, 2025 14:06
@vilhalmer
Copy link
Author

Tweaked so that the compiledb can still be generated with just the downstream project's code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant