aboutsummaryrefslogtreecommitdiff
path: root/build_msvc/msvc-autogen.py
diff options
context:
space:
mode:
authorW. J. van der Laan <laanwj@protonmail.com>2021-11-15 14:54:56 +0100
committerW. J. van der Laan <laanwj@protonmail.com>2021-11-15 15:11:44 +0100
commit2efc8c0999a4b99cfe3076f7312806e83e778261 (patch)
tree6738be0b09c2de4cf690b1a7daf6e63aacbf3ab1 /build_msvc/msvc-autogen.py
parent41a1b5f58ca59d2177dcadf834efd187fa3fba52 (diff)
parent410f99faed47e27fca77531a864383b6119e7b0b (diff)
downloadbitcoin-2efc8c0999a4b99cfe3076f7312806e83e778261.tar.xz
Merge bitcoin/bitcoin#23198: build: Parse version information in msvc-autogen.py
410f99faed47e27fca77531a864383b6119e7b0b build_msvc/bitcoin_config.h is generated using build_msvc/msvc-autogen.py (CallMeMisterOwl) Pull request description: Added a function that parses version information from `configure.ac` into `build_msvc/bitcoin_config.h`. This is done by default in `msvc-autogen.py`, so manual changing of `build_msvc/bitcoin_config.h` is no longer required. In addition to that I updated the Release Process doc. Following values are updated: -**CLIENT_VERSION_BUILD** -**CLIENT_VERSION_IS_RELEASE** -**CLIENT_VERSION_MAJOR** -**CLIENT_VERSION_MINOR** -**COPYRIGHT_YEAR** -**PACKAGE_STRING** -**PACKAGE_VERSION** fixes #23073 ACKs for top commit: laanwj: Code review and lightly tested ACK 410f99faed47e27fca77531a864383b6119e7b0b Tree-SHA512: 6b324ec8680b70c405c46a0fcd61836d1b57bb3eaef2cc36bb1e9856890f0423c201a8fdddc95ca0fb5b3dade71ff6d4d14351c606b3351eef2faa0c70bca38a
Diffstat (limited to 'build_msvc/msvc-autogen.py')
-rwxr-xr-xbuild_msvc/msvc-autogen.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/build_msvc/msvc-autogen.py b/build_msvc/msvc-autogen.py
index a1ed935996..6ce65f3fa3 100755
--- a/build_msvc/msvc-autogen.py
+++ b/build_msvc/msvc-autogen.py
@@ -57,6 +57,41 @@ def set_common_properties(toolset):
with open(os.path.join(SOURCE_DIR, '../build_msvc/common.init.vcxproj'), 'w', encoding='utf-8',newline='\n') as wfile:
wfile.write(s)
+def parse_config_into_btc_config():
+ def find_between( s, first, last ):
+ try:
+ start = s.index( first ) + len( first )
+ end = s.index( last, start )
+ return s[start:end]
+ except ValueError:
+ return ""
+
+ config_info = []
+ with open(os.path.join(SOURCE_DIR,'../configure.ac'), encoding="utf8") as f:
+ for line in f:
+ if line.startswith("define"):
+ config_info.append(find_between(line, "(_", ")"))
+
+ config_info = [c for c in config_info if not c.startswith("COPYRIGHT_HOLDERS")]
+
+ config_dict = dict(item.split(", ") for item in config_info)
+ config_dict["PACKAGE_VERSION"] = f"\"{config_dict['CLIENT_VERSION_MAJOR']}.{config_dict['CLIENT_VERSION_MINOR']}.{config_dict['CLIENT_VERSION_BUILD']}\""
+ version = config_dict["PACKAGE_VERSION"].strip('"')
+ config_dict["PACKAGE_STRING"] = f"\"Bitcoin Core {version}\""
+
+ with open(os.path.join(SOURCE_DIR,'../build_msvc/bitcoin_config.h.in'), "r", encoding="utf8") as template_file:
+ template = template_file.readlines()
+
+ for index, line in enumerate(template):
+ header = ""
+ if line.startswith("#define"):
+ header = line.split(" ")[1]
+ if header in config_dict:
+ template[index] = line.replace("$", f"{config_dict[header]}")
+
+ with open(os.path.join(SOURCE_DIR,'../build_msvc/bitcoin_config.h'), "w", encoding="utf8") as btc_config:
+ btc_config.writelines(template)
+
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.'
@@ -79,6 +114,7 @@ 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))
+ parse_config_into_btc_config()
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'))