/**************************************************************************/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_HIDDEN,44};4546static void print_header(bool p_rich);47static void print_help_copyright(const char *p_notice);48static void print_help_title(const char *p_title);49static void print_help_option(const char *p_option, const char *p_description, CLIOptionAvailability p_availability = CLI_OPTION_AVAILABILITY_TEMPLATE_RELEASE);50static String format_help_option(const char *p_option);51static void print_help(const char *p_binary);52static uint64_t last_ticks;53static uint32_t hide_print_fps_attempts;54static uint32_t frames;55static uint32_t frame;56static bool force_redraw_requested;57static int iterating;5859public:60static bool is_cmdline_tool();61#ifdef TOOLS_ENABLED62enum CLIScope {63CLI_SCOPE_TOOL, // Editor and project manager.64CLI_SCOPE_PROJECT,65};66static const Vector<String> &get_forwardable_cli_arguments(CLIScope p_scope);67#endif6869static int test_entrypoint(int argc, char *argv[], bool &tests_need_run);70static Error setup(const char *execpath, int argc, char *argv[], bool p_second_phase = true);71static Error setup2(bool p_show_boot_logo = true); // The thread calling setup2() will effectively become the main thread.72static String get_rendering_driver_name();73static void setup_boot_logo();74#ifdef TESTS_ENABLED75static Error test_setup();76static void test_cleanup();77#endif78static int start();7980static bool iteration();81static void force_redraw();8283static bool is_iterating();8485static void cleanup(bool p_force = false);86};8788// Test main override is for the testing behavior.89#define TEST_MAIN_OVERRIDE \90bool run_test = false; \91int return_code = Main::test_entrypoint(argc, argv, run_test); \92if (run_test) { \93return return_code; \94}9596#define TEST_MAIN_PARAM_OVERRIDE(argc, argv) \97bool run_test = false; \98int return_code = Main::test_entrypoint(argc, argv, run_test); \99if (run_test) { \100return return_code; \101}102103104