From fdeea72bb02a74ee596244d9fa1cb1604c8438f7 Mon Sep 17 00:00:00 2001 From: WhuAegeanSea Date: Tue, 7 Jun 2022 04:22:22 +0800 Subject: [PATCH] [glog] Avoid including Windows.h (#24538) * Fix building errors of glog * Bump the port version of glog * Update version database * Fix building errors * Update version database --- ports/glog/fix-windows-CXX11_ATOMIC.patch | 17 +++++++ ports/glog/nogdi-nominmax.patch | 59 ----------------------- ports/glog/portfile.cmake | 2 +- ports/glog/vcpkg.json | 2 +- versions/baseline.json | 2 +- versions/g-/glog.json | 5 ++ 6 files changed, 25 insertions(+), 62 deletions(-) create mode 100644 ports/glog/fix-windows-CXX11_ATOMIC.patch delete mode 100644 ports/glog/nogdi-nominmax.patch diff --git a/ports/glog/fix-windows-CXX11_ATOMIC.patch b/ports/glog/fix-windows-CXX11_ATOMIC.patch new file mode 100644 index 0000000000..1e1723e363 --- /dev/null +++ b/ports/glog/fix-windows-CXX11_ATOMIC.patch @@ -0,0 +1,17 @@ +diff --git a/src/glog/logging.h.in b/src/glog/logging.h.in +index 3ecacfb..2d48a0e 100644 +--- a/src/glog/logging.h.in ++++ b/src/glog/logging.h.in +@@ -100,6 +100,12 @@ + #include + #endif + ++#ifdef GLOG_OS_WINDOWS ++#ifndef HAVE_CXX11_ATOMIC ++#define HAVE_CXX11_ATOMIC ++#endif ++#endif ++ + #ifdef HAVE_CXX11_ATOMIC + #include + #elif defined(GLOG_OS_WINDOWS) diff --git a/ports/glog/nogdi-nominmax.patch b/ports/glog/nogdi-nominmax.patch deleted file mode 100644 index 83ee58cb50..0000000000 --- a/ports/glog/nogdi-nominmax.patch +++ /dev/null @@ -1,59 +0,0 @@ -diff --git a/src/glog/logging.h.in b/src/glog/logging.h.in -index 3ecacfb..42cc9b1 100644 ---- a/src/glog/logging.h.in -+++ b/src/glog/logging.h.in -@@ -103,6 +103,18 @@ - #ifdef HAVE_CXX11_ATOMIC - #include - #elif defined(GLOG_OS_WINDOWS) -+# ifndef WIN32_LEAN_AND_MEAN -+# define WIN32_LEAN_AND_MEAN // We only need minimal includes -+# endif -+// To avoid macro definition of ERROR. -+# ifndef NOGDI -+# define NOGDI -+# endif -+// To avoid macro definition of min/max. -+# ifndef NOMINMAX -+# define NOMINMAX -+# endif -+ - #include - #endif - -@@ -1061,7 +1073,7 @@ namespace google { - #elif defined(GLOG_OS_WINDOWS) - - #define SOME_KIND_OF_LOG_EVERY_N(severity, n, what_to_do) \ -- static int LOG_OCCURRENCES = 0, LOG_OCCURRENCES_MOD_N = 0; \ -+ static volatile unsigned LOG_OCCURRENCES = 0, LOG_OCCURRENCES_MOD_N = 0; \ - InterlockedIncrement(&LOG_OCCURRENCES); \ - if (InterlockedIncrement(&LOG_OCCURRENCES_MOD_N) > n) \ - InterlockedExchangeSubtract(&LOG_OCCURRENCES_MOD_N, n); \ -@@ -1071,7 +1083,7 @@ namespace google { - &what_to_do).stream() - - #define SOME_KIND_OF_LOG_IF_EVERY_N(severity, condition, n, what_to_do) \ -- static int LOG_OCCURRENCES = 0, LOG_OCCURRENCES_MOD_N = 0; \ -+ static volatile unsigned LOG_OCCURRENCES = 0, LOG_OCCURRENCES_MOD_N = 0; \ - InterlockedIncrement(&LOG_OCCURRENCES); \ - if (condition && \ - (InterlockedIncrement(&LOG_OCCURRENCES_MOD_N) || true) && \ -@@ -1082,7 +1094,7 @@ namespace google { - &what_to_do).stream() - - #define SOME_KIND_OF_PLOG_EVERY_N(severity, n, what_to_do) \ -- static int LOG_OCCURRENCES = 0, LOG_OCCURRENCES_MOD_N = 0; \ -+ static volatile unsigned LOG_OCCURRENCES = 0, LOG_OCCURRENCES_MOD_N = 0; \ - InterlockedIncrement(&LOG_OCCURRENCES); \ - if (InterlockedIncrement(&LOG_OCCURRENCES_MOD_N) > n) \ - InterlockedExchangeSubtract(&LOG_OCCURRENCES_MOD_N, n); \ -@@ -1092,7 +1104,7 @@ namespace google { - &what_to_do).stream() - - #define SOME_KIND_OF_LOG_FIRST_N(severity, n, what_to_do) \ -- static int LOG_OCCURRENCES = 0; \ -+ static volatile unsigned LOG_OCCURRENCES = 0; \ - if (LOG_OCCURRENCES <= n) \ - InterlockedIncrement(&LOG_OCCURRENCES); \ - if (LOG_OCCURRENCES <= n) \ diff --git a/ports/glog/portfile.cmake b/ports/glog/portfile.cmake index e1a90cf391..10e1d13c23 100644 --- a/ports/glog/portfile.cmake +++ b/ports/glog/portfile.cmake @@ -8,7 +8,7 @@ vcpkg_from_github( glog_disable_debug_postfix.patch fix_glog_CMAKE_MODULE_PATH.patch fix_log_every_n.patch - nogdi-nominmax.patch + fix-windows-CXX11_ATOMIC.patch fix_crosscompile_symbolize.patch ) diff --git a/ports/glog/vcpkg.json b/ports/glog/vcpkg.json index 1b62ea548c..5f6b947fed 100644 --- a/ports/glog/vcpkg.json +++ b/ports/glog/vcpkg.json @@ -1,7 +1,7 @@ { "name": "glog", "version": "0.5.0", - "port-version": 3, + "port-version": 4, "description": "C++ implementation of the Google logging module", "homepage": "https://github.com/google/glog", "license": "BSD-3-Clause", diff --git a/versions/baseline.json b/versions/baseline.json index 2808323310..d041194f4b 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -2570,7 +2570,7 @@ }, "glog": { "baseline": "0.5.0", - "port-version": 3 + "port-version": 4 }, "gloo": { "baseline": "20201203", diff --git a/versions/g-/glog.json b/versions/g-/glog.json index 62d76e7bab..94c50d82ac 100644 --- a/versions/g-/glog.json +++ b/versions/g-/glog.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "bb5f54eba990cc0f03c64e1d09f343dd6cd7b22b", + "version": "0.5.0", + "port-version": 4 + }, { "git-tree": "ecb04a5ba4d046af782f62ae7c167bd05b0101a8", "version": "0.5.0",