@@ -64,9 +64,24 @@ struct PluginConfigTVOS {
6464 static const char * DEPENDENCIES_SYSTEM_KEY ;
6565 static const char * DEPENDENCIES_CAPABILITIES_KEY ;
6666 static const char * DEPENDENCIES_FILES_KEY ;
67+ static const char * DEPENDENCIES_LINKER_FLAGS ;
6768
6869 static const char * PLIST_SECTION ;
6970
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+
7085 // Set to true when the config file is properly loaded.
7186 bool valid_config = false;
7287 bool supports_targets = false;
@@ -86,10 +101,13 @@ struct PluginConfigTVOS {
86101
87102 Vector < String > files_to_copy ;
88103 Vector < String > capabilities ;
104+ Vector < String > linker_flags ;
89105
90106 // 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 ;
93111};
94112
95113const char * PluginConfigTVOS ::PLUGIN_CONFIG_EXT = ".gdatvp" ;
@@ -106,6 +124,7 @@ const char *PluginConfigTVOS::DEPENDENCIES_EMBEDDED_KEY = "embedded";
106124const char * PluginConfigTVOS ::DEPENDENCIES_SYSTEM_KEY = "system" ;
107125const char * PluginConfigTVOS ::DEPENDENCIES_CAPABILITIES_KEY = "capabilities" ;
108126const char * PluginConfigTVOS ::DEPENDENCIES_FILES_KEY = "files" ;
127+ const char * PluginConfigTVOS ::DEPENDENCIES_LINKER_FLAGS = "linker_flags" ;
109128
110129const char * PluginConfigTVOS ::PLIST_SECTION = "plist" ;
111130
@@ -247,6 +266,8 @@ static inline PluginConfigTVOS load_plugin_config(Ref<ConfigFile> config_file, c
247266 return plugin_config ;
248267 }
249268
269+ config_file -> clear ();
270+
250271 Error err = config_file -> load (path );
251272
252273 if (err != OK ) {
@@ -275,20 +296,77 @@ static inline PluginConfigTVOS load_plugin_config(Ref<ConfigFile> config_file, c
275296 plugin_config .files_to_copy = resolve_local_dependencies (config_base_dir , files );
276297
277298 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 > ( ));
278301 }
279302
280303 if (config_file -> has_section (PluginConfigTVOS ::PLIST_SECTION )) {
281304 List < String > keys ;
282305 config_file -> get_section_keys (PluginConfigTVOS ::PLIST_SECTION , & keys );
283306
284307 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+ }
286331
287- if (value .empty ()) {
332+ if (key_value .empty () || key_type == PluginConfigTVOS :: PlistItemType :: UNKNOWN ) {
288333 continue ;
289334 }
290335
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 };
292370 }
293371 }
294372
0 commit comments