editor_export_plugin.h 10.0 KB

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