From cc92cca6b9a7fb96c798c0f092afc70466a6a8ce Mon Sep 17 00:00:00 2001 From: KongQun Yang Date: Fri, 14 Jul 2017 14:00:00 -0700 Subject: [PATCH] Enable C++11 in gtest Change-Id: I2860a34eee12bc2bdb584cc89c871da0ffb127ff --- packager/testing/gmock.gyp | 5 +++- .../gmock/internal/custom/gmock-port.h | 28 +++++++++++++++++++ packager/testing/gtest.gyp | 5 ++-- 3 files changed, 34 insertions(+), 4 deletions(-) create mode 100644 packager/testing/gmock_custom/gmock/internal/custom/gmock-port.h diff --git a/packager/testing/gmock.gyp b/packager/testing/gmock.gyp index 22a1893bd2..10ccf7949e 100644 --- a/packager/testing/gmock.gyp +++ b/packager/testing/gmock.gyp @@ -30,6 +30,7 @@ 'gmock/src/gmock-matchers.cc', 'gmock/src/gmock-spec-builders.cc', 'gmock/src/gmock.cc', + "gmock_custom/gmock/internal/custom/gmock-port.h", 'gmock_mutant.h', # gMock helpers ], 'sources!': [ @@ -37,11 +38,13 @@ ], 'include_dirs': [ 'gmock', + 'gmock_custom', 'gmock/include', ], 'direct_dependent_settings': { 'include_dirs': [ - 'gmock/include', # So that gmock headers can find themselves. + 'gmock_custom', + 'gmock/include', # Allow #include ], }, 'export_dependent_settings': [ diff --git a/packager/testing/gmock_custom/gmock/internal/custom/gmock-port.h b/packager/testing/gmock_custom/gmock/internal/custom/gmock-port.h new file mode 100644 index 0000000000..b329765117 --- /dev/null +++ b/packager/testing/gmock_custom/gmock/internal/custom/gmock-port.h @@ -0,0 +1,28 @@ +// Copyright 2017 Google Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file or at +// https://developers.google.com/open-source/licenses/bsd + +#ifndef PACKAGER_TESTING_GMOCK_CUSTOM_GMOCK_INTERNAL_CUSTOM_GMOCK_PORT_H_ +#define PACKAGER_TESTING_GMOCK_CUSTOM_GMOCK_INTERNAL_CUSTOM_GMOCK_PORT_H_ + +#include + +namespace std { + +// Provide alternative implementation of std::is_default_constructible for +// old, pre-4.7 of libstdc++, where is_default_constructible is missing. +// <20120322 below implies pre-4.7.0. In addition we blacklist several version +// that released after 4.7.0 from pre-4.7.0 branch. 20120702 implies 4.5.4, and +// 20121127 implies 4.6.4. +#if defined(__GLIBCXX__) && \ + (__GLIBCXX__ < 20120322 || __GLIBCXX__ == 20120702 || \ + __GLIBCXX__ == 20121127) +template +using is_default_constructible = std::is_constructible; +#endif + +} // namespace std + +#endif // PACKAGER_TESTING_GMOCK_CUSTOM_GMOCK_INTERNAL_CUSTOM_GMOCK_PORT_H_ diff --git a/packager/testing/gtest.gyp b/packager/testing/gtest.gyp index 671a508675..2e5510f897 100644 --- a/packager/testing/gtest.gyp +++ b/packager/testing/gtest.gyp @@ -25,13 +25,12 @@ # In order to allow regex matches in gtest to be shared between Windows # and other systems, we tell gtest to always use it's internal engine. 'GTEST_HAS_POSIX_RE=0', - # Chrome doesn't support / require C++11, yet. - 'GTEST_LANG_CXX11=0', + 'GTEST_LANG_CXX11=1', ], 'all_dependent_settings': { 'defines': [ 'GTEST_HAS_POSIX_RE=0', - 'GTEST_LANG_CXX11=0', + 'GTEST_LANG_CXX11=1', ], }, 'conditions': [