MCPcopy Create free account
hub / github.com/ElementsProject/elements / parse_config_into_btc_config

Function parse_config_into_btc_config

build_msvc/msvc-autogen.py:60–93  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

58 wfile.write(s)
59
60def 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
95def main():
96 parser = argparse.ArgumentParser(description='Bitcoin-core msbuild configuration initialiser.')

Callers 1

mainFunction · 0.85

Calls 3

find_betweenFunction · 0.85
enumerateFunction · 0.50
joinMethod · 0.45

Tested by

no test coverage detected