@@ -64,9 +64,24 @@ struct PluginConfigTVOS {
64
64
static const char * DEPENDENCIES_SYSTEM_KEY ;
65
65
static const char * DEPENDENCIES_CAPABILITIES_KEY ;
66
66
static const char * DEPENDENCIES_FILES_KEY ;
67
+ static const char * DEPENDENCIES_LINKER_FLAGS ;
67
68
68
69
static const char * PLIST_SECTION ;
69
70
71
+ enum PlistItemType {
72
+ UNKNOWN ,
73
+ STRING ,
74
+ INTEGER ,
75
+ BOOLEAN ,
76
+ RAW ,
77
+ STRING_INPUT ,
78
+ };
79
+
80
+ struct PlistItem {
81
+ PlistItemType type ;
82
+ String value ;
83
+ };
84
+
70
85
// Set to true when the config file is properly loaded.
71
86
bool valid_config = false;
72
87
bool supports_targets = false;
@@ -86,10 +101,13 @@ struct PluginConfigTVOS {
86
101
87
102
Vector < String > files_to_copy ;
88
103
Vector < String > capabilities ;
104
+ Vector < String > linker_flags ;
89
105
90
106
// Optional plist section
91
- // Supports only string types for now
92
- HashMap < String , String > plist ;
107
+ // String value is default value.
108
+ // Currently supports `string`, `boolean`, `integer`, `raw`, `string_input` types
109
+ // <name>:<type> = <value>
110
+ HashMap < String , PlistItem > plist ;
93
111
};
94
112
95
113
const char * PluginConfigTVOS ::PLUGIN_CONFIG_EXT = ".gdatvp" ;
@@ -106,6 +124,7 @@ const char *PluginConfigTVOS::DEPENDENCIES_EMBEDDED_KEY = "embedded";
106
124
const char * PluginConfigTVOS ::DEPENDENCIES_SYSTEM_KEY = "system" ;
107
125
const char * PluginConfigTVOS ::DEPENDENCIES_CAPABILITIES_KEY = "capabilities" ;
108
126
const char * PluginConfigTVOS ::DEPENDENCIES_FILES_KEY = "files" ;
127
+ const char * PluginConfigTVOS ::DEPENDENCIES_LINKER_FLAGS = "linker_flags" ;
109
128
110
129
const char * PluginConfigTVOS ::PLIST_SECTION = "plist" ;
111
130
@@ -247,6 +266,8 @@ static inline PluginConfigTVOS load_plugin_config(Ref<ConfigFile> config_file, c
247
266
return plugin_config ;
248
267
}
249
268
269
+ config_file -> clear ();
270
+
250
271
Error err = config_file -> load (path );
251
272
252
273
if (err != OK ) {
@@ -275,20 +296,77 @@ static inline PluginConfigTVOS load_plugin_config(Ref<ConfigFile> config_file, c
275
296
plugin_config .files_to_copy = resolve_local_dependencies (config_base_dir , files );
276
297
277
298
plugin_config .capabilities = config_file -> get_value (PluginConfigTVOS ::DEPENDENCIES_SECTION , PluginConfigTVOS ::DEPENDENCIES_CAPABILITIES_KEY , Vector < String > ( ));
299
+
300
+ plugin_config .linker_flags = config_file -> get_value (PluginConfigTVOS ::DEPENDENCIES_SECTION , PluginConfigTVOS ::DEPENDENCIES_LINKER_FLAGS , Vector < String > ( ));
278
301
}
279
302
280
303
if (config_file -> has_section (PluginConfigTVOS ::PLIST_SECTION )) {
281
304
List < String > keys ;
282
305
config_file -> get_section_keys (PluginConfigTVOS ::PLIST_SECTION , & keys );
283
306
284
307
for (int i = 0 ; i < keys .size (); i ++ ) {
285
- String value = config_file -> get_value (PluginConfigTVOS ::PLIST_SECTION , keys [i ], String ());
308
+ Vector < String > key_components = keys [i ].split (":" );
309
+
310
+ String key_value = "" ;
311
+ PluginConfigTVOS ::PlistItemType key_type = PluginConfigTVOS ::PlistItemType ::UNKNOWN ;
312
+
313
+ if (key_components .size () == 1 ) {
314
+ key_value = key_components [0 ];
315
+ key_type = PluginConfigTVOS ::PlistItemType ::STRING ;
316
+ } else if (key_components .size () == 2 ) {
317
+ key_value = key_components [0 ];
318
+
319
+ if (key_components [1 ].to_lower () == "string" ) {
320
+ key_type = PluginConfigTVOS ::PlistItemType ::STRING ;
321
+ } else if (key_components [1 ].to_lower () == "integer" ) {
322
+ key_type = PluginConfigTVOS ::PlistItemType ::INTEGER ;
323
+ } else if (key_components [1 ].to_lower () == "boolean" ) {
324
+ key_type = PluginConfigTVOS ::PlistItemType ::BOOLEAN ;
325
+ } else if (key_components [1 ].to_lower () == "raw" ) {
326
+ key_type = PluginConfigTVOS ::PlistItemType ::RAW ;
327
+ } else if (key_components [1 ].to_lower () == "string_input" ) {
328
+ key_type = PluginConfigTVOS ::PlistItemType ::STRING_INPUT ;
329
+ }
330
+ }
286
331
287
- if (value .empty ()) {
332
+ if (key_value .empty () || key_type == PluginConfigTVOS :: PlistItemType :: UNKNOWN ) {
288
333
continue ;
289
334
}
290
335
291
- plugin_config .plist [keys [i ]] = value ;
336
+ String value ;
337
+
338
+ switch (key_type ) {
339
+ case PluginConfigTVOS ::PlistItemType ::STRING : {
340
+ String raw_value = config_file -> get_value (PluginConfigTVOS ::PLIST_SECTION , keys [i ], String ());
341
+ value = "<string>" + raw_value + "</string>" ;
342
+ } break ;
343
+ case PluginConfigTVOS ::PlistItemType ::INTEGER : {
344
+ int raw_value = config_file -> get_value (PluginConfigTVOS ::PLIST_SECTION , keys [i ], 0 );
345
+ Dictionary value_dictionary ;
346
+ String value_format = "<integer>$value</integer>" ;
347
+ value_dictionary ["value" ] = raw_value ;
348
+ value = value_format .format (value_dictionary , "$_" );
349
+ } break ;
350
+ case PluginConfigTVOS ::PlistItemType ::BOOLEAN :
351
+ if (config_file -> get_value (PluginConfigTVOS ::PLIST_SECTION , keys [i ], false)) {
352
+ value = "<true/>" ;
353
+ } else {
354
+ value = "<false/>" ;
355
+ }
356
+ break ;
357
+ case PluginConfigTVOS ::PlistItemType ::RAW : {
358
+ String raw_value = config_file -> get_value (PluginConfigTVOS ::PLIST_SECTION , keys [i ], String ());
359
+ value = raw_value ;
360
+ } break ;
361
+ case PluginConfigTVOS ::PlistItemType ::STRING_INPUT : {
362
+ String raw_value = config_file -> get_value (PluginConfigTVOS ::PLIST_SECTION , keys [i ], String ());
363
+ value = raw_value ;
364
+ } break ;
365
+ default :
366
+ continue ;
367
+ }
368
+
369
+ plugin_config .plist [key_value ] = PluginConfigTVOS ::PlistItem { key_type , value };
292
370
}
293
371
}
294
372
0 commit comments