From f0e0986b74dd3fd464b263a505c0a03afabedc05 Mon Sep 17 00:00:00 2001 From: Bill Doyle Date: Wed, 25 Jun 2025 12:35:02 -0400 Subject: [PATCH] Allow searching LIBRARY_PATH with build_library=no 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. --- tools/godotcpp.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/tools/godotcpp.py b/tools/godotcpp.py index fa78ecd15..13bebaac8 100644 --- a/tools/godotcpp.py +++ b/tools/godotcpp.py @@ -564,16 +564,25 @@ def _godot_cpp(env): library = None library_name = "libgodot-cpp" + env["suffix"] + env["LIBSUFFIX"] + default_args = [] + if env["build_library"]: library = env.StaticLibrary(target=env.File("bin/%s" % library_name), source=sources) env.NoCache(library) default_args = [library] - # Add compiledb if the option is set - if env.get("compiledb", False): - default_args += ["compiledb"] + env.AppendUnique(LIBS=[env.File("bin/%s" % library_name)]) + else: + # When not building the library, allow it to be found in other library + # paths on the system. It may have been built previously, so still add + # bin/ to the search path. + env.AppendUnique(LIBPATH=[env.Dir("bin/")]) + env.AppendUnique(LIBS=[library_name]) + + # Add compiledb if the option is set + if env.get("compiledb", False): + default_args += ["compiledb"] - env.Default(*default_args) + env.Default(*default_args) - env.AppendUnique(LIBS=[env.File("bin/%s" % library_name)]) return library