1/**************************************************************************/
2/* editor_export_plugin.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#ifndef EDITOR_EXPORT_PLUGIN_H
32#define EDITOR_EXPORT_PLUGIN_H
33
34#include "core/extension/gdextension.h"
35#include "editor_export_platform.h"
36#include "editor_export_preset.h"
37#include "editor_export_shared_object.h"
38#include "scene/main/node.h"
39
40class EditorExportPlugin : public RefCounted {
41 GDCLASS(EditorExportPlugin, RefCounted);
42
43 friend class EditorExport;
44 friend class EditorExportPlatform;
45 friend class EditorExportPreset;
46
47 Ref<EditorExportPreset> export_preset;
48
49 Vector<SharedObject> shared_objects;
50 struct ExtraFile {
51 String path;
52 Vector<uint8_t> data;
53 bool remap = false;
54 };
55 Vector<ExtraFile> extra_files;
56 bool skipped = false;
57
58 Vector<String> ios_frameworks;
59 Vector<String> ios_embedded_frameworks;
60 Vector<String> ios_project_static_libs;
61 String ios_plist_content;
62 String ios_linker_flags;
63 Vector<String> ios_bundle_files;
64 String ios_cpp_code;
65
66 Vector<String> macos_plugin_files;
67
68 _FORCE_INLINE_ void _clear() {
69 shared_objects.clear();
70 extra_files.clear();
71 skipped = false;
72 }
73
74 _FORCE_INLINE_ void _export_end() {
75 ios_frameworks.clear();
76 ios_embedded_frameworks.clear();
77 ios_bundle_files.clear();
78 ios_plist_content = "";
79 ios_linker_flags = "";
80 ios_cpp_code = "";
81 macos_plugin_files.clear();
82 }
83
84 // Export
85 void _export_file_script(const String &p_path, const String &p_type, const Vector<String> &p_features);
86 void _export_begin_script(const Vector<String> &p_features, bool p_debug, const String &p_path, int p_flags);
87 void _export_end_script();
88
89 String _has_valid_export_configuration(const Ref<EditorExportPlatform> &p_export_platform, const Ref<EditorExportPreset> &p_preset);
90
91protected:
92 void set_export_preset(const Ref<EditorExportPreset> &p_preset);
93 Ref<EditorExportPreset> get_export_preset() const;
94
95 void add_file(const String &p_path, const Vector<uint8_t> &p_file, bool p_remap);
96 void add_shared_object(const String &p_path, const Vector<String> &tags, const String &p_target = String());
97
98 void add_ios_framework(const String &p_path);
99 void add_ios_embedded_framework(const String &p_path);
100 void add_ios_project_static_lib(const String &p_path);
101 void add_ios_plist_content(const String &p_plist_content);
102 void add_ios_linker_flags(const String &p_flags);
103 void add_ios_bundle_file(const String &p_path);
104 void add_ios_cpp_code(const String &p_code);
105 void add_macos_plugin_file(const String &p_path);
106
107 void skip();
108
109 virtual void _export_file(const String &p_path, const String &p_type, const HashSet<String> &p_features);
110 virtual void _export_begin(const HashSet<String> &p_features, bool p_debug, const String &p_path, int p_flags);
111
112 static void _bind_methods();
113
114 GDVIRTUAL3(_export_file, String, String, Vector<String>)
115 GDVIRTUAL4(_export_begin, Vector<String>, bool, String, uint32_t)
116 GDVIRTUAL0(_export_end)
117
118 GDVIRTUAL2RC(bool, _begin_customize_resources, const Ref<EditorExportPlatform> &, const Vector<String> &)
119 GDVIRTUAL2R(Ref<Resource>, _customize_resource, const Ref<Resource> &, String)
120
121 GDVIRTUAL2RC(bool, _begin_customize_scenes, const Ref<EditorExportPlatform> &, const Vector<String> &)
122 GDVIRTUAL2R(Node *, _customize_scene, Node *, String)
123 GDVIRTUAL0RC(uint64_t, _get_customization_configuration_hash)
124
125 GDVIRTUAL0(_end_customize_scenes)
126 GDVIRTUAL0(_end_customize_resources)
127
128 GDVIRTUAL2RC(PackedStringArray, _get_export_features, const Ref<EditorExportPlatform> &, bool);
129 GDVIRTUAL1RC(TypedArray<Dictionary>, _get_export_options, const Ref<EditorExportPlatform> &);
130 GDVIRTUAL1RC(bool, _should_update_export_options, const Ref<EditorExportPlatform> &);
131 GDVIRTUAL2RC(String, _get_export_option_warning, const Ref<EditorExportPlatform> &, String);
132
133 GDVIRTUAL0RC(String, _get_name)
134
135 GDVIRTUAL1RC(bool, _supports_platform, const Ref<EditorExportPlatform> &);
136
137 GDVIRTUAL2RC(PackedStringArray, _get_android_dependencies, const Ref<EditorExportPlatform> &, bool);
138 GDVIRTUAL2RC(PackedStringArray, _get_android_dependencies_maven_repos, const Ref<EditorExportPlatform> &, bool);
139 GDVIRTUAL2RC(PackedStringArray, _get_android_libraries, const Ref<EditorExportPlatform> &, bool);
140 GDVIRTUAL2RC(String, _get_android_manifest_activity_element_contents, const Ref<EditorExportPlatform> &, bool);
141 GDVIRTUAL2RC(String, _get_android_manifest_application_element_contents, const Ref<EditorExportPlatform> &, bool);
142 GDVIRTUAL2RC(String, _get_android_manifest_element_contents, const Ref<EditorExportPlatform> &, bool);
143
144 virtual bool _begin_customize_resources(const Ref<EditorExportPlatform> &p_platform, const Vector<String> &p_features); // Return true if this plugin does property export customization
145 virtual Ref<Resource> _customize_resource(const Ref<Resource> &p_resource, const String &p_path); // If nothing is returned, it means do not touch (nothing changed). If something is returned (either the same or a different resource) it means changes are made.
146
147 virtual bool _begin_customize_scenes(const Ref<EditorExportPlatform> &p_platform, const Vector<String> &p_features); // Return true if this plugin does property export customization
148 virtual Node *_customize_scene(Node *p_root, const String &p_path); // Return true if a change was made
149
150 virtual uint64_t _get_customization_configuration_hash() const; // Hash used for caching customized resources and scenes.
151
152 virtual void _end_customize_scenes();
153 virtual void _end_customize_resources();
154
155 virtual PackedStringArray _get_export_features(const Ref<EditorExportPlatform> &p_export_platform, bool p_debug) const;
156 virtual void _get_export_options(const Ref<EditorExportPlatform> &p_export_platform, List<EditorExportPlatform::ExportOption> *r_options) const;
157 virtual bool _should_update_export_options(const Ref<EditorExportPlatform> &p_export_platform) const;
158 virtual String _get_export_option_warning(const Ref<EditorExportPlatform> &p_export_platform, const String &p_option_name) const;
159
160public:
161 virtual String get_name() const;
162
163 virtual bool supports_platform(const Ref<EditorExportPlatform> &p_export_platform) const;
164
165 virtual PackedStringArray get_android_dependencies(const Ref<EditorExportPlatform> &p_export_platform, bool p_debug) const;
166 virtual PackedStringArray get_android_dependencies_maven_repos(const Ref<EditorExportPlatform> &p_export_platform, bool p_debug) const;
167 virtual PackedStringArray get_android_libraries(const Ref<EditorExportPlatform> &p_export_platform, bool p_debug) const;
168 virtual String get_android_manifest_activity_element_contents(const Ref<EditorExportPlatform> &p_export_platform, bool p_debug) const;
169 virtual String get_android_manifest_application_element_contents(const Ref<EditorExportPlatform> &p_export_platform, bool p_debug) const;
170 virtual String get_android_manifest_element_contents(const Ref<EditorExportPlatform> &p_export_platform, bool p_debug) const;
171
172 Vector<String> get_ios_frameworks() const;
173 Vector<String> get_ios_embedded_frameworks() const;
174 Vector<String> get_ios_project_static_libs() const;
175 String get_ios_plist_content() const;
176 String get_ios_linker_flags() const;
177 Vector<String> get_ios_bundle_files() const;
178 String get_ios_cpp_code() const;
179 const Vector<String> &get_macos_plugin_files() const;
180 Variant get_option(const StringName &p_name) const;
181
182 EditorExportPlugin();
183};
184
185#endif // EDITOR_EXPORT_PLUGIN_H
186