Skip to content

Commit 410f99f

Browse files
build_msvc/bitcoin_config.h is generated using build_msvc/msvc-autogen.py
1 parent 9d28951 commit 410f99f

File tree

3 files changed

+44
-9
lines changed

3 files changed

+44
-9
lines changed

build_msvc/bitcoin_config.h renamed to build_msvc/bitcoin_config.h.in

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@
66
#define BITCOIN_BITCOIN_CONFIG_H
77

88
/* Version Build */
9-
#define CLIENT_VERSION_BUILD 0
9+
#define CLIENT_VERSION_BUILD $
1010

1111
/* Version is release */
12-
#define CLIENT_VERSION_IS_RELEASE false
12+
#define CLIENT_VERSION_IS_RELEASE $
1313

1414
/* Major version */
15-
#define CLIENT_VERSION_MAJOR 22
15+
#define CLIENT_VERSION_MAJOR $
1616

1717
/* Minor version */
18-
#define CLIENT_VERSION_MINOR 99
18+
#define CLIENT_VERSION_MINOR $
1919

2020
/* Copyright holder(s) before %s replacement */
2121
#define COPYRIGHT_HOLDERS "The %s developers"
@@ -27,7 +27,7 @@
2727
#define COPYRIGHT_HOLDERS_SUBSTITUTION "Bitcoin Core"
2828

2929
/* Copyright year */
30-
#define COPYRIGHT_YEAR 2021
30+
#define COPYRIGHT_YEAR $
3131

3232
/* Define to 1 to enable wallet functions */
3333
#define ENABLE_WALLET 1
@@ -184,13 +184,13 @@
184184
#define PACKAGE_NAME "Bitcoin Core"
185185

186186
/* Define to the full name and version of this package. */
187-
#define PACKAGE_STRING "Bitcoin Core 22.99.0"
187+
#define PACKAGE_STRING $
188188

189189
/* Define to the home page for this package. */
190190
#define PACKAGE_URL "https://bitcoincore.org/"
191191

192192
/* Define to the version of this package. */
193-
#define PACKAGE_VERSION "22.99.0"
193+
#define PACKAGE_VERSION $
194194

195195
/* Define this symbol if the minimal qt platform exists */
196196
#define QT_QPA_PLATFORM_MINIMAL 1

build_msvc/msvc-autogen.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,41 @@ def set_common_properties(toolset):
5757
with open(os.path.join(SOURCE_DIR, '../build_msvc/common.init.vcxproj'), 'w', encoding='utf-8',newline='\n') as wfile:
5858
wfile.write(s)
5959

60+
def parse_config_into_btc_config():
61+
def find_between( s, first, last ):
62+
try:
63+
start = s.index( first ) + len( first )
64+
end = s.index( last, start )
65+
return s[start:end]
66+
except ValueError:
67+
return ""
68+
69+
config_info = []
70+
with open(os.path.join(SOURCE_DIR,'../configure.ac'), encoding="utf8") as f:
71+
for line in f:
72+
if line.startswith("define"):
73+
config_info.append(find_between(line, "(_", ")"))
74+
75+
config_info = [c for c in config_info if not c.startswith("COPYRIGHT_HOLDERS")]
76+
77+
config_dict = dict(item.split(", ") for item in config_info)
78+
config_dict["PACKAGE_VERSION"] = f"\"{config_dict['CLIENT_VERSION_MAJOR']}.{config_dict['CLIENT_VERSION_MINOR']}.{config_dict['CLIENT_VERSION_BUILD']}\""
79+
version = config_dict["PACKAGE_VERSION"].strip('"')
80+
config_dict["PACKAGE_STRING"] = f"\"Bitcoin Core {version}\""
81+
82+
with open(os.path.join(SOURCE_DIR,'../build_msvc/bitcoin_config.h.in'), "r", encoding="utf8") as template_file:
83+
template = template_file.readlines()
84+
85+
for index, line in enumerate(template):
86+
header = ""
87+
if line.startswith("#define"):
88+
header = line.split(" ")[1]
89+
if header in config_dict:
90+
template[index] = line.replace("$", f"{config_dict[header]}")
91+
92+
with open(os.path.join(SOURCE_DIR,'../build_msvc/bitcoin_config.h'), "w", encoding="utf8") as btc_config:
93+
btc_config.writelines(template)
94+
6095
def main():
6196
parser = argparse.ArgumentParser(description='Bitcoin-core msbuild configuration initialiser.')
6297
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():
79114
with open(vcxproj_filename, 'w', encoding='utf-8') as vcxproj_file:
80115
vcxproj_file.write(vcxproj_in_file.read().replace(
81116
'@SOURCE_FILES@\n', content))
117+
parse_config_into_btc_config()
82118
copyfile(os.path.join(SOURCE_DIR,'../build_msvc/bitcoin_config.h'), os.path.join(SOURCE_DIR, 'config/bitcoin-config.h'))
83119
copyfile(os.path.join(SOURCE_DIR,'../build_msvc/libsecp256k1_config.h'), os.path.join(SOURCE_DIR, 'secp256k1/src/libsecp256k1-config.h'))
84120

doc/release-process.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ Release Process
1919

2020
* On both the master branch and the new release branch:
2121
- update `CLIENT_VERSION_MAJOR` in [`configure.ac`](../configure.ac)
22-
- update `CLIENT_VERSION_MAJOR`, `PACKAGE_VERSION`, and `PACKAGE_STRING` in [`build_msvc/bitcoin_config.h`](/build_msvc/bitcoin_config.h)
23-
* On the new release branch in [`configure.ac`](../configure.ac) and [`build_msvc/bitcoin_config.h`](/build_msvc/bitcoin_config.h) (see [this commit](https://github.com/bitcoin/bitcoin/commit/742f7dd)):
22+
* On the new release branch in [`configure.ac`](../configure.ac)(see [this commit](https://github.com/bitcoin/bitcoin/commit/742f7dd)):
2423
- set `CLIENT_VERSION_MINOR` to `0`
2524
- set `CLIENT_VERSION_BUILD` to `0`
2625
- set `CLIENT_VERSION_IS_RELEASE` to `true`

0 commit comments

Comments
 (0)