You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-09 12:50:35 +00:00
Merge pull request #104613 from zaevi/caching_csharp_tfm_validation
[.NET] Add caching for dotnet TFM validation result
This commit is contained in:
@@ -2618,6 +2618,9 @@ bool EditorExportPlatformAndroid::has_valid_username_and_password(const Ref<Edit
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MODULE_MONO_ENABLED
|
#ifdef MODULE_MONO_ENABLED
|
||||||
|
static uint64_t _last_validate_tfm_time = 0;
|
||||||
|
static String _last_validate_tfm = "";
|
||||||
|
|
||||||
bool _validate_dotnet_tfm(const String &required_tfm, String &r_error) {
|
bool _validate_dotnet_tfm(const String &required_tfm, String &r_error) {
|
||||||
String assembly_name = Path::get_csharp_project_name();
|
String assembly_name = Path::get_csharp_project_name();
|
||||||
String project_path = ProjectSettings::get_singleton()->globalize_path("res://" + assembly_name + ".csproj");
|
String project_path = ProjectSettings::get_singleton()->globalize_path("res://" + assembly_name + ".csproj");
|
||||||
@@ -2626,30 +2629,41 @@ bool _validate_dotnet_tfm(const String &required_tfm, String &r_error) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
String pipe;
|
uint64_t modified_time = FileAccess::get_modified_time(project_path);
|
||||||
List<String> args;
|
String tfm;
|
||||||
args.push_back("build");
|
|
||||||
args.push_back(project_path);
|
|
||||||
args.push_back("--getProperty:TargetFramework");
|
|
||||||
|
|
||||||
int exitcode;
|
if (modified_time == _last_validate_tfm_time) {
|
||||||
Error err = OS::get_singleton()->execute("dotnet", args, &pipe, &exitcode, true);
|
tfm = _last_validate_tfm;
|
||||||
if (err != OK || exitcode != 0) {
|
|
||||||
if (err != OK) {
|
|
||||||
WARN_PRINT("Failed to execute dotnet command. Error " + String(error_names[err]));
|
|
||||||
} else if (exitcode != 0) {
|
|
||||||
print_line(pipe);
|
|
||||||
WARN_PRINT("dotnet command exited with code " + itos(exitcode) + ". See output above for more details.");
|
|
||||||
}
|
|
||||||
r_error += vformat(TTR("Unable to determine the C# project's TFM, it may be incompatible. The export template only supports '%s'. Make sure the project targets '%s' or consider using gradle builds instead."), required_tfm, required_tfm) + "\n";
|
|
||||||
} else {
|
} else {
|
||||||
String tfm = pipe.strip_edges();
|
String pipe;
|
||||||
if (tfm != required_tfm) {
|
List<String> args;
|
||||||
r_error += vformat(TTR("C# project targets '%s' but the export template only supports '%s'. Consider using gradle builds instead."), tfm, required_tfm) + "\n";
|
args.push_back("build");
|
||||||
return false;
|
args.push_back(project_path);
|
||||||
|
args.push_back("--getProperty:TargetFramework");
|
||||||
|
|
||||||
|
int exitcode;
|
||||||
|
Error err = OS::get_singleton()->execute("dotnet", args, &pipe, &exitcode, true);
|
||||||
|
if (err != OK || exitcode != 0) {
|
||||||
|
if (err != OK) {
|
||||||
|
WARN_PRINT("Failed to execute dotnet command. Error " + String(error_names[err]));
|
||||||
|
} else if (exitcode != 0) {
|
||||||
|
print_line(pipe);
|
||||||
|
WARN_PRINT("dotnet command exited with code " + itos(exitcode) + ". See output above for more details.");
|
||||||
|
}
|
||||||
|
r_error += vformat(TTR("Unable to determine the C# project's TFM, it may be incompatible. The export template only supports '%s'. Make sure the project targets '%s' or consider using gradle builds instead."), required_tfm, required_tfm) + "\n";
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
tfm = pipe.strip_edges();
|
||||||
|
_last_validate_tfm_time = modified_time;
|
||||||
|
_last_validate_tfm = tfm;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tfm != required_tfm) {
|
||||||
|
r_error += vformat(TTR("C# project targets '%s' but the export template only supports '%s'. Consider using gradle builds instead."), tfm, required_tfm) + "\n";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user