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