diff options
-rw-r--r-- | mesonbuild/backend/vs2010backend.py | 27 | ||||
-rw-r--r-- | mesonbuild/backend/vs2015backend.py | 34 | ||||
-rw-r--r-- | mesonbuild/coredata.py | 3 | ||||
-rw-r--r-- | mesonbuild/mesonmain.py | 4 | ||||
-rwxr-xr-x | run_tests.py | 7 |
5 files changed, 69 insertions, 6 deletions
diff --git a/mesonbuild/backend/vs2010backend.py b/mesonbuild/backend/vs2010backend.py index 355798d..540dd04 100644 --- a/mesonbuild/backend/vs2010backend.py +++ b/mesonbuild/backend/vs2010backend.py @@ -39,6 +39,7 @@ class Vs2010Backend(backends.Backend): super().__init__(build) self.project_file_version = '10.0.30319.1' self.sources_conflicts = {} + self.platform_toolset = None def object_filename_from_source(self, target, source): basename = os.path.basename(source.fname) @@ -309,6 +310,8 @@ class Vs2010Backend(backends.Backend): ET.SubElement(type_config, 'ConfigurationType') ET.SubElement(type_config, 'CharacterSet').text = 'MultiByte' ET.SubElement(type_config, 'UseOfMfc').text = 'false' + if self.platform_toolset: + ET.SubElement(type_config, 'PlatformToolset').text = self.platform_toolset ET.SubElement(root, 'Import', Project='$(VCTargetsPath)\Microsoft.Cpp.props') direlem = ET.SubElement(root, 'PropertyGroup') fver = ET.SubElement(direlem, '_ProjectFileVersion') @@ -385,6 +388,18 @@ class Vs2010Backend(backends.Backend): lang = Vs2010Backend.lang_from_source_file(source_file) ET.SubElement(parent_node, "AdditionalOptions").text = ' '.join(extra_args[lang]) + ' %(AdditionalOptions)' + @staticmethod + def has_objects(objects, additional_objects, generated_objects): + # Ignore generated objects, those are automatically used by MSBuild for VS2010, because they are part of + # the CustomBuildStep Outputs. + return len(objects) + len(additional_objects) > 0 + + @staticmethod + def add_generated_objects(node, generated_objects): + # Do not add generated objects to project file. Those are automatically used by MSBuild for VS2010, because + # they are part of the CustomBuildStep Outputs. + return + @classmethod def quote_define_cmdline(cls, arg): return re.sub(r'^([-/])D(.*?)="(.*)"$', r'\1D\2=\"\3\"', arg) @@ -441,6 +456,8 @@ class Vs2010Backend(backends.Backend): type_config = ET.SubElement(root, 'PropertyGroup', Label='Configuration') ET.SubElement(type_config, 'ConfigurationType').text = conftype ET.SubElement(type_config, 'CharacterSet').text = 'MultiByte' + if self.platform_toolset: + ET.SubElement(type_config, 'PlatformToolset').text = self.platform_toolset ET.SubElement(type_config, 'WholeProgramOptimization').text = 'false' ET.SubElement(type_config, 'UseDebugLibraries').text = 'true' ET.SubElement(root, 'Import', Project='$(VCTargetsPath)\Microsoft.Cpp.props') @@ -641,15 +658,15 @@ class Vs2010Backend(backends.Backend): pch_file.text = os.path.split(header)[1] self.add_additional_options(impl, inc_cl, extra_args, additional_options_set) - if len(objects) + len(additional_objects) > 0: - # Do not add gen_objs to project file. Those are automatically used by MSBuild, because they are part of - # the CustomBuildStep Outputs. + if self.has_objects(objects, additional_objects, gen_objs): inc_objs = ET.SubElement(root, 'ItemGroup') for s in objects: relpath = s.rel_to_builddir(proj_to_src_root) ET.SubElement(inc_objs, 'Object', Include=relpath) for s in additional_objects: ET.SubElement(inc_objs, 'Object', Include=s) + self.add_generated_objects(inc_objs, gen_objs) + ET.SubElement(root, 'Import', Project='$(VCTargetsPath)\Microsoft.Cpp.targets') # Reference the regen target. ig = ET.SubElement(root, 'ItemGroup') @@ -691,6 +708,8 @@ class Vs2010Backend(backends.Backend): ET.SubElement(type_config, 'ConfigurationType').text = "Utility" ET.SubElement(type_config, 'CharacterSet').text = 'MultiByte' ET.SubElement(type_config, 'UseOfMfc').text = 'false' + if self.platform_toolset: + ET.SubElement(type_config, 'PlatformToolset').text = self.platform_toolset ET.SubElement(root, 'Import', Project='$(VCTargetsPath)\Microsoft.Cpp.props') direlem = ET.SubElement(root, 'PropertyGroup') fver = ET.SubElement(direlem, '_ProjectFileVersion') @@ -768,6 +787,8 @@ if %%errorlevel%% neq 0 goto :VCEnd''' ET.SubElement(type_config, 'ConfigurationType') ET.SubElement(type_config, 'CharacterSet').text = 'MultiByte' ET.SubElement(type_config, 'UseOfMfc').text = 'false' + if self.platform_toolset: + ET.SubElement(type_config, 'PlatformToolset').text = self.platform_toolset ET.SubElement(root, 'Import', Project='$(VCTargetsPath)\Microsoft.Cpp.props') direlem = ET.SubElement(root, 'PropertyGroup') fver = ET.SubElement(direlem, '_ProjectFileVersion') diff --git a/mesonbuild/backend/vs2015backend.py b/mesonbuild/backend/vs2015backend.py new file mode 100644 index 0000000..c138cb5 --- /dev/null +++ b/mesonbuild/backend/vs2015backend.py @@ -0,0 +1,34 @@ +# Copyright 2014-2016 The Meson development team + +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at + +# http://www.apache.org/licenses/LICENSE-2.0 + +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from xml.etree import ElementTree as ET +from .vs2010backend import Vs2010Backend + + +class Vs2015Backend(Vs2010Backend): + def __init__(self, build): + super().__init__(build) + self.platform_toolset = 'v140' + + @staticmethod + def has_objects(objects, additional_objects, generated_objects): + # VS2015 requires generated objects to be added explicitly to the project file. + return len(objects) + len(additional_objects) + len(generated_objects) > 0 + + @staticmethod + def add_generated_objects(node, generated_objects): + # VS2015 requires generated objects to be added explicitly to the project file. + for s in generated_objects: + ET.SubElement(node, 'Object', Include=s) + return diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py index 837681c..5f00ac3 100644 --- a/mesonbuild/coredata.py +++ b/mesonbuild/coredata.py @@ -16,6 +16,7 @@ import pickle, os, uuid from .mesonlib import MesonException, default_libdir, default_libexecdir, default_prefix version = '0.32.0.dev1' +backendlist = ['ninja', 'vs2010', 'vs2015', 'xcode'] class UserOption: def __init__(self, name, description, choices): @@ -212,7 +213,7 @@ builtin_options = { 'warning_level' : [ UserComboOption, 'Compiler warning level to use.', [ '1', '2', '3' ], '1'], 'layout' : [ UserComboOption, 'Build directory layout.', ['mirror', 'flat' ], 'mirror' ], 'default_library' : [ UserComboOption, 'Default library type.', [ 'shared', 'static' ], 'shared' ], - 'backend' : [ UserComboOption, 'Backend to use.', [ 'ninja', 'vs2010', 'xcode' ], 'ninja' ], + 'backend' : [ UserComboOption, 'Backend to use.', backendlist, 'ninja' ], 'stdsplit' : [ UserBooleanOption, 'Split stdout and stderr in test logs.', True ], 'errorlogs' : [ UserBooleanOption, "Whether to print the logs from failing tests.", False ], } diff --git a/mesonbuild/mesonmain.py b/mesonbuild/mesonmain.py index 4f8314c..3f5612b 100644 --- a/mesonbuild/mesonmain.py +++ b/mesonbuild/mesonmain.py @@ -23,7 +23,6 @@ import platform from . import mlog, coredata from .mesonlib import MesonException -backendlist = ['ninja', 'vs2010', 'xcode'] parser = argparse.ArgumentParser() @@ -139,6 +138,9 @@ itself as required.''' elif self.options.backend == 'vs2010': from .backend import vs2010backend g = vs2010backend.Vs2010Backend(b) + elif self.options.backend == 'vs2015': + from .backend import vs2015backend + g = vs2015backend.Vs2015Backend(b) elif self.options.backend == 'xcode': from .backend import xcodebackend g = xcodebackend.XCodeBackend(b) diff --git a/run_tests.py b/run_tests.py index 0a47157..1c6ae11 100755 --- a/run_tests.py +++ b/run_tests.py @@ -31,7 +31,7 @@ import time import multiprocessing import concurrent.futures as conc -from mesonbuild.mesonmain import backendlist +from mesonbuild.coredata import backendlist class TestResult: def __init__(self, msg, stdo, stde, conftime=0, buildtime=0, testtime=0): @@ -100,6 +100,11 @@ def setup_commands(backend): compile_commands = ['msbuild'] test_commands = ['msbuild', 'RUN_TESTS.vcxproj'] install_commands = [] + elif backend == 'vs2015': + backend_flags = ['--backend=vs2015'] + compile_commands = ['msbuild'] + test_commands = ['msbuild', 'RUN_TESTS.vcxproj'] + install_commands = [] elif backend == 'xcode' or (backend is None and mesonlib.is_osx()): backend_flags = ['--backend=xcode'] compile_commands = ['xcodebuild'] |