plugin_config_apple_embedded.h 5.6 KB

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