-
Notifications
You must be signed in to change notification settings - Fork 82
/
SCsub
99 lines (78 loc) · 3.83 KB
/
SCsub
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/usr/bin/env python
import os
from misc.generate.generate_files import generate
Import("env")
Import("env_modules")
env_javascript = env_modules.Clone()
# Default engine to use we might add some more in the future like node or v8
JS_ENGINE = "quickjs"
javascript_dir = os.path.join(GetLaunchDir(), "modules", os.path.basename(os.getcwd()))
# Windows workaround
if env["platform"] == "windows":
if env["use_mingw"]:
env.Append(LIBS=["pthread"])
# Add required files for quickjs into godot
if JS_ENGINE == "quickjs":
import generate_builtin_api
generate_builtin_api.generate_api_json(javascript_dir)
import thirdparty.quickjs.builtin_binding_generator
thirdparty.quickjs.builtin_binding_generator.generate_builtin_bindings()
version = open("thirdparty/quickjs/quickjs/VERSION.txt", "r").read().split("\n")[0]
quickjs_env = env_javascript.Clone()
quickjs_env.Append(CPPDEFINES={"QUICKJS_CONFIG_VERSION": '"' + version + '"'})
quickjs_env.Append(CPPDEFINES=["CONFIG_BIGNUM"])
if "release" not in (quickjs_env["target"] or ""):
quickjs_env.Append(CPPDEFINES={"DUMP_LEAKS": 1})
# TODO: Fix debugger
# quickjs_env.Append(CPPDEFINES={"QUICKJS_WITH_DEBUGGER": 1})
quickjs_env.Append(CPPPATH=["thirdparty/quickjs/quickjs"])
quickjs_env.Append(CPPPATH=["thirdparty/quickjs"])
quickjs_env.disable_warnings()
quickjs_env.add_source_files(env.modules_sources, "thirdparty/quickjs/quickjs_builtin_binder.gen.cpp")
quickjs_env.add_source_files(env.modules_sources, "thirdparty/quickjs/*.cpp")
quickjs_env.add_source_files(env.modules_sources, "thirdparty/quickjs/quickjs/*.c")
# If target=editor is provided via scons
if env.editor_build:
env_javascript.add_source_files(env.modules_sources, "editor/workarounds/*.cpp")
env_javascript.add_source_files(env.modules_sources, "editor/*.cpp")
# --- Generate editor tool files ---
from misc.generate.editor_tools import get_editor_tools_files
from misc.generate.editor_tools import get_editor_tools_header
files = get_editor_tools_files()
generate(javascript_dir, get_editor_tools_header(), files)
env_javascript.add_source_files(env.modules_sources, files.keys())
# If tests=yes flag is provided via scons
if env["tests"]:
env_javascript.Append(CPPDEFINES=["TESTS_ENABLED"])
# --- Generate test files ---
from misc.generate.test_manager import get_test_files
from misc.generate.test_manager import get_test_manager_header
files = get_test_files()
generate(javascript_dir, get_test_manager_header(), files)
env_javascript.add_source_files(env.modules_sources, files.keys())
# --- Files inside editor & targets ---
sources = [
"register_types.cpp",
"javascript_instance.cpp",
"javascript.cpp",
]
# Add all required files for "Javascript" language into godot
env_javascript.Append(CPPPATH=["#modules/javascript"])
env_javascript.add_source_files(env.modules_sources, sources)
env_javascript.add_source_files(env.modules_sources, "src/language/*.cpp")
env_javascript.add_source_files(env.modules_sources, "src/language/templates/*.cpp")
# --- Generate template files ---
from misc.generate.templates import get_templates_header
from misc.generate.templates import get_templates_files
from misc.generate.generate_files import generate_templates
files = get_templates_files()
generate_templates(javascript_dir, get_templates_header(), files)
env_javascript.add_source_files(env.modules_sources, files.keys())
# --- Generate binding files ---
# Binding script to run at engine initializing
# The bindings add some functionality for `this.connect(...)`
from misc.generate.bindings import get_bindings_header
from misc.generate.bindings import get_binding_files
files = get_binding_files()
generate(javascript_dir, get_bindings_header(), files)
env_javascript.add_source_files(env.modules_sources, files.keys())