godot_plugin_config.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /**************************************************************************/
  2. /* godot_plugin_config.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 IOS_GODOT_PLUGIN_CONFIG_H
  31. #define IOS_GODOT_PLUGIN_CONFIG_H
  32. #include "core/error/error_list.h"
  33. #include "core/io/config_file.h"
  34. #include "core/string/ustring.h"
  35. /*
  36. The `config` section and fields are required and defined as follow:
  37. - **name**: name of the plugin
  38. - **binary**: path to static `.a` library
  39. - **use_swift_runtime**: optional boolean field used to determine if Swift runtime is used
  40. The `dependencies` and fields are optional.
  41. - **linked**: dependencies that should only be linked.
  42. - **embedded**: dependencies that should be linked and embedded into application.
  43. - **system**: system dependencies that should be linked.
  44. - **capabilities**: capabilities that would be used for `UIRequiredDeviceCapabilities` options in Info.plist file.
  45. - **files**: files that would be copied into application
  46. The `plist` section are optional.
  47. - **key**: key and value that would be added in Info.plist file.
  48. */
  49. struct PluginConfigIOS {
  50. inline static const char *PLUGIN_CONFIG_EXT = ".gdip";
  51. inline static const char *CONFIG_SECTION = "config";
  52. inline static const char *CONFIG_NAME_KEY = "name";
  53. inline static const char *CONFIG_BINARY_KEY = "binary";
  54. inline static const char *CONFIG_USE_SWIFT_KEY = "use_swift_runtime";
  55. inline static const char *CONFIG_INITIALIZE_KEY = "initialization";
  56. inline static const char *CONFIG_DEINITIALIZE_KEY = "deinitialization";
  57. inline static const char *DEPENDENCIES_SECTION = "dependencies";
  58. inline static const char *DEPENDENCIES_LINKED_KEY = "linked";
  59. inline static const char *DEPENDENCIES_EMBEDDED_KEY = "embedded";
  60. inline static const char *DEPENDENCIES_SYSTEM_KEY = "system";
  61. inline static const char *DEPENDENCIES_CAPABILITIES_KEY = "capabilities";
  62. inline static const char *DEPENDENCIES_FILES_KEY = "files";
  63. inline static const char *DEPENDENCIES_LINKER_FLAGS = "linker_flags";
  64. inline static const char *PLIST_SECTION = "plist";
  65. enum PlistItemType {
  66. UNKNOWN,
  67. STRING,
  68. INTEGER,
  69. BOOLEAN,
  70. RAW,
  71. STRING_INPUT,
  72. };
  73. struct PlistItem {
  74. PlistItemType type;
  75. String value;
  76. };
  77. // Set to true when the config file is properly loaded.
  78. bool valid_config = false;
  79. bool supports_targets = false;
  80. // Unix timestamp of last change to this plugin.
  81. uint64_t last_updated = 0;
  82. // Required config section
  83. String name;
  84. String binary;
  85. bool use_swift_runtime;
  86. String initialization_method;
  87. String deinitialization_method;
  88. // Optional dependencies section
  89. Vector<String> linked_dependencies;
  90. Vector<String> embedded_dependencies;
  91. Vector<String> system_dependencies;
  92. Vector<String> files_to_copy;
  93. Vector<String> capabilities;
  94. Vector<String> linker_flags;
  95. // Optional plist section
  96. // String value is default value.
  97. // Currently supports `string`, `boolean`, `integer`, `raw`, `string_input` types
  98. // <name>:<type> = <value>
  99. HashMap<String, PlistItem> plist;
  100. static String resolve_local_dependency_path(String plugin_config_dir, String dependency_path);
  101. static String resolve_system_dependency_path(String dependency_path);
  102. static Vector<String> resolve_local_dependencies(String plugin_config_dir, Vector<String> p_paths);
  103. static Vector<String> resolve_system_dependencies(Vector<String> p_paths);
  104. static bool validate_plugin(PluginConfigIOS &plugin_config);
  105. static String get_plugin_main_binary(PluginConfigIOS &plugin_config, bool p_debug);
  106. static uint64_t get_plugin_modification_time(const PluginConfigIOS &plugin_config, const String &config_path);
  107. static PluginConfigIOS load_plugin_config(Ref<ConfigFile> config_file, const String &path);
  108. };
  109. #endif // IOS_GODOT_PLUGIN_CONFIG_H