#!/usr/bin/env python3 # This file is a part of toml++ and is subject to the the terms of the MIT license. # Copyright (c) Mark Gillard # See https://github.com/marzer/tomlplusplus/blob/master/LICENSE for the full license text. # SPDX-License-Identifier: MIT import sys import utils import re import itertools from pathlib import Path from uuid import UUID, uuid5 def main(): mode_keys = [ '!!debug', '!x86', 'cpplatest', 'unrel', 'noexcept' ] modes = [ [] ] for n in range(1, len(mode_keys)): for combo in itertools.combinations(mode_keys, n): modes.append([i for i in combo]) modes.append(mode_keys) for mode in modes: if '!x86' not in mode: mode.insert(0, '!x64') if '!!debug' not in mode: mode.insert(0, '!!release') mode.sort() for i in range(0, len(mode)): while mode[i].startswith('!'): mode[i] = mode[i][1:] modes.sort() test_root = Path(utils.entry_script_dir(), '..', 'tests', 'vs').resolve() uuid_namespace = UUID('{51C7001B-048C-4AF0-B598-D75E78FF31F0}') configuration_name = lambda x: 'Debug' if x.lower() == 'debug' else 'Release' platform_name = lambda x: 'Win32' if x == 'x86' else x for mode in modes: file_path = Path(test_root, 'test_{}.vcxproj'.format('_'.join(mode))) print(f"Writing to {file_path}") with open(file_path, 'w', encoding='utf-8-sig', newline='\r\n') as file: write = lambda txt: print(txt, file=file) write(r''' {configuration} {platform} 16.0 {{{uuid}}} 10.0 x64 Application true v143 MultiByte Application false v143 true MultiByte ..\tests;%(AdditionalIncludeDirectories) {exceptions} Use tests.hpp TOML_ENABLE_UNRELEASED_FEATURES={unreleased_features};%(PreprocessorDefinitions) LEAK_TESTS=1;%(PreprocessorDefinitions) _HAS_EXCEPTIONS=0;%(PreprocessorDefinitions) SHOULD_HAVE_EXCEPTIONS=0;%(PreprocessorDefinitions) SHOULD_HAVE_EXCEPTIONS=1;%(PreprocessorDefinitions) std{standard} true EnableAllWarnings %(DisableSpecificWarnings);4127 %(DisableSpecificWarnings);4324 %(DisableSpecificWarnings);4464 %(DisableSpecificWarnings);4505 %(DisableSpecificWarnings);4514 %(DisableSpecificWarnings);4577 %(DisableSpecificWarnings);4582 %(DisableSpecificWarnings);4623 %(DisableSpecificWarnings);4625 %(DisableSpecificWarnings);4626 %(DisableSpecificWarnings);4710 %(DisableSpecificWarnings);4711 %(DisableSpecificWarnings);4738 %(DisableSpecificWarnings);4820 %(DisableSpecificWarnings);4866 %(DisableSpecificWarnings);4868 %(DisableSpecificWarnings);4946 %(DisableSpecificWarnings);5026 %(DisableSpecificWarnings);5027 %(DisableSpecificWarnings);5039 %(DisableSpecificWarnings);5045 $(ProjectDir)..\ NotUsing NotUsing Create '''.strip().format( configuration=next(configuration_name(x) for x in mode if x in ('debug', 'release')), platform=next(platform_name(x) for x in mode if x in ('x64', 'x86')), uuid=str(uuid5(uuid_namespace, '_'.join(mode))).upper(), exceptions='false' if 'noexcept' in mode else 'Sync', unreleased_features=1 if 'unrel' in mode else 0, standard='cpplatest' if 'cpplatest' in mode else 'cpp17' )) if __name__ == '__main__': utils.run(main, verbose=True)