godot_plugin_config.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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 ANDROID_GODOT_PLUGIN_CONFIG_H
  31. #define ANDROID_GODOT_PLUGIN_CONFIG_H
  32. #ifndef DISABLE_DEPRECATED
  33. #include "core/config/project_settings.h"
  34. #include "core/error/error_list.h"
  35. #include "core/io/config_file.h"
  36. #include "core/string/ustring.h"
  37. /*
  38. The `config` section and fields are required and defined as follow:
  39. - **name**: name of the plugin.
  40. - **binary_type**: can be either `local` or `remote`. The type affects the **binary** field.
  41. - **binary**:
  42. - if **binary_type** is `local`, then this should be the filename of the plugin `aar` file in the `res://android/plugins` directory (e.g: `MyPlugin.aar`).
  43. - if **binary_type** is `remote`, then this should be a declaration for a remote gradle binary (e.g: "org.godot.example:my-plugin:0.0.0").
  44. The `dependencies` section and fields are optional and defined as follow:
  45. - **local**: contains a list of local `.aar` binary files the plugin depends on. The local binary dependencies must also be located in the `res://android/plugins` directory.
  46. - **remote**: contains a list of remote binary gradle dependencies for the plugin.
  47. - **custom_maven_repos**: contains a list of urls specifying custom maven repos required for the plugin's dependencies.
  48. See https://github.com/godotengine/godot/issues/38157#issuecomment-618773871
  49. */
  50. struct PluginConfigAndroid {
  51. inline static const char *PLUGIN_CONFIG_EXT = ".gdap";
  52. inline static const char *CONFIG_SECTION = "config";
  53. inline static const char *CONFIG_NAME_KEY = "name";
  54. inline static const char *CONFIG_BINARY_TYPE_KEY = "binary_type";
  55. inline static const char *CONFIG_BINARY_KEY = "binary";
  56. inline static const char *DEPENDENCIES_SECTION = "dependencies";
  57. inline static const char *DEPENDENCIES_LOCAL_KEY = "local";
  58. inline static const char *DEPENDENCIES_REMOTE_KEY = "remote";
  59. inline static const char *DEPENDENCIES_CUSTOM_MAVEN_REPOS_KEY = "custom_maven_repos";
  60. inline static const char *BINARY_TYPE_LOCAL = "local";
  61. inline static const char *BINARY_TYPE_REMOTE = "remote";
  62. // Set to true when the config file is properly loaded.
  63. bool valid_config = false;
  64. // Unix timestamp of last change to this plugin.
  65. uint64_t last_updated = 0;
  66. // Required config section
  67. String name;
  68. String binary_type;
  69. String binary;
  70. // Optional dependencies section
  71. Vector<String> local_dependencies;
  72. Vector<String> remote_dependencies;
  73. Vector<String> custom_maven_repos;
  74. static String resolve_local_dependency_path(String plugin_config_dir, String dependency_path);
  75. static PluginConfigAndroid resolve_prebuilt_plugin(PluginConfigAndroid prebuilt_plugin, String plugin_config_dir);
  76. static Vector<PluginConfigAndroid> get_prebuilt_plugins(String plugins_base_dir);
  77. static bool is_plugin_config_valid(PluginConfigAndroid plugin_config);
  78. static uint64_t get_plugin_modification_time(const PluginConfigAndroid &plugin_config, const String &config_path);
  79. static PluginConfigAndroid load_plugin_config(Ref<ConfigFile> config_file, const String &path);
  80. static void get_plugins_binaries(String binary_type, Vector<PluginConfigAndroid> plugins_configs, Vector<String> &r_result);
  81. static void get_plugins_custom_maven_repos(Vector<PluginConfigAndroid> plugins_configs, Vector<String> &r_result);
  82. static void get_plugins_names(Vector<PluginConfigAndroid> plugins_configs, Vector<String> &r_result);
  83. };
  84. #endif // DISABLE_DEPRECATED
  85. #endif // ANDROID_GODOT_PLUGIN_CONFIG_H