From 536ca28ea96c093505e1b33939bd0c810bbaae1f Mon Sep 17 00:00:00 2001 From: Andreia Gaita Date: Wed, 10 Apr 2024 16:59:57 +0200 Subject: [PATCH] Ensure all Visual Studio files are generated with CRLF --- .gitattributes | 2 ++ methods.py | 6 +++--- misc/msvs/props.template | 5 ++++- misc/msvs/sln.template | 24 ++++++++++++------------ misc/msvs/vcxproj.filters.template | 2 +- misc/msvs/vcxproj.template | 5 ++++- 6 files changed, 26 insertions(+), 18 deletions(-) diff --git a/.gitattributes b/.gitattributes index 8d2fb108ba0a..ccc576c2e12c 100644 --- a/.gitattributes +++ b/.gitattributes @@ -9,6 +9,8 @@ thirdparty/* linguist-vendored *.bat eol=crlf # And some test files where the EOL matters *.test.txt -text +# And also the templates for Visual Studio files, which VS will always force CRLF on +/misc/msvs/*.template eol=crlf # The above only works properly for Git 2.10+, so for older versions # we need to manually list the binary files we don't want modified. diff --git a/methods.py b/methods.py index fa7db95e923d..dd01469b8691 100644 --- a/methods.py +++ b/methods.py @@ -1326,7 +1326,7 @@ def generate_vs_project(env, original_args, project_name="godot"): filters_template = filters_template.replace("%%HASH%%", md5) - with open(f"{project_name}.vcxproj.filters", "w", encoding="utf-8", newline="\n") as f: + with open(f"{project_name}.vcxproj.filters", "w", encoding="utf-8", newline="\r\n") as f: f.write(filters_template) envsources = [] @@ -1507,7 +1507,7 @@ def generate_vs_project(env, original_args, project_name="godot"): props_template = props_template.replace("%%CLEAN%%", cmd) with open( - f"{project_name}.{platform}.{target}.{arch}.generated.props", "w", encoding="utf-8", newline="\n" + f"{project_name}.{platform}.{target}.{arch}.generated.props", "w", encoding="utf-8", newline="\r\n" ) as f: f.write(props_template) @@ -1624,7 +1624,7 @@ def generate_vs_project(env, original_args, project_name="godot"): sln_template = sln_template.replace("%%SECTION1%%", "\n ".join(section1)) sln_template = sln_template.replace("%%SECTION2%%", "\n ".join(section2)) - with open(f"{project_name}.sln", "w", encoding="utf-8", newline="\n") as f: + with open(f"{project_name}.sln", "w", encoding="utf-8", newline="\r\n") as f: f.write(sln_template) if get_bool(original_args, "vsproj_gen_only", True): diff --git a/misc/msvs/props.template b/misc/msvs/props.template index f360871b7282..82e3e81f1827 100644 --- a/misc/msvs/props.template +++ b/misc/msvs/props.template @@ -18,4 +18,7 @@ %%EXTRA_ITEMS%% - \ No newline at end of file + + diff --git a/misc/msvs/sln.template b/misc/msvs/sln.template index 7d05548c6ed4..25d9d88a496b 100644 --- a/misc/msvs/sln.template +++ b/misc/msvs/sln.template @@ -5,16 +5,16 @@ MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "%%NAME%%", "%%NAME%%.vcxproj", "{%%UUID%%}" EndProject Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - %%SECTION1%% - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - %%SECTION2%% - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {%%SLNUUID%%} - EndGlobalSection + GlobalSection(SolutionConfigurationPlatforms) = preSolution + %%SECTION1%% + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + %%SECTION2%% + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {%%SLNUUID%%} + EndGlobalSection EndGlobal diff --git a/misc/msvs/vcxproj.filters.template b/misc/msvs/vcxproj.filters.template index d57eeee811cf..11d331d15da2 100644 --- a/misc/msvs/vcxproj.filters.template +++ b/misc/msvs/vcxproj.filters.template @@ -27,4 +27,4 @@ \ No newline at end of file +--> diff --git a/misc/msvs/vcxproj.template b/misc/msvs/vcxproj.template index 30f29a55f876..2cdb82d01f20 100644 --- a/misc/msvs/vcxproj.template +++ b/misc/msvs/vcxproj.template @@ -37,4 +37,7 @@ - \ No newline at end of file + +