kernel: Fix bitcoin-chainstate for windows

And turn it on in the CI.
This commit is contained in:
TheCharlatan 2025-04-08 16:51:37 +02:00
parent 1db7bde6d2
commit 4fce466d1a
No known key found for this signature in database
GPG Key ID: 9B79B45691DB4173
2 changed files with 27 additions and 1 deletions

View File

@ -202,7 +202,7 @@ jobs:
job-type: [standard, fuzz]
include:
- job-type: standard
generate-options: '-DBUILD_GUI=ON -DWITH_ZMQ=ON -DBUILD_BENCH=ON -DBUILD_KERNEL_LIB=ON -DWERROR=ON'
generate-options: '-DBUILD_GUI=ON -DWITH_ZMQ=ON -DBUILD_BENCH=ON -DBUILD_KERNEL_LIB=ON -DBUILD_UTIL_CHAINSTATE=ON -DBUILD_KERNEL_TEST=OFF -DWERROR=ON'
job-name: 'Windows native, VS 2022'
- job-type: fuzz
generate-options: '-DVCPKG_MANIFEST_NO_DEFAULT_FEATURES=ON -DVCPKG_MANIFEST_FEATURES="wallet" -DBUILD_GUI=OFF -DBUILD_FOR_FUZZING=ON -DWERROR=ON'
@ -307,6 +307,7 @@ jobs:
BITCOINTX: '${{ github.workspace }}\build\bin\Release\bitcoin-tx.exe'
BITCOINUTIL: '${{ github.workspace }}\build\bin\Release\bitcoin-util.exe'
BITCOINWALLET: '${{ github.workspace }}\build\bin\Release\bitcoin-wallet.exe'
BITCOINCHAINSTATE: '${{ github.workspace }}\build\bin\Release\bitcoin-chainstate.exe'
TEST_RUNNER_EXTRA: ${{ github.event_name != 'pull_request' && '--extended' || '' }}
run: py -3 test/functional/test_runner.py --jobs $NUMBER_OF_PROCESSORS --ci --quiet --tmpdirprefix="${RUNNER_TEMP}" --combinedlogslen=99999999 --timeout-factor=${TEST_RUNNER_TIMEOUT_FACTOR} ${TEST_RUNNER_EXTRA}

View File

@ -9,6 +9,15 @@
#include <string_view>
#include <vector>
#ifdef WIN32
// clang-format off
#include <windows.h>
// clang-format on
#include <codecvt>
#include <locale>
#include <shellapi.h>
#endif
using namespace btck;
std::vector<std::byte> hex_string_to_byte_vec(std::string_view hex)
@ -140,6 +149,22 @@ int main(int argc, char* argv[])
<< " BREAK IN FUTURE VERSIONS. DO NOT USE ON YOUR ACTUAL DATADIR." << std::endl;
return 1;
}
#ifdef WIN32
int win_argc;
wchar_t** wargv = CommandLineToArgvW(GetCommandLineW(), &win_argc);
std::vector<std::string> utf8_args(win_argc);
std::vector<char*> win_argv(win_argc);
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>, wchar_t> utf8_cvt;
for (int i = 0; i < win_argc; i++) {
utf8_args[i] = utf8_cvt.to_bytes(wargv[i]);
win_argv[i] = &utf8_args[i][0];
}
LocalFree(wargv);
argc = win_argc;
argv = win_argv.data();
#endif
std::filesystem::path abs_datadir{std::filesystem::absolute(argv[1])};
std::filesystem::create_directories(abs_datadir);