editor_export_plugin.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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 "editor_export_preset.h"
  34. #include "editor_export_shared_object.h"
  35. #include "scene/main/node.h"
  36. class EditorExportPlugin : public RefCounted {
  37. GDCLASS(EditorExportPlugin, RefCounted);
  38. friend class EditorExportPlatform;
  39. Ref<EditorExportPreset> export_preset;
  40. Vector<SharedObject> shared_objects;
  41. struct ExtraFile {
  42. String path;
  43. Vector<uint8_t> data;
  44. bool remap = false;
  45. };
  46. Vector<ExtraFile> extra_files;
  47. bool skipped = false;
  48. Vector<String> ios_frameworks;
  49. Vector<String> ios_embedded_frameworks;
  50. Vector<String> ios_project_static_libs;
  51. String ios_plist_content;
  52. String ios_linker_flags;
  53. Vector<String> ios_bundle_files;
  54. String ios_cpp_code;
  55. Vector<String> macos_plugin_files;
  56. _FORCE_INLINE_ void _clear() {
  57. shared_objects.clear();
  58. extra_files.clear();
  59. skipped = false;
  60. }
  61. _FORCE_INLINE_ void _export_end() {
  62. ios_frameworks.clear();
  63. ios_embedded_frameworks.clear();
  64. ios_bundle_files.clear();
  65. ios_plist_content = "";
  66. ios_linker_flags = "";
  67. ios_cpp_code = "";
  68. macos_plugin_files.clear();
  69. }
  70. // Export
  71. void _export_file_script(const String &p_path, const String &p_type, const Vector<String> &p_features);
  72. void _export_begin_script(const Vector<String> &p_features, bool p_debug, const String &p_path, int p_flags);
  73. void _export_end_script();
  74. protected:
  75. void set_export_preset(const Ref<EditorExportPreset> &p_preset);
  76. Ref<EditorExportPreset> get_export_preset() const;
  77. void add_file(const String &p_path, const Vector<uint8_t> &p_file, bool p_remap);
  78. void add_shared_object(const String &p_path, const Vector<String> &tags, const String &p_target = String());
  79. void add_ios_framework(const String &p_path);
  80. void add_ios_embedded_framework(const String &p_path);
  81. void add_ios_project_static_lib(const String &p_path);
  82. void add_ios_plist_content(const String &p_plist_content);
  83. void add_ios_linker_flags(const String &p_flags);
  84. void add_ios_bundle_file(const String &p_path);
  85. void add_ios_cpp_code(const String &p_code);
  86. void add_macos_plugin_file(const String &p_path);
  87. void skip();
  88. virtual void _export_file(const String &p_path, const String &p_type, const HashSet<String> &p_features);
  89. virtual void _export_begin(const HashSet<String> &p_features, bool p_debug, const String &p_path, int p_flags);
  90. static void _bind_methods();
  91. GDVIRTUAL3(_export_file, String, String, Vector<String>)
  92. GDVIRTUAL4(_export_begin, Vector<String>, bool, String, uint32_t)
  93. GDVIRTUAL0(_export_end)
  94. GDVIRTUAL2RC(bool, _begin_customize_resources, const Ref<EditorExportPlatform> &, const Vector<String> &)
  95. GDVIRTUAL2R(Ref<Resource>, _customize_resource, const Ref<Resource> &, String)
  96. GDVIRTUAL2RC(bool, _begin_customize_scenes, const Ref<EditorExportPlatform> &, const Vector<String> &)
  97. GDVIRTUAL2R(Node *, _customize_scene, Node *, String)
  98. GDVIRTUAL0RC(uint64_t, _get_customization_configuration_hash)
  99. GDVIRTUAL0(_end_customize_scenes)
  100. GDVIRTUAL0(_end_customize_resources)
  101. GDVIRTUAL2RC(PackedStringArray, _get_export_features, const Ref<EditorExportPlatform> &, bool);
  102. GDVIRTUAL0RC(String, _get_name)
  103. virtual bool _begin_customize_resources(const Ref<EditorExportPlatform> &p_platform, const Vector<String> &p_features); // Return true if this plugin does property export customization
  104. 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.
  105. virtual bool _begin_customize_scenes(const Ref<EditorExportPlatform> &p_platform, const Vector<String> &p_features); // Return true if this plugin does property export customization
  106. virtual Node *_customize_scene(Node *p_root, const String &p_path); // Return true if a change was made
  107. virtual uint64_t _get_customization_configuration_hash() const; // Hash used for caching customized resources and scenes.
  108. virtual void _end_customize_scenes();
  109. virtual void _end_customize_resources();
  110. virtual PackedStringArray _get_export_features(const Ref<EditorExportPlatform> &p_export_platform, bool p_debug) const;
  111. virtual String _get_name() const;
  112. public:
  113. Vector<String> get_ios_frameworks() const;
  114. Vector<String> get_ios_embedded_frameworks() const;
  115. Vector<String> get_ios_project_static_libs() const;
  116. String get_ios_plist_content() const;
  117. String get_ios_linker_flags() const;
  118. Vector<String> get_ios_bundle_files() const;
  119. String get_ios_cpp_code() const;
  120. const Vector<String> &get_macos_plugin_files() const;
  121. EditorExportPlugin();
  122. };
  123. #endif // EDITOR_EXPORT_PLUGIN_H