godotengine / godot-cpp-template

Quickstart template for GDExtension development with Godot
https://docs.godotengine.org/en/stable/tutorials/scripting/gdextension/what_is_gdextension.html
The Unlicense
145 stars 55 forks source link

Fixes gde library copying #19

Closed dmitrii-t closed 1 year ago

dmitrii-t commented 1 year ago

Fixes the following scons error

scons: *** Multiple ways to build the same target were specified for: bin\windows\extension.windows.template_debug.x86_64.dll (from ['src\register_types.windows.template_debug.x86_64.obj'] and from [])

Adds projectlib as a target and modifies the command to copy extenxion library to from .\bin to the projeect's .\demo\bin\

Faless commented 1 year ago

I'm not sure why the current code uses env.Command and shutil. This should be done via env.InstallAs instead:

diff --git a/SConstruct b/SConstruct
index be5445b..75c2372 100644
--- a/SConstruct
+++ b/SConstruct
@@ -65,16 +65,7 @@ library = env.SharedLibrary(
     source=sources,
 )

-
-def copy_bin_to_projectdir(target, source, env):
-    import shutil
-
-    targetfrom = "bin/{}/lib{}".format(env["platform"], file)
-    targetdest = "{}/bin/{}/lib{}".format(projectdir, env["platform"], file)
-    shutil.copyfile(targetfrom, targetdest)
-
-
-copy = env.Command(libraryfile, None, copy_bin_to_projectdir)
+copy = env.InstallAs("{}/bin/{}/lib{}".format(projectdir, env["platform"], file), library)

 default_args = [library, copy]
 if localEnv.get("compiledb", False):
adamscott commented 1 year ago

@dmitrii-t If you could change your PR to match @Faless' suggestion, we will merge it.

@Faless I didn't even know that it existed! Thanks for the tip.

paddy-exe commented 1 year ago

Hey @dmitrii-t not sure if you are done with the PR but could you squish the commits if if it is ready?