2023-08-05 22:42:21 +00:00
|
|
|
#!/usr/bin/env python
|
2023-08-17 14:25:50 +00:00
|
|
|
import os
|
2024-08-08 22:19:52 +00:00
|
|
|
import sys
|
|
|
|
|
|
|
|
from methods import print_error
|
2023-08-17 14:25:50 +00:00
|
|
|
|
|
|
|
|
2023-08-05 22:42:21 +00:00
|
|
|
libname = "EXTENSION-NAME"
|
2023-10-15 17:50:01 +00:00
|
|
|
projectdir = "demo"
|
2023-08-05 22:42:21 +00:00
|
|
|
|
2023-08-17 14:25:50 +00:00
|
|
|
localEnv = Environment(tools=["default"], PLATFORM="")
|
|
|
|
|
|
|
|
customs = ["custom.py"]
|
|
|
|
customs = [os.path.abspath(path) for path in customs]
|
|
|
|
|
|
|
|
opts = Variables(customs, ARGUMENTS)
|
|
|
|
opts.Update(localEnv)
|
|
|
|
|
|
|
|
Help(opts.GenerateHelpText(localEnv))
|
|
|
|
|
|
|
|
env = localEnv.Clone()
|
|
|
|
|
2024-08-08 22:19:52 +00:00
|
|
|
submodule_initialized = False
|
|
|
|
dir_name = 'godot-cpp'
|
|
|
|
if os.path.isdir(dir_name):
|
|
|
|
if os.listdir(dir_name):
|
|
|
|
submodule_initialized = True
|
|
|
|
|
|
|
|
if not submodule_initialized:
|
|
|
|
print_error("""godot-cpp is not available within this folder, as Git submodules haven't been initialized.
|
|
|
|
Run the following command to download godot-cpp:
|
|
|
|
|
|
|
|
git submodule update --init --recursive""")
|
|
|
|
sys.exit(1)
|
|
|
|
|
2023-08-17 14:25:50 +00:00
|
|
|
env = SConscript("godot-cpp/SConstruct", {"env": env, "customs": customs})
|
2023-08-05 22:42:21 +00:00
|
|
|
|
|
|
|
env.Append(CPPPATH=["src/"])
|
|
|
|
sources = Glob("src/*.cpp")
|
|
|
|
|
2024-08-16 18:39:39 +00:00
|
|
|
if env["target"] in ["editor", "template_debug"]:
|
|
|
|
try:
|
|
|
|
doc_data = env.GodotCPPDocData("src/gen/doc_data.gen.cpp", source=Glob("doc_classes/*.xml"))
|
|
|
|
sources.append(doc_data)
|
|
|
|
except AttributeError:
|
|
|
|
print("Not including class reference as we're targeting a pre-4.3 baseline.")
|
|
|
|
|
2023-10-15 17:50:01 +00:00
|
|
|
file = "{}{}{}".format(libname, env["suffix"], env["SHLIBSUFFIX"])
|
2024-09-17 00:25:31 +00:00
|
|
|
filepath = ""
|
2023-10-15 17:50:01 +00:00
|
|
|
|
2024-05-17 11:08:55 +00:00
|
|
|
if env["platform"] == "macos" or env["platform"] == "ios":
|
2024-09-17 00:25:31 +00:00
|
|
|
filepath = "{}.framework/".format(env["platform"])
|
|
|
|
file = "{}.{}.{}".format(libname, env["platform"], env["target"])
|
2023-10-15 17:50:01 +00:00
|
|
|
|
2024-09-17 00:25:31 +00:00
|
|
|
libraryfile = "bin/{}/{}{}".format(env["platform"], filepath, file)
|
2023-10-15 17:50:01 +00:00
|
|
|
library = env.SharedLibrary(
|
|
|
|
libraryfile,
|
|
|
|
source=sources,
|
|
|
|
)
|
|
|
|
|
2024-09-17 00:25:31 +00:00
|
|
|
copy = env.InstallAs("{}/bin/{}/{}lib{}".format(projectdir, env["platform"], filepath, file), library)
|
2023-08-05 22:42:21 +00:00
|
|
|
|
2023-10-15 17:50:01 +00:00
|
|
|
default_args = [library, copy]
|
2023-08-17 14:25:50 +00:00
|
|
|
Default(*default_args)
|