From 89ee5de7d591899317eeb9551fc58a0c5f4613cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole-Andr=C3=A9=20Rodlie?= Date: Mon, 5 Aug 2024 18:29:32 +0200 Subject: [PATCH 1/5] Windows CI (first try) --- .github/workflows/windows.yml | 14 ++++++ CMakeLists.txt | 10 ++++- src/app/CMakeLists.txt | 6 +-- src/cmake/friction-common.cmake | 2 + src/cmake/friction-ffmpeg.cmake | 4 +- src/core/CMakeLists.txt | 2 +- src/scripts/build_ci.bat | 77 +++++++++++++++++++++++++++++++++ src/ui/CMakeLists.txt | 2 +- 8 files changed, 108 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/windows.yml create mode 100644 src/scripts/build_ci.bat diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml new file mode 100644 index 000000000..3db43529c --- /dev/null +++ b/.github/workflows/windows.yml @@ -0,0 +1,14 @@ +name: Windows + +on: [push, pull_request] + +jobs: + build: + + runs-on: windows-2019 + + steps: + - uses: actions/checkout@v3 + - name: Build + shell: cmd + run: \src\scripts\build_ci.bat diff --git a/CMakeLists.txt b/CMakeLists.txt index 84a30da44..05d6cd95b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,6 +20,8 @@ cmake_minimum_required(VERSION 3.12) project(friction.graphics) +option(BUILD_ENGINE "Build Engine" ON) + set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/src/cmake") include(friction-version) include(friction-meta) @@ -55,7 +57,9 @@ if(UNIX AND NOT APPLE) include(CPack) endif() -add_subdirectory(src/engine) +if(${BUILD_ENGINE}) + add_subdirectory(src/engine) +endif() if(UNIX) option(BUILD_TESTING "Don't build gperftools tests" OFF) add_subdirectory(src/gperftools) @@ -64,4 +68,6 @@ add_subdirectory(src/core) add_subdirectory(src/ui) add_subdirectory(src/app) -add_dependencies(frictioncore Engine) +if(${BUILD_ENGINE}) + add_dependencies(frictioncore Engine) +endif() diff --git a/src/app/CMakeLists.txt b/src/app/CMakeLists.txt index 2754f0524..3bf3e6d0f 100644 --- a/src/app/CMakeLists.txt +++ b/src/app/CMakeLists.txt @@ -66,9 +66,9 @@ if(APPLE) endif() if(WIN32) - set(QSCINTILLA_LIBRARIES_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../qscintilla/src/release) + set(QSCINTILLA_LIBRARIES_DIRS ${CMAKE_SOURCE_DIR}/sdk/bin) set(QSCINTILLA_LIBRARIES qscintilla2_qt5) - set(QSCINTILLA_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../qscintilla/src) + set(QSCINTILLA_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/sdk/include) add_definitions(-DQSCINTILLA_DLL) else() set(QSCINTILLA_LIBRARIES_DIRS "/usr/lib" CACHE STRING "qscintilla library path") @@ -289,7 +289,7 @@ target_link_directories( ${FFMPEG_LIBRARIES_DIRS} ${QSCINTILLA_LIBRARIES_DIRS} #${QUAZIP_LIBRARIES_DIRS} - ${CMAKE_CURRENT_BINARY_DIR}/../engine/skia + ${SKIA_LIBRARIES_DIRS} ) if(${USE_SKIA_SYSTEM_LIBS} AND UNIX) diff --git a/src/cmake/friction-common.cmake b/src/cmake/friction-common.cmake index 0566f5a68..47b8a56f6 100644 --- a/src/cmake/friction-common.cmake +++ b/src/cmake/friction-common.cmake @@ -105,6 +105,7 @@ if(WIN32) user32 opengl32) add_definitions(-DSKIA_DLL) + set(SKIA_LIBRARIES_DIRS ${CMAKE_SOURCE_DIR}/sdk/bin) else() if(APPLE) set(SKIA_LIBRARIES skia) @@ -117,4 +118,5 @@ else() set(GPERF_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/../gperftools ${UNWIND_INCLUDE_DIRS}) set(GPERF_LIBRARIES tcmalloc_static ${UNWIND_LIBRARIES}) endif() + set(SKIA_LIBRARIES_DIRS ${CMAKE_CURRENT_BINARY_DIR}/../engine/skia) endif() diff --git a/src/cmake/friction-ffmpeg.cmake b/src/cmake/friction-ffmpeg.cmake index b98eca3b3..0fbeae99c 100644 --- a/src/cmake/friction-ffmpeg.cmake +++ b/src/cmake/friction-ffmpeg.cmake @@ -20,14 +20,14 @@ # if(WIN32) - set(FFMPEG_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/src/ffmpeg/include) + set(FFMPEG_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/sdk/include) set(FFMPEG_LIBRARIES avformat avcodec avutil swscale swresample) - set(FFMPEG_LIBRARIES_DIRS ${CMAKE_SOURCE_DIR}/src/ffmpeg/bin) + set(FFMPEG_LIBRARIES_DIRS ${CMAKE_SOURCE_DIR}/sdk/bin) else() pkg_check_modules(AVFORMAT REQUIRED libavformat) pkg_check_modules(AVCODEC REQUIRED libavcodec) diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index b06143979..59122fdeb 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -716,7 +716,7 @@ target_link_directories( ${PROJECT_NAME} PRIVATE ${FFMPEG_LIBRARIES_DIRS} - ${CMAKE_CURRENT_BINARY_DIR}/../engine/skia + ${SKIA_LIBRARIES_DIRS} #${QUAZIP_LIBRARIES_DIRS} ) diff --git a/src/scripts/build_ci.bat b/src/scripts/build_ci.bat new file mode 100644 index 000000000..5899fe334 --- /dev/null +++ b/src/scripts/build_ci.bat @@ -0,0 +1,77 @@ +@echo off + +REM ### BUILD FRICTION ON WINDOWS +REM # Copyright (c) Friction contributors +REM # GPLv3+ + +set OPT=%1 +set REL=OFF +if "%OPT%" == "release" ( + set REL=ON +) + +set CWD=%cd% +set SDK_DIR=%CWD%\sdk +set SDK_VERSION=20240805 + +set PATH=%SDK_DIR%\bin;%PATH% + +set BRANCH= +for /f %%I in ('git rev-parse --abbrev-ref HEAD 2^> NUL') do set BRANCH=%%I + +set COMMIT= +for /f %%i in ('git rev-parse --short^=8 HEAD') do set COMMIT=%%i + +if not exist "sdk\" ( + curl -OL "https://github.com/friction2d/friction-sdk/releases/download/%SDK_VERSION%/friction-sdk-%SDK_VERSION%-windows-x64.7z" + 7z x friction-sdk-%SDK_VERSION%-windows-x64.7z +) + +if exist "build\" ( + @RD /S /Q build +) +mkdir build + +cd "%CWD%\build" +mkdir output + +cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=%SDK_DIR% -DBUILD_ENGINE=OFF -DFRICTION_OFFICIAL_RELEASE=%REL% -DWIN_DEPLOY=ON -DGIT_COMMIT=%COMMIT% -DGIT_BRANCH=%BRANCH% .. +set /p VERSION= Date: Mon, 5 Aug 2024 18:31:02 +0200 Subject: [PATCH 2/5] Update windows.yml --- .github/workflows/windows.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 3db43529c..cb1520565 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -11,4 +11,4 @@ jobs: - uses: actions/checkout@v3 - name: Build shell: cmd - run: \src\scripts\build_ci.bat + run: .\src\scripts\build_ci.bat From 249ba52ef091ab7e4142586f92bb62a155b0896e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole-Andr=C3=A9=20Rodlie?= Date: Mon, 5 Aug 2024 18:34:29 +0200 Subject: [PATCH 3/5] Update build_ci.bat --- src/scripts/build_ci.bat | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/scripts/build_ci.bat b/src/scripts/build_ci.bat index 5899fe334..4dcc0d556 100644 --- a/src/scripts/build_ci.bat +++ b/src/scripts/build_ci.bat @@ -16,6 +16,8 @@ set SDK_VERSION=20240805 set PATH=%SDK_DIR%\bin;%PATH% +git submodule update -i --recursive + set BRANCH= for /f %%I in ('git rev-parse --abbrev-ref HEAD 2^> NUL') do set BRANCH=%%I From 66dab042b8a4f3207026cd1b163ab5ef9e4006e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole-Andr=C3=A9=20Rodlie?= Date: Mon, 5 Aug 2024 18:52:55 +0200 Subject: [PATCH 4/5] Update exceptions.h --- src/core/exceptions.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/core/exceptions.h b/src/core/exceptions.h index 4856272b0..1614e047d 100644 --- a/src/core/exceptions.h +++ b/src/core/exceptions.h @@ -29,6 +29,7 @@ #include "core_global.h" #include +#include #include #include From 41447b99f632f2480c22aa8e997f9687b7767736 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole-Andr=C3=A9=20Rodlie?= Date: Mon, 5 Aug 2024 19:31:30 +0200 Subject: [PATCH 5/5] Update windows.yml --- .github/workflows/windows.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index cb1520565..347d6926e 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -12,3 +12,8 @@ jobs: - name: Build shell: cmd run: .\src\scripts\build_ci.bat + - name: Artifact + uses: actions/upload-artifact@v4 + with: + name: friction-ci-${{github.sha}}-windows-x64 + path: build\output\*.7z