editor_export_plugin.h 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  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. void add_file(const String &p_path, const Vector<uint8_t> &p_file, bool p_remap);
  82. void add_shared_object(const String &p_path, const Vector<String> &tags, const String &p_target = String());
  83. void _add_shared_object(const SharedObject &p_shared_object);
  84. void add_ios_framework(const String &p_path);
  85. void add_ios_embedded_framework(const String &p_path);
  86. void add_ios_project_static_lib(const String &p_path);
  87. void add_ios_plist_content(const String &p_plist_content);
  88. void add_ios_linker_flags(const String &p_flags);
  89. void add_ios_bundle_file(const String &p_path);
  90. void add_ios_cpp_code(const String &p_code);
  91. void add_macos_plugin_file(const String &p_path);
  92. void skip();
  93. virtual void _export_file(const String &p_path, const String &p_type, const HashSet<String> &p_features);
  94. virtual void _export_begin(const HashSet<String> &p_features, bool p_debug, const String &p_path, int p_flags);
  95. virtual void _export_end();
  96. static void _bind_methods();
  97. GDVIRTUAL3(_export_file, String, String, Vector<String>)
  98. GDVIRTUAL4(_export_begin, Vector<String>, bool, String, uint32_t)
  99. GDVIRTUAL0(_export_end)
  100. GDVIRTUAL2RC(bool, _begin_customize_resources, const Ref<EditorExportPlatform> &, const Vector<String> &)
  101. GDVIRTUAL2R(Ref<Resource>, _customize_resource, const Ref<Resource> &, String)
  102. GDVIRTUAL2RC(bool, _begin_customize_scenes, const Ref<EditorExportPlatform> &, const Vector<String> &)
  103. GDVIRTUAL2R(Node *, _customize_scene, Node *, String)
  104. GDVIRTUAL0RC(uint64_t, _get_customization_configuration_hash)
  105. GDVIRTUAL0(_end_customize_scenes)
  106. GDVIRTUAL0(_end_customize_resources)
  107. GDVIRTUAL2RC(PackedStringArray, _get_export_features, const Ref<EditorExportPlatform> &, bool);
  108. GDVIRTUAL1RC(TypedArray<Dictionary>, _get_export_options, const Ref<EditorExportPlatform> &);
  109. GDVIRTUAL1RC(Dictionary, _get_export_options_overrides, const Ref<EditorExportPlatform> &);
  110. GDVIRTUAL1RC(bool, _should_update_export_options, const Ref<EditorExportPlatform> &);
  111. GDVIRTUAL2RC(String, _get_export_option_warning, const Ref<EditorExportPlatform> &, String);
  112. GDVIRTUAL0RC(String, _get_name)
  113. GDVIRTUAL1RC(bool, _supports_platform, const Ref<EditorExportPlatform> &);
  114. GDVIRTUAL2RC(PackedStringArray, _get_android_dependencies, const Ref<EditorExportPlatform> &, bool);
  115. GDVIRTUAL2RC(PackedStringArray, _get_android_dependencies_maven_repos, const Ref<EditorExportPlatform> &, bool);
  116. GDVIRTUAL2RC(PackedStringArray, _get_android_libraries, const Ref<EditorExportPlatform> &, bool);
  117. GDVIRTUAL2RC(String, _get_android_manifest_activity_element_contents, const Ref<EditorExportPlatform> &, bool);
  118. GDVIRTUAL2RC(String, _get_android_manifest_application_element_contents, const Ref<EditorExportPlatform> &, bool);
  119. GDVIRTUAL2RC(String, _get_android_manifest_element_contents, const Ref<EditorExportPlatform> &, bool);
  120. virtual bool _begin_customize_resources(const Ref<EditorExportPlatform> &p_platform, const Vector<String> &p_features); // Return true if this plugin does property export customization
  121. 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.
  122. virtual bool _begin_customize_scenes(const Ref<EditorExportPlatform> &p_platform, const Vector<String> &p_features); // Return true if this plugin does property export customization
  123. virtual Node *_customize_scene(Node *p_root, const String &p_path); // Return true if a change was made
  124. virtual uint64_t _get_customization_configuration_hash() const; // Hash used for caching customized resources and scenes.
  125. virtual void _end_customize_scenes();
  126. virtual void _end_customize_resources();
  127. virtual PackedStringArray _get_export_features(const Ref<EditorExportPlatform> &p_export_platform, bool p_debug) const;
  128. virtual void _get_export_options(const Ref<EditorExportPlatform> &p_export_platform, List<EditorExportPlatform::ExportOption> *r_options) const;
  129. virtual Dictionary _get_export_options_overrides(const Ref<EditorExportPlatform> &p_export_platform) const;
  130. virtual bool _should_update_export_options(const Ref<EditorExportPlatform> &p_export_platform) const;
  131. virtual String _get_export_option_warning(const Ref<EditorExportPlatform> &p_export_platform, const String &p_option_name) const;
  132. public:
  133. virtual String get_name() const;
  134. virtual bool supports_platform(const Ref<EditorExportPlatform> &p_export_platform) const;
  135. virtual PackedStringArray get_android_dependencies(const Ref<EditorExportPlatform> &p_export_platform, bool p_debug) const;
  136. virtual PackedStringArray get_android_dependencies_maven_repos(const Ref<EditorExportPlatform> &p_export_platform, bool p_debug) const;
  137. virtual PackedStringArray get_android_libraries(const Ref<EditorExportPlatform> &p_export_platform, bool p_debug) const;
  138. virtual String get_android_manifest_activity_element_contents(const Ref<EditorExportPlatform> &p_export_platform, bool p_debug) const;
  139. virtual String get_android_manifest_application_element_contents(const Ref<EditorExportPlatform> &p_export_platform, bool p_debug) const;
  140. virtual String get_android_manifest_element_contents(const Ref<EditorExportPlatform> &p_export_platform, bool p_debug) const;
  141. Vector<String> get_ios_frameworks() const;
  142. Vector<String> get_ios_embedded_frameworks() const;
  143. Vector<String> get_ios_project_static_libs() const;
  144. String get_ios_plist_content() const;
  145. String get_ios_linker_flags() const;
  146. Vector<String> get_ios_bundle_files() const;
  147. String get_ios_cpp_code() const;
  148. const Vector<String> &get_macos_plugin_files() const;
  149. Variant get_option(const StringName &p_name) const;
  150. EditorExportPlugin();
  151. };
  152. #endif // EDITOR_EXPORT_PLUGIN_H