This repository has been archived by the owner on Jun 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathSCsub
85 lines (73 loc) · 2.38 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
#! /usr/bin/env python
# SCSub
#
# FRT - A Godot platform targeting single board computers
# Copyright (c) 2017-2023 Emanuele Fornara
# SPDX-License-Identifier: MIT
#
Import('env')
def text_action(target, source, env):
src = str(source[0])
tgt = str(target[0])
with open(src, 'rb') as f:
content = f.read()
tag = tgt[tgt.rfind('/')+1:tgt.find('.')]
with open(tgt, 'w') as f:
f.write('static const char data[] = {\n')
while len(content) > 0:
head = content[:16]
content = content[16:]
for c in head:
f.write('%d, ' % c)
f.write('\n')
f.write('0 }; namespace frt { const char *%s = data; }\n' % tag)
import sys
dl_path = './dl'
sys.path.append(dl_path)
import procdl
sys.path.remove(dl_path)
env.Append(BUILDERS={'DLH': env.Builder(action=procdl.build_h_action, suffix='.gen.h', src_suffix='.dl')})
env.Append(BUILDERS={'DLCPP': env.Builder(action=procdl.build_cc_action, suffix='.gen.cc', src_suffix='.dl')})
env.Append(BUILDERS={'TEXT': env.Builder(action=text_action)})
for dl in Glob('dl/*.dl'):
env.DLH(str(dl))
env.DLCPP(str(dl))
for libname in ['gles2', 'gles3']:
env.Depends('platform_config.h', 'dl/' + libname + '.gen.h')
env.TEXT('license.gen.cc', 'LICENSE')
frt_env = env.Clone()
frt_env.ParseConfig(env['FRT_PKG_CONFIG'] + ' sdl2 --cflags --libs')
common_sources = [ 'frt_exe.cc', 'frt.cc', 'license.gen.cc' ]
import os
import subprocess
try:
os.stat('.git/HEAD')
git_cmd = ['git', 'rev-parse', 'HEAD']
with subprocess.Popen(git_cmd, stdout=subprocess.PIPE, text=True) as p:
commit_id = p.stdout.read()[:7]
with open('commit_id.gen.cc', 'w') as f:
f.write('namespace frt { const char *commit_id = "%s"; }\n' % commit_id)
common_sources.append('commit_id.gen.cc')
except:
common_sources.append('commit_id_nogit.cc')
import version
if version.major == 2:
version_sources = ['frt_godot2.cc', 'dl/gles2.gen.cc']
elif version.major == 3:
version_sources = ['frt_godot3.cc', 'dl/gles2.gen.cc', 'dl/gles3.gen.cc']
elif version.major == 4:
version_sources = ['frt_godot4.cc', 'dl/gles3.gen.cc']
if env['frt_custom_renderer']:
frt_env.Append(CPPDEFINES=['FRT_CUSTOM_RENDERER'])
else:
version_sources.append('dummy_renderer.cc')
std = env['frt_std']
if std == 'auto':
std = {
2: 'c++98',
3: 'c++14',
4: 'c++17',
}[version.major]
if std != 'no':
frt_env.Append(CCFLAGS=['-std=' + std])
prog = frt_env.add_program('#bin/godot', common_sources + version_sources)