From 54a177ce398dc8fe6e2a9ca63571719eb7d22df6 Mon Sep 17 00:00:00 2001 From: Adam Scott Date: Sun, 15 Oct 2023 13:50:01 -0400 Subject: [PATCH] Copy generated library to the projectdir --- .gitignore | 12 ++++++++++++ SConstruct | 32 ++++++++++++++++++++++---------- bin/android/.gitkeep | 0 bin/linux/.gitkeep | 0 bin/macos/.gitkeep | 0 bin/windows/.gitkeep | 0 demo/bin/android/.gitkeep | 0 demo/bin/linux/.gitkeep | 0 demo/bin/macos/.gitkeep | 0 demo/bin/windows/.gitkeep | 0 10 files changed, 34 insertions(+), 10 deletions(-) create mode 100644 bin/android/.gitkeep create mode 100644 bin/linux/.gitkeep create mode 100644 bin/macos/.gitkeep create mode 100644 bin/windows/.gitkeep create mode 100644 demo/bin/android/.gitkeep create mode 100644 demo/bin/linux/.gitkeep create mode 100644 demo/bin/macos/.gitkeep create mode 100644 demo/bin/windows/.gitkeep diff --git a/.gitignore b/.gitignore index 22f954d..de143d4 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,18 @@ # Ignore library files but not the gdextension file demo/bin/* +!demo/bin/android +demo/bin/android/* +!demo/bin/android/.gitkeep +!demo/bin/linux +demo/bin/linux/* +!demo/bin/linux/.gitkeep +!demo/bin/macos +demo/bin/macos/* +!demo/bin/macos/.gitkeep +!demo/bin/windows +demo/bin/windows/* +!demo/bin/windows/.gitkeep !demo/bin/*.gdextension .sconsign*.dblite diff --git a/SConstruct b/SConstruct index a02a9e2..be5445b 100644 --- a/SConstruct +++ b/SConstruct @@ -12,6 +12,7 @@ def validate_parent_dir(key, val, env): libname = "EXTENSION-NAME" +projectdir = "demo" localEnv = Environment(tools=["default"], PLATFORM="") @@ -52,19 +53,30 @@ env = SConscript("godot-cpp/SConstruct", {"env": env, "customs": customs}) env.Append(CPPPATH=["src/"]) sources = Glob("src/*.cpp") +file = "{}{}{}".format(libname, env["suffix"], env["SHLIBSUFFIX"]) + if env["platform"] == "macos": platlibname = "{}.{}.{}".format(libname, env["platform"], env["target"]) - library = env.SharedLibrary( - "bin/{}.framework/{}".format(platlibname, platlibname), - source=sources, - ) -else: - library = env.SharedLibrary( - "bin/{}{}{}".format(libname, env["suffix"], env["SHLIBSUFFIX"]), - source=sources, - ) + file = "{}.framework/{}".format(env["platform"], platlibname, platlibname) -default_args = [library] +libraryfile = "bin/{}/{}".format(env["platform"], file) +library = env.SharedLibrary( + libraryfile, + 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) + +default_args = [library, copy] if localEnv.get("compiledb", False): default_args += [compilation_db] Default(*default_args) diff --git a/bin/android/.gitkeep b/bin/android/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/bin/linux/.gitkeep b/bin/linux/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/bin/macos/.gitkeep b/bin/macos/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/bin/windows/.gitkeep b/bin/windows/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/demo/bin/android/.gitkeep b/demo/bin/android/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/demo/bin/linux/.gitkeep b/demo/bin/linux/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/demo/bin/macos/.gitkeep b/demo/bin/macos/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/demo/bin/windows/.gitkeep b/demo/bin/windows/.gitkeep new file mode 100644 index 0000000..e69de29