Skip to content

Commit 79cd2c5

Browse files
committed
Merge branch 'wixp-support'
2 parents dee988b + c073213 commit 79cd2c5

File tree

6 files changed

+186
-7
lines changed

6 files changed

+186
-7
lines changed

CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ find_package(uriparser REQUIRED)
3232
find_package(tomlplusplus REQUIRED)
3333
find_package(nlohmann_json REQUIRED)
3434

35-
set(SYNCSPIRIT_VERSION "v0.3.0")
35+
set(SYNCSPIRIT_VERSION "v0.3.1")
3636

3737
configure_file(misc/syncspirit-config.h.in include/syncspirit-config.h @ONLY)
3838
set(Protobuf_IMPORT_DIRS ${syncspirit_SOURCE_DIR}/src/protobuf)
@@ -177,6 +177,7 @@ set(BUILD_SHARED_LIBS false CACHE BOOL "BUILD_SHARED_LIBS")
177177
set(MDBX_BUILD_TOOLS false CACHE BOOL "MDBX_BUILD_TOOLS")
178178
set(MDBX_ENABLE_TESTS false CACHE BOOL "MDBX_ENABLE_TESTS")
179179
set(MDBX_BUILD_CXX false CACHE BOOL "MDBX_BUILD_CXX")
180+
set(MDBX_BUILD_SHARED_LIBRARY true CACHE BOOL "MDBX_BUILD_SHARED_LIBRARY")
180181

181182
add_subdirectory("lib/mbdx")
182183

@@ -203,7 +204,7 @@ target_link_libraries(syncspirit_lib
203204
tomlplusplus::tomlplusplus
204205
nlohmann_json::nlohmann_json
205206
lz4::lz4
206-
mdbx-static
207+
$<IF:$<PLATFORM_ID:Windows>,mdbx,mdbx-static>
207208
$<$<PLATFORM_ID:Windows>:iphlpapi>
208209
$<$<PLATFORM_ID:Windows>:ws2_32>
209210
)

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ after the core completion.
117117

118118
# changes
119119

120+
## 0.3.1 (23-Apr-2024)
121+
- [feature] added `syncspirit` binary fow windows xp
122+
- [build, docs] improved build documentation
123+
120124
## 0.3.0 (14-Apr-2024)
121125
- [feature] implemented complete files syncrhonisation
122126
- [feature] added local files watcher and updates streamer

docs/building.md

Lines changed: 151 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ make -j`nproc`
4141
```
4242

4343

44-
## cross building on linus for windows (single executable)
44+
## cross building on linux for windows (single executable, simple way)
4545

4646
Install mingw on linux (something like `cross-x86_64-w64-mingw32`)
4747

@@ -84,6 +84,155 @@ cmake .. -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=$PWD/conan_toolchain.cmake \
8484
make -j`nproc`
8585
```
8686

87+
## cross building on linux for modern windows (single executable, more reliable way)
88+
89+
Download [mxe](https://mxe.cc); make sure all requirements are met.
90+
91+
Your `settings.mk` should contain something like:
92+
93+
```
94+
MXE_TARGETS := x86_64-w64-mingw32.static
95+
```
96+
97+
98+
Validate, that everything is OK via typing in mxe dir something like
99+
100+
```
101+
make zip
102+
```
103+
104+
105+
Add $mxe_dir/uer/bin to your `PATH`, and make sure something like that works:
106+
107+
```
108+
export PATH=`pwd`/usr/bin:$PATH
109+
x86_64-w64-mingw32.static-g++ --version
110+
x86_64-w64-mingw32.static-g++ (GCC) 11.2.0
111+
```
112+
113+
Make a conan profile for mingw:
114+
115+
```
116+
cat ~/.conan2/profiles/mxe
117+
[settings]
118+
os=Windows
119+
arch=x86_64
120+
compiler=gcc
121+
build_type=Release
122+
compiler.cppstd=gnu17
123+
compiler.libcxx=libstdc++11
124+
compiler.version=11
125+
[buildenv]
126+
CC=x86_64-w64-mingw32.static-gcc
127+
CXX=x86_64-w64-mingw32.static-g++
128+
LD=x86_64-w64-mingw32.static-ld
129+
RC=x86_64-w64-mingw32.static-windres
130+
131+
[options]
132+
boost/*:without_fiber=True
133+
boost/*:without_graph=True
134+
boost/*:without_log=True
135+
boost/*:without_stacktrace=True
136+
boost/*:without_test=True
137+
boost/*:without_wave=True
138+
```
139+
140+
Go to `syncspirit` dir and then make a build
141+
142+
143+
```
144+
cd syncspirit
145+
mkdir build.release && cd build.release
146+
conan install --build=missing -o '*:shared=False' -o shared=False --output-folder . \
147+
-s build_type=Release --profile:build=default --profile:host=mxe ..
148+
source ./conanbuild.sh
149+
cmake .. -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=$PWD/conan_toolchain.cmake \
150+
-DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=off
151+
make -j`nproc`
152+
```
153+
154+
## cross building on linux for windows xp
155+
156+
Download [mxe](https://mxe.cc); make sure all requirements are met.
157+
158+
Your `settings.mk` should contain something like:
159+
160+
```
161+
MXE_TARGETS := i686-w64-mingw32.static
162+
MXE_PLUGIN_DIRS=plugins/windows-xp
163+
```
164+
165+
166+
Validate, that everything is OK via typing in mxe dir something like
167+
168+
```
169+
make zip
170+
```
171+
172+
Copy the resulting `zip.exe` to windows xp host and launch, i.e. make sure
173+
everything is ok with the toolchain.
174+
175+
176+
Add $mxe_dir/uer/bin to your `PATH`, and make sure something like that works:
177+
178+
```
179+
export PATH=`pwd`/usr/bin:$PATH
180+
i686-w64-mingw32.static-g++ --version
181+
i686-w64-mingw32.static-g++ (GCC) 11.2.0
182+
```
183+
184+
Make a conan profile for mingw:
185+
186+
```
187+
cat ~/.conan2/profiles/xp
188+
[settings]
189+
os=Windows
190+
arch=x86
191+
compiler=gcc
192+
build_type=Release
193+
compiler.cppstd=gnu17
194+
compiler.libcxx=libstdc++11
195+
compiler.version=12
196+
[buildenv]
197+
CC=i686-w64-mingw32.static-gcc
198+
CXX=i686-w64-mingw32.static-g++
199+
LD=i686-w64-mingw32.static-ld
200+
RC=i686-w64-mingw32.static-windres
201+
202+
[options]
203+
boost/*:without_fiber=True
204+
boost/*:without_graph=True
205+
boost/*:without_log=True
206+
boost/*:without_stacktrace=True
207+
boost/*:without_test=True
208+
boost/*:without_wave=True
209+
210+
[conf]
211+
tools.build:cflags=["-D_WIN32_WINNT=0x0501"]
212+
tools.build:cxxflags=["-D_WIN32_WINNT=0x0501"]
213+
```
214+
215+
The supped libmbdx should be patched for windows xp support:
216+
217+
```
218+
cd syncspirit/lib/mbdx
219+
patch -p1 < ../windows-xp.patch
220+
```
221+
222+
Go to `syncspirit` dir and then make a build
223+
224+
```
225+
cd syncspirit
226+
mkdir build.release && cd build.release
227+
conan install --build=missing -o '*:shared=False' -o shared=False --output-folder . \
228+
-s build_type=Release --profile:build=default --profile:host=xp ..
229+
source ./conanbuild.sh
230+
cmake .. -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=$PWD/conan_toolchain.cmake \
231+
-DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=off \
232+
-DCMAKE_CXX_FLAGS="-D_WIN32_WINNT=0x0501 -DBOOST_ASIO_ENABLE_CANCELIO=1"
233+
make -j`nproc`
234+
```
235+
87236

88237
## cross building on linux for old linux (ubuntu 16.04 etc.)
89238

@@ -128,7 +277,7 @@ boost/*:without_wave=True
128277
```
129278

130279
```
131-
conan install --build=missing -o '*:shared=False' -o shared=False --output-folder .
280+
conan install --build=missing -o '*:shared=False' -o shared=False --output-folder . \
132281
-s build_type=Release --profile:build=default --profile:host=old_linux ..
133282
source ./conanbuild.sh
134283
cmake .. -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=$PWD/conan_toolchain.cmake \

lib/windows-xp.patch

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/src/osal.c b/src/osal.c
2+
index 5a0ae633..ec56591c 100644
3+
--- a/src/osal.c
4+
+++ b/src/osal.c
5+
@@ -1090,7 +1090,7 @@ MDBX_INTERNAL_FUNC void osal_ioring_reset(osal_ioring_t *ior) {
6+
for (ior_item_t *item = ior->pool; item <= ior->last;) {
7+
if (!HasOverlappedIoCompleted(&item->ov)) {
8+
assert(ior->overlapped_fd);
9+
- CancelIoEx(ior->overlapped_fd, &item->ov);
10+
+ CancelIo(ior->overlapped_fd);
11+
}
12+
if (item->ov.hEvent && item->ov.hEvent != ior)
13+
ior_put_event(ior, item->ov.hEvent);

src/net/db_actor.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
#include "utils/platform.h"
77
#include "db/prefix.h"
88
#include "db/utils.h"
9+
#include "../../lib/mbdx/src/internals.h"
10+
#include "src/internals.h"
911
#include "db/error_code.h"
1012
#include "model/diff/load/blocks.h"
1113
#include "model/diff/load/close_transaction.h"
@@ -43,13 +45,24 @@ r::plugin::resource_id_t db = 0;
4345
}
4446
} // namespace
4547

48+
#if 0
49+
static void _my_log(MDBX_log_level_t loglevel, const char *function,int line, const char *fmt, va_list args) noexcept
50+
{
51+
vprintf(fmt, args);
52+
}
53+
#endif
54+
4655
db_actor_t::db_actor_t(config_t &config)
4756
: r::actor_base_t{config}, env{nullptr}, db_dir{config.db_dir}, db_config{config.db_config},
4857
cluster{config.cluster} {
4958
log = utils::get_logger("net.db");
59+
60+
// mdbx_module_handler({}, {}, {});
61+
// mdbx_setup_debug(MDBX_LOG_TRACE, MDBX_DBG_ASSERT, &_my_log);
62+
5063
auto r = mdbx_env_create(&env);
5164
if (r != MDBX_SUCCESS) {
52-
LOG_CRITICAL(log, "{}, mbdx environment creation error ({}): {}", log->name(), r, mdbx_strerror(r));
65+
LOG_CRITICAL(log, "{}, mbdx environment creation error ({}): {}", "net::db", r, mdbx_strerror(r));
5366
throw std::runtime_error(std::string(mdbx_strerror(r)));
5467
}
5568
}

src/utils/network_interface.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,7 @@ static uri_container_t _local_interfaces(logger_t &log, std::uint16_t port) noex
115115
// IPv4
116116
SOCKADDR_IN *ipv4 = reinterpret_cast<SOCKADDR_IN *>(address->Address.lpSockaddr);
117117

118-
char host[INET_ADDRSTRLEN] = {0};
119-
inet_ntop(AF_INET, &(ipv4->sin_addr), host, INET_ADDRSTRLEN);
118+
auto host = inet_ntoa(ipv4->sin_addr);
120119
auto full = fmt::format("tcp://{}:{}/", host, port);
121120
auto uri = utils::parse(full).value();
122121
r.emplace_back(std::move(uri));

0 commit comments

Comments
 (0)