Bug 964133 - Build gflags; r=ted.mielczarik
This adds gflags to the list of ignored directories for clang static
analysis and adds "explicit" where required in mutex.h.
We also stop building a duplicate copy of snprintf for windows as our builds
already include a definition for it.
MozReview-Commit-ID: 4uMhTMvAKL0
--- a/build/clang-plugin/Utils.h
+++ b/build/clang-plugin/Utils.h
@@ -232,16 +232,17 @@ inline bool isIgnoredPathForSprintfLiter
llvm::sys::fs::make_absolute(FileName);
llvm::sys::path::reverse_iterator Begin = llvm::sys::path::rbegin(FileName),
End = llvm::sys::path::rend(FileName);
for (; Begin != End; ++Begin) {
if (Begin->compare_lower(StringRef("angle")) == 0 ||
Begin->compare_lower(StringRef("chromium")) == 0 ||
Begin->compare_lower(StringRef("crashreporter")) == 0 ||
Begin->compare_lower(StringRef("google-breakpad")) == 0 ||
+ Begin->compare_lower(StringRef("gflags")) == 0 ||
Begin->compare_lower(StringRef("harfbuzz")) == 0 ||
Begin->compare_lower(StringRef("libstagefright")) == 0 ||
Begin->compare_lower(StringRef("mtransport")) == 0 ||
Begin->compare_lower(StringRef("protobuf")) == 0 ||
Begin->compare_lower(StringRef("skia")) == 0 ||
Begin->compare_lower(StringRef("sfntly")) == 0 ||
// Gtest uses snprintf as GTEST_SNPRINTF_ with sizeof
Begin->compare_lower(StringRef("testing")) == 0) {
--- a/media/webrtc/moz.build
+++ b/media/webrtc/moz.build
@@ -96,16 +96,21 @@ if CONFIG['MOZ_WEBRTC_SIGNALING']:
'signaling/src/sdp/sipcc/sdp_main.c',
'signaling/src/sdp/sipcc/sdp_services_unix.c',
'signaling/src/sdp/sipcc/sdp_token.c',
'signaling/src/sdp/sipcc/sdp_utils.c',
]
GYP_DIRS['signaling'].non_unified_sources += signaling_non_unified_sources
+ GYP_DIRS += ['trunk/third_party/gflags']
+ GYP_DIRS['trunk/third_party/gflags'].input = 'trunk/third_party/gflags/gflags.gyp'
+ GYP_DIRS['trunk/third_party/gflags'].variables = gyp_vars
+ GYP_DIRS['trunk/third_party/gflags'].sandbox_vars['ALLOW_COMPILER_WARNINGS'] = True
+
if CONFIG['_MSC_VER']:
# Avoid warnings from third-party code that we can not modify.
if CONFIG['CLANG_CL']:
CXXFLAGS += ['-Wno-invalid-source-encoding']
else:
CXXFLAGS += ['-validate-charset-']
if CONFIG['ENABLE_TESTS']:
--- a/media/webrtc/trunk/third_party/gflags/src/mutex.h
+++ b/media/webrtc/trunk/third_party/gflags/src/mutex.h
@@ -166,17 +166,17 @@ class Mutex {
// Create a Mutex that is not held by anybody. This constructor is
// typically used for Mutexes allocated on the heap or the stack.
inline Mutex();
// This constructor should be used for global, static Mutex objects.
// It inhibits work being done by the destructor, which makes it
// safer for code that tries to acqiure this mutex in their global
// destructor.
- inline Mutex(LinkerInitialized);
+ explicit inline Mutex(LinkerInitialized);
// Destructor
inline ~Mutex();
inline void Lock(); // Block if needed until free then acquire exclusively
inline void Unlock(); // Release a lock acquired via Lock()
#ifdef GMUTEX_TRYLOCK
inline bool TryLock(); // If free, Lock() and return true, else return false
@@ -197,17 +197,17 @@ class Mutex {
// always true. volatile is the most reliable way to do that.
volatile bool is_safe_;
// This indicates which constructor was called.
bool destroy_;
inline void SetIsSafe() { is_safe_ = true; }
// Catch the error of writing Mutex when intending MutexLock.
- Mutex(Mutex* /*ignored*/) {}
+ explicit Mutex(Mutex* /*ignored*/) {}
// Disallow "evil" constructors
Mutex(const Mutex&);
void operator=(const Mutex&);
};
// Now the implementation of Mutex for various systems
#if defined(NO_THREADS)
--- a/media/webrtc/trunk/third_party/gflags/src/windows/port.cc
+++ b/media/webrtc/trunk/third_party/gflags/src/windows/port.cc
@@ -45,18 +45,19 @@
// These call the windows _vsnprintf, but always NUL-terminate.
#if !defined(__MINGW32__) && !defined(__MINGW64__) /* mingw already defines */
int safe_vsnprintf(char *str, size_t size, const char *format, va_list ap) {
if (size == 0) // not even room for a \0?
return -1; // not what C99 says to do, but what windows does
str[size-1] = '\0';
return _vsnprintf(str, size-1, format, ap);
}
-
+#if !(defined(_MSC_VER) && _MSC_VER >= 1900)
int snprintf(char *str, size_t size, const char *format, ...) {
int r;
va_list ap;
va_start(ap, format);
r = vsnprintf(str, size, format, ap);
va_end(ap);
return r;
}
+#endif
#endif /* #if !defined(__MINGW32__) && !defined(__MINGW64__) */