diff --git a/appveyor.yml b/appveyor.yml index c6a5a91ba5..85b1a999d1 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -6,6 +6,8 @@ platform: x64 environment: APPVEYOR_SAVE_CACHE_ON_ERROR: true cache: C:\tools\vcpkg\installed\ +init: +- cmd: set PATH=C:\Python36-x64;%PATH% before_build: - ps: >- $packages = @( @@ -28,6 +30,7 @@ before_build: git -C C:\Tools\vcpkg pull # This is a temporary fix, can be removed after appveyor update its image to include Microsoft/vcpkg#4046 Invoke-Expression -Command "vcpkg install $all_packages" +- cmd: python build_msvc\msvc-autogen.py build: project: build_msvc\bitcoin.sln parallel: true diff --git a/build_msvc/.gitignore b/build_msvc/.gitignore index fbcd1077b3..d5aa22c05e 100644 --- a/build_msvc/.gitignore +++ b/build_msvc/.gitignore @@ -8,3 +8,4 @@ packages/* */Release */x64 *.vcxproj.user +*.vcxproj diff --git a/build_msvc/README.md b/build_msvc/README.md index 6de464e92f..5fb08df8d7 100644 --- a/build_msvc/README.md +++ b/build_msvc/README.md @@ -47,4 +47,10 @@ The instructions below use vcpkg to install the dependencies. leveldb:x64-windows-static ``` +- Use Python to generate *.vcxproj from Makefile + +``` + PS >python msvc-autogen.py +``` + - Build in Visual Studio. \ No newline at end of file diff --git a/build_msvc/libbitcoin_cli/libbitcoin_cli.vcxproj b/build_msvc/libbitcoin_cli/libbitcoin_cli.vcxproj.in similarity index 99% rename from build_msvc/libbitcoin_cli/libbitcoin_cli.vcxproj rename to build_msvc/libbitcoin_cli/libbitcoin_cli.vcxproj.in index 623d24da10..b7265054fb 100644 --- a/build_msvc/libbitcoin_cli/libbitcoin_cli.vcxproj +++ b/build_msvc/libbitcoin_cli/libbitcoin_cli.vcxproj.in @@ -20,7 +20,7 @@ - +@SOURCE_FILES@ diff --git a/build_msvc/libbitcoin_common/libbitcoin_common.vcxproj b/build_msvc/libbitcoin_common/libbitcoin_common.vcxproj.in similarity index 82% rename from build_msvc/libbitcoin_common/libbitcoin_common.vcxproj rename to build_msvc/libbitcoin_common/libbitcoin_common.vcxproj.in index e6d95ed5f3..42145c15ad 100644 --- a/build_msvc/libbitcoin_common/libbitcoin_common.vcxproj +++ b/build_msvc/libbitcoin_common/libbitcoin_common.vcxproj.in @@ -165,43 +165,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +@SOURCE_FILES@ diff --git a/build_msvc/libbitcoin_crypto/libbitcoin_crypto.vcxproj b/build_msvc/libbitcoin_crypto/libbitcoin_crypto.vcxproj.in similarity index 88% rename from build_msvc/libbitcoin_crypto/libbitcoin_crypto.vcxproj rename to build_msvc/libbitcoin_crypto/libbitcoin_crypto.vcxproj.in index 50519d045f..a05125723a 100644 --- a/build_msvc/libbitcoin_crypto/libbitcoin_crypto.vcxproj +++ b/build_msvc/libbitcoin_crypto/libbitcoin_crypto.vcxproj.in @@ -151,25 +151,7 @@ - - - - - - - - - - - - - - - - - - - +@SOURCE_FILES@ diff --git a/build_msvc/libbitcoin_server/libbitcoin_server.vcxproj b/build_msvc/libbitcoin_server/libbitcoin_server.vcxproj.in similarity index 80% rename from build_msvc/libbitcoin_server/libbitcoin_server.vcxproj rename to build_msvc/libbitcoin_server/libbitcoin_server.vcxproj.in index 9d4ac1a7f7..0a165d0b75 100644 --- a/build_msvc/libbitcoin_server/libbitcoin_server.vcxproj +++ b/build_msvc/libbitcoin_server/libbitcoin_server.vcxproj.in @@ -154,53 +154,13 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - $(IntDir)\netrpc.obj $(IntDir)\netrpc.obj $(IntDir)\netrpc.obj $(IntDir)\netrpc.obj - - - - - - - - - - - - - - +@SOURCE_FILES@ diff --git a/build_msvc/libbitcoin_util/libbitcoin_util.vcxproj b/build_msvc/libbitcoin_util/libbitcoin_util.vcxproj.in similarity index 90% rename from build_msvc/libbitcoin_util/libbitcoin_util.vcxproj rename to build_msvc/libbitcoin_util/libbitcoin_util.vcxproj.in index 9e960682e5..dc17c98e98 100644 --- a/build_msvc/libbitcoin_util/libbitcoin_util.vcxproj +++ b/build_msvc/libbitcoin_util/libbitcoin_util.vcxproj.in @@ -174,23 +174,7 @@ - - - - - - - - - - - - - - - - - +@SOURCE_FILES@ diff --git a/build_msvc/libbitcoin_wallet/libbitcoin_wallet.vcxproj b/build_msvc/libbitcoin_wallet/libbitcoin_wallet.vcxproj.in similarity index 92% rename from build_msvc/libbitcoin_wallet/libbitcoin_wallet.vcxproj rename to build_msvc/libbitcoin_wallet/libbitcoin_wallet.vcxproj.in index 64f3e16289..1bb7be6f7f 100644 --- a/build_msvc/libbitcoin_wallet/libbitcoin_wallet.vcxproj +++ b/build_msvc/libbitcoin_wallet/libbitcoin_wallet.vcxproj.in @@ -20,18 +20,7 @@ - - - - - - - - - - - - +@SOURCE_FILES@ diff --git a/build_msvc/libbitcoin_zmq/libbitcoin_zmq.vcxproj b/build_msvc/libbitcoin_zmq/libbitcoin_zmq.vcxproj.in similarity index 97% rename from build_msvc/libbitcoin_zmq/libbitcoin_zmq.vcxproj rename to build_msvc/libbitcoin_zmq/libbitcoin_zmq.vcxproj.in index d7fbdd94b7..e396c1ad0c 100644 --- a/build_msvc/libbitcoin_zmq/libbitcoin_zmq.vcxproj +++ b/build_msvc/libbitcoin_zmq/libbitcoin_zmq.vcxproj.in @@ -20,10 +20,7 @@ - - - - +@SOURCE_FILES@ diff --git a/build_msvc/msvc-autogen.py b/build_msvc/msvc-autogen.py new file mode 100644 index 0000000000..8888487e75 --- /dev/null +++ b/build_msvc/msvc-autogen.py @@ -0,0 +1,63 @@ +#!/usr/bin/env python3 + +import os +import re + +SOURCE_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'src')) + +libs = [ + 'libbitcoin_cli', + 'libbitcoin_common', + 'libbitcoin_crypto', + 'libbitcoin_server', + 'libbitcoin_util', + 'libbitcoin_wallet', + 'libbitcoin_zmq', +] + +ignore_list = [ + 'rpc/net.cpp', + 'interfaces/handler.cpp', + 'interfaces/node.cpp', + 'interfaces/wallet.cpp', +] + +lib_sources = {} + + +def parse_makefile(makefile): + with open(makefile, 'r', encoding='utf-8') as file: + current_lib = '' + for line in file.read().splitlines(): + if current_lib: + source = line.split()[0] + if source.endswith('.cpp') and not source.startswith('$') and source not in ignore_list: + lib_sources[current_lib].append(source.replace('/', '\\')) + if not line.endswith('\\'): + current_lib = '' + continue + for lib in libs: + _lib = lib.replace('-', '_') + if re.search(_lib + '.*_SOURCES \\= \\\\', line): + current_lib = lib + lib_sources[current_lib] = [] + break + + +def main(): + for makefile_name in os.listdir(SOURCE_DIR): + if 'Makefile' in makefile_name: + parse_makefile(os.path.join(SOURCE_DIR, makefile_name)) + for key, value in lib_sources.items(): + vcxproj_filename = os.path.abspath(os.path.join(os.path.dirname(__file__), key, key + '.vcxproj')) + content = '' + for source_filename in value: + content += ' \n' + with open(vcxproj_filename + '.in', 'r', encoding='utf-8') as vcxproj_in_file: + with open(vcxproj_filename, 'w', encoding='utf-8') as vcxproj_file: + vcxproj_file.write(vcxproj_in_file.read().replace( + '@SOURCE_FILES@\n', content)) + + +if __name__ == '__main__': + main()