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