mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-02 01:36:13 +00:00
Note, the use of process_cpu_count() is intentional. It was only added in Python 3.13, according to https://docs.python.org/3/library/os.html#os.process_cpu_count . However, Python 3.13 is also the minimum required version on Windows, according to https://github.com/bitcoin/bitcoin/issues/29897#issuecomment-2940318094 to avoid intermittent test failures.
87 lines
2.0 KiB
Python
Executable File
87 lines
2.0 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
# Copyright (c) The Bitcoin Core developers
|
|
# Distributed under the MIT software license, see the accompanying
|
|
# file COPYING or https://opensource.org/license/mit/.
|
|
|
|
import argparse
|
|
import os
|
|
import shlex
|
|
import subprocess
|
|
import sys
|
|
|
|
|
|
def run(cmd, **kwargs):
|
|
print("+ " + shlex.join(cmd), flush=True)
|
|
kwargs.setdefault("check", True)
|
|
try:
|
|
return subprocess.run(cmd, **kwargs)
|
|
except Exception as e:
|
|
sys.exit(str(e))
|
|
|
|
|
|
GENERATE_OPTIONS = {
|
|
"standard": [
|
|
"-DBUILD_BENCH=ON",
|
|
"-DBUILD_KERNEL_LIB=ON",
|
|
"-DBUILD_UTIL_CHAINSTATE=ON",
|
|
"-DCMAKE_COMPILE_WARNING_AS_ERROR=ON",
|
|
],
|
|
"fuzz": [
|
|
"-DVCPKG_MANIFEST_NO_DEFAULT_FEATURES=ON",
|
|
"-DVCPKG_MANIFEST_FEATURES=wallet",
|
|
"-DBUILD_GUI=OFF",
|
|
"-DWITH_ZMQ=OFF",
|
|
"-DBUILD_FOR_FUZZING=ON",
|
|
"-DCMAKE_COMPILE_WARNING_AS_ERROR=ON",
|
|
],
|
|
}
|
|
|
|
|
|
def generate(ci_type):
|
|
toolchain_file = os.path.join(
|
|
os.environ["VCPKG_INSTALLATION_ROOT"],
|
|
"scripts",
|
|
"buildsystems",
|
|
"vcpkg.cmake",
|
|
)
|
|
command = [
|
|
"cmake",
|
|
"-B",
|
|
"build",
|
|
"-Werror=dev",
|
|
"--preset",
|
|
"vs2022",
|
|
f"-DCMAKE_TOOLCHAIN_FILE={toolchain_file}",
|
|
] + GENERATE_OPTIONS[ci_type]
|
|
run(command)
|
|
|
|
|
|
def build():
|
|
command = [
|
|
"cmake",
|
|
"--build",
|
|
"build",
|
|
"-j",
|
|
str(os.process_cpu_count()),
|
|
"--config",
|
|
"Release",
|
|
]
|
|
run(command)
|
|
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser(description="Utility to run Windows CI steps.")
|
|
parser.add_argument("ci_type", choices=GENERATE_OPTIONS, help="CI type to run.")
|
|
steps = ["generate", "build"]
|
|
parser.add_argument("step", choices=steps, help="CI step to perform.")
|
|
args = parser.parse_args()
|
|
|
|
if args.step == "generate":
|
|
generate(args.ci_type)
|
|
elif args.step == "build":
|
|
build()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|