138 lines
		
	
	
		
			4 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			138 lines
		
	
	
		
			4 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
#!/usr/bin/env python
 | 
						|
from misc.utility.scons_hints import *
 | 
						|
 | 
						|
Import("env")
 | 
						|
 | 
						|
env.editor_sources = []
 | 
						|
 | 
						|
import os
 | 
						|
 | 
						|
import editor_builders
 | 
						|
 | 
						|
import methods
 | 
						|
 | 
						|
if env.editor_build:
 | 
						|
    # Generate doc data paths
 | 
						|
    def doc_data_class_path_builder(target, source, env):
 | 
						|
        paths = dict(sorted(source[0].read().items()))
 | 
						|
        data = "\n".join([f'\t{{"{key}", "{value}"}},' for key, value in paths.items()])
 | 
						|
        with methods.generated_wrapper(str(target[0])) as file:
 | 
						|
            file.write(
 | 
						|
                f"""\
 | 
						|
struct _DocDataClassPath {{
 | 
						|
	const char *name;
 | 
						|
	const char *path;
 | 
						|
}};
 | 
						|
 | 
						|
inline constexpr int _doc_data_class_path_count = {len(paths)};
 | 
						|
inline constexpr _DocDataClassPath _doc_data_class_paths[{len(env.doc_class_path) + 1}] = {{
 | 
						|
{data}
 | 
						|
	{{nullptr, nullptr}},
 | 
						|
}};
 | 
						|
"""
 | 
						|
            )
 | 
						|
 | 
						|
    env.CommandNoCache("doc_data_class_path.gen.h", env.Value(env.doc_class_path), env.Run(doc_data_class_path_builder))
 | 
						|
 | 
						|
    # Register exporters
 | 
						|
    def register_exporters_builder(target, source, env):
 | 
						|
        platforms = source[0].read()
 | 
						|
        exp_inc = "\n".join([f'#include "platform/{p}/export/export.h"' for p in platforms])
 | 
						|
        exp_reg = "\n".join([f"\tregister_{p}_exporter();" for p in platforms])
 | 
						|
        exp_type = "\n".join([f"\tregister_{p}_exporter_types();" for p in platforms])
 | 
						|
        with methods.generated_wrapper(str(target[0])) as file:
 | 
						|
            file.write(
 | 
						|
                f"""\
 | 
						|
#include "register_exporters.h"
 | 
						|
 | 
						|
{exp_inc}
 | 
						|
 | 
						|
void register_exporters() {{
 | 
						|
{exp_reg}
 | 
						|
}}
 | 
						|
 | 
						|
void register_exporter_types() {{
 | 
						|
{exp_type}
 | 
						|
}}
 | 
						|
"""
 | 
						|
            )
 | 
						|
 | 
						|
    gen_exporters = env.CommandNoCache(
 | 
						|
        "register_exporters.gen.cpp", env.Value(env.platform_exporters), env.Run(register_exporters_builder)
 | 
						|
    )
 | 
						|
    for e in env.platform_exporters:
 | 
						|
        # Add all .cpp files in export folder
 | 
						|
        env.add_source_files(env.editor_sources, f"../platform/{e}/export/*.cpp")
 | 
						|
 | 
						|
    # Core API documentation.
 | 
						|
    docs = []
 | 
						|
    docs += Glob("#doc/classes/*.xml")
 | 
						|
 | 
						|
    # Module API documentation.
 | 
						|
    module_dirs = []
 | 
						|
    for d in env.doc_class_path.values():
 | 
						|
        if d not in module_dirs:
 | 
						|
            module_dirs.append(d)
 | 
						|
 | 
						|
    for d in module_dirs:
 | 
						|
        if not os.path.isabs(d):
 | 
						|
            docs += Glob("#" + d + "/*.xml")  # Built-in.
 | 
						|
        else:
 | 
						|
            docs += Glob(d + "/*.xml")  # Custom.
 | 
						|
 | 
						|
    docs = sorted(docs)
 | 
						|
    env.CommandNoCache(
 | 
						|
        "#editor/doc_data_compressed.gen.h",
 | 
						|
        docs,
 | 
						|
        env.Run(editor_builders.make_doc_header),
 | 
						|
    )
 | 
						|
 | 
						|
    # Editor interface and class reference translations incur a significant size
 | 
						|
    # cost for the editor binary (see godot-proposals#3421).
 | 
						|
    # To limit it, we only include translations with a high enough completion
 | 
						|
    # ratio (20% for the editor UI, 10% for the class reference).
 | 
						|
    # Generated with `make include-list` for each resource.
 | 
						|
 | 
						|
    # Editor translations
 | 
						|
    env.CommandNoCache(
 | 
						|
        "#editor/editor_translations.gen.h",
 | 
						|
        Glob("#editor/translations/editor/*"),
 | 
						|
        env.Run(editor_builders.make_translations_header),
 | 
						|
    )
 | 
						|
 | 
						|
    # Property translations
 | 
						|
    env.CommandNoCache(
 | 
						|
        "#editor/property_translations.gen.h",
 | 
						|
        Glob("#editor/translations/properties/*"),
 | 
						|
        env.Run(editor_builders.make_translations_header),
 | 
						|
    )
 | 
						|
 | 
						|
    # Documentation translations
 | 
						|
    env.CommandNoCache(
 | 
						|
        "#editor/doc_translations.gen.h",
 | 
						|
        Glob("#doc/translations/*"),
 | 
						|
        env.Run(editor_builders.make_translations_header),
 | 
						|
    )
 | 
						|
 | 
						|
    # Extractable translations
 | 
						|
    env.CommandNoCache(
 | 
						|
        "#editor/extractable_translations.gen.h",
 | 
						|
        Glob("#editor/translations/extractable/*"),
 | 
						|
        env.Run(editor_builders.make_translations_header),
 | 
						|
    )
 | 
						|
 | 
						|
    env.add_source_files(env.editor_sources, "*.cpp")
 | 
						|
    env.add_source_files(env.editor_sources, gen_exporters)
 | 
						|
 | 
						|
    SConscript("debugger/SCsub")
 | 
						|
    SConscript("export/SCsub")
 | 
						|
    SConscript("gui/SCsub")
 | 
						|
    SConscript("icons/SCsub")
 | 
						|
    SConscript("import/SCsub")
 | 
						|
    SConscript("plugins/SCsub")
 | 
						|
    SConscript("project_manager/SCsub")
 | 
						|
    SConscript("themes/SCsub")
 | 
						|
 | 
						|
    lib = env.add_library("editor", env.editor_sources)
 | 
						|
    env.Prepend(LIBS=[lib])
 |