Repository navigation
Expand file tree
/
Copy pathSCsub
More file actions
71 lines (63 loc) · 2.7 KB
/
Copy pathSCsub
File metadata and controls
71 lines (63 loc) · 2.7 KB
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
#!/usr/bin/env python
import platform, os, sys
Import('env')
Import('env_modules')
env_module = env_modules.Clone()
def quickjs():
if platform.python_version() > '3':
import generate_builtin_api
generate_builtin_api.generate_api_json()
import quickjs.builtin_binding_generator
quickjs.builtin_binding_generator.generate_builtin_bindings()
else:
doc_path = os.path.abspath(os.path.join(Dir('.').srcnode().abspath, "../../doc/classes"))
os.system('python generate_builtin_api.py ' + doc_path)
os.system('python quickjs/builtin_binding_generator.py')
version = open('quickjs/quickjs/VERSION', 'r').read().split('\n')[0]
env_module.Append(CPPDEFINES={"QUICKJS_CONFIG_VERSION": '"'+ version +'"'})
env_module.Append(CPPDEFINES=["CONFIG_BIGNUM"])
if env_module['target'] == 'debug':
env_module.Append(CPPDEFINES={"DUMP_LEAKS": 1})
env_module.Append(CPPPATH=["quickjs/quickjs"])
env_module.add_source_files(env.modules_sources, 'quickjs/*.cpp')
env_module.add_source_files(env.modules_sources, 'quickjs/quickjs/*.c')
def dump_text_file_to_cpp(file):
source = ""
if platform.python_version() > '3':
source = open(file, 'r', encoding='utf8').read()
else:
source = open(file, 'r').read()
lines = source.split('\n')
source = ""
length = len(lines)
for i in range(length):
line = lines[i].replace('"', '\\"')
line = '\t"' + line + '\\n"';
if i < length -1:
line += "\n"
source += line
return source
jsengine = 'quickjs'
if jsengine == 'quickjs':
quickjs()
with open("misc/godot.binding_script.gen.cpp", "w") as f:
text = '/* THIS FILE IS GENERATED DO NOT EDIT */\n#include "../ecmascript_binder.h"\nString ECMAScriptBinder::BINDING_SCRIPT_CONTENT = \n${source};'
f.write(text.replace('${source}', dump_text_file_to_cpp("misc/binding_script.js")))
sources = [
'register_types.cpp',
'ecmascript_language.cpp',
'ecmascript_instance.cpp',
'ecmascript.cpp',
'misc/godot.binding_script.gen.cpp',
]
if env['tools']:
with open("tools/godot.d.ts.gen.cpp", "w", encoding="utf-8") as f:
text = '/* THIS FILE IS GENERATED DO NOT EDIT */\n#include "editor_tools.h"\nString ECMAScriptPlugin::BUILTIN_DECLEARATION_TEXT = \n${source};';
f.write(text.replace('${source}', dump_text_file_to_cpp("misc/godot.d.ts")))
with open("tools/tsconfig.json.gen.cpp", "w", encoding="utf-8") as f:
text = '/* THIS FILE IS GENERATED DO NOT EDIT */\n#include "editor_tools.h"\nString ECMAScriptPlugin::TSCONFIG_CONTENT = \n${source};'
f.write(text.replace('${source}', dump_text_file_to_cpp("misc/tsconfig.json")))
env_module.add_source_files(env.modules_sources, 'tools/*.cpp')
env_module.Append(CPPPATH=["#modules/ECMAScript"])
env_module.Append(CXXFLAGS=["-std=c++11"])
env_module.add_source_files(env.modules_sources, sources)