mirror of
https://github.com/Neo-Desktop/WindowsXPKg
synced 2025-07-05 11:50:23 +03:00
Compare commits
5 Commits
master
...
libumskt-s
Author | SHA1 | Date | |
---|---|---|---|
60fffee505 | |||
542c3d65e0 | |||
a88b4a11e5 | |||
e118ecbbba | |||
df22f0e4c4 |
46
.github/workflows/windows.yml
vendored
46
.github/workflows/windows.yml
vendored
@ -32,6 +32,10 @@ jobs:
|
||||
strategy:
|
||||
matrix:
|
||||
arch: [x64, x86, arm64]
|
||||
binary_type: [static, shared]
|
||||
outputs:
|
||||
binary_type: ${{ matrix.binary_type }}
|
||||
arch: ${{ matrix.arch }}
|
||||
steps:
|
||||
- name: Setup TDM-GCC
|
||||
if: matrix.arch != 'arm64'
|
||||
@ -112,6 +116,7 @@ jobs:
|
||||
run: |
|
||||
New-Item -ItemType Directory -Force -Path $env:VCPKG_DEFAULT_BINARY_CACHE
|
||||
& "$env:VCPKG_ROOT\vcpkg.exe" install openssl:arm64-windows-static --clean-after-build
|
||||
& "$env:VCPKG_ROOT\vcpkg.exe" install fmt:arm64-windows-${{ matrix.binary_type }} --clean-after-build
|
||||
|
||||
- name: Configure UMSKT (TDM-GCC ${{ matrix.arch }})
|
||||
if: matrix.arch != 'arm64'
|
||||
@ -121,6 +126,7 @@ jobs:
|
||||
$OPENSSL_ROOT = "$env:OPENSSL_ROOT"
|
||||
$OPENSSL_LIB = "$OPENSSL_ROOT/$env:OPENSSL_LIBDIR"
|
||||
$OPENSSL_INC = "$OPENSSL_ROOT/include"
|
||||
$SHARED = if ('${{ matrix.binary_type }}' -eq 'shared') { 'ON' } else { 'OFF' }
|
||||
cmake -G "MinGW Makefiles" `
|
||||
-DCMAKE_C_COMPILER="gcc" `
|
||||
-DCMAKE_CXX_COMPILER="g++" `
|
||||
@ -130,17 +136,20 @@ jobs:
|
||||
-DOPENSSL_SSL_LIBRARY="$OPENSSL_LIB/libssl.a" `
|
||||
-DCMAKE_C_FLAGS="$env:CMAKE_FLAGS" `
|
||||
-DCMAKE_CXX_FLAGS="$env:CMAKE_FLAGS" `
|
||||
-DBUILD_SHARED_LIBS="$SHARED" `
|
||||
.
|
||||
|
||||
- name: Configure UMSKT (MSVC ARM64)
|
||||
if: matrix.arch == 'arm64'
|
||||
shell: pwsh
|
||||
run: |
|
||||
$SHARED = if ('${{ matrix.binary_type }}' -eq 'shared') { 'ON' } else { 'OFF' }
|
||||
cmake -G "Visual Studio 17 2022" `
|
||||
-A ARM64 `
|
||||
-DWINDOWS_ARM=ON `
|
||||
-DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake" `
|
||||
-DVCPKG_TARGET_TRIPLET=arm64-windows-static `
|
||||
-DVCPKG_TARGET_TRIPLET=arm64-windows-${{ matrix.binary_type }} `
|
||||
-DBUILD_SHARED_LIBS="$SHARED" `
|
||||
.
|
||||
|
||||
- name: Build UMSKT (TDM-GCC ${{ matrix.arch }})
|
||||
@ -168,18 +177,20 @@ jobs:
|
||||
- name: Upload build artifact
|
||||
uses: actions/upload-artifact@v4.6.2
|
||||
with:
|
||||
name: UMSKT-WinNT-${{ matrix.arch }}
|
||||
path: ${{ matrix.arch == 'arm64' && 'Release/umskt.exe' || 'umskt.exe' }}
|
||||
name: UMSKT-WinNT-${{ matrix.arch }}-${{ matrix.binary_type }}
|
||||
path: |
|
||||
${{ matrix.arch == 'arm64' && 'Release/umskt.exe' || 'umskt.exe' }}
|
||||
${{ matrix.binary_type == 'shared' && (matrix.arch == 'arm64' && 'Release/*.dll' || '*.dll') || '' }}
|
||||
|
||||
test-arm64:
|
||||
needs: build
|
||||
if: success()
|
||||
if: success() && needs.build.outputs.binary_type == 'static' && needs.build.outputs.arch == 'arm64'
|
||||
runs-on: windows-11-arm
|
||||
steps:
|
||||
- name: Download ARM64 artifact
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: UMSKT-WinNT-arm64
|
||||
name: UMSKT-WinNT-arm64-static
|
||||
path: .
|
||||
|
||||
- name: Run tests (ARM64)
|
||||
@ -189,3 +200,28 @@ jobs:
|
||||
.\umskt.exe -b 2C -c 365 -s 069420 -v
|
||||
Write-Host Test 2 - generatng confid
|
||||
.\umskt.exe -i 253286028742154311079061239762245184619981623171292574
|
||||
|
||||
test-arm64-shared:
|
||||
needs: build
|
||||
if: success() && needs.build.outputs.binary_type == 'shared' && needs.build.outputs.arch == 'arm64'
|
||||
runs-on: windows-11-arm
|
||||
steps:
|
||||
- name: Download ARM64 shared artifact
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: UMSKT-WinNT-arm64-shared
|
||||
path: .
|
||||
|
||||
- name: Setup shared library environment
|
||||
shell: pwsh
|
||||
run: |
|
||||
# Add current directory to PATH so Windows can find the DLLs
|
||||
$env:PATH = "$pwd;" + $env:PATH
|
||||
|
||||
- name: Run tests (ARM64 Shared)
|
||||
shell: pwsh
|
||||
run: |
|
||||
Write-Host Test 1 - generating key
|
||||
.\umskt.exe -b 2C -c 365 -s 069420 -v
|
||||
Write-Host Test 2 - generatng confid
|
||||
.\umskt.exe -i 253286028742154311079061239762245184619981623171292574
|
||||
|
6
.gitignore
vendored
6
.gitignore
vendored
@ -258,4 +258,8 @@ CPM_modules
|
||||
CPM_*.cmake
|
||||
cpm-package-lock.cmake
|
||||
*.a
|
||||
*_cmrc*
|
||||
*_cmrc*
|
||||
fmt_install/
|
||||
fmt_external-prefix/
|
||||
*.dll
|
||||
*.o
|
127
CMakeLists.txt
127
CMakeLists.txt
@ -27,23 +27,31 @@ if (WIN32 AND NOT MSVC)
|
||||
set(CMAKE_CXX_COMPILER "C:/TDM-GCC-64/bin/g++.exe" CACHE FILEPATH "C++ Compiler" FORCE)
|
||||
message(STATUS "[UMSKT] Forcing use of TDM-GCC in C:/TDM-GCC-64")
|
||||
|
||||
# Configure windres for resource compilation
|
||||
set(CMAKE_RC_COMPILER "C:/TDM-GCC-64/bin/windres.exe")
|
||||
set(CMAKE_RC_COMPILER_INIT windres)
|
||||
enable_language(RC)
|
||||
set(CMAKE_RC_FLAGS "--use-temp-file -c65001")
|
||||
# Set up resource compilation for Windows
|
||||
set(RC_COMPILER "C:/TDM-GCC-64/bin/windres.exe")
|
||||
set(RC_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/umskt_res.o")
|
||||
|
||||
# Match resource architecture with target architecture
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||
set(CMAKE_RC_FLAGS "${CMAKE_RC_FLAGS} -F pe-i386")
|
||||
set(RC_TARGET "pe-i386")
|
||||
else()
|
||||
set(CMAKE_RC_FLAGS "${CMAKE_RC_FLAGS} -F pe-x86-64")
|
||||
set(RC_TARGET "pe-x86-64")
|
||||
endif()
|
||||
|
||||
set(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> <FLAGS> -O coff -I${CMAKE_CURRENT_SOURCE_DIR}/src/windows <DEFINES> -i <SOURCE> -o <OBJECT>")
|
||||
add_custom_command(
|
||||
OUTPUT ${RC_OUTPUT}
|
||||
COMMAND ${RC_COMPILER}
|
||||
ARGS --input-format=rc
|
||||
--output-format=coff
|
||||
--target=${RC_TARGET}
|
||||
-I${CMAKE_CURRENT_SOURCE_DIR}/src/windows
|
||||
-i${CMAKE_CURRENT_SOURCE_DIR}/src/windows/umskt.rc
|
||||
-o${RC_OUTPUT}
|
||||
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/src/windows/umskt.rc
|
||||
COMMENT "Compiling Windows resources"
|
||||
)
|
||||
|
||||
# Set the Windows resource file for GCC builds
|
||||
set(UMSKT_EXE_WINDOWS_EXTRA src/windows/umskt.rc)
|
||||
set(UMSKT_EXE_WINDOWS_EXTRA ${RC_OUTPUT})
|
||||
endif()
|
||||
|
||||
SET(CMAKE_CXX_STANDARD 17)
|
||||
@ -195,14 +203,55 @@ CPMAddPackage(
|
||||
VERSION 3.11.2
|
||||
)
|
||||
|
||||
# Build fmt separately first if we're building shared libraries, CPM doesn't include shared
|
||||
if(BUILD_SHARED_LIBS AND NOT (WINDOWS_ARM AND MSVC))
|
||||
include(ExternalProject)
|
||||
set(FMT_INSTALL_DIR ${CMAKE_BINARY_DIR}/fmt_install)
|
||||
ExternalProject_Add(fmt_external
|
||||
GIT_REPOSITORY https://github.com/fmtlib/fmt.git
|
||||
GIT_TAG 10.0.0
|
||||
CMAKE_ARGS
|
||||
-DCMAKE_INSTALL_PREFIX=${FMT_INSTALL_DIR}
|
||||
-DBUILD_SHARED_LIBS=ON
|
||||
-DFMT_TEST=OFF
|
||||
-DFMT_DOC=OFF
|
||||
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
|
||||
INSTALL_DIR ${FMT_INSTALL_DIR}
|
||||
)
|
||||
endif()
|
||||
|
||||
# Include fmt development library
|
||||
CPMAddPackage(
|
||||
if(BUILD_SHARED_LIBS)
|
||||
if(WINDOWS_ARM AND MSVC)
|
||||
# For ARM64 MSVC shared builds, use vcpkg's fmt
|
||||
find_package(fmt CONFIG REQUIRED)
|
||||
else()
|
||||
# For other shared builds, use our custom build
|
||||
ExternalProject_Get_Property(fmt_external INSTALL_DIR)
|
||||
add_library(fmt::fmt SHARED IMPORTED GLOBAL)
|
||||
file(MAKE_DIRECTORY ${INSTALL_DIR}/include)
|
||||
if(WIN32)
|
||||
set_target_properties(fmt::fmt PROPERTIES
|
||||
IMPORTED_IMPLIB ${INSTALL_DIR}/lib/libfmt.dll.a
|
||||
IMPORTED_LOCATION ${INSTALL_DIR}/bin/libfmt.dll
|
||||
INTERFACE_INCLUDE_DIRECTORIES ${INSTALL_DIR}/include
|
||||
)
|
||||
else()
|
||||
set_target_properties(fmt::fmt PROPERTIES
|
||||
IMPORTED_LOCATION ${INSTALL_DIR}/lib/libfmt.so
|
||||
INTERFACE_INCLUDE_DIRECTORIES ${INSTALL_DIR}/include
|
||||
)
|
||||
endif()
|
||||
add_dependencies(fmt::fmt fmt_external)
|
||||
endif()
|
||||
else()
|
||||
CPMAddPackage(
|
||||
NAME fmt
|
||||
GITHUB_REPOSITORY fmtlib/fmt
|
||||
GIT_TAG 10.0.0
|
||||
VERSION 10.0.0
|
||||
#OPTIONS "FMT_INSTALL YES" "BUILD_SHARED_LIBS OFF"
|
||||
)
|
||||
)
|
||||
endif()
|
||||
|
||||
# Include cmrc resource compiler
|
||||
CPMAddPackage(
|
||||
@ -244,16 +293,54 @@ IF (EMSCRIPTEN)
|
||||
SET_TARGET_PROPERTIES(umskt PROPERTIES COMPILE_FLAGS "-Os -sEXPORTED_RUNTIME_METHODS=ccall,cwrap")
|
||||
SET_TARGET_PROPERTIES(umskt PROPERTIES LINK_FLAGS "-Os -sWASM=1 -sEXPORT_ALL=1 -sEXPORTED_RUNTIME_METHODS=ccall,cwrap --no-entry")
|
||||
ELSE()
|
||||
ADD_LIBRARY(_umskt ${LIBUMSKT_SRC} ${UMSKT_EXE_WINDOWS_EXTRA} ${UMSKT_EXE_WINDOWS_DLL})
|
||||
TARGET_INCLUDE_DIRECTORIES(_umskt PUBLIC ${OPENSSL_INCLUDE_DIR})
|
||||
# Library target - no resource file needed here
|
||||
ADD_LIBRARY(_umskt ${LIBUMSKT_SRC} ${UMSKT_EXE_WINDOWS_DLL})
|
||||
TARGET_INCLUDE_DIRECTORIES(_umskt PUBLIC
|
||||
${OPENSSL_INCLUDE_DIR}
|
||||
$<$<BOOL:${BUILD_SHARED_LIBS}>:${FMT_INSTALL_DIR}/include>
|
||||
)
|
||||
TARGET_LINK_DIRECTORIES(_umskt PUBLIC ${UMSKT_LINK_DIRS})
|
||||
TARGET_LINK_LIBRARIES(_umskt ${OPENSSL_CRYPTO_LIBRARIES} fmt ${UMSKT_LINK_LIBS})
|
||||
if(BUILD_SHARED_LIBS)
|
||||
TARGET_LINK_LIBRARIES(_umskt ${OPENSSL_CRYPTO_LIBRARIES} fmt::fmt ${UMSKT_LINK_LIBS})
|
||||
else()
|
||||
TARGET_LINK_LIBRARIES(_umskt ${OPENSSL_CRYPTO_LIBRARIES} fmt ${UMSKT_LINK_LIBS})
|
||||
endif()
|
||||
|
||||
### UMSKT executable compilation
|
||||
# Add Windows system libraries for shared library builds
|
||||
if (WIN32)
|
||||
if (BUILD_SHARED_LIBS)
|
||||
target_link_libraries(_umskt ws2_32 crypt32 wsock32 advapi32)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
### UMSKT executable compilation - include resource file here
|
||||
ADD_EXECUTABLE(umskt src/main.cpp src/cli.cpp ${UMSKT_EXE_WINDOWS_EXTRA})
|
||||
TARGET_INCLUDE_DIRECTORIES(umskt PUBLIC ${OPENSSL_INCLUDE_DIR})
|
||||
TARGET_LINK_LIBRARIES(umskt _umskt ${OPENSSL_CRYPTO_LIBRARIES} ${ZLIB_LIBRARIES} fmt nlohmann_json::nlohmann_json umskt::rc ${UMSKT_LINK_LIBS})
|
||||
TARGET_LINK_DIRECTORIES(umskt PUBLIC ${UMSKT_LINK_DIRS})
|
||||
TARGET_INCLUDE_DIRECTORIES(umskt PUBLIC
|
||||
${OPENSSL_INCLUDE_DIR}
|
||||
$<$<BOOL:${BUILD_SHARED_LIBS}>:${FMT_INSTALL_DIR}/include>
|
||||
)
|
||||
if(BUILD_SHARED_LIBS)
|
||||
TARGET_LINK_LIBRARIES(umskt _umskt ${OPENSSL_CRYPTO_LIBRARIES} ${ZLIB_LIBRARIES} fmt::fmt nlohmann_json::nlohmann_json umskt::rc ${UMSKT_LINK_LIBS})
|
||||
|
||||
# Copy shared libraries to build directory
|
||||
if(WIN32)
|
||||
add_custom_command(TARGET umskt POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
"${FMT_INSTALL_DIR}/bin/libfmt.dll"
|
||||
"${CMAKE_BINARY_DIR}/libfmt.dll"
|
||||
COMMENT "Copying fmt DLL to build directory"
|
||||
)
|
||||
else()
|
||||
add_custom_command(TARGET umskt POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
"${FMT_INSTALL_DIR}/lib/libfmt.so"
|
||||
"${CMAKE_BINARY_DIR}/libfmt.so"
|
||||
COMMENT "Copying fmt shared library to build directory"
|
||||
)
|
||||
endif()
|
||||
else()
|
||||
TARGET_LINK_LIBRARIES(umskt _umskt ${OPENSSL_CRYPTO_LIBRARIES} ${ZLIB_LIBRARIES} fmt nlohmann_json::nlohmann_json umskt::rc ${UMSKT_LINK_LIBS})
|
||||
endif()
|
||||
|
||||
# Link required Windows system libraries for OpenSSL
|
||||
if (WIN32)
|
||||
|
Reference in New Issue
Block a user