Skip to content

Commit

Permalink
add windows x64 workflow (jasongdove#38)
Browse files Browse the repository at this point in the history
* add windows workflow

* not ready for warnings as errors

* update output path on windows

* try to fix windows output directory again

* fix worldserver version command
  • Loading branch information
jasongdove authored Oct 1, 2024
1 parent fffde3d commit 2b1a16e
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 7 deletions.
103 changes: 103 additions & 0 deletions .github/workflows/build-win-x64.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
name: Windows x64

on:
push:
pull_request:

jobs:
build:
runs-on: windows-latest
env:
CMAKE_BUILD_TYPE: RelWithDebInfo
MYSQL_ROOT_DIR: C:/Program Files/MySQL/MySQL Server 8.0
OPENSSL_ROOT_DIR: C:/libs/openssl
steps:
- uses: actions/checkout@v4

- name: Set reusable strings
id: strings
shell: bash
run: |
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
- name: Get current OpenSSL version
id: openssl-info
run: |
$VersionsUrl = "https://api.github.com/repos/slproweb/opensslhashes/contents/win32_openssl_hashes.json"
$Headers = @{
Accept="application/vnd.github.raw+json"
Authorization="Bearer ${{ secrets.GITHUB_TOKEN }}"
}
$openSSL = (Invoke-RestMethod $VersionsUrl -Headers $Headers).files.PSObject.Properties |
Select-Object -ExpandProperty Value |
Where-Object { $_.arch -eq 'INTEL' } |
Where-Object { $_.bits -eq '64' } |
Where-Object { $_.light -eq $false } |
Where-Object { $_.installer -eq 'exe' } |
Sort-Object -Descending @{ Expression = { [version]$_.basever } } |
Select-Object -First 1
[System.String]::Format("cache-key=openssl-{0}-win-{1}-{2}", $openSSL.basever, $openSSL.arch, $openSSL.bits) >> $env:GITHUB_OUTPUT
[System.String]::Format("url={0}", $openSSL.url) >> $env:GITHUB_OUTPUT
- name: Cache OpenSSL
id: cache-openssl
uses: actions/cache@v4
with:
path: ${{ env.OPENSSL_ROOT_DIR }}
key: ${{ steps.openssl-info.outputs.cache-key }}

- name: Download and install Openssl 3.x
if: ${{ steps.cache-openssl.outputs.cache-hit != 'true' }}
run: |
(New-Object System.Net.WebClient).DownloadFile("${{ steps.openssl-info.outputs.url }}", "${{ env.TEMP }}\openssl.exe")
Start-Process -Wait -FilePath "${{ env.TEMP }}\openssl.exe" "/SILENT","/SP-","/SUPPRESSMSGBOXES",/DIR=${{ env.OPENSSL_ROOT_DIR }}
# Quick Openssl install test
& ${{ env.OPENSSL_ROOT_DIR }}/bin/openssl.exe version
- name: Download and install Boost
uses: MarkusJx/[email protected]
id: install-boost
with:
boost_version: 1.84.0
link: static
platform_version: 2022
toolset: msvc

- name: Initialize Visual Studio Environment
uses: egor-tensin/vs-shell@v2
with:
arch: x64

- name: Configure CMake
env:
BOOST_ROOT: ${{ steps.install-boost.outputs.BOOST_ROOT }}
run: >
cmake -GNinja -S ${{ github.workspace }} -B ${{ steps.strings.outputs.build-output-dir }}
-DTOOLS=ON
- name: Build
run: |
cmake --build ${{ steps.strings.outputs.build-output-dir }}
- name: Copy Dependencies
run: |
cd ${{ steps.strings.outputs.build-output-dir }}/bin/${{ env.CMAKE_BUILD_TYPE }}
copy "${{ env.MYSQL_ROOT_DIR }}/lib/libmysql.dll" libmysql.dll
copy "${{ env.OPENSSL_ROOT_DIR }}/bin/libssl-3-x64.dll" libssl-3-x64.dll
copy "${{ env.OPENSSL_ROOT_DIR }}/bin/libcrypto-3-x64.dll" libcrypto-3-x64.dll
copy "${{ env.OPENSSL_ROOT_DIR }}/bin/legacy.dll" legacy.dll
- name: Check binaries
run: |
cd ${{ steps.strings.outputs.build-output-dir }}/bin/${{ env.CMAKE_BUILD_TYPE }}
./bnetserver --version
./worldserver --version
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
path: ${{ steps.strings.outputs.build-output-dir }}/bin/${{ env.CMAKE_BUILD_TYPE }}
name: LegionCoreMainWin64VS2022
# Set a custom retention for artifacts
#retention-days: 7
3 changes: 0 additions & 3 deletions cmake/compiler/mingw/settings.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# set up output paths for executable binaries (.exe-files, and .dll-files on DLL-capable platforms)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)

# Set build-directive (used in core to tell which buildtype we used)
target_compile_definitions(trinity-compile-option-interface
INTERFACE
Expand Down
3 changes: 0 additions & 3 deletions cmake/compiler/msvc/settings.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# set up output paths for executable binaries (.exe-files, and .dll-files on DLL-capable platforms)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)

set(MSVC_EXPECTED_VERSION 19.10)
set(MSVC_EXPECTED_VERSION_STRING "MSVC 2017")

Expand Down
3 changes: 3 additions & 0 deletions cmake/platform/win/settings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ add_definitions(-D_WIN32_WINNT=0x0601)
add_definitions(-DWIN32_LEAN_AND_MEAN)
add_definitions(-DNOMINMAX)

# set up output paths for executable binaries (.exe-files, and .dll-files on DLL-capable platforms)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/$<CONFIG>")

if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
include(${CMAKE_SOURCE_DIR}/cmake/compiler/msvc/settings.cmake)
elseif (CMAKE_CXX_PLATFORM_ID MATCHES "MinGW")
Expand Down
8 changes: 7 additions & 1 deletion src/server/worldserver/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,7 @@ variables_map GetConsoleArguments(int argc, char** argv, std::string& configFile
options_description all("Allowed options");
all.add_options()
("help,h", "print usage message")
("version,v", "print version build info")
("config,c", value<std::string>(&configFile)->default_value(_TRINITY_CORE_CONFIG), "use <arg> as configuration file")
;
#ifdef _WIN32
Expand All @@ -605,9 +606,14 @@ variables_map GetConsoleArguments(int argc, char** argv, std::string& configFile
std::cerr << e.what() << "\n";
}

if (vm.count("help")) {
if (vm.count("help"))
{
std::cout << all << "\n";
}
else if (vm.count("version"))
{
std::cout << GitRevision::GetFullVersion() << "\n";
}

return vm;
}

0 comments on commit 2b1a16e

Please sign in to comment.