editor_export_plugin.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /*************************************************************************/
  2. /* editor_export_plugin.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
  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/native_extension.h"
  33. #include "editor_export_preset.h"
  34. #include "editor_export_shared_object.h"
  35. class EditorExportPlugin : public RefCounted {
  36. GDCLASS(EditorExportPlugin, RefCounted);
  37. friend class EditorExportPlatform;
  38. Ref<EditorExportPreset> export_preset;
  39. Vector<SharedObject> shared_objects;
  40. struct ExtraFile {
  41. String path;
  42. Vector<uint8_t> data;
  43. bool remap = false;
  44. };
  45. Vector<ExtraFile> extra_files;
  46. bool skipped = false;
  47. Vector<String> ios_frameworks;
  48. Vector<String> ios_embedded_frameworks;
  49. Vector<String> ios_project_static_libs;
  50. String ios_plist_content;
  51. String ios_linker_flags;
  52. Vector<String> ios_bundle_files;
  53. String ios_cpp_code;
  54. Vector<String> macos_plugin_files;
  55. _FORCE_INLINE_ void _clear() {
  56. shared_objects.clear();
  57. extra_files.clear();
  58. skipped = false;
  59. }
  60. _FORCE_INLINE_ void _export_end() {
  61. ios_frameworks.clear();
  62. ios_embedded_frameworks.clear();
  63. ios_bundle_files.clear();
  64. ios_plist_content = "";
  65. ios_linker_flags = "";
  66. ios_cpp_code = "";
  67. macos_plugin_files.clear();
  68. }
  69. void _export_file_script(const String &p_path, const String &p_type, const Vector<String> &p_features);
  70. void _export_begin_script(const Vector<String> &p_features, bool p_debug, const String &p_path, int p_flags);
  71. void _export_end_script();
  72. protected:
  73. void set_export_preset(const Ref<EditorExportPreset> &p_preset);
  74. Ref<EditorExportPreset> get_export_preset() const;
  75. void add_file(const String &p_path, const Vector<uint8_t> &p_file, bool p_remap);
  76. void add_shared_object(const String &p_path, const Vector<String> &tags, const String &p_target = String());
  77. void add_ios_framework(const String &p_path);
  78. void add_ios_embedded_framework(const String &p_path);
  79. void add_ios_project_static_lib(const String &p_path);
  80. void add_ios_plist_content(const String &p_plist_content);
  81. void add_ios_linker_flags(const String &p_flags);
  82. void add_ios_bundle_file(const String &p_path);
  83. void add_ios_cpp_code(const String &p_code);
  84. void add_macos_plugin_file(const String &p_path);
  85. void skip();
  86. virtual void _export_file(const String &p_path, const String &p_type, const HashSet<String> &p_features);
  87. virtual void _export_begin(const HashSet<String> &p_features, bool p_debug, const String &p_path, int p_flags);
  88. static void _bind_methods();
  89. GDVIRTUAL3(_export_file, String, String, Vector<String>)
  90. GDVIRTUAL4(_export_begin, Vector<String>, bool, String, uint32_t)
  91. GDVIRTUAL0(_export_end)
  92. public:
  93. Vector<String> get_ios_frameworks() const;
  94. Vector<String> get_ios_embedded_frameworks() const;
  95. Vector<String> get_ios_project_static_libs() const;
  96. String get_ios_plist_content() const;
  97. String get_ios_linker_flags() const;
  98. Vector<String> get_ios_bundle_files() const;
  99. String get_ios_cpp_code() const;
  100. const Vector<String> &get_macos_plugin_files() const;
  101. EditorExportPlugin();
  102. };
  103. class EditorExportTextSceneToBinaryPlugin : public EditorExportPlugin {
  104. GDCLASS(EditorExportTextSceneToBinaryPlugin, EditorExportPlugin);
  105. public:
  106. virtual void _export_file(const String &p_path, const String &p_type, const HashSet<String> &p_features) override;
  107. EditorExportTextSceneToBinaryPlugin();
  108. };
  109. #endif // EDITOR_EXPORT_PLUGIN_H