Skip to content

Commit

Permalink
Merge branch 'wixp-support'
Browse files Browse the repository at this point in the history
  • Loading branch information
basiliscos committed Apr 23, 2024
2 parents dee988b + c073213 commit 79cd2c5
Show file tree
Hide file tree
Showing 6 changed files with 186 additions and 7 deletions.
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ find_package(uriparser REQUIRED)
find_package(tomlplusplus REQUIRED)
find_package(nlohmann_json REQUIRED)

set(SYNCSPIRIT_VERSION "v0.3.0")
set(SYNCSPIRIT_VERSION "v0.3.1")

configure_file(misc/syncspirit-config.h.in include/syncspirit-config.h @ONLY)
set(Protobuf_IMPORT_DIRS ${syncspirit_SOURCE_DIR}/src/protobuf)
Expand Down Expand Up @@ -177,6 +177,7 @@ set(BUILD_SHARED_LIBS false CACHE BOOL "BUILD_SHARED_LIBS")
set(MDBX_BUILD_TOOLS false CACHE BOOL "MDBX_BUILD_TOOLS")
set(MDBX_ENABLE_TESTS false CACHE BOOL "MDBX_ENABLE_TESTS")
set(MDBX_BUILD_CXX false CACHE BOOL "MDBX_BUILD_CXX")
set(MDBX_BUILD_SHARED_LIBRARY true CACHE BOOL "MDBX_BUILD_SHARED_LIBRARY")

add_subdirectory("lib/mbdx")

Expand All @@ -203,7 +204,7 @@ target_link_libraries(syncspirit_lib
tomlplusplus::tomlplusplus
nlohmann_json::nlohmann_json
lz4::lz4
mdbx-static
$<IF:$<PLATFORM_ID:Windows>,mdbx,mdbx-static>
$<$<PLATFORM_ID:Windows>:iphlpapi>
$<$<PLATFORM_ID:Windows>:ws2_32>
)
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ after the core completion.

# changes

## 0.3.1 (23-Apr-2024)
- [feature] added `syncspirit` binary fow windows xp
- [build, docs] improved build documentation

## 0.3.0 (14-Apr-2024)
- [feature] implemented complete files syncrhonisation
- [feature] added local files watcher and updates streamer
Expand Down
153 changes: 151 additions & 2 deletions docs/building.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ make -j`nproc`
```


## cross building on linus for windows (single executable)
## cross building on linux for windows (single executable, simple way)

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

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

## cross building on linux for modern windows (single executable, more reliable way)

Download [mxe](https://mxe.cc); make sure all requirements are met.

Your `settings.mk` should contain something like:

```
MXE_TARGETS := x86_64-w64-mingw32.static
```


Validate, that everything is OK via typing in mxe dir something like

```
make zip
```


Add $mxe_dir/uer/bin to your `PATH`, and make sure something like that works:

```
export PATH=`pwd`/usr/bin:$PATH
x86_64-w64-mingw32.static-g++ --version
x86_64-w64-mingw32.static-g++ (GCC) 11.2.0
```

Make a conan profile for mingw:

```
cat ~/.conan2/profiles/mxe
[settings]
os=Windows
arch=x86_64
compiler=gcc
build_type=Release
compiler.cppstd=gnu17
compiler.libcxx=libstdc++11
compiler.version=11
[buildenv]
CC=x86_64-w64-mingw32.static-gcc
CXX=x86_64-w64-mingw32.static-g++
LD=x86_64-w64-mingw32.static-ld
RC=x86_64-w64-mingw32.static-windres
[options]
boost/*:without_fiber=True
boost/*:without_graph=True
boost/*:without_log=True
boost/*:without_stacktrace=True
boost/*:without_test=True
boost/*:without_wave=True
```

Go to `syncspirit` dir and then make a build


```
cd syncspirit
mkdir build.release && cd build.release
conan install --build=missing -o '*:shared=False' -o shared=False --output-folder . \
-s build_type=Release --profile:build=default --profile:host=mxe ..
source ./conanbuild.sh
cmake .. -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=$PWD/conan_toolchain.cmake \
-DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=off
make -j`nproc`
```

## cross building on linux for windows xp

Download [mxe](https://mxe.cc); make sure all requirements are met.

Your `settings.mk` should contain something like:

```
MXE_TARGETS := i686-w64-mingw32.static
MXE_PLUGIN_DIRS=plugins/windows-xp
```


Validate, that everything is OK via typing in mxe dir something like

```
make zip
```

Copy the resulting `zip.exe` to windows xp host and launch, i.e. make sure
everything is ok with the toolchain.


Add $mxe_dir/uer/bin to your `PATH`, and make sure something like that works:

```
export PATH=`pwd`/usr/bin:$PATH
i686-w64-mingw32.static-g++ --version
i686-w64-mingw32.static-g++ (GCC) 11.2.0
```

Make a conan profile for mingw:

```
cat ~/.conan2/profiles/xp
[settings]
os=Windows
arch=x86
compiler=gcc
build_type=Release
compiler.cppstd=gnu17
compiler.libcxx=libstdc++11
compiler.version=12
[buildenv]
CC=i686-w64-mingw32.static-gcc
CXX=i686-w64-mingw32.static-g++
LD=i686-w64-mingw32.static-ld
RC=i686-w64-mingw32.static-windres
[options]
boost/*:without_fiber=True
boost/*:without_graph=True
boost/*:without_log=True
boost/*:without_stacktrace=True
boost/*:without_test=True
boost/*:without_wave=True
[conf]
tools.build:cflags=["-D_WIN32_WINNT=0x0501"]
tools.build:cxxflags=["-D_WIN32_WINNT=0x0501"]
```

The supped libmbdx should be patched for windows xp support:

```
cd syncspirit/lib/mbdx
patch -p1 < ../windows-xp.patch
```

Go to `syncspirit` dir and then make a build

```
cd syncspirit
mkdir build.release && cd build.release
conan install --build=missing -o '*:shared=False' -o shared=False --output-folder . \
-s build_type=Release --profile:build=default --profile:host=xp ..
source ./conanbuild.sh
cmake .. -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=$PWD/conan_toolchain.cmake \
-DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=off \
-DCMAKE_CXX_FLAGS="-D_WIN32_WINNT=0x0501 -DBOOST_ASIO_ENABLE_CANCELIO=1"
make -j`nproc`
```


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

Expand Down Expand Up @@ -128,7 +277,7 @@ boost/*:without_wave=True
```

```
conan install --build=missing -o '*:shared=False' -o shared=False --output-folder .
conan install --build=missing -o '*:shared=False' -o shared=False --output-folder . \
-s build_type=Release --profile:build=default --profile:host=old_linux ..
source ./conanbuild.sh
cmake .. -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=$PWD/conan_toolchain.cmake \
Expand Down
13 changes: 13 additions & 0 deletions lib/windows-xp.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/src/osal.c b/src/osal.c
index 5a0ae633..ec56591c 100644
--- a/src/osal.c
+++ b/src/osal.c
@@ -1090,7 +1090,7 @@ MDBX_INTERNAL_FUNC void osal_ioring_reset(osal_ioring_t *ior) {
for (ior_item_t *item = ior->pool; item <= ior->last;) {
if (!HasOverlappedIoCompleted(&item->ov)) {
assert(ior->overlapped_fd);
- CancelIoEx(ior->overlapped_fd, &item->ov);
+ CancelIo(ior->overlapped_fd);
}
if (item->ov.hEvent && item->ov.hEvent != ior)
ior_put_event(ior, item->ov.hEvent);
15 changes: 14 additions & 1 deletion src/net/db_actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#include "utils/platform.h"
#include "db/prefix.h"
#include "db/utils.h"
#include "../../lib/mbdx/src/internals.h"
#include "src/internals.h"
#include "db/error_code.h"
#include "model/diff/load/blocks.h"
#include "model/diff/load/close_transaction.h"
Expand Down Expand Up @@ -43,13 +45,24 @@ r::plugin::resource_id_t db = 0;
}
} // namespace

#if 0
static void _my_log(MDBX_log_level_t loglevel, const char *function,int line, const char *fmt, va_list args) noexcept
{
vprintf(fmt, args);
}
#endif

db_actor_t::db_actor_t(config_t &config)
: r::actor_base_t{config}, env{nullptr}, db_dir{config.db_dir}, db_config{config.db_config},
cluster{config.cluster} {
log = utils::get_logger("net.db");

// mdbx_module_handler({}, {}, {});
// mdbx_setup_debug(MDBX_LOG_TRACE, MDBX_DBG_ASSERT, &_my_log);

auto r = mdbx_env_create(&env);
if (r != MDBX_SUCCESS) {
LOG_CRITICAL(log, "{}, mbdx environment creation error ({}): {}", log->name(), r, mdbx_strerror(r));
LOG_CRITICAL(log, "{}, mbdx environment creation error ({}): {}", "net::db", r, mdbx_strerror(r));
throw std::runtime_error(std::string(mdbx_strerror(r)));
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/utils/network_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,7 @@ static uri_container_t _local_interfaces(logger_t &log, std::uint16_t port) noex
// IPv4
SOCKADDR_IN *ipv4 = reinterpret_cast<SOCKADDR_IN *>(address->Address.lpSockaddr);

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

0 comments on commit 79cd2c5

Please sign in to comment.