godot_plugin_config.h 5.4 KB

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