Skip to content

Commit

Permalink
Add Windows build with Clang (#411)
Browse files Browse the repository at this point in the history
after 72 commits and 24 hours
  • Loading branch information
MihailRis authored Dec 14, 2024
1 parent 76559cc commit 12c10d1
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 6 deletions.
75 changes: 75 additions & 0 deletions .github/workflows/windows-clang.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Windows Build (CLang)

on:
push:
branches: [ "main", "release-**"]
pull_request:
branches: [ "main" ]

jobs:
build-windows:

strategy:
matrix:
include:
- os: windows-latest
compiler: clang

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v2
with:
submodules: 'true'
- uses: msys2/setup-msys2@v2
id: msys2
name: Setup MSYS2
with:
msystem: clang64
install: >-
mingw-w64-clang-x86_64-toolchain
mingw-w64-clang-x86_64-cmake
mingw-w64-clang-x86_64-make
mingw-w64-clang-x86_64-luajit
git tree
- name: Set up vcpkg
shell: msys2 {0}
run: |
git clone https://github.com/microsoft/vcpkg.git
cd vcpkg
./bootstrap-vcpkg.bat
./vcpkg integrate install
cd ..
- name: Configure project with CMake and vcpkg
shell: msys2 {0}
run: |
export VCPKG_DEFAULT_TRIPLET=x64-mingw-static
export VCPKG_DEFAULT_HOST_TRIPLET=x64-mingw-static
mkdir build
cd build
cmake -G "MinGW Makefiles" -DVCPKG_TARGET_TRIPLET=x64-mingw-static -DCMAKE_BUILD_TYPE=Release -DVOXELENGINE_BUILD_WINDOWS_VCPKG=ON ..
cmake --build . --config Release
- name: Package for Windows
run: |
mkdir packaged
mkdir packaged/res
cp build/VoxelEngine.exe packaged/
cp build/vctest/vctest.exe packaged/
cp build/*.dll packaged/
cp -r build/res/* packaged/res/
mv packaged/VoxelEngine.exe packaged/VoxelCore.exe
- env:
MSYS2_LOCATION: ${{ steps.msys2.outputs.msys2-location }}
name: Add lua51.dll to the package
run: |
cp $env:MSYS2_LOCATION/clang64/bin/lua51.dll ${{ github.workspace }}/packaged/
working-directory: ${{ github.workspace }}
- uses: actions/upload-artifact@v4
with:
name: Windows-Build
path: 'packaged/*'
- name: Run engine tests
shell: msys2 {0}
working-directory: ${{ github.workspace }}
run: |
packaged/vctest.exe -e packaged/VoxelCore.exe -d dev/tests -u build --output-always
15 changes: 11 additions & 4 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,19 @@ if (NOT APPLE)
find_package(EnTT REQUIRED)
endif()

set(LIBS "")

if (WIN32)
if(VOXELENGINE_BUILD_WINDOWS_VCPKG)
set(LUA_LIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/../vcpkg/packages/luajit_x64-windows/lib/lua51.lib")
set(LUA_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../vcpkg/packages/luajit_x64-windows/include/luajit")
if (MSVC)
set(LUA_LIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/../vcpkg/packages/luajit_x64-windows/lib/lua51.lib")
set(LUA_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../vcpkg/packages/luajit_x64-windows/include/luajit")
else()
find_package(PkgConfig)
pkg_check_modules(OpenAL REQUIRED IMPORTED_TARGET openal)
set(LIBS ${LIBS} luajit-5.1 wsock32 ws2_32 pthread PkgConfig::OpenAL -static-libstdc++)
message(${OPENAL_LIBRARY})
endif()
find_package(glfw3 REQUIRED)
find_package(glm REQUIRED)
find_package(vorbis REQUIRED)
Expand Down Expand Up @@ -53,8 +62,6 @@ else()
set(VORBISLIB ${VORBIS_LDFLAGS})
endif()

set(LIBS "")

if(UNIX)
find_package(glfw3 3.3 REQUIRED)
find_package(Threads REQUIRED)
Expand Down
3 changes: 1 addition & 2 deletions src/logic/scripting/lua/lua_commons.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
#include "delegates.hpp"
#include "logic/scripting/scripting.hpp"

#ifdef __linux__
#if (defined __linux__) || (defined __MINGW32__)
#include <luajit-2.1/luaconf.h>

#include <luajit-2.1/lua.hpp>
#else
#include <lua.hpp>
Expand Down

0 comments on commit 12c10d1

Please sign in to comment.