mirror of
				https://github.com/godotengine/godot.git
				synced 2025-11-04 07:31:16 +00:00 
			
		
		
		
	iOS Export: support multi-target plugin
Plugins can use 'binary_name.a' or 'binary_name.release.a' and 'binary_name.debug.a' for plugin library.
This commit is contained in:
		
							parent
							
								
									d5047603a3
								
							
						
					
					
						commit
						cb15abda29
					
				
					 2 changed files with 210 additions and 137 deletions
				
			
		| 
						 | 
					@ -112,9 +112,10 @@ class EditorExportPlatformIOS : public EditorExportPlatform {
 | 
				
			||||||
	Vector<String> _get_preset_architectures(const Ref<EditorExportPreset> &p_preset);
 | 
						Vector<String> _get_preset_architectures(const Ref<EditorExportPreset> &p_preset);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	void _add_assets_to_project(const Ref<EditorExportPreset> &p_preset, Vector<uint8_t> &p_project_data, const Vector<IOSExportAsset> &p_additional_assets);
 | 
						void _add_assets_to_project(const Ref<EditorExportPreset> &p_preset, Vector<uint8_t> &p_project_data, const Vector<IOSExportAsset> &p_additional_assets);
 | 
				
			||||||
 | 
						Error _copy_asset(const String &p_out_dir, const String &p_asset, const String *p_custom_file_name, bool p_is_framework, bool p_should_embed, Vector<IOSExportAsset> &r_exported_assets);
 | 
				
			||||||
	Error _export_additional_assets(const String &p_out_dir, const Vector<String> &p_assets, bool p_is_framework, bool p_should_embed, Vector<IOSExportAsset> &r_exported_assets);
 | 
						Error _export_additional_assets(const String &p_out_dir, const Vector<String> &p_assets, bool p_is_framework, bool p_should_embed, Vector<IOSExportAsset> &r_exported_assets);
 | 
				
			||||||
	Error _export_additional_assets(const String &p_out_dir, const Vector<SharedObject> &p_libraries, Vector<IOSExportAsset> &r_exported_assets);
 | 
						Error _export_additional_assets(const String &p_out_dir, const Vector<SharedObject> &p_libraries, Vector<IOSExportAsset> &r_exported_assets);
 | 
				
			||||||
	Error _export_plugins(const Ref<EditorExportPreset> &p_preset, IOSConfigData &p_config_data, const String &dest_dir, Vector<IOSExportAsset> &r_exported_assets);
 | 
						Error _export_ios_plugins(const Ref<EditorExportPreset> &p_preset, IOSConfigData &p_config_data, const String &dest_dir, Vector<IOSExportAsset> &r_exported_assets, bool p_debug);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	bool is_package_name_valid(const String &p_package, String *r_error = NULL) const {
 | 
						bool is_package_name_valid(const String &p_package, String *r_error = NULL) const {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -992,61 +993,76 @@ void EditorExportPlatformIOS::_add_assets_to_project(const Ref<EditorExportPrese
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Error EditorExportPlatformIOS::_export_additional_assets(const String &p_out_dir, const Vector<String> &p_assets, bool p_is_framework, bool p_should_embed, Vector<IOSExportAsset> &r_exported_assets) {
 | 
					Error EditorExportPlatformIOS::_copy_asset(const String &p_out_dir, const String &p_asset, const String *p_custom_file_name, bool p_is_framework, bool p_should_embed, Vector<IOSExportAsset> &r_exported_assets) {
 | 
				
			||||||
	DirAccess *filesystem_da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
 | 
						DirAccess *filesystem_da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
 | 
				
			||||||
 | 
						ERR_FAIL_COND_V_MSG(!filesystem_da, ERR_CANT_CREATE, "Cannot create DirAccess for path '" + p_out_dir + "'.");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	String binary_name = p_out_dir.get_file().get_basename();
 | 
						String binary_name = p_out_dir.get_file().get_basename();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ERR_FAIL_COND_V_MSG(!filesystem_da, ERR_CANT_CREATE, "Cannot create DirAccess for path '" + p_out_dir + "'.");
 | 
						DirAccess *da = DirAccess::create_for_path(p_asset);
 | 
				
			||||||
	for (int f_idx = 0; f_idx < p_assets.size(); ++f_idx) {
 | 
					 | 
				
			||||||
		String asset = p_assets[f_idx];
 | 
					 | 
				
			||||||
		if (!asset.begins_with("res://")) {
 | 
					 | 
				
			||||||
			// either SDK-builtin or already a part of the export template
 | 
					 | 
				
			||||||
			IOSExportAsset exported_asset = { asset, p_is_framework, p_should_embed };
 | 
					 | 
				
			||||||
			r_exported_assets.push_back(exported_asset);
 | 
					 | 
				
			||||||
		} else {
 | 
					 | 
				
			||||||
			DirAccess *da = DirAccess::create_for_path(asset);
 | 
					 | 
				
			||||||
	if (!da) {
 | 
						if (!da) {
 | 
				
			||||||
		memdelete(filesystem_da);
 | 
							memdelete(filesystem_da);
 | 
				
			||||||
				ERR_FAIL_V_MSG(ERR_CANT_CREATE, "Can't create directory: " + asset + ".");
 | 
							ERR_FAIL_V_MSG(ERR_CANT_CREATE, "Can't create directory: " + p_asset + ".");
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
			bool file_exists = da->file_exists(asset);
 | 
						bool file_exists = da->file_exists(p_asset);
 | 
				
			||||||
			bool dir_exists = da->dir_exists(asset);
 | 
						bool dir_exists = da->dir_exists(p_asset);
 | 
				
			||||||
	if (!file_exists && !dir_exists) {
 | 
						if (!file_exists && !dir_exists) {
 | 
				
			||||||
		memdelete(da);
 | 
							memdelete(da);
 | 
				
			||||||
		memdelete(filesystem_da);
 | 
							memdelete(filesystem_da);
 | 
				
			||||||
		return ERR_FILE_NOT_FOUND;
 | 
							return ERR_FILE_NOT_FOUND;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			String base_dir = asset.get_base_dir().replace("res://", "");
 | 
						String base_dir = p_asset.get_base_dir().replace("res://", "");
 | 
				
			||||||
	String destination_dir;
 | 
						String destination_dir;
 | 
				
			||||||
	String destination;
 | 
						String destination;
 | 
				
			||||||
	String asset_path;
 | 
						String asset_path;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	bool create_framework = false;
 | 
						bool create_framework = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			if (p_is_framework && asset.ends_with(".dylib")) {
 | 
						if (p_is_framework && p_asset.ends_with(".dylib")) {
 | 
				
			||||||
		// For iOS we need to turn .dylib into .framework
 | 
							// For iOS we need to turn .dylib into .framework
 | 
				
			||||||
		// to be able to send application to AppStore
 | 
							// to be able to send application to AppStore
 | 
				
			||||||
		asset_path = String("dylibs").plus_file(base_dir);
 | 
							asset_path = String("dylibs").plus_file(base_dir);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				String file_name = asset.get_basename().get_file();
 | 
							String file_name;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if (!p_custom_file_name) {
 | 
				
			||||||
 | 
								file_name = p_asset.get_basename().get_file();
 | 
				
			||||||
 | 
							} else {
 | 
				
			||||||
 | 
								file_name = *p_custom_file_name;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		String framework_name = file_name + ".framework";
 | 
							String framework_name = file_name + ".framework";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		asset_path = asset_path.plus_file(framework_name);
 | 
							asset_path = asset_path.plus_file(framework_name);
 | 
				
			||||||
		destination_dir = p_out_dir.plus_file(asset_path);
 | 
							destination_dir = p_out_dir.plus_file(asset_path);
 | 
				
			||||||
		destination = destination_dir.plus_file(file_name);
 | 
							destination = destination_dir.plus_file(file_name);
 | 
				
			||||||
		create_framework = true;
 | 
							create_framework = true;
 | 
				
			||||||
			} else if (p_is_framework && (asset.ends_with(".framework") || asset.ends_with(".xcframework"))) {
 | 
						} else if (p_is_framework && (p_asset.ends_with(".framework") || p_asset.ends_with(".xcframework"))) {
 | 
				
			||||||
		asset_path = String("dylibs").plus_file(base_dir);
 | 
							asset_path = String("dylibs").plus_file(base_dir);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				String file_name = asset.get_file();
 | 
							String file_name;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if (!p_custom_file_name) {
 | 
				
			||||||
 | 
								file_name = p_asset.get_file();
 | 
				
			||||||
 | 
							} else {
 | 
				
			||||||
 | 
								file_name = *p_custom_file_name;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		asset_path = asset_path.plus_file(file_name);
 | 
							asset_path = asset_path.plus_file(file_name);
 | 
				
			||||||
		destination_dir = p_out_dir.plus_file(asset_path);
 | 
							destination_dir = p_out_dir.plus_file(asset_path);
 | 
				
			||||||
		destination = destination_dir;
 | 
							destination = destination_dir;
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		asset_path = base_dir;
 | 
							asset_path = base_dir;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				String file_name = asset.get_file();
 | 
							String file_name;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if (!p_custom_file_name) {
 | 
				
			||||||
 | 
								file_name = p_asset.get_file();
 | 
				
			||||||
 | 
							} else {
 | 
				
			||||||
 | 
								file_name = *p_custom_file_name;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		destination_dir = p_out_dir.plus_file(asset_path);
 | 
							destination_dir = p_out_dir.plus_file(asset_path);
 | 
				
			||||||
		asset_path = asset_path.plus_file(file_name);
 | 
							asset_path = asset_path.plus_file(file_name);
 | 
				
			||||||
		destination = p_out_dir.plus_file(asset_path);
 | 
							destination = p_out_dir.plus_file(asset_path);
 | 
				
			||||||
| 
						 | 
					@ -1061,7 +1077,7 @@ Error EditorExportPlatformIOS::_export_additional_assets(const String &p_out_dir
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			Error err = dir_exists ? da->copy_dir(asset, destination) : da->copy(asset, destination);
 | 
						Error err = dir_exists ? da->copy_dir(p_asset, destination) : da->copy(p_asset, destination);
 | 
				
			||||||
	memdelete(da);
 | 
						memdelete(da);
 | 
				
			||||||
	if (err) {
 | 
						if (err) {
 | 
				
			||||||
		memdelete(filesystem_da);
 | 
							memdelete(filesystem_da);
 | 
				
			||||||
| 
						 | 
					@ -1071,7 +1087,14 @@ Error EditorExportPlatformIOS::_export_additional_assets(const String &p_out_dir
 | 
				
			||||||
	r_exported_assets.push_back(exported_asset);
 | 
						r_exported_assets.push_back(exported_asset);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (create_framework) {
 | 
						if (create_framework) {
 | 
				
			||||||
				String file_name = asset.get_basename().get_file();
 | 
							String file_name;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if (!p_custom_file_name) {
 | 
				
			||||||
 | 
								file_name = p_asset.get_basename().get_file();
 | 
				
			||||||
 | 
							} else {
 | 
				
			||||||
 | 
								file_name = *p_custom_file_name;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		String framework_name = file_name + ".framework";
 | 
							String framework_name = file_name + ".framework";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		// Performing `install_name_tool -id @rpath/{name}.framework/{name} ./{name}` on dylib
 | 
							// Performing `install_name_tool -id @rpath/{name}.framework/{name} ./{name}` on dylib
 | 
				
			||||||
| 
						 | 
					@ -1121,13 +1144,28 @@ Error EditorExportPlatformIOS::_export_additional_assets(const String &p_out_dir
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
		}
 | 
					
 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	memdelete(filesystem_da);
 | 
						memdelete(filesystem_da);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return OK;
 | 
						return OK;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Error EditorExportPlatformIOS::_export_additional_assets(const String &p_out_dir, const Vector<String> &p_assets, bool p_is_framework, bool p_should_embed, Vector<IOSExportAsset> &r_exported_assets) {
 | 
				
			||||||
 | 
						for (int f_idx = 0; f_idx < p_assets.size(); ++f_idx) {
 | 
				
			||||||
 | 
							String asset = p_assets[f_idx];
 | 
				
			||||||
 | 
							if (!asset.begins_with("res://")) {
 | 
				
			||||||
 | 
								// either SDK-builtin or already a part of the export template
 | 
				
			||||||
 | 
								IOSExportAsset exported_asset = { asset, p_is_framework, p_should_embed };
 | 
				
			||||||
 | 
								r_exported_assets.push_back(exported_asset);
 | 
				
			||||||
 | 
							} else {
 | 
				
			||||||
 | 
								Error err = _copy_asset(p_out_dir, asset, nullptr, p_is_framework, p_should_embed, r_exported_assets);
 | 
				
			||||||
 | 
								ERR_FAIL_COND_V(err, err);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return OK;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Error EditorExportPlatformIOS::_export_additional_assets(const String &p_out_dir, const Vector<SharedObject> &p_libraries, Vector<IOSExportAsset> &r_exported_assets) {
 | 
					Error EditorExportPlatformIOS::_export_additional_assets(const String &p_out_dir, const Vector<SharedObject> &p_libraries, Vector<IOSExportAsset> &r_exported_assets) {
 | 
				
			||||||
	Vector<Ref<EditorExportPlugin> > export_plugins = EditorExport::get_singleton()->get_export_plugins();
 | 
						Vector<Ref<EditorExportPlugin> > export_plugins = EditorExport::get_singleton()->get_export_plugins();
 | 
				
			||||||
	for (int i = 0; i < export_plugins.size(); i++) {
 | 
						for (int i = 0; i < export_plugins.size(); i++) {
 | 
				
			||||||
| 
						 | 
					@ -1172,12 +1210,11 @@ Vector<String> EditorExportPlatformIOS::_get_preset_architectures(const Ref<Edit
 | 
				
			||||||
	return enabled_archs;
 | 
						return enabled_archs;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Error EditorExportPlatformIOS::_export_plugins(const Ref<EditorExportPreset> &p_preset, IOSConfigData &p_config_data, const String &dest_dir, Vector<IOSExportAsset> &r_exported_assets) {
 | 
					Error EditorExportPlatformIOS::_export_ios_plugins(const Ref<EditorExportPreset> &p_preset, IOSConfigData &p_config_data, const String &dest_dir, Vector<IOSExportAsset> &r_exported_assets, bool p_debug) {
 | 
				
			||||||
	String plugin_definition_cpp_code;
 | 
						String plugin_definition_cpp_code;
 | 
				
			||||||
	String plugin_initialization_cpp_code;
 | 
						String plugin_initialization_cpp_code;
 | 
				
			||||||
	String plugin_deinitialization_cpp_code;
 | 
						String plugin_deinitialization_cpp_code;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	Vector<String> plugin_libraries;
 | 
					 | 
				
			||||||
	Vector<String> plugin_linked_dependencies;
 | 
						Vector<String> plugin_linked_dependencies;
 | 
				
			||||||
	Vector<String> plugin_embedded_dependencies;
 | 
						Vector<String> plugin_embedded_dependencies;
 | 
				
			||||||
	Vector<String> plugin_files;
 | 
						Vector<String> plugin_files;
 | 
				
			||||||
| 
						 | 
					@ -1188,11 +1225,24 @@ Error EditorExportPlatformIOS::_export_plugins(const Ref<EditorExportPreset> &p_
 | 
				
			||||||
	Vector<String> added_embedded_dependenciy_names;
 | 
						Vector<String> added_embedded_dependenciy_names;
 | 
				
			||||||
	HashMap<String, String> plist_values;
 | 
						HashMap<String, String> plist_values;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						Error err;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for (int i = 0; i < enabled_plugins.size(); i++) {
 | 
						for (int i = 0; i < enabled_plugins.size(); i++) {
 | 
				
			||||||
		PluginConfig plugin = enabled_plugins[i];
 | 
							PluginConfig plugin = enabled_plugins[i];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		// Adding plugin binary.
 | 
							// Export plugin binary.
 | 
				
			||||||
		plugin_libraries.push_back(plugin.binary);
 | 
							if (!plugin.supports_targets) {
 | 
				
			||||||
 | 
								err = _copy_asset(dest_dir, plugin.binary, nullptr, true, true, r_exported_assets);
 | 
				
			||||||
 | 
							} else {
 | 
				
			||||||
 | 
								String plugin_binary_dir = plugin.binary.get_base_dir();
 | 
				
			||||||
 | 
								String plugin_name_prefix = plugin.binary.get_basename().get_file();
 | 
				
			||||||
 | 
								String plugin_file = plugin_name_prefix + "." + (p_debug ? "debug" : "release") + ".a";
 | 
				
			||||||
 | 
								String result_file_name = plugin.binary.get_file();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								err = _copy_asset(dest_dir, plugin_binary_dir.plus_file(plugin_file), &result_file_name, true, true, r_exported_assets);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							ERR_FAIL_COND_V(err, err);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		// Adding dependencies.
 | 
							// Adding dependencies.
 | 
				
			||||||
		// Use separate container for names to check for duplicates.
 | 
							// Use separate container for names to check for duplicates.
 | 
				
			||||||
| 
						 | 
					@ -1291,10 +1341,6 @@ Error EditorExportPlatformIOS::_export_plugins(const Ref<EditorExportPreset> &p_
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Export files
 | 
						// Export files
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		// Export plugin libraries
 | 
					 | 
				
			||||||
		Error err = _export_additional_assets(dest_dir, plugin_libraries, true, true, r_exported_assets);
 | 
					 | 
				
			||||||
		ERR_FAIL_COND_V(err, err);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		// Export linked plugin dependency
 | 
							// Export linked plugin dependency
 | 
				
			||||||
		err = _export_additional_assets(dest_dir, plugin_linked_dependencies, true, false, r_exported_assets);
 | 
							err = _export_additional_assets(dest_dir, plugin_linked_dependencies, true, false, r_exported_assets);
 | 
				
			||||||
		ERR_FAIL_COND_V(err, err);
 | 
							ERR_FAIL_COND_V(err, err);
 | 
				
			||||||
| 
						 | 
					@ -1454,7 +1500,7 @@ Error EditorExportPlatformIOS::export_project(const Ref<EditorExportPreset> &p_p
 | 
				
			||||||
		return ERR_CANT_OPEN;
 | 
							return ERR_CANT_OPEN;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	err = _export_plugins(p_preset, config_data, dest_dir + binary_name, assets);
 | 
						err = _export_ios_plugins(p_preset, config_data, dest_dir + binary_name, assets, p_debug);
 | 
				
			||||||
	ERR_FAIL_COND_V(err, err);
 | 
						ERR_FAIL_COND_V(err, err);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	//export rest of the files
 | 
						//export rest of the files
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -71,6 +71,7 @@ The `plist` section are optional.
 | 
				
			||||||
struct PluginConfig {
 | 
					struct PluginConfig {
 | 
				
			||||||
	// Set to true when the config file is properly loaded.
 | 
						// Set to true when the config file is properly loaded.
 | 
				
			||||||
	bool valid_config = false;
 | 
						bool valid_config = false;
 | 
				
			||||||
 | 
						bool supports_targets = false;
 | 
				
			||||||
	// Unix timestamp of last change to this plugin.
 | 
						// Unix timestamp of last change to this plugin.
 | 
				
			||||||
	uint64_t last_updated = 0;
 | 
						uint64_t last_updated = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -158,18 +159,46 @@ static inline Vector<String> resolve_system_dependencies(Vector<String> p_paths)
 | 
				
			||||||
	return paths;
 | 
						return paths;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static inline bool is_plugin_config_valid(PluginConfig plugin_config) {
 | 
					static inline bool validate_plugin(PluginConfig &plugin_config) {
 | 
				
			||||||
	bool valid_name = !plugin_config.name.empty();
 | 
						bool valid_name = !plugin_config.name.empty();
 | 
				
			||||||
	bool valid_binary = !plugin_config.binary.empty() && FileAccess::exists(plugin_config.binary);
 | 
						bool valid_binary_name = !plugin_config.binary.empty();
 | 
				
			||||||
	bool valid_initialize = !plugin_config.initialization_method.empty();
 | 
						bool valid_initialize = !plugin_config.initialization_method.empty();
 | 
				
			||||||
	bool valid_deinitialize = !plugin_config.deinitialization_method.empty();
 | 
						bool valid_deinitialize = !plugin_config.deinitialization_method.empty();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return valid_name && valid_binary && valid_initialize && valid_deinitialize;
 | 
						bool fields_value = valid_name && valid_binary_name && valid_initialize && valid_deinitialize;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (fields_value && FileAccess::exists(plugin_config.binary)) {
 | 
				
			||||||
 | 
							plugin_config.valid_config = true;
 | 
				
			||||||
 | 
							plugin_config.supports_targets = false;
 | 
				
			||||||
 | 
						} else if (fields_value) {
 | 
				
			||||||
 | 
							String file_path = plugin_config.binary.get_base_dir();
 | 
				
			||||||
 | 
							String file_name = plugin_config.binary.get_basename().get_file();
 | 
				
			||||||
 | 
							String release_file_name = file_path.plus_file(file_name + ".release.a");
 | 
				
			||||||
 | 
							String debug_file_name = file_path.plus_file(file_name + ".debug.a");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if (FileAccess::exists(release_file_name) && FileAccess::exists(debug_file_name)) {
 | 
				
			||||||
 | 
								plugin_config.valid_config = true;
 | 
				
			||||||
 | 
								plugin_config.supports_targets = true;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return plugin_config.valid_config;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static inline uint64_t get_plugin_modification_time(const PluginConfig &plugin_config, const String &config_path) {
 | 
					static inline uint64_t get_plugin_modification_time(const PluginConfig &plugin_config, const String &config_path) {
 | 
				
			||||||
	uint64_t last_updated = FileAccess::get_modified_time(config_path);
 | 
						uint64_t last_updated = FileAccess::get_modified_time(config_path);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (!plugin_config.supports_targets) {
 | 
				
			||||||
		last_updated = MAX(last_updated, FileAccess::get_modified_time(plugin_config.binary));
 | 
							last_updated = MAX(last_updated, FileAccess::get_modified_time(plugin_config.binary));
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
							String file_path = plugin_config.binary.get_base_dir();
 | 
				
			||||||
 | 
							String file_name = plugin_config.binary.get_basename().get_file();
 | 
				
			||||||
 | 
							String release_file_name = file_path.plus_file(file_name + ".release.a");
 | 
				
			||||||
 | 
							String debug_file_name = file_path.plus_file(file_name + ".debug.a");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							last_updated = MAX(last_updated, FileAccess::get_modified_time(release_file_name));
 | 
				
			||||||
 | 
							last_updated = MAX(last_updated, FileAccess::get_modified_time(debug_file_name));
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return last_updated;
 | 
						return last_updated;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -226,9 +255,7 @@ static inline PluginConfig load_plugin_config(Ref<ConfigFile> config_file, const
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	plugin_config.valid_config = is_plugin_config_valid(plugin_config);
 | 
						if (validate_plugin(plugin_config)) {
 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (plugin_config.valid_config) {
 | 
					 | 
				
			||||||
		plugin_config.last_updated = get_plugin_modification_time(plugin_config, path);
 | 
							plugin_config.last_updated = get_plugin_modification_time(plugin_config, path);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue