Browse Source

Fix issue #97207 by filtering extension_list.cfg

The implemented solution to the problem of the error message
appearing when an excluded GDExtension in an export of a project, is
to filter the lines in the extension_list.cfg file to only include
those that are in the paths actually included for export.  If there
are no entries remaining, don't write the file at all.
mendrak 10 months ago
parent
commit
c57eaf7757
2 changed files with 27 additions and 1 deletions
  1. 25 1
      editor/export/editor_export_platform.cpp
  2. 2 0
      editor/export/editor_export_platform.h

+ 25 - 1
editor/export/editor_export_platform.cpp

@@ -1495,7 +1495,15 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> &
 
 
 	Vector<String> forced_export = get_forced_export_files();
 	Vector<String> forced_export = get_forced_export_files();
 	for (int i = 0; i < forced_export.size(); i++) {
 	for (int i = 0; i < forced_export.size(); i++) {
-		Vector<uint8_t> array = FileAccess::get_file_as_bytes(forced_export[i]);
+		Vector<uint8_t> array;
+		if (GDExtension::get_extension_list_config_file() == forced_export[i]) {
+			array = _filter_extension_list_config_file(forced_export[i], paths);
+			if (array.size() == 0) {
+				continue;
+			}
+		} else {
+			array = FileAccess::get_file_as_bytes(forced_export[i]);
+		}
 		err = p_save_func(p_udata, forced_export[i], array, idx, total, enc_in_filters, enc_ex_filters, key, seed);
 		err = p_save_func(p_udata, forced_export[i], array, idx, total, enc_in_filters, enc_ex_filters, key, seed);
 		if (err != OK) {
 		if (err != OK) {
 			return err;
 			return err;
@@ -1534,6 +1542,22 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> &
 	return OK;
 	return OK;
 }
 }
 
 
+Vector<uint8_t> EditorExportPlatform::_filter_extension_list_config_file(const String &p_config_path, const HashSet<String> &p_paths) {
+	Ref<FileAccess> f = FileAccess::open(p_config_path, FileAccess::READ);
+	if (f.is_null()) {
+		ERR_FAIL_V_MSG(Vector<uint8_t>(), "Can't open file from path '" + String(p_config_path) + "'.");
+	}
+	Vector<uint8_t> data;
+	while (!f->eof_reached()) {
+		String l = f->get_line().strip_edges();
+		if (p_paths.has(l)) {
+			data.append_array(l.to_utf8_buffer());
+			data.append('\n');
+		}
+	}
+	return data;
+}
+
 Error EditorExportPlatform::_pack_add_shared_object(void *p_userdata, const SharedObject &p_so) {
 Error EditorExportPlatform::_pack_add_shared_object(void *p_userdata, const SharedObject &p_so) {
 	PackData *pack_data = (PackData *)p_userdata;
 	PackData *pack_data = (PackData *)p_userdata;
 	if (pack_data->so_files) {
 	if (pack_data->so_files) {

+ 2 - 0
editor/export/editor_export_platform.h

@@ -135,6 +135,8 @@ private:
 	void _edit_files_with_filter(Ref<DirAccess> &da, const Vector<String> &p_filters, HashSet<String> &r_list, bool exclude);
 	void _edit_files_with_filter(Ref<DirAccess> &da, const Vector<String> &p_filters, HashSet<String> &r_list, bool exclude);
 	void _edit_filter_list(HashSet<String> &r_list, const String &p_filter, bool exclude);
 	void _edit_filter_list(HashSet<String> &r_list, const String &p_filter, bool exclude);
 
 
+	static Vector<uint8_t> _filter_extension_list_config_file(const String &p_config_path, const HashSet<String> &p_paths);
+
 	struct FileExportCache {
 	struct FileExportCache {
 		uint64_t source_modified_time = 0;
 		uint64_t source_modified_time = 0;
 		String source_md5;
 		String source_md5;