simplify flags export
This commit is contained in:
parent
17269d649d
commit
aa94e6b9ab
80
.github/workflows/windows.yml
vendored
80
.github/workflows/windows.yml
vendored
@ -11,7 +11,7 @@ jobs:
|
||||
shell: powershell
|
||||
env:
|
||||
CL: /MP
|
||||
CXXFLAGS: /WX
|
||||
CXXFLAGS: /WX /permissive-
|
||||
strategy:
|
||||
fail-fast: true
|
||||
matrix:
|
||||
@ -20,7 +20,8 @@ jobs:
|
||||
extra: [no-custom-prefix, custom-prefix]
|
||||
lib: [shared, static]
|
||||
msvc: [VS-16-2019, VS-17-2022]
|
||||
std: [98, 11, 14, 17, 20]
|
||||
# Visual Studio 17 2022 does not support C++11 and older language standard
|
||||
std: [14, 17, 20]
|
||||
include:
|
||||
- msvc: VS-16-2019
|
||||
os: windows-2019
|
||||
@ -32,6 +33,67 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Cache GTest
|
||||
id: cache-gtest
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: gtest/
|
||||
key: ${{runner.os}}-gtest-1.11-${{matrix.lib}}-${{matrix.arch}}-${{matrix.build_type}}
|
||||
|
||||
- name: Download GTest
|
||||
if: steps.cache-gtest.outputs.cache-hit != 'true'
|
||||
run: |
|
||||
(New-Object System.Net.WebClient).DownloadFile("https://github.com/google/googletest/archive/refs/tags/release-1.11.0.zip", "release-1.11.0.zip")
|
||||
Expand-Archive release-1.11.0.zip .
|
||||
|
||||
- name: Build GTest
|
||||
if: steps.cache-gtest.outputs.cache-hit != 'true'
|
||||
run: |
|
||||
cmake -S googletest-release-1.11.0 -B build-googletest `
|
||||
-A ${{matrix.arch}} `
|
||||
-DBUILD_SHARED_LIBS=${{matrix.lib == 'shared'}} `
|
||||
-Dgtest_force_shared_crt=ON `
|
||||
-DCMAKE_INSTALL_PREFIX=${{github.workspace}}/gtest
|
||||
cmake --build build-googletest `
|
||||
--config ${{matrix.build_type}} `
|
||||
--target install
|
||||
|
||||
- name: Cache gflags
|
||||
id: cache-gflags
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: gflags/
|
||||
key: ${{runner.os}}-gflags-2.2.2-${{matrix.lib}}-${{matrix.arch}}-${{matrix.build_type}}
|
||||
|
||||
- name: Download gflags
|
||||
if: steps.cache-gflags.outputs.cache-hit != 'true'
|
||||
run: |
|
||||
(New-Object System.Net.WebClient).DownloadFile("https://github.com/gflags/gflags/archive/refs/tags/v2.2.2.zip", "v2.2.2.zip")
|
||||
Expand-Archive v2.2.2.zip .
|
||||
|
||||
- name: Build gflags
|
||||
if: steps.cache-gflags.outputs.cache-hit != 'true'
|
||||
run: |
|
||||
cmake -S gflags-2.2.2 -B build-gflags `
|
||||
-A ${{matrix.arch}} `
|
||||
-DBUILD_SHARED_LIBS=${{matrix.lib == 'shared'}} `
|
||||
-DCMAKE_INSTALL_PREFIX=${{github.workspace}}/gflags
|
||||
cmake --build build-gflags `
|
||||
--config ${{matrix.build_type}} `
|
||||
--target install
|
||||
|
||||
- name: Setup Environment
|
||||
run: |
|
||||
echo "GTest_ROOT=$((Get-Item .).FullName)/gtest" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
||||
echo "gflags_ROOT=$((Get-Item .).FullName)/gflags" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
||||
echo "${{github.workspace}}/gtest/bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
|
||||
echo "${{github.workspace}}/gflags/bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
|
||||
|
||||
- name: Setup Release Environment
|
||||
if: matrix.build_type != 'Debug'
|
||||
run: |
|
||||
echo "CXXFLAGS=/Zi ${{env.CXXFLAGS}}" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
||||
|
||||
- name: Configure
|
||||
run: |
|
||||
cmake -S . -B build_${{matrix.build_type}} `
|
||||
@ -40,7 +102,10 @@ jobs:
|
||||
-DCMAKE_CXX_EXTENSIONS=OFF `
|
||||
-DCMAKE_CXX_STANDARD=${{matrix.std}} `
|
||||
-DCMAKE_CXX_STANDARD_REQUIRED=ON `
|
||||
-DCMAKE_EXE_LINKER_FLAGS='/NOIMPLIB' `
|
||||
-DCMAKE_EXE_LINKER_FLAGS_RELEASE='/INCREMENTAL:NO /DEBUG' `
|
||||
-DCMAKE_INSTALL_PREFIX:PATH=./install `
|
||||
-DCMAKE_MSVC_RUNTIME_LIBRARY='MultiThreaded$<$<CONFIG:Debug>:Debug>DLL' `
|
||||
-DWITH_CUSTOM_PREFIX=${{matrix.extra == 'custom-prefix'}} `
|
||||
-G "${{matrix.generator}}" `
|
||||
-Werror
|
||||
@ -65,7 +130,7 @@ jobs:
|
||||
|
||||
build-mingw:
|
||||
name: ${{matrix.sys}}-${{matrix.env}}-C++${{matrix.std}}-${{matrix.build_type}}-${{matrix.lib}}-${{matrix.extra}}
|
||||
runs-on: windows-latest
|
||||
runs-on: windows-2022
|
||||
env:
|
||||
BUILDDIR: 'build_${{matrix.sys}}-${{matrix.env}}-C++${{matrix.std}}-${{matrix.build_type}}-${{matrix.lib}}-${{matrix.extra}}'
|
||||
defaults:
|
||||
@ -102,14 +167,15 @@ jobs:
|
||||
run: |
|
||||
echo 'CXXFLAGS=-Wno-error=variadic-macros -Wno-error=long-long ${{env.CXXFLAGS}}' >> $GITHUB_ENV
|
||||
|
||||
- name: Setup Environment
|
||||
if: matrix.build_type == 'Debug'
|
||||
run: |
|
||||
echo 'CXXFLAGS=--coverage ${{env.CXXFLAGS}}' >> $GITHUB_ENV
|
||||
|
||||
- name: Configure
|
||||
env:
|
||||
CXXFLAGS: -Wall -Wextra -Wpedantic -Wsign-conversion -Wtautological-compare -Wformat-nonliteral -Wundef -Werror ${{env.CXXFLAGS}}
|
||||
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}} \
|
||||
|
||||
@ -651,11 +651,6 @@ if (gflags_FOUND)
|
||||
endif (TARGET gflags::gflags)
|
||||
|
||||
set (glog_libraries_options_for_static_linking "${glog_libraries_options_for_static_linking} -lgflags")
|
||||
|
||||
target_compile_definitions (glog PRIVATE
|
||||
GFLAGS_DLL_DECLARE_FLAG=GOOGLE_GLOG_DLL_DECL
|
||||
GFLAGS_DLL_DEFINE_FLAG=GOOGLE_GLOG_DLL_DECL
|
||||
)
|
||||
endif (gflags_FOUND)
|
||||
|
||||
if (ANDROID)
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright (c) 1999, Google Inc.
|
||||
// Copyright (c) 2022, Google Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
@ -94,14 +94,6 @@
|
||||
#include <inttypes.h> // a third place for uint16_t or u_int16_t
|
||||
#endif
|
||||
|
||||
#ifdef GFLAGS_DLL_DECLARE_FLAG
|
||||
#define GLOG_GFLAGS_DLL_DECLARE_FLAG_WAS_DEFINED
|
||||
#pragma push_macro("GFLAGS_DLL_DECLARE_FLAG")
|
||||
#undef GFLAGS_DLL_DECLARE_FLAG
|
||||
#endif // defined(GFLAGS_DLL_DECLARE_FLAG)
|
||||
|
||||
#define GFLAGS_DLL_DECLARE_FLAG GOOGLE_GLOG_DLL_DECL
|
||||
|
||||
#if @ac_cv_have_libgflags@
|
||||
#include <gflags/gflags.h>
|
||||
#endif
|
||||
@ -386,8 +378,33 @@ typedef void(*CustomPrefixCallback)(std::ostream& s, const LogMessageInfo& l, vo
|
||||
// synchronized. Hence, use caution when comparing the low bits of
|
||||
// timestamps from different machines.
|
||||
|
||||
#pragma push_macro("DECLARE_VARIABLE")
|
||||
#pragma push_macro("DECLARE_bool")
|
||||
#pragma push_macro("DECLARE_string")
|
||||
#pragma push_macro("DECLARE_int32")
|
||||
#pragma push_macro("DECLARE_uint32")
|
||||
|
||||
#ifdef DECLARE_VARIABLE
|
||||
#undef DECLARE_VARIABLE
|
||||
#endif
|
||||
|
||||
#ifdef DECLARE_bool
|
||||
#undef DECLARE_bool
|
||||
#endif
|
||||
|
||||
#ifdef DECLARE_string
|
||||
#undef DECLARE_string
|
||||
#endif
|
||||
|
||||
#ifdef DECLARE_int32
|
||||
#undef DECLARE_int32
|
||||
#endif
|
||||
|
||||
#ifdef DECLARE_uint32
|
||||
#undef DECLARE_uint32
|
||||
#endif
|
||||
|
||||
#ifndef DECLARE_VARIABLE
|
||||
#define MUST_UNDEF_GFLAGS_DECLARE_MACROS
|
||||
#define DECLARE_VARIABLE(type, shorttype, name, tn) \
|
||||
namespace fL##shorttype { \
|
||||
extern GOOGLE_GLOG_DLL_DECL type FLAGS_##name; \
|
||||
@ -402,7 +419,7 @@ typedef void(*CustomPrefixCallback)(std::ostream& s, const LogMessageInfo& l, vo
|
||||
#define DECLARE_int32(name) \
|
||||
DECLARE_VARIABLE(@ac_google_namespace@::int32, I, name, int32)
|
||||
|
||||
#if !defined(DECLARE_uint32) && !(@ac_cv_have_libgflags@)
|
||||
#if !defined(DECLARE_uint32)
|
||||
// uint32 specialization
|
||||
#define DECLARE_uint32(name) \
|
||||
DECLARE_VARIABLE(@ac_google_namespace@::uint32, U, name, uint32)
|
||||
@ -474,15 +491,6 @@ DECLARE_bool(stop_logging_if_full_disk);
|
||||
// Use UTC time for logging
|
||||
DECLARE_bool(log_utc_time);
|
||||
|
||||
#ifdef MUST_UNDEF_GFLAGS_DECLARE_MACROS
|
||||
#undef MUST_UNDEF_GFLAGS_DECLARE_MACROS
|
||||
#undef DECLARE_VARIABLE
|
||||
#undef DECLARE_bool
|
||||
#undef DECLARE_int32
|
||||
#undef DECLARE_uint32
|
||||
#undef DECLARE_string
|
||||
#endif
|
||||
|
||||
// Log messages below the GOOGLE_STRIP_LOG level will be compiled away for
|
||||
// security reasons. See LOG(severtiy) below.
|
||||
|
||||
@ -1989,9 +1997,10 @@ GOOGLE_GLOG_DLL_DECL void InstallFailureWriter(
|
||||
|
||||
@ac_google_end_namespace@
|
||||
|
||||
#ifdef GLOG_GFLAGS_DLL_DECLARE_FLAG_WAS_DEFINED
|
||||
#undef GLOG_GFLAGS_DLL_DECLARE_FLAG_WAS_DEFINED
|
||||
#pragma pop_macro("GFLAGS_DLL_DECLARE_FLAG")
|
||||
#endif // defined(GLOG_GFLAGS_DLL_DECLARE_FLAG_WAS_DEFINED)
|
||||
#pragma pop_macro("DECLARE_VARIABLE")
|
||||
#pragma pop_macro("DECLARE_bool")
|
||||
#pragma pop_macro("DECLARE_string")
|
||||
#pragma pop_macro("DECLARE_int32")
|
||||
#pragma pop_macro("DECLARE_uint32")
|
||||
|
||||
#endif // GLOG_LOGGING_H
|
||||
|
||||
@ -207,9 +207,7 @@ void PrefixAttacher(std::ostream &s, const LogMessageInfo &l, void* data) {
|
||||
int main(int argc, char **argv) {
|
||||
FLAGS_colorlogtostderr = false;
|
||||
FLAGS_timestamp_in_logfile_name = true;
|
||||
#ifdef HAVE_LIB_GFLAGS
|
||||
ParseCommandLineFlags(&argc, &argv, true);
|
||||
#endif
|
||||
|
||||
// Make sure stderr is not buffered as stderr seems to be buffered
|
||||
// on recent windows.
|
||||
setbuf(stderr, NULL);
|
||||
@ -239,6 +237,10 @@ int main(int argc, char **argv) {
|
||||
InitGoogleMock(&argc, argv);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LIB_GFLAGS
|
||||
ParseCommandLineFlags(&argc, &argv, true);
|
||||
#endif
|
||||
|
||||
// so that death tests run before we use threads
|
||||
CHECK_EQ(RUN_ALL_TESTS(), 0);
|
||||
|
||||
|
||||
@ -185,9 +185,7 @@ BENCHMARK(BM_vlog)
|
||||
int main(int argc, char **argv) {
|
||||
FLAGS_colorlogtostderr = false;
|
||||
FLAGS_timestamp_in_logfile_name = true;
|
||||
#ifdef HAVE_LIB_GFLAGS
|
||||
ParseCommandLineFlags(&argc, &argv, true);
|
||||
#endif
|
||||
|
||||
// Make sure stderr is not buffered as stderr seems to be buffered
|
||||
// on recent windows.
|
||||
setbuf(stderr, NULL);
|
||||
@ -214,6 +212,10 @@ int main(int argc, char **argv) {
|
||||
InitGoogleMock(&argc, argv);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LIB_GFLAGS
|
||||
ParseCommandLineFlags(&argc, &argv, true);
|
||||
#endif
|
||||
|
||||
// so that death tests run before we use threads
|
||||
CHECK_EQ(RUN_ALL_TESTS(), 0);
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2007, Google Inc.
|
||||
// Copyright (c) 2022, Google Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
@ -40,13 +40,13 @@
|
||||
|
||||
namespace {
|
||||
|
||||
using GOOGLE_NAMESPACE::GLOG_ERROR;
|
||||
using GOOGLE_NAMESPACE::GLOG_INFO;
|
||||
using GOOGLE_NAMESPACE::GLOG_WARNING;
|
||||
using GOOGLE_NAMESPACE::GLOG_ERROR;
|
||||
using GOOGLE_NAMESPACE::glog_testing::ScopedMockLog;
|
||||
using std::string;
|
||||
using testing::_;
|
||||
using testing::HasSubstr;
|
||||
using testing::EndsWith;
|
||||
using testing::InSequence;
|
||||
using testing::InvokeWithoutArgs;
|
||||
|
||||
@ -55,7 +55,8 @@ TEST(ScopedMockLogTest, InterceptsLog) {
|
||||
ScopedMockLog log;
|
||||
|
||||
InSequence s;
|
||||
EXPECT_CALL(log, Log(GLOG_WARNING, HasSubstr("/mock-log_unittest.cc"), "Fishy."));
|
||||
EXPECT_CALL(log,
|
||||
Log(GLOG_WARNING, EndsWith("mock-log_unittest.cc"), "Fishy."));
|
||||
EXPECT_CALL(log, Log(GLOG_INFO, _, "Working..."))
|
||||
.Times(2);
|
||||
EXPECT_CALL(log, Log(GLOG_ERROR, _, "Bad!!"));
|
||||
@ -100,6 +101,7 @@ TEST(ScopedMockLogTest, LogDuringIntercept) {
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
GOOGLE_NAMESPACE::InitGoogleLogging(argv[0]);
|
||||
testing::InitGoogleTest(&argc, argv);
|
||||
testing::InitGoogleMock(&argc, argv);
|
||||
|
||||
return RUN_ALL_TESTS();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user