Skip to content

Commit

Permalink
Add CI/CD building script using MinGW64
Browse files Browse the repository at this point in the history
  • Loading branch information
gkv311 committed Sep 22, 2024
1 parent 1d6f3b7 commit 62efdd3
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 6 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/build_wglinfo_mingw.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# This workflow will build wglinfo on Windows
name: Build (MinGW64)

on: [push]

jobs:
build-windows-mingw:
name: Build on Windows with GCC
runs-on: windows-latest
defaults:
run:
shell: msys2 {0}

steps:
- name: Checkout repository
uses: actions/checkout@v4.1.7
with:
fetch-depth: 0

- name: Setup MSYS2
uses: msys2/setup-msys2@v2
with:
msystem: ucrt64
update: true
install: >-
git
make
pacboy: >-
toolchain:p
cmake:p
ninja:p
- name: Configure wglinfo
run: |
mkdir "build"
cmake -G Ninja -D BUILD_TREAT_WARNINGS_AS_ERRORS=ON -S . -B "./build"
- name: Build wglinfo
run: |
cmake --build "./build" --config Release
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: wglinfo-mingw
path: build/wglinfo.exe
4 changes: 3 additions & 1 deletion .github/workflows/build_wglinfo_msvc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4.1.7
with:
fetch-depth: 0

- name: Set up MSVC
- name: Setup MSVC
uses: ilammy/msvc-dev-cmd@v1.13.0
with:
arch: x64
Expand Down
25 changes: 23 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,19 @@ set (CMAKE_CXX_STANDARD 11)
if (MSVC)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /fp:precise /EHa /MP")
string (REGEX REPLACE "/EHsc" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
add_definitions (-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE -DUNICODE)
add_definitions (-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE)
# static linking with CRT
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
#set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
else()
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions -fPIC")
if (WIN32)
# force static linking to gcc C++ runtime libraries
set (CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++ ${CMAKE_EXE_LINKER_FLAGS}")
endif()
endif()
if (WIN32)
add_definitions(-DUNICODE)
endif()

set (BUILD_TREAT_WARNINGS_AS_ERRORS OFF CACHE BOOL "Treat compilation warnings as errors")
Expand All @@ -37,8 +47,19 @@ endif()
# Find OpenGL
find_package (OpenGL REQUIRED)

set (USED_SRCFILES "wglinfo.cpp")
set (USED_RCFILE "")
if (WIN32)
set (USED_RCFILE "wglinfo.rc")
endif()

# main project target
add_executable (${PROJECT_NAME}
wglinfo.cpp
${USED_SRCFILES} ${RESOURCE_FILES}
)
target_link_libraries (${PROJECT_NAME} PRIVATE ${OPENGL_LIBRARIES})

# force static linking to winpthreads
if (WIN32 AND CMAKE_COMPILER_IS_GNUCXX)
target_link_libraries (${PROJECT_NAME} PRIVATE -static gcc stdc++ winpthread -dynamic)
endif()
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ wglinfo - command line tool for printing OpenGL information on Windows platform
[![Downloads](https://img.shields.io/github/downloads/gkv311/wglinfo/total.svg)](https://github.com/gkv311/wglinfo/releases)
[![License: GPL v3](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/gkv311/wglinfo/blob/master/LICENSE.txt)
[![Status](https://github.com/gkv311/wglinfo/actions/workflows/build_wglinfo_msvc.yml/badge.svg?branch=master)](https://github.com/gkv311/wglinfo/actions?query=branch%3Amaster)
[![Status](https://github.com/gkv311/wglinfo/actions/workflows/build_wglinfo_mingw.yml/badge.svg?branch=master)](https://github.com/gkv311/wglinfo/actions?query=branch%3Amaster)

wglinfo is a small utility printing information about OpenGL library available in Windows system in similar way as glxinfo does on Linux.
In case, if libEGL.dll (e.g. Angle or another implementation) is in PATH, it also prints information about EGL/GLES.
Expand Down
12 changes: 9 additions & 3 deletions wglinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@

#include <GL/gl.h>

#if defined(__GNUC__) && !defined(__INTEL_COMPILER) && !defined(__clang__)
#if (__GNUC__ > 8) || ((__GNUC__ == 8) && (__GNUC_MINOR__ >= 1))
#pragma GCC diagnostic ignored "-Wcast-function-type"
#endif
#endif

//! Window creation tool.
struct GlWindow
{
Expand Down Expand Up @@ -1184,7 +1190,7 @@ class EglInfoWindow

};

int actual_main (int theNbArgs, char** theArgVec)
static int actual_main (int theNbArgs, const char** theArgVec)
{
bool isVerbose = false, toPrintVisuals = true, toShowEgl = true;
for (int anArgIter = 1; anArgIter < theNbArgs; ++anArgIter)
Expand All @@ -1211,7 +1217,7 @@ int actual_main (int theNbArgs, char** theArgVec)
else
{
std::cerr << "Syntax error! Unknown argument '" << theArgVec[anArgIter] << "'\n\n";
char* anArgs[2] = { theArgVec[0], "-h" };
const char* anArgs[2] = { theArgVec[0], "-h" };
actual_main (2, anArgs);
return 1;
}
Expand Down Expand Up @@ -1252,7 +1258,7 @@ int actual_main (int theNbArgs, char** theArgVec)
return 0;
}

int main(int argc, char** argv)
int main(int argc, const char** argv)
{
return actual_main(argc, argv);
}

0 comments on commit 62efdd3

Please sign in to comment.