Skip to content

Commit edf99b8

Browse files
committed
kernel: Fix bitcoin-chainstate for windows
And turn it on in the CI.
1 parent 8fbe027 commit edf99b8

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ jobs:
202202
job-type: [standard, fuzz]
203203
include:
204204
- job-type: standard
205-
generate-options: '-DBUILD_GUI=ON -DWITH_ZMQ=ON -DBUILD_BENCH=ON -DBUILD_KERNEL_LIB=ON -DWERROR=ON'
205+
generate-options: '-DBUILD_GUI=ON -DWITH_ZMQ=ON -DBUILD_BENCH=ON -DBUILD_KERNEL_LIB=ON -DBUILD_UTIL_CHAINSTATE=ON -DWERROR=ON'
206206
job-name: 'Windows native, VS 2022'
207207
- job-type: fuzz
208208
generate-options: '-DVCPKG_MANIFEST_NO_DEFAULT_FEATURES=ON -DVCPKG_MANIFEST_FEATURES="wallet" -DBUILD_GUI=OFF -DBUILD_FOR_FUZZING=ON -DWERROR=ON'
@@ -280,7 +280,7 @@ jobs:
280280
$exeName = $_.Name
281281
282282
# Skip as they currently do not have manifests
283-
if ($exeName -eq "fuzz.exe" -or $exeName -eq "bench_bitcoin.exe" -or $exeName -eq "test_bitcoin-qt.exe" -or $exeName -eq "test_kernel.exe") {
283+
if ($exeName -eq "fuzz.exe" -or $exeName -eq "bench_bitcoin.exe" -or $exeName -eq "test_bitcoin-qt.exe" -or $exeName -eq "test_kernel.exe" -or $exeName -eq "bitcoin-chainstate.exe") {
284284
Write-Host "Skipping $exeName (no manifest present)"
285285
return
286286
}
@@ -307,6 +307,7 @@ jobs:
307307
BITCOINTX: '${{ github.workspace }}\build\bin\Release\bitcoin-tx.exe'
308308
BITCOINUTIL: '${{ github.workspace }}\build\bin\Release\bitcoin-util.exe'
309309
BITCOINWALLET: '${{ github.workspace }}\build\bin\Release\bitcoin-wallet.exe'
310+
BITCOINCHAINSTATE: '${{ github.workspace }}\build\bin\Release\bitcoin-chainstate.exe'
310311
TEST_RUNNER_EXTRA: ${{ github.event_name != 'pull_request' && '--extended' || '' }}
311312
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}
312313

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)