Skip to content

Commit

Permalink
Merge pull request #15 from adamscott/copy-bin-to-projectdir
Browse files Browse the repository at this point in the history
  • Loading branch information
paddy-exe committed Oct 17, 2023
2 parents 055ab32 + 54a177c commit 843b225
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 10 deletions.
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
32 changes: 22 additions & 10 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ def validate_parent_dir(key, val, env):


libname = "EXTENSION-NAME"
projectdir = "demo"

localEnv = Environment(tools=["default"], PLATFORM="")

Expand Down Expand Up @@ -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)

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]
default_args = [library, copy]
if localEnv.get("compiledb", False):
default_args += [compilation_db]
Default(*default_args)
Empty file added bin/android/.gitkeep
Empty file.
Empty file added bin/linux/.gitkeep
Empty file.
Empty file added bin/macos/.gitkeep
Empty file.
Empty file added bin/windows/.gitkeep
Empty file.
Empty file added demo/bin/android/.gitkeep
Empty file.
Empty file added demo/bin/linux/.gitkeep
Empty file.
Empty file added demo/bin/macos/.gitkeep
Empty file.
Empty file added demo/bin/windows/.gitkeep
Empty file.

0 comments on commit 843b225

Please sign in to comment.