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