Skip to content

Commit ba5b475

Browse files
committed
kernel: Fix bitcoin-chainstate for windows
And turn it on in the CI.
1 parent 262290b commit ba5b475

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ jobs:
175175
job-type: [standard, fuzz]
176176
include:
177177
- job-type: standard
178-
generate-options: '-DBUILD_GUI=ON -DWITH_ZMQ=ON -DBUILD_BENCH=ON -DBUILD_KERNEL_LIB=ON -DWERROR=ON'
178+
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'
179179
job-name: 'Windows native, VS 2022'
180180
- job-type: fuzz
181181
generate-options: '-DVCPKG_MANIFEST_NO_DEFAULT_FEATURES=ON -DVCPKG_MANIFEST_FEATURES="wallet" -DBUILD_GUI=OFF -DBUILD_FOR_FUZZING=ON -DWERROR=ON'
@@ -263,6 +263,7 @@ jobs:
263263
BITCOINTX: '${{ github.workspace }}\build\bin\Release\bitcoin-tx.exe'
264264
BITCOINUTIL: '${{ github.workspace }}\build\bin\Release\bitcoin-util.exe'
265265
BITCOINWALLET: '${{ github.workspace }}\build\bin\Release\bitcoin-wallet.exe'
266+
BITCOINCHAINSTATE: '${{ github.workspace }}\build\bin\Release\bitcoin-chainstate.exe'
266267
TEST_RUNNER_EXTRA: ${{ github.event_name != 'pull_request' && '--extended' || '' }}
267268
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}
268269

src/bitcoin-chainstate.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,15 @@
99
#include <string_view>
1010
#include <vector>
1111

12+
#ifdef WIN32
13+
// clang-format off
14+
#include <windows.h>
15+
// clang-format on
16+
#include <codecvt>
17+
#include <locale>
18+
#include <shellapi.h>
19+
#endif
20+
1221
using namespace btck;
1322

1423
std::vector<std::byte> hex_string_to_byte_vec(std::string_view hex)
@@ -140,6 +149,22 @@ int main(int argc, char* argv[])
140149
<< " BREAK IN FUTURE VERSIONS. DO NOT USE ON YOUR ACTUAL DATADIR." << std::endl;
141150
return 1;
142151
}
152+
153+
#ifdef WIN32
154+
int win_argc;
155+
wchar_t** wargv = CommandLineToArgvW(GetCommandLineW(), &win_argc);
156+
std::vector<std::string> utf8_args(win_argc);
157+
std::vector<char*> win_argv(win_argc);
158+
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>, wchar_t> utf8_cvt;
159+
for (int i = 0; i < win_argc; i++) {
160+
utf8_args[i] = utf8_cvt.to_bytes(wargv[i]);
161+
win_argv[i] = &utf8_args[i][0];
162+
}
163+
LocalFree(wargv);
164+
argc = win_argc;
165+
argv = win_argv.data();
166+
#endif
167+
143168
std::filesystem::path abs_datadir{std::filesystem::absolute(argv[1])};
144169
std::filesystem::create_directories(abs_datadir);
145170

0 commit comments

Comments
 (0)