Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/editor/settings/editor_build_profile.h
21344 views
1
/**************************************************************************/
2
/* editor_build_profile.h */
3
/**************************************************************************/
4
/* This file is part of: */
5
/* GODOT ENGINE */
6
/* https://godotengine.org */
7
/**************************************************************************/
8
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10
/* */
11
/* Permission is hereby granted, free of charge, to any person obtaining */
12
/* a copy of this software and associated documentation files (the */
13
/* "Software"), to deal in the Software without restriction, including */
14
/* without limitation the rights to use, copy, modify, merge, publish, */
15
/* distribute, sublicense, and/or sell copies of the Software, and to */
16
/* permit persons to whom the Software is furnished to do so, subject to */
17
/* the following conditions: */
18
/* */
19
/* The above copyright notice and this permission notice shall be */
20
/* included in all copies or substantial portions of the Software. */
21
/* */
22
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
29
/**************************************************************************/
30
31
#pragma once
32
33
#include "core/object/ref_counted.h"
34
#include "editor/doc/editor_help.h"
35
#include "scene/gui/dialogs.h"
36
#include "scene/gui/tree.h"
37
38
class EditorBuildProfile : public RefCounted {
39
GDCLASS(EditorBuildProfile, RefCounted);
40
41
public:
42
enum BuildOption {
43
BUILD_OPTION_3D,
44
BUILD_OPTION_NAVIGATION_2D,
45
BUILD_OPTION_NAVIGATION_3D,
46
BUILD_OPTION_ACCESSKIT,
47
BUILD_OPTION_SDL,
48
BUILD_OPTION_XR,
49
BUILD_OPTION_OPENXR,
50
BUILD_OPTION_WAYLAND,
51
BUILD_OPTION_X11,
52
BUILD_OPTION_PULSEAUDIO,
53
BUILD_OPTION_ALSA,
54
BUILD_OPTION_RENDERING_DEVICE,
55
BUILD_OPTION_FORWARD_RENDERER,
56
BUILD_OPTION_MOBILE_RENDERER,
57
BUILD_OPTION_VULKAN,
58
BUILD_OPTION_D3D12,
59
BUILD_OPTION_METAL,
60
BUILD_OPTION_OPENGL,
61
BUILD_OPTION_PHYSICS_2D,
62
BUILD_OPTION_PHYSICS_GODOT_2D,
63
BUILD_OPTION_PHYSICS_3D,
64
BUILD_OPTION_PHYSICS_GODOT_3D,
65
BUILD_OPTION_PHYSICS_JOLT,
66
BUILD_OPTION_TEXT_SERVER_FALLBACK,
67
BUILD_OPTION_TEXT_SERVER_ADVANCED,
68
BUILD_OPTION_DYNAMIC_FONTS,
69
BUILD_OPTION_WOFF2_FONTS,
70
BUILD_OPTION_GRAPHITE_FONTS,
71
BUILD_OPTION_MSDFGEN,
72
BUILD_OPTION_MAX,
73
};
74
75
enum BuildOptionCategory {
76
BUILD_OPTION_CATEGORY_GENERAL,
77
BUILD_OPTION_CATEGORY_GRAPHICS,
78
BUILD_OPTION_CATEGORY_PHYSICS,
79
BUILD_OPTION_CATEGORY_TEXT_SERVER,
80
BUILD_OPTION_CATEGORY_MAX,
81
};
82
83
private:
84
HashSet<StringName> disabled_classes;
85
86
HashSet<StringName> collapsed_classes;
87
88
String force_detect_classes;
89
90
bool build_options_disabled[BUILD_OPTION_MAX] = {};
91
static const char *build_option_identifiers[BUILD_OPTION_MAX];
92
static const bool build_option_disabled_by_default[BUILD_OPTION_MAX];
93
static const bool build_option_disable_values[BUILD_OPTION_MAX];
94
static const bool build_option_explicit_use[BUILD_OPTION_MAX];
95
static const BuildOptionCategory build_option_category[BUILD_OPTION_MAX];
96
static const HashMap<BuildOption, LocalVector<BuildOption>> build_option_dependencies;
97
static HashMap<BuildOption, HashMap<String, LocalVector<Variant>>> build_option_settings;
98
static const HashMap<BuildOption, LocalVector<String>> build_option_classes;
99
100
String _get_build_option_name(BuildOption p_build_option) { return get_build_option_name(p_build_option); }
101
102
protected:
103
static void _bind_methods();
104
105
public:
106
void set_disable_class(const StringName &p_class, bool p_disabled);
107
bool is_class_disabled(const StringName &p_class) const;
108
109
void set_item_collapsed(const StringName &p_class, bool p_collapsed);
110
bool is_item_collapsed(const StringName &p_class) const;
111
112
void set_disable_build_option(BuildOption p_build_option, bool p_disable);
113
bool is_build_option_disabled(BuildOption p_build_option) const;
114
115
void reset_build_options();
116
117
void set_force_detect_classes(const String &p_classes);
118
String get_force_detect_classes() const;
119
120
void clear_disabled_classes();
121
122
Error save_to_file(const String &p_path);
123
Error load_from_file(const String &p_path);
124
125
static String get_build_option_name(BuildOption p_build_option);
126
static String get_build_option_description(BuildOption p_build_option);
127
static String get_build_option_identifier(BuildOption p_build_option);
128
static bool get_build_option_disable_value(BuildOption p_build_option);
129
static bool get_build_option_explicit_use(BuildOption p_build_option);
130
static BuildOptionCategory get_build_option_category(BuildOption p_build_option);
131
static LocalVector<BuildOption> get_build_option_dependencies(BuildOption p_build_option);
132
static HashMap<String, LocalVector<Variant>> get_build_option_settings(BuildOption p_build_option);
133
static LocalVector<String> get_build_option_classes(BuildOption p_build_option);
134
135
static String get_build_option_category_name(BuildOptionCategory p_build_option_category);
136
137
EditorBuildProfile();
138
};
139
140
VARIANT_ENUM_CAST(EditorBuildProfile::BuildOption)
141
VARIANT_ENUM_CAST(EditorBuildProfile::BuildOptionCategory)
142
143
class EditorFileDialog;
144
class EditorFileSystemDirectory;
145
146
class EditorBuildProfileManager : public AcceptDialog {
147
GDCLASS(EditorBuildProfileManager, AcceptDialog);
148
149
enum Action {
150
ACTION_NEW,
151
ACTION_RESET,
152
ACTION_LOAD,
153
ACTION_SAVE,
154
ACTION_SAVE_AS,
155
ACTION_DETECT,
156
ACTION_MAX
157
};
158
159
Action last_action = ACTION_NEW;
160
161
ConfirmationDialog *confirm_dialog = nullptr;
162
Button *profile_actions[ACTION_MAX];
163
164
Tree *class_list = nullptr;
165
EditorHelpBit *description_bit = nullptr;
166
167
EditorFileDialog *import_profile = nullptr;
168
EditorFileDialog *export_profile = nullptr;
169
170
LineEdit *profile_path = nullptr;
171
172
LineEdit *force_detect_classes = nullptr;
173
174
void _profile_action(int p_action);
175
void _action_confirm();
176
void _hide_requested();
177
178
void _update_edited_profile();
179
void _fill_classes_from(TreeItem *p_parent, const String &p_class, const String &p_selected);
180
181
Ref<EditorBuildProfile> edited;
182
183
void _import_profile(const String &p_path);
184
void _export_profile(const String &p_path);
185
186
bool updating_build_options = false;
187
188
void _class_list_item_selected();
189
void _class_list_item_edited();
190
void _class_list_item_collapsed(Object *p_item);
191
192
bool project_scan_canceled = false;
193
194
void _detect_from_project();
195
196
void _force_detect_classes_changed(const String &p_text);
197
198
struct DetectedFile {
199
uint32_t timestamp = 0;
200
String md5;
201
Vector<String> classes;
202
Vector<String> build_deps;
203
};
204
205
void _find_files(EditorFileSystemDirectory *p_dir, const HashMap<String, DetectedFile> &p_cache, HashMap<String, DetectedFile> &r_detected);
206
207
static EditorBuildProfileManager *singleton;
208
209
protected:
210
static void _bind_methods();
211
void _notification(int p_what);
212
213
public:
214
Ref<EditorBuildProfile> get_current_profile();
215
216
static EditorBuildProfileManager *get_singleton() { return singleton; }
217
EditorBuildProfileManager();
218
};
219
220