Bug 1343557 - Update build for gtest and gmock 1.7.0; r?ted.mielczarek
I've moved the mozilla specific gtest stuff to link directly in xul-gtest
rather than in the gtest static library to make it possible for standalone
programs to link against this library and not have to link
against other mozilla libraries. This allows us to build
media/webrtc/signaling/fuzztest against this version of gtest rather than the
webrtc version of gtest, which I plan to remove in a follow on bug.
I had to add a global disable for -Wgnu-zero-variadic-macro-arguments as we
hit that everywhere we use the INSTANTIATE_TEST_CASE_P macro.
This brings forward the fix from
Bug 844630 to the visibility of environ in
gtest-death-test.cc.
I also removed code that set GTEST_API_ to a visibility that conflicts with
what we've defined elsewhere in tree.
MozReview-Commit-ID: 3cfuapC6vn0
--- a/build/moz.configure/warnings.configure
+++ b/build/moz.configure/warnings.configure
@@ -101,11 +101,14 @@ check_and_add_gcc_warning('-Wno-error=fr
# catches format/argument mismatches with printf
check_and_add_gcc_warning('-Wformat')
# We use mix of both POSIX and Win32 printf format across the tree, so format
# warnings are useless on mingw.
check_and_add_gcc_warning('-Wno-format',
when=depends(target)(lambda t: t.kernel == 'WINNT'))
+# We hit this all over the place with the gtest INSTANTIATE_TEST_CASE_P macro
+check_and_add_gcc_warning('-Wno-gnu-zero-variadic-macro-arguments')
+
# Please keep these last in this file
add_old_configure_assignment('_WARNINGS_CFLAGS', warnings_cflags)
add_old_configure_assignment('_WARNINGS_CXXFLAGS', warnings_cxxflags)
--- a/media/webrtc/signaling/fuzztest/moz.build
+++ b/media/webrtc/signaling/fuzztest/moz.build
@@ -15,17 +15,17 @@ if CONFIG['OS_TARGET'] == 'Linux' or CON
LOCAL_INCLUDES += [
'../..',
'/media/mtransport',
'/media/webrtc/signaling/src/common/browser_logging',
]
USE_LIBS += [
- '/media/webrtc/trunk/testing/gtest_gtest/gtest',
+ '/testing/gtest/gtest',
'mozglue',
'nspr',
]
SOURCES = [
'/media/webrtc/signaling/src/sdp/SdpAttribute.cpp',
'/media/webrtc/signaling/src/sdp/SdpHelper.cpp',
'/media/webrtc/signaling/src/sdp/SdpMediaSection.cpp',
--- a/testing/gtest/gtest/include/gtest/internal/gtest-port.h
+++ b/testing/gtest/gtest/include/gtest/internal/gtest-port.h
@@ -925,25 +925,27 @@ using ::std::tuple_size;
#define GTEST_IS_THREADSAFE \
(GTEST_HAS_MUTEX_AND_THREAD_LOCAL_ \
|| (GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT) \
|| GTEST_HAS_PTHREAD)
#endif // GTEST_HAS_SEH
+/*
#ifdef _MSC_VER
# if GTEST_LINKED_AS_SHARED_LIBRARY
# define GTEST_API_ __declspec(dllimport)
# elif GTEST_CREATE_SHARED_LIBRARY
# define GTEST_API_ __declspec(dllexport)
# endif
#elif __GNUC__ >= 4 || defined(__clang__)
# define GTEST_API_ __attribute__((visibility ("default")))
#endif // _MSC_VER
+*/
#ifndef GTEST_API_
# define GTEST_API_
#endif
#ifdef __GNUC__
// Ask the compiler to never inline a given function.
# define GTEST_NO_INLINE_ __attribute__((noinline))
--- a/testing/gtest/gtest/src/gtest-death-test.cc
+++ b/testing/gtest/gtest/src/gtest-death-test.cc
@@ -944,17 +944,17 @@ inline char** GetEnviron() {
// When Google Test is built as a framework on MacOS X, the environ variable
// is unavailable. Apple's documentation (man environ) recommends using
// _NSGetEnviron() instead.
return *_NSGetEnviron();
}
# else
// Some POSIX platforms expect you to declare environ. extern "C" makes
// it reside in the global namespace.
-extern "C" char** environ;
+extern "C" __attribute__ ((visibility ("default"))) char** environ;
inline char** GetEnviron() { return environ; }
# endif // GTEST_OS_MAC
# if !GTEST_OS_QNX
// The main function for a threadsafe-style death test child process.
// This function is called in a clone()-ed process and thus must avoid
// any potentially unsafe operations like malloc or libc functions.
static int ExecDeathTestChildMain(void* child_arg) {
--- a/testing/gtest/moz.build
+++ b/testing/gtest/moz.build
@@ -26,60 +26,69 @@ if CONFIG['ENABLE_TESTS']:
# GTest internal are exposed in gtest.h. See comment in gtest.h
EXPORTS.gtest.internal += [
'gtest/include/gtest/internal/gtest-death-test-internal.h',
'gtest/include/gtest/internal/gtest-filepath.h',
'gtest/include/gtest/internal/gtest-internal.h',
'gtest/include/gtest/internal/gtest-linked_ptr.h',
'gtest/include/gtest/internal/gtest-param-util-generated.h',
'gtest/include/gtest/internal/gtest-param-util.h',
+ 'gtest/include/gtest/internal/gtest-port-arch.h',
'gtest/include/gtest/internal/gtest-port.h',
'gtest/include/gtest/internal/gtest-string.h',
'gtest/include/gtest/internal/gtest-tuple.h',
'gtest/include/gtest/internal/gtest-type-util.h',
]
+ EXPORTS.gtest.internal.custom += [
+ 'gtest/include/gtest/internal/custom/gtest-port.h',
+ 'gtest/include/gtest/internal/custom/gtest-printers.h',
+ ]
+
EXPORTS.gmock += [
'gmock/include/gmock/gmock-actions.h',
'gmock/include/gmock/gmock-cardinalities.h',
'gmock/include/gmock/gmock-generated-actions.h',
'gmock/include/gmock/gmock-generated-function-mockers.h',
'gmock/include/gmock/gmock-generated-matchers.h',
'gmock/include/gmock/gmock-generated-nice-strict.h',
'gmock/include/gmock/gmock-matchers.h',
'gmock/include/gmock/gmock-more-actions.h',
+ 'gmock/include/gmock/gmock-more-matchers.h',
'gmock/include/gmock/gmock-spec-builders.h',
'gmock/include/gmock/gmock.h',
]
# gmock also includes internal interfaces in it's public header
EXPORTS.gmock.internal += [
'gmock/include/gmock/internal/gmock-generated-internal-utils.h',
'gmock/include/gmock/internal/gmock-internal-utils.h',
'gmock/include/gmock/internal/gmock-port.h',
]
+ EXPORTS.gmock.internal.custom += [
+ 'gmock/include/gmock/internal/custom/gmock-generated-actions.h',
+ 'gmock/include/gmock/internal/custom/gmock-matchers.h',
+ 'gmock/include/gmock/internal/custom/gmock-port.h',
+ ]
+
SOURCES += [
'gmock/src/gmock-all.cc',
'gtest/src/gtest-all.cc',
- 'mozilla/GTestRunner.cpp',
- 'mozilla/MozGTestBench.cpp',
]
Library('gtest')
- SOURCES += [
- 'mozilla/SanityTest.cpp',
- ]
-
LOCAL_INCLUDES += [
'gmock',
'gmock/include',
'gtest',
'gtest/include',
]
if CONFIG['OS_ARCH'] == 'WINNT':
LOCAL_INCLUDES += [
'/security/sandbox/chromium',
- ]
-
+ ]
+
+ DIRS += ['mozilla']
+
FINAL_LIBRARY = 'xul-gtest'
new file mode 100644
--- /dev/null
+++ b/testing/gtest/mozilla/moz.build
@@ -0,0 +1,18 @@
+# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+if CONFIG['ENABLE_TESTS']:
+ SOURCES += [
+ 'GTestRunner.cpp',
+ 'MozGTestBench.cpp',
+ 'SanityTest.cpp',
+ ]
+
+ if CONFIG['OS_ARCH'] == 'WINNT':
+ LOCAL_INCLUDES += [
+ '/security/sandbox/chromium',
+ ]
+
+ FINAL_LIBRARY = 'xul-gtest'