/**************************************************************************/1/* main.h */2/**************************************************************************/3/* This file is part of: */4/* GODOT ENGINE */5/* https://godotengine.org */6/**************************************************************************/7/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */8/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */9/* */10/* Permission is hereby granted, free of charge, to any person obtaining */11/* a copy of this software and associated documentation files (the */12/* "Software"), to deal in the Software without restriction, including */13/* without limitation the rights to use, copy, modify, merge, publish, */14/* distribute, sublicense, and/or sell copies of the Software, and to */15/* permit persons to whom the Software is furnished to do so, subject to */16/* the following conditions: */17/* */18/* The above copyright notice and this permission notice shall be */19/* included in all copies or substantial portions of the Software. */20/* */21/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */22/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */23/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */24/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */25/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */26/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */27/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */28/**************************************************************************/2930#pragma once3132#include "core/os/thread.h"33#include "core/typedefs.h"3435template <typename T>36class Vector;3738class Main {39enum CLIOptionAvailability {40CLI_OPTION_AVAILABILITY_EDITOR,41CLI_OPTION_AVAILABILITY_TEMPLATE_DEBUG,42CLI_OPTION_AVAILABILITY_TEMPLATE_RELEASE,43CLI_OPTION_AVAILABILITY_TEMPLATE_UNSAFE,44CLI_OPTION_AVAILABILITY_HIDDEN,45};4647static void print_header(bool p_rich);48static void print_help_copyright(const char *p_notice);49static void print_help_title(const char *p_title);50static void print_help_option(const char *p_option, const char *p_description, CLIOptionAvailability p_availability = CLI_OPTION_AVAILABILITY_TEMPLATE_RELEASE);51static String format_help_option(const char *p_option);52static void print_help(const char *p_binary);53static uint64_t last_ticks;54static uint32_t hide_print_fps_attempts;55static uint32_t frames;56static uint32_t frame;57static bool force_redraw_requested;58static int iterating;5960public:61static bool is_cmdline_tool();62#ifdef TOOLS_ENABLED63enum CLIScope {64CLI_SCOPE_TOOL, // Editor and project manager.65CLI_SCOPE_PROJECT,66};67static const Vector<String> &get_forwardable_cli_arguments(CLIScope p_scope);68#endif6970static int test_entrypoint(int argc, char *argv[], bool &tests_need_run);71static Error setup(const char *execpath, int argc, char *argv[], bool p_second_phase = true);72static Error setup2(bool p_show_boot_logo = true); // The thread calling setup2() will effectively become the main thread.73static String get_locale_override();74static void setup_boot_logo();75#ifdef TESTS_ENABLED76static Error test_setup();77static void test_cleanup();78#endif79static int start();8081static bool iteration();82static void force_redraw();8384static bool is_iterating();8586static void cleanup(bool p_force = false);87};8889// Test main override is for the testing behavior.90#define TEST_MAIN_OVERRIDE \91bool run_test = false; \92int return_code = Main::test_entrypoint(argc, argv, run_test); \93if (run_test) { \94godot_cleanup_profiler(); \95return return_code; \96}9798#define TEST_MAIN_PARAM_OVERRIDE(argc, argv) \99bool run_test = false; \100int return_code = Main::test_entrypoint(argc, argv, run_test); \101if (run_test) { \102godot_cleanup_profiler(); \103return return_code; \104}105106107