2016-10-17 08:50:25 +02:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
Import('env')
|
2017-08-26 18:53:49 +02:00
|
|
|
from compat import byte_to_str
|
2018-03-06 04:10:17 +01:00
|
|
|
from collections import OrderedDict
|
2017-04-10 01:02:04 +02:00
|
|
|
|
|
|
|
def make_splash(target, source, env):
|
|
|
|
|
|
|
|
src = source[0].srcnode().abspath
|
|
|
|
dst = target[0].srcnode().abspath
|
|
|
|
|
2018-03-10 18:37:33 +01:00
|
|
|
with open(src, "rb") as f:
|
|
|
|
buf = f.read()
|
2017-04-10 01:02:04 +02:00
|
|
|
|
2018-03-10 18:37:33 +01:00
|
|
|
with open(dst, "w") as g:
|
|
|
|
g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
|
|
|
|
g.write("#ifndef BOOT_SPLASH_H\n")
|
|
|
|
g.write("#define BOOT_SPLASH_H\n")
|
|
|
|
g.write('static const Color boot_splash_bg_color = Color::html("#232323");\n')
|
|
|
|
g.write("static const unsigned char boot_splash_png[] = {\n")
|
|
|
|
for i in range(len(buf)):
|
|
|
|
g.write(byte_to_str(buf[i]) + ",\n")
|
|
|
|
g.write("};\n")
|
|
|
|
g.write("#endif")
|
2017-04-10 01:02:04 +02:00
|
|
|
|
|
|
|
|
2017-12-16 20:11:13 +01:00
|
|
|
def make_splash_editor(target, source, env):
|
|
|
|
|
|
|
|
src = source[0].srcnode().abspath
|
|
|
|
dst = target[0].srcnode().abspath
|
|
|
|
|
2018-03-10 18:37:33 +01:00
|
|
|
with open(src, "rb") as f:
|
|
|
|
buf = f.read()
|
2017-12-16 20:11:13 +01:00
|
|
|
|
2018-03-10 18:37:33 +01:00
|
|
|
with open(dst, "w") as g:
|
|
|
|
g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
|
|
|
|
g.write("#ifndef BOOT_SPLASH_EDITOR_H\n")
|
|
|
|
g.write("#define BOOT_SPLASH_EDITOR_H\n")
|
|
|
|
g.write('static const Color boot_splash_editor_bg_color = Color::html("#232323");\n')
|
|
|
|
g.write("static const unsigned char boot_splash_editor_png[] = {\n")
|
|
|
|
for i in range(len(buf)):
|
|
|
|
g.write(byte_to_str(buf[i]) + ",\n")
|
|
|
|
g.write("};\n")
|
|
|
|
g.write("#endif")
|
2017-12-16 20:11:13 +01:00
|
|
|
|
|
|
|
|
2017-04-10 01:02:04 +02:00
|
|
|
def make_app_icon(target, source, env):
|
|
|
|
|
|
|
|
src = source[0].srcnode().abspath
|
|
|
|
dst = target[0].srcnode().abspath
|
2018-03-10 18:37:33 +01:00
|
|
|
|
|
|
|
with open(src, "rb") as f:
|
|
|
|
buf = f.read()
|
|
|
|
|
|
|
|
with open(dst, "w") as g:
|
|
|
|
g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
|
|
|
|
g.write("#ifndef APP_ICON_H\n")
|
|
|
|
g.write("#define APP_ICON_H\n")
|
|
|
|
g.write("static const unsigned char app_icon_png[] = {\n")
|
|
|
|
for i in range(len(buf)):
|
|
|
|
g.write(byte_to_str(buf[i]) + ",\n")
|
|
|
|
g.write("};\n")
|
|
|
|
g.write("#endif")
|
2017-04-10 01:02:04 +02:00
|
|
|
|
2018-03-06 04:10:17 +01:00
|
|
|
def make_default_controller_mappings(target, source, env):
|
|
|
|
dst = target[0].srcnode().abspath
|
|
|
|
g = open(dst, "w")
|
|
|
|
|
|
|
|
g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
|
|
|
|
g.write("#include \"default_controller_mappings.h\"\n")
|
|
|
|
g.write("#include \"typedefs.h\"\n")
|
|
|
|
|
|
|
|
# ensure mappings have a consistent order
|
|
|
|
platform_mappings = OrderedDict()
|
|
|
|
for src in source:
|
|
|
|
src_path = src.srcnode().abspath
|
2018-03-16 16:28:05 +01:00
|
|
|
with open(src_path, "r") as f:
|
2018-03-16 08:40:33 +01:00
|
|
|
# read mapping file and skip header
|
|
|
|
mapping_file_lines = f.readlines()[2:]
|
2018-03-06 04:10:17 +01:00
|
|
|
|
|
|
|
current_platform = None
|
|
|
|
for line in mapping_file_lines:
|
|
|
|
if not line:
|
|
|
|
continue
|
|
|
|
line = line.strip()
|
|
|
|
if len(line) == 0:
|
|
|
|
continue
|
|
|
|
if line[0] == "#":
|
|
|
|
current_platform = line[1:].strip()
|
|
|
|
if current_platform not in platform_mappings:
|
|
|
|
platform_mappings[current_platform] = {}
|
|
|
|
elif current_platform:
|
|
|
|
line_parts = line.split(",")
|
|
|
|
guid = line_parts[0]
|
|
|
|
if guid in platform_mappings[current_platform]:
|
|
|
|
g.write("// WARNING - DATABASE {} OVERWROTE PRIOR MAPPING: {} {}\n".format(src_path, current_platform, platform_mappings[current_platform][guid]))
|
|
|
|
valid_mapping = True
|
|
|
|
for input_map in line_parts[2:]:
|
|
|
|
if "+" in input_map or "-" in input_map or "~" in input_map:
|
|
|
|
g.write("// WARNING - DISCARDED UNSUPPORTED MAPPING TYPE FROM DATABASE {}: {} {}\n".format(src_path, current_platform, line))
|
|
|
|
valid_mapping = False
|
|
|
|
break
|
|
|
|
if valid_mapping:
|
|
|
|
platform_mappings[current_platform][guid] = line
|
|
|
|
|
|
|
|
platform_variables = {
|
|
|
|
"Linux": "#if X11_ENABLED",
|
|
|
|
"Windows": "#ifdef WINDOWS_ENABLED",
|
|
|
|
"Mac OS X": "#ifdef OSX_ENABLED",
|
|
|
|
"Android": "#if defined(__ANDROID__)",
|
|
|
|
"iOS": "#ifdef IPHONE_ENABLED",
|
|
|
|
"Javascript": "#ifdef JAVASCRIPT_ENABLED",
|
|
|
|
"UWP": "#ifdef UWP_ENABLED",
|
|
|
|
}
|
|
|
|
|
|
|
|
g.write("const char* DefaultControllerMappings::mappings[] = {\n")
|
|
|
|
for platform, mappings in platform_mappings.items():
|
|
|
|
variable = platform_variables[platform]
|
|
|
|
g.write("{}\n".format(variable))
|
|
|
|
for mapping in mappings.values():
|
|
|
|
g.write("\t\"{}\",\n".format(mapping))
|
|
|
|
g.write("#endif\n")
|
|
|
|
|
2018-04-05 04:23:38 +02:00
|
|
|
g.write("\tNULL\n};\n")
|
2018-03-16 08:40:33 +01:00
|
|
|
g.close()
|
2017-04-10 01:02:04 +02:00
|
|
|
|
2016-10-30 18:57:40 +01:00
|
|
|
env.main_sources = []
|
|
|
|
env.add_source_files(env.main_sources, "*.cpp")
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2018-03-06 04:10:17 +01:00
|
|
|
# order matters here. higher index controller database files write on top of lower index database files
|
|
|
|
controller_databases = ["#main/gamecontrollerdb.txt", "#main/gamecontrollerdb_205.txt", "#main/gamecontrollerdb_204.txt", "#main/godotcontrollerdb.txt"]
|
|
|
|
|
|
|
|
env.Depends("#main/default_controller_mappings.gen.cpp", controller_databases)
|
|
|
|
env.Command("#main/default_controller_mappings.gen.cpp", controller_databases, make_default_controller_mappings)
|
|
|
|
|
|
|
|
env.main_sources.append("#main/default_controller_mappings.gen.cpp")
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
Export('env')
|
|
|
|
|
2017-06-23 17:03:41 +02:00
|
|
|
env.Depends("#main/splash.gen.h", "#main/splash.png")
|
|
|
|
env.Command("#main/splash.gen.h", "#main/splash.png", make_splash)
|
2017-04-10 01:02:04 +02:00
|
|
|
|
2017-12-16 20:20:36 +01:00
|
|
|
env.Depends("#main/splash_editor.gen.h", "#main/splash_editor.png")
|
2017-12-16 20:11:13 +01:00
|
|
|
env.Command("#main/splash_editor.gen.h", "#main/splash_editor.png", make_splash_editor)
|
|
|
|
|
2017-06-23 17:03:41 +02:00
|
|
|
env.Depends("#main/app_icon.gen.h", "#main/app_icon.png")
|
|
|
|
env.Command("#main/app_icon.gen.h", "#main/app_icon.png", make_app_icon)
|
2017-04-10 01:02:04 +02:00
|
|
|
|
2017-01-08 21:33:23 +01:00
|
|
|
SConscript('tests/SCsub')
|
|
|
|
|
2017-11-28 21:27:57 +01:00
|
|
|
lib = env.add_library("main", env.main_sources)
|
2014-02-10 02:10:30 +01:00
|
|
|
env.Prepend(LIBS=[lib])
|