diff options
Diffstat (limited to 'build_msvc/msvc-autogen.py')
-rw-r--r-- | build_msvc/msvc-autogen.py | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/build_msvc/msvc-autogen.py b/build_msvc/msvc-autogen.py index c8df29eecb..b612467bf3 100644 --- a/build_msvc/msvc-autogen.py +++ b/build_msvc/msvc-autogen.py @@ -2,8 +2,11 @@ import os import re +import argparse +from shutil import copyfile SOURCE_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'src')) +DEFAULT_PLATFORM_TOOLSET = R'v141' libs = [ 'libbitcoin_cli', @@ -42,8 +45,21 @@ def parse_makefile(makefile): lib_sources[current_lib] = [] break +def set_common_properties(toolset): + with open(os.path.join(SOURCE_DIR, '../build_msvc/common.init.vcxproj'), 'r', encoding='utf-8') as rfile: + s = rfile.read() + s = re.sub('<PlatformToolset>.*?</PlatformToolset>', '<PlatformToolset>'+toolset+'</PlatformToolset>', s) + with open(os.path.join(SOURCE_DIR, '../build_msvc/common.init.vcxproj'), 'w', encoding='utf-8',newline='\n') as wfile: + wfile.write(s) def main(): + parser = argparse.ArgumentParser(description='Bitcoin-core msbuild configuration initialiser.') + parser.add_argument('-toolset', nargs='?',help='Optionally sets the msbuild platform toolset, e.g. v142 for Visual Studio 2019.' + ' default is %s.'%DEFAULT_PLATFORM_TOOLSET) + args = parser.parse_args() + if args.toolset: + set_common_properties(args.toolset) + for makefile_name in os.listdir(SOURCE_DIR): if 'Makefile' in makefile_name: parse_makefile(os.path.join(SOURCE_DIR, makefile_name)) @@ -58,7 +74,8 @@ def main(): with open(vcxproj_filename, 'w', encoding='utf-8') as vcxproj_file: vcxproj_file.write(vcxproj_in_file.read().replace( '@SOURCE_FILES@\n', content)) - + copyfile(os.path.join(SOURCE_DIR,'../build_msvc/bitcoin_config.h'), os.path.join(SOURCE_DIR, 'config/bitcoin-config.h')) + copyfile(os.path.join(SOURCE_DIR,'../build_msvc/libsecp256k1_config.h'), os.path.join(SOURCE_DIR, 'secp256k1/src/libsecp256k1-config.h')) if __name__ == '__main__': main() |