Skip to content

Commit

Permalink
ci: reworked windows builds
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiud committed Nov 9, 2021
1 parent 3369666 commit 26490d6
Show file tree
Hide file tree
Showing 12 changed files with 213 additions and 138 deletions.
253 changes: 148 additions & 105 deletions .github/workflows/windows-builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,114 +3,157 @@ name: Windows
on: [push, pull_request]

jobs:
build:
# available environments: https://github.com/actions/virtual-environments
name: ${{matrix.config.name}} ${{matrix.build_type}}
runs-on: ${{matrix.config.os}}
build-msvc:
name: ${{matrix.msvc}}-${{matrix.arch}}-C++${{matrix.std}}-${{matrix.build_type}}-${{matrix.lib}}-${{matrix.extra}}
runs-on: ${{matrix.os}}
defaults:
run:
shell: powershell
strategy:
fail-fast: false
matrix:
config:
- {
name: "VS-15-2017-win64-C++11",
os: windows-2016,
generator: "Visual Studio 15 2017",
std: 11,
test_target: RUN_TESTS,
}
- {
name: "VS-16-2019-win64-C++98",
os: windows-2019,
generator: "Visual Studio 16 2019",
std: 98,
test_target: RUN_TESTS,
}
- {
name: "VS-16-2019-win64-C++11",
os: windows-2019,
generator: "Visual Studio 16 2019",
std: 11,
test_target: RUN_TESTS,
}
- {
name: "VS-16-2019-win64-C++17",
os: windows-2019,
generator: "Visual Studio 16 2019",
std: 17,
test_target: RUN_TESTS,
}
- {
name: "VS-16-2019-win64-C++20",
os: windows-2019,
generator: "Visual Studio 16 2019",
std: 20,
test_target: RUN_TESTS,
}
- {
name: "MinGW-C++98",
os: windows-latest,
generator: "MinGW Makefiles",
std: 98,
test_target: test,
}
- {
name: "MinGW-C++11",
os: windows-latest,
generator: "MinGW Makefiles",
std: 11,
test_target: test,
}
- {
name: "MinGW-C++14",
os: windows-latest,
generator: "MinGW Makefiles",
std: 14,
test_target: test,
}
- {
name: "MinGW-C++17",
os: windows-latest,
generator: "MinGW Makefiles",
std: 17,
test_target: test,
}
- {
name: "MinGW-C++20",
os: windows-latest,
generator: "MinGW Makefiles",
std: 20,
test_target: test,
}
build_type: [Debug] #, Release]
ARCH: ["x64"]
std: [98, 11, 14, 17, 20]
msvc: [VS-15-2017, VS-16-2019, VS-17-2022]
build_type: [Debug, Release]
lib: [shared, static]
arch: [Win32, x64]
extra: [no-custom-prefix, custom-prefix]
include:
- msvc: VS-15-2017
os: windows-2016
generator: 'Visual Studio 15 2017'
- msvc: VS-16-2019
os: windows-2019
generator: 'Visual Studio 16 2019'
- msvc: VS-17-2022
os: windows-2022
generator: 'Visual Studio 17 2022'

steps:
- uses: actions/checkout@v2

# Visual Studio build steps
- name: Configure build MSVC
if: ${{ startswith(matrix.config.name, 'VS-') }}
shell: powershell
run: cmake -S . -B ${{runner.workspace}}/build_${{matrix.config.name}}_${{matrix.build_type}} -G "${{matrix.config.generator}}" -A "${{matrix.ARCH}}" -DCMAKE_CXX_STANDARD=${{matrix.config.std}} -DCMAKE_CXX_STANDARD_REQUIRED=ON -DCMAKE_CXX_EXTENSIONS=OFF
- name: Build MSVC
if: ${{ startswith(matrix.config.name, 'VS-') }}
shell: powershell
run: cmake --build ${{runner.workspace}}/build_${{matrix.config.name}}_${{matrix.build_type}} --config ${{matrix.build_type}}

# MinGW build steps
- name: Configure build MinGW
if: ${{ startswith(matrix.config.name, 'MinGW-') }}
shell: powershell
env:
CXXFLAGS: -Wall -Wextra -Wpedantic -Wsign-conversion -Wtautological-compare -Werror -Wno-error=variadic-macros -Wno-error=long-long
run: cmake -S . -B ${{runner.workspace}}/build_${{matrix.config.name}}_${{matrix.build_type}} -G "${{matrix.config.generator}}" -DCMAKE_CXX_STANDARD=${{matrix.config.std}} -DCMAKE_CXX_EXTENSIONS=OFF -DCMAKE_CXX_STANDARD_REQUIRED=ON -DCMAKE_BUILD_TYPE=${{matrix.build_type}}
- name: Build MinGW
if: ${{ startswith(matrix.config.name, 'MinGW-') }}
shell: powershell
run: cmake --build ${{runner.workspace}}/build_${{matrix.config.name}}_${{matrix.build_type}}

- name: Run tests
shell: powershell
env:
- uses: actions/checkout@v2

- name: Configure
run: |
cmake -S . -B build_${{matrix.build_type}} `
-A ${{matrix.arch}} `
-DBUILD_SHARED_LIBS=${{matrix.lib == 'shared'}} `
-DCMAKE_CXX_EXTENSIONS=OFF `
-DCMAKE_CXX_STANDARD=${{matrix.std}} `
-DCMAKE_CXX_STANDARD_REQUIRED=ON `
-DCMAKE_INSTALL_PREFIX:PATH=./install `
-DWITH_CUSTOM_PREFIX=${{matrix.extra == 'custom-prefix'}} `
-G "${{matrix.generator}}"
- name: Build
run: cmake --build build_${{matrix.build_type}} `
--config ${{matrix.build_type}}

- name: Test
env:
CTEST_OUTPUT_ON_FAILURE: 1
run: |
cmake --build build_${{matrix.build_type}}/ `
--config ${{matrix.build_type}} `
--target RUN_TESTS
- name: Install
run: |
cmake --build build_${{matrix.build_type}}/ `
--config ${{matrix.build_type}} `
--target install
build-mingw:
name: ${{matrix.sys}}-${{matrix.env}}-C++${{matrix.std}}-${{matrix.build_type}}-${{matrix.lib}}-${{matrix.extra}}
runs-on: windows-latest
defaults:
run:
shell: msys2 {0}
strategy:
fail-fast: false
matrix:
std: [98, 11, 14, 17, 20]
build_type: [Debug, Release]
sys: [mingw32, mingw64]
lib: [shared, static]
extra: [no-custom-prefix, custom-prefix]
include:
- sys: mingw32
env: i686
- sys: mingw64
env: x86_64

steps:
- uses: actions/checkout@v2
- uses: msys2/setup-msys2@v2
with:
msystem: ${{matrix.sys}}
install: >-
lcov
mingw-w64-${{matrix.env}}-cmake
mingw-w64-${{matrix.env}}-gcc
mingw-w64-${{matrix.env}}-gflags
mingw-w64-${{matrix.env}}-ninja
- name: Configure
env:
CXXFLAGS: -Wall -Wextra -Wpedantic -Wsign-conversion -Wtautological-compare -Werror -Wno-error=variadic-macros -Wno-error=long-long
run: |
if [[ ${{matrix.build_type}} == "Debug" ]]; then
export CXXFLAGS="--coverage ${CXXFLAGS}"
fi
cmake -S . -B build_${{matrix.build_type}}/ \
-DBUILD_SHARED_LIBS=${{matrix.lib == 'shared'}} \
-DCMAKE_BUILD_TYPE=${{matrix.build_type}} \
-DCMAKE_CXX_EXTENSIONS=OFF \
-DCMAKE_CXX_STANDARD=${{matrix.std}} \
-DCMAKE_CXX_STANDARD_REQUIRED=ON \
-DCMAKE_INSTALL_PREFIX:PATH=./install \
-DWITH_CUSTOM_PREFIX=${{matrix.extra == 'custom-prefix'}} \
-G Ninja
- name: Build
run: |
cmake --build build_${{matrix.build_type}}/ --config ${{matrix.build_type}}
- name: Test
env:
CTEST_OUTPUT_ON_FAILURE: 1
run: cmake --build ${{runner.workspace}}/build_${{matrix.config.name}}_${{matrix.build_type}} --target ${{matrix.config.test_target}}
run: |
cmake --build build_${{matrix.build_type}}/ --config ${{matrix.build_type}} \
--target test
- name: Install
run: |
cmake --build build_${{matrix.build_type}}/ \
--config ${{matrix.build_type}} \
--target install
- name: Generate Coverage
if: ${{ startswith(matrix.build_type, 'Debug') }}
run: |
lcov --directory . --capture --output-file coverage.info
lcov --remove coverage.info \
'*/install/include/*' \
'*/msys64/mingw32/*' \
'*/msys64/mingw64/*' \
'*/src/*_unittest.cc' \
'*/src/googletest.h' \
'*/src/mock-log.h' \
--output-file coverage.info
for file in src/glog/*.h.in; do
name=$(basename ${file})
name_we=${name%.h.in}
sed -i "s|build_${{matrix.build_type}}/glog/${name_we}.h\$|${file}|g" coverage.info
done
lcov --list coverage.info
- name: Upload Coverage to Coveralls
if: ${{ startswith(matrix.build_type, 'Debug') }}
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: ./coverage.info
base-path: $GITHUB_WORKSPACE
9 changes: 5 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -643,11 +643,11 @@ if (Unwind_FOUND)
endif (Unwind_FOUND)

if (HAVE_DBGHELP)
target_link_libraries (glog PUBLIC dbghelp)
target_link_libraries (glog PRIVATE dbghelp)
endif (HAVE_DBGHELP)

if (HAVE_PTHREAD)
target_link_libraries (glog PUBLIC ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (glog PRIVATE ${CMAKE_THREAD_LIBS_INIT})
endif (HAVE_PTHREAD)

if (gflags_FOUND)
Expand All @@ -665,8 +665,8 @@ if (gflags_FOUND)
endif (gflags_FOUND)

if (ANDROID)
target_link_libraries (glog PUBLIC log)
endif()
target_link_libraries (glog PRIVATE log)
endif (ANDROID)

set_target_properties (glog PROPERTIES VERSION ${PROJECT_VERSION})
set_target_properties (glog PROPERTIES SOVERSION 1)
Expand Down Expand Up @@ -899,6 +899,7 @@ if (BUILD_TESTING)

add_test (NAME cmake_package_config_build COMMAND
${CMAKE_COMMAND} --build ${CMAKE_CURRENT_BINARY_DIR}/test_package_config/working_config
--config $<CONFIG>
)

add_test (NAME cmake_package_config_cleanup COMMAND ${CMAKE_COMMAND} -E
Expand Down
3 changes: 3 additions & 0 deletions src/config.h.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
/* define if you have google gtest library */
#cmakedefine HAVE_LIB_GTEST

/* define if you have dbghelp library */
#cmakedefine HAVE_DBGHELP

/* define if you have libunwind */
#cmakedefine HAVE_LIB_UNWIND

Expand Down
7 changes: 7 additions & 0 deletions src/demangle.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1325,6 +1325,7 @@ static bool ParseTopLevelMangledName(State *state) {
// The demangler entry point.
bool Demangle(const char *mangled, char *out, size_t out_size) {
#if defined(GLOG_OS_WINDOWS)
#if defined(HAVE_DBGHELP)
// When built with incremental linking, the Windows debugger
// library provides a more complicated `Symbol->Name` with the
// Incremental Linking Table offset, which looks like
Expand All @@ -1346,6 +1347,12 @@ bool Demangle(const char *mangled, char *out, size_t out_size) {
} // Else the symbol wasn't inside a set of parentheses
// We use the ANSI version to ensure the string type is always `char *`.
return UnDecorateSymbolName(mangled, out, out_size, UNDNAME_COMPLETE);
#else
(void)mangled;
(void)out;
(void)out_size;
return false;
#endif
#else
State state;
InitState(&state, mangled, out, out_size);
Expand Down
2 changes: 2 additions & 0 deletions src/demangle_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ static const char *DemangleIt(const char * const mangled) {

#if defined(GLOG_OS_WINDOWS)

#if defined(HAVE_DBGHELP) && !defined(NDEBUG)
TEST(Demangle, Windows) {
EXPECT_STREQ(
"public: static void __cdecl Foo::func(int)",
Expand All @@ -75,6 +76,7 @@ TEST(Demangle, Windows) {
"int __cdecl foobarArray(int * const)",
DemangleIt("?foobarArray@@YAHQAH@Z"));
}
#endif

#else

Expand Down
2 changes: 1 addition & 1 deletion src/glog/logging.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ struct LogMessageTime {
const time_t& timestamp() const { return ts; }
const int& sec() const { return time_struct.tm_sec; }
const int32_t& usec() const { return usecs; }
const int& min() const { return time_struct.tm_min; }
const int& (min)() const { return time_struct.tm_min; }
const int& hour() const { return time_struct.tm_hour; }
const int& day() const { return time_struct.tm_mday; }
const int& month() const { return time_struct.tm_mon; }
Expand Down
4 changes: 2 additions & 2 deletions src/googletest.h
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ class Thread {
handle_ = CreateThread(NULL,
0,
&Thread::InvokeThreadW,
(LPVOID)this,
this,
0,
&th_);
CHECK(handle_) << "CreateThread";
Expand Down Expand Up @@ -594,7 +594,7 @@ class Thread {
}

#if defined(GLOG_OS_WINDOWS) && !defined(GLOG_OS_CYGWIN)
static DWORD InvokeThreadW(void* self) {
static DWORD __stdcall InvokeThreadW(LPVOID self) {
InvokeThread(self);
return 0;
}
Expand Down
Loading

0 comments on commit 26490d6

Please sign in to comment.