#!/usr/bin/env python3 # This file is a part of toml++ and is subject to the the terms of the MIT license. # Copyright (c) 2019-2020 Mark Gillard # See https://github.com/marzer/tomlplusplus/blob/master/LICENSE for the full license text. # SPDX-License-Identifier: MIT import sys import os.path as path import utils import re import itertools from uuid import UUID, uuid5 def main(): mode_keys = [ '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') modes.sort() vs_root = path.join(utils.get_script_folder(), '..', 'vs') uuid_namespace = UUID('{51C7001B-048C-4AF0-B598-D75E78FF31F0}') platform_name = lambda x: 'Win32' if x == 'x86' else x language_level = lambda x: 'Win32' if x == 'x86' else x for mode in modes: file_path = path.join(vs_root, 'test_{}.vcxproj'.format('_'.join(mode))) print("Writing to {}".format(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''' Debug {platform} Release {platform} 16.0 {{{uuid}}} 10.0 Application true v142 MultiByte Application false v142 true MultiByte ..\tests;%(AdditionalIncludeDirectories) {exceptions} Use tests.h TOML_UNRELEASED_FEATURES={unreleased_features};%(PreprocessorDefinitions) _HAS_EXCEPTIONS=0;%(PreprocessorDefinitions) std{standard} ..\tests\ NotUsing NotUsing Create '''.strip().format( 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)