-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSConstruct
61 lines (52 loc) · 1.72 KB
/
SConstruct
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env python
import os
from glob import glob
from pathlib import Path
env = SConscript("thirdparty/godot-cpp/SConstruct")
# add sources
env.Append(CPPPATH=["src/"])
sources = Glob("src/*.cpp")
# link libserialport (statically)
env.Append(CPPPATH=["thirdparty/libserialport"])
env.Append(LIBS=File("thirdparty/libserialport/.libs/libserialport.a"))
if env["platform"] == "windows":
env.Append(LIBS=["setupapi"])
# # find pkg-config command
# if env["platform"] == "macos" and "OSXCROSS_ROOT" in os.environ:
# pkg_config = "x86_64-apple-%s-pkg-config" % env["osxcross_sdk"]
# else:
# pkg_config = "pkg-config"
# # link libserialport (shared)
# env.ParseConfig(f"{pkg_config} libserialport --cflags --libs --static")
# find extension path
(extension_path,) = glob("project/addons/*/*.gdextension")
addon_path = Path(extension_path).parent
project_name = Path(extension_path).stem
# scons cache
scons_cache_path = os.environ.get("SCONS_CACHE")
if scons_cache_path:
CacheDir(scons_cache_path)
else:
CacheDir(".scons_cache/%s_%s_%s" % (env["platform"], env["arch"], env["target"]))
# create library target
debug_or_release = "release" if env["target"] == "template_release" else "debug"
if env["platform"] == "macos":
library = env.SharedLibrary(
"{0}/bin/{1}.{2}.{3}.framework/{1}.{2}.{3}".format(
addon_path, project_name, env["platform"], debug_or_release
),
source=sources,
)
else:
library = env.SharedLibrary(
"{}/bin/{}.{}.{}.{}{}".format(
addon_path,
project_name,
env["platform"],
debug_or_release,
env["arch"],
env["SHLIBSUFFIX"],
),
source=sources,
)
Default(library)