1
0
Fork 0

Add support to build under linux wine

This commit is contained in:
Eldar Khayrullin 2025-07-20 23:45:29 +03:00
parent 98291b35b7
commit 8f97124495
12 changed files with 127 additions and 3 deletions

2
CMakeLists.txt generated
View File

@ -56,8 +56,8 @@ find_package(Qt5 REQUIRED
# Target: zydis_wrapper
set(zydis_wrapper_SOURCES
cmake.toml
"src/zydis_wrapper/Zydis/Zydis.c"
"src/zydis_wrapper/Zydis/Zydis.h"
"src/zydis_wrapper/zydis/Zydis.c"
"src/zydis_wrapper/zydis_wrapper.cpp"
"src/zydis_wrapper/zydis_wrapper.h"
)

21
COMPILE-linux.md Normal file
View File

@ -0,0 +1,21 @@
## Prerequisites
```sh
sudo apt update
sudo apt install cmake ninja-build wine
```
## Install MSVC
Download https://github.com/mstorsjo/msvc-wine
```sh
cd msvc-wine
./vsdownload.py --accept-license --dest ~/opt/msvc Microsoft.VisualStudio.Workload.VCTools Microsoft.VisualStudio.Component.VC.ATL
./install.sh ~/opt/msvc
```
## Build
```sh
export MSVC_BIN_DIR=~/opt/msvc/bin/x86
export QT_BIN_DIR=~/src/x64dbg/build32/_deps/qt5-src/bin
cmake -B build32 -DCMAKE_TOOLCHAIN_FILE=cmake/msvc-wine.cmake -G Ninja
cmake --build build32 -j4
```

View File

@ -32,7 +32,7 @@ sources = [
"src/zydis_wrapper/*.cpp",
"src/zydis_wrapper/*.h",
"src/zydis_wrapper/Zydis/Zydis.h",
"src/zydis_wrapper/zydis/Zydis.c",
"src/zydis_wrapper/Zydis/Zydis.c",
]
include-directories = [
"src/zydis_wrapper",

13
cmake/msvc-wine.cmake Normal file
View File

@ -0,0 +1,13 @@
set(CMAKE_SYSTEM_NAME Windows)
set(MSVC_BIN_DIR $ENV{MSVC_BIN_DIR})
set(CMAKE_C_COMPILER ${MSVC_BIN_DIR}/cl)
set(CMAKE_CXX_COMPILER ${MSVC_BIN_DIR}/cl)
set(CMAKE_RC_COMPILER ${MSVC_BIN_DIR}/rc)
# FIX LINK : fatal error LNK1158: cannot run 'rc.exe'
set(CMAKE_EXE_LINKER_FLAGS /MANIFEST:NO)
set(CMAKE_SHARED_LINKER_FLAGS /MANIFEST:NO)
set(CMAKE_PROJECT_INCLUDE ${CMAKE_CURRENT_LIST_DIR}/qt-wine.cmake)

33
cmake/qt-wine.cmake Normal file
View File

@ -0,0 +1,33 @@
include_guard()
message(STATUS "Configuring Qt for Wine cross-compilation...")
set(QT_HOST_BIN_DIR ${CMAKE_CURRENT_LIST_DIR}/wine)
function(qt5_host_tool name)
if (NOT TARGET Qt5::${name})
add_executable(Qt5::${name} IMPORTED)
set(imported_location ${QT_HOST_BIN_DIR}/${name})
# FIXME run after deps.cmake to enable next
#if(NOT EXISTS ${imported_location})
# message(FATAL_ERROR "Qt5 tool not found: ${imported_location}")
#endif()
set_target_properties(Qt5::${name} PROPERTIES
IMPORTED_LOCATION ${imported_location}
)
endif()
endfunction()
qt5_host_tool(windeployqt)
qt5_host_tool(qmake)
qt5_host_tool(moc)
qt5_host_tool(rcc)
qt5_host_tool(uic)
# FIX: -external:I not found system includes
set(CMAKE_INCLUDE_SYSTEM_FLAG_C "-I")
set(CMAKE_INCLUDE_SYSTEM_FLAG_CXX "-I")

1
cmake/wine/moc Symbolic link
View File

@ -0,0 +1 @@
run

1
cmake/wine/qmake Symbolic link
View File

@ -0,0 +1 @@
run

1
cmake/wine/rcc Symbolic link
View File

@ -0,0 +1 @@
run

52
cmake/wine/run Executable file
View File

@ -0,0 +1,52 @@
#!/usr/bin/env bash
#
# Copyright (c) 2018 Martin Storsjo
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#. msvcenv.sh
# /showIncludes
unixify_path='/^Note: including file: /{ s/z:([\\/])/\1/i; s,\\,/,g; }'
# /E
unixify_line='/^[[:blank:]]*#[[:blank:]]*line[[:blank:]]/{ s/z:([\\/])/\1/i; s,\\\\,/,g; }'
# Warnings and Errors
unixify_note='/^[zZ]:.*\([[:digit:]]+\): (note|error C[[:digit:]]{4}|warning C[[:digit:]]{4}): /{ s/z:([\\/])/\1/ig; s,\\,/,g; }'
export WINE_MSVC_STDOUT_SED="$unixify_path;$unixify_line;$unixify_note"
export WINE_MSVC_STDERR_SED="$unixify_path"
"$MSVC_BIN_DIR"/wine-msvc.sh "$QT_BIN_DIR"/$(basename $0).exe "$@"
ec=$?
[ $ec -ne 0 ] && exit $ec
# Postprocess
for a in "$@"; do
case $a in
[-/]P) arg_P=$a ;;
[-/]Fi*) arg_Fi=${a:3} ;;
esac
done
# Unixify paths for /P
if [ -n "$arg_P" ] && [ -f "$arg_Fi" ]; then
if sed --help 2>&1 | grep '\-i extension' >/dev/null; then
inplace=(-i '') # BSD sed
else
inplace=(-i) # GNU sed
fi
sed "${inplace[@]}" -E 's/\r//;'"$unixify_line" "$arg_Fi"
fi
exit $ec

1
cmake/wine/uic Symbolic link
View File

@ -0,0 +1 @@
run

1
cmake/wine/windeployqt Symbolic link
View File

@ -0,0 +1 @@
run

View File

@ -1,5 +1,5 @@
#include "SelectFields.h"
#include "ui_selectfields.h"
#include "ui_SelectFields.h"
SelectFields::SelectFields(QWidget* parent) :
QDialog(parent),