aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild
diff options
context:
space:
mode:
authorLuke Elliott <luke.b.elliott@gmail.com>2021-11-24 09:54:37 +0000
committerJussi Pakkanen <jpakkane@gmail.com>2021-11-27 20:06:54 +0200
commit26b102e817af99d8da55eecba09e8398ec0e3d88 (patch)
treef2daff6d0dcad85a1f432ef998fef1c96713cebf /mesonbuild
parent007c4659c2154755fc1f57d415afc8a736f81af2 (diff)
downloadmeson-26b102e817af99d8da55eecba09e8398ec0e3d88.zip
meson-26b102e817af99d8da55eecba09e8398ec0e3d88.tar.gz
meson-26b102e817af99d8da55eecba09e8398ec0e3d88.tar.bz2
Fix '# Visual Studio <>' comment in sln files with VS backend
such that Visual Studio Version Selector works.
Diffstat (limited to 'mesonbuild')
-rw-r--r--mesonbuild/backend/vs2010backend.py11
-rw-r--r--mesonbuild/backend/vs2012backend.py2
-rw-r--r--mesonbuild/backend/vs2013backend.py2
-rw-r--r--mesonbuild/backend/vs2015backend.py2
-rw-r--r--mesonbuild/backend/vs2017backend.py4
-rw-r--r--mesonbuild/backend/vs2019backend.py2
-rw-r--r--mesonbuild/backend/vs2022backend.py2
7 files changed, 20 insertions, 5 deletions
diff --git a/mesonbuild/backend/vs2010backend.py b/mesonbuild/backend/vs2010backend.py
index 1c0b9ad..7a56041 100644
--- a/mesonbuild/backend/vs2010backend.py
+++ b/mesonbuild/backend/vs2010backend.py
@@ -98,6 +98,8 @@ class Vs2010Backend(backends.Backend):
super().__init__(build, interpreter)
self.name = 'vs2010'
self.project_file_version = '10.0.30319.1'
+ self.sln_file_version = '11.00'
+ self.sln_version_comment = '2010'
self.platform_toolset = None
self.vs_version = '2010'
self.windows_target_platform_version = None
@@ -348,10 +350,11 @@ class Vs2010Backend(backends.Backend):
def generate_solution(self, sln_filename, projlist):
default_projlist = self.get_build_by_default_targets()
sln_filename_tmp = sln_filename + '~'
- with open(sln_filename_tmp, 'w', encoding='utf-8') as ofile:
- ofile.write('Microsoft Visual Studio Solution File, Format '
- 'Version 11.00\n')
- ofile.write('# Visual Studio ' + self.vs_version + '\n')
+ # Note using the utf-8 BOM requires the blank line, otherwise Visual Studio Version Selector fails.
+ # Without the BOM, VSVS fails if there is a blank line.
+ with open(sln_filename_tmp, 'w', encoding='utf-8-sig') as ofile:
+ ofile.write('\nMicrosoft Visual Studio Solution File, Format Version %s\n' % self.sln_file_version)
+ ofile.write('# Visual Studio %s\n' % self.sln_version_comment)
prj_templ = 'Project("{%s}") = "%s", "%s", "{%s}"\n'
for prj in projlist:
coredata = self.environment.coredata
diff --git a/mesonbuild/backend/vs2012backend.py b/mesonbuild/backend/vs2012backend.py
index a9ba5f4..ee2f022 100644
--- a/mesonbuild/backend/vs2012backend.py
+++ b/mesonbuild/backend/vs2012backend.py
@@ -24,6 +24,8 @@ class Vs2012Backend(Vs2010Backend):
super().__init__(build, interpreter)
self.name = 'vs2012'
self.vs_version = '2012'
+ self.sln_file_version = '12.00'
+ self.sln_version_comment = '2012'
if self.environment is not None:
# TODO: we assume host == build
comps = self.environment.coredata.compilers.host
diff --git a/mesonbuild/backend/vs2013backend.py b/mesonbuild/backend/vs2013backend.py
index 0f2c8bd..37724db 100644
--- a/mesonbuild/backend/vs2013backend.py
+++ b/mesonbuild/backend/vs2013backend.py
@@ -24,6 +24,8 @@ class Vs2013Backend(Vs2010Backend):
super().__init__(build, interpreter)
self.name = 'vs2013'
self.vs_version = '2013'
+ self.sln_file_version = '12.00'
+ self.sln_version_comment = '2013'
if self.environment is not None:
# TODO: we assume host == build
comps = self.environment.coredata.compilers.host
diff --git a/mesonbuild/backend/vs2015backend.py b/mesonbuild/backend/vs2015backend.py
index bdc1675..4952caf 100644
--- a/mesonbuild/backend/vs2015backend.py
+++ b/mesonbuild/backend/vs2015backend.py
@@ -24,6 +24,8 @@ class Vs2015Backend(Vs2010Backend):
super().__init__(build, interpreter)
self.name = 'vs2015'
self.vs_version = '2015'
+ self.sln_file_version = '12.00'
+ self.sln_version_comment = '14'
if self.environment is not None:
# TODO: we assume host == build
comps = self.environment.coredata.compilers.host
diff --git a/mesonbuild/backend/vs2017backend.py b/mesonbuild/backend/vs2017backend.py
index 452d7a6..e9f949d 100644
--- a/mesonbuild/backend/vs2017backend.py
+++ b/mesonbuild/backend/vs2017backend.py
@@ -27,6 +27,8 @@ class Vs2017Backend(Vs2010Backend):
super().__init__(build, interpreter)
self.name = 'vs2017'
self.vs_version = '2017'
+ self.sln_file_version = '12.00'
+ self.sln_version_comment = '15'
# We assume that host == build
if self.environment is not None:
comps = self.environment.coredata.compilers.host
@@ -59,4 +61,4 @@ class Vs2017Backend(Vs2010Backend):
if 'c' in file_args:
optargs = [x for x in file_args['c'] if x.startswith('/std:c')]
if optargs:
- ET.SubElement(clconf, 'LanguageStandard_C').text = optargs[0].replace("/std:c", "stdc") \ No newline at end of file
+ ET.SubElement(clconf, 'LanguageStandard_C').text = optargs[0].replace("/std:c", "stdc")
diff --git a/mesonbuild/backend/vs2019backend.py b/mesonbuild/backend/vs2019backend.py
index a87fa8a..1efadcd 100644
--- a/mesonbuild/backend/vs2019backend.py
+++ b/mesonbuild/backend/vs2019backend.py
@@ -25,6 +25,8 @@ class Vs2019Backend(Vs2010Backend):
def __init__(self, build: T.Optional[Build], interpreter: T.Optional[Interpreter]):
super().__init__(build, interpreter)
self.name = 'vs2019'
+ self.sln_file_version = '12.00'
+ self.sln_version_comment = 'Version 16'
if self.environment is not None:
comps = self.environment.coredata.compilers.host
if comps and all(c.id == 'clang-cl' for c in comps.values()):
diff --git a/mesonbuild/backend/vs2022backend.py b/mesonbuild/backend/vs2022backend.py
index 19ad090..b0925a4 100644
--- a/mesonbuild/backend/vs2022backend.py
+++ b/mesonbuild/backend/vs2022backend.py
@@ -25,6 +25,8 @@ class Vs2022Backend(Vs2010Backend):
def __init__(self, build: T.Optional[Build], interpreter: T.Optional[Interpreter]):
super().__init__(build, interpreter)
self.name = 'vs2022'
+ self.sln_file_version = '12.00'
+ self.sln_version_comment = 'Version 17'
if self.environment is not None:
comps = self.environment.coredata.compilers.host
if comps and all(c.id == 'clang-cl' for c in comps.values()):