Commit 492ac156 authored by Andreas Schuh's avatar Andreas Schuh

Fix DLL build on Windows and use PathMatchSpec instead of fnmatch.

Expose as few system variables as possible through public interface.
Perform STRIP_FLAGS_HELP test using CMake instead of Bash.
Change file path separator used by gflags_reporting.cc to backslash on Windwos.
parent cf92ec3b
cmake_minimum_required(VERSION 2.8.4 FATAL_ERROR)
if (WIN32 AND NOT CYGWIN)
set (WINDOWS 1)
else ()
set (WINDOWS 0)
endif ()
# ----------------------------------------------------------------------------
# includes
set (CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
......@@ -27,7 +33,12 @@ version_numbers (
# ----------------------------------------------------------------------------
# configure options
option (BUILD_SHARED_LIBS "Request build of shared libraries." OFF)
set (GFLAGS_SHARED_LIBS ${BUILD_SHARED_LIBS})
if (WINDOWS AND BUILD_SHARED_LIBS)
set (GFLAGS_IS_A_DLL 1)
else ()
set (GFLAGS_IS_A_DLL 0)
endif ()
option (BUILD_gflags_LIB "Request build of the multi-threaded gflags library." ON)
option (BUILD_gflags_nothreads_LIB "Request build of the single-threaded gflags library." ON)
......@@ -91,18 +102,44 @@ if (NOT GFLAGS_INTTYPES_FORMAT)
" Set GFLAGS_INTTYPES_FORMAT to either C99, BSD, or VC7 and try again.")
endif ()
endif ()
set ("GFLAGS_INTTYPES_FORMAT_${GFLAGS_INTTYPES_FORMAT}" TRUE)
# use of special characters in strings to circumvent bug #0008226
if ("^${GFLAGS_INTTYPES_FORMAT}$" STREQUAL "^WIN$")
set_property (CACHE GFLAGS_INTTYPES_FORMAT PROPERTY VALUE VC7)
endif ()
if (NOT GFLAGS_INTTYPES_FORMAT MATCHES "^(C99|BSD|VC7)$")
message (FATAL_ERROR "Invalid value for GFLAGS_INTTYPES_FORMAT! Choose one of \"C99\", \"BSD\", or \"VC7\"")
endif ()
set (GFLAGS_INTTYPES_FORMAT_C99 0)
set (GFLAGS_INTTYPES_FORMAT_BSD 0)
set (GFLAGS_INTTYPES_FORMAT_VC7 0)
set ("GFLAGS_INTTYPES_FORMAT_${GFLAGS_INTTYPES_FORMAT}" 1)
foreach (fname IN ITEMS stdint sys/types fnmatch inttypes unistd sys/stat)
string (TOUPPER "${fname}" FNAME)
string (REGEX REPLACE "/" "_" FNAME "${FNAME}")
check_include_file_cxx ("${fname}.h" GFLAGS_HAVE_${FNAME}_H)
if (HAVE_${FNAME}_H)
# set by check_type_size already
set (GFLAGS_HAVE_${FNAME}_H ${HAVE_${FNAME}_H})
else ()
check_include_file_cxx ("${fname}.h" GFLAGS_HAVE_${FNAME}_H)
endif ()
endforeach ()
if (NOT GFLAGS_HAVE_FNMATCH_H AND WINDOWS)
check_include_file_cxx ("shlwapi.h" GFLAGS_HAVE_SHLWAPI_H)
endif ()
bool_to_int(GFLAGS_HAVE_STDINT_H)
bool_to_int(GFLAGS_HAVE_SYS_TYPES_H)
bool_to_int(GFLAGS_HAVE_INTTYPES_H)
foreach (fname IN ITEMS strtoll strtoq)
string (TOUPPER "${fname}" FNAME)
check_cxx_symbol_exists ("${fname}" stdlib.h GFLAGS_HAVE_${FNAME})
endforeach ()
if (MSVC)
set (GFLAGS_HAVE_strtoll FALSE)
set (GFLAGS_HAVE_strtoq FALSE)
else ()
foreach (fname IN ITEMS strtoll strtoq)
string (TOUPPER "${fname}" FNAME)
check_cxx_symbol_exists ("${fname}" stdlib.h GFLAGS_HAVE_${FNAME})
endforeach ()
endif ()
set (CMAKE_THREAD_PREFER_PTHREAD TRUE)
find_package (ThreadsCXX)
......@@ -137,7 +174,7 @@ set (GFLAGS_SRCS
"gflags_completions.cc"
)
if (WIN32)
if (WINDOWS)
list (APPEND PRIVATE_HDRS "windows_port.h")
list (APPEND GFLAGS_SRCS "windows_port.cc")
endif ()
......@@ -169,18 +206,11 @@ include_directories ("${PROJECT_BINARY_DIR}/include/${GFLAGS_NAMESPACE}")
set (LIB_TARGETS)
if (BUILD_gflags_LIB)
add_library (gflags ${GFLAGS_SRCS} ${PRIVATE_HDRS} ${PUBLIC_HDRS})
if (WIN32 AND BUILD_SHARED_LIBS)
set_target_properties (gflags PROPERTIES COMPILE_DEFINITIONS GFLAGS_DLL_EXPORT)
endif ()
list (APPEND LIB_TARGETS gflags)
endif ()
if (BUILD_gflags_nothreads_LIB)
add_library (gflags_nothreads ${GFLAGS_SRCS} ${PRIVATE_HDRS} ${PUBLIC_HDRS})
if (WIN32 AND BUILD_SHARED_LIBS)
set_target_properties (gflags_nothreads PROPERTIES COMPILE_DEFINITIONS "GFLAGS_DLL_EXPORT;NO_THREADS")
else ()
set_target_properties (gflags_nothreads PROPERTIES COMPILE_DEFINITIONS NO_THREADS)
endif ()
set_target_properties (gflags_nothreads PROPERTIES COMPILE_DEFINITIONS NO_THREADS)
list (APPEND LIB_TARGETS gflags_nothreads)
endif ()
......
## Utility CMake functions.
# ----------------------------------------------------------------------------
## Convert boolean value to 0 or 1
macro (bool_to_int VAR)
if (${VAR})
set (${VAR} 1)
else ()
set (${VAR} 0)
endif ()
endmacro ()
# ----------------------------------------------------------------------------
## Extract version numbers from version string.
function (version_numbers version major minor patch)
......
......@@ -2,10 +2,86 @@
// Note: This header file is only used internally. It is not part of public interface!
#include "gflags_declare.h" // system checks
// Whether gflags library is shared. Used for DLL import declaration.
#define GFLAGS_IS_A_DLL @GFLAGS_IS_A_DLL@
// ---------------------------------------------------------------------------
// Additional meta-information
// System checks
// Define if you have the <stdint.h> header file.
#cmakedefine GFLAGS_HAVE_STDINT_H
// Define if you have the <sys/types.h> header file.
#cmakedefine GFLAGS_HAVE_SYS_TYPES_H
// Define if you have the <inttypes.h> header file.
#cmakedefine GFLAGS_HAVE_INTTYPES_H
// Define if you have the <sys/stat.h> header file.
#cmakedefine GFLAGS_HAVE_SYS_STAT_H
// Define if you have the <unistd.h> header file.
#cmakedefine GFLAGS_HAVE_UNISTD_H
// Define if you have the <fnmatch.h> header file.
#cmakedefine GFLAGS_HAVE_FNMATCH_H
// Define if you have the <shlwapi.h> header file (Windows 2000/XP).
#cmakedefine GFLAGS_HAVE_SHLWAPI_H
// Define if you have the strtoll function.
#cmakedefine GFLAGS_HAVE_STRTOLL
// Define if you have the strtoq function.
#cmakedefine GFLAGS_HAVE_STRTOQ
// Define if you have the <pthread.h> header file.
#cmakedefine GFLAGS_HAVE_PTHREAD
// Define if your pthread library defines the type pthread_rwlock_t
#cmakedefine GFLAGS_HAVE_RWLOCK
// Backwards compatibility in case users defined these macros themselves
// or allow users to use these more general macros if the gflags library
// is build as part of a user project, e.g., included as Git submodule
#if defined(HAVE_STDINT_H) && !defined(GFLAGS_HAVE_STDINT_H)
# define GFLAGS_HAVE_STDINT_H
#endif
#if defined(HAVE_SYS_TYPES_H) && !defined(GFLAGS_HAVE_SYS_TYPES_H)
# define GFLAGS_HAVE_SYS_TYPES_H
#endif
#if defined(HAVE_INTTYPES_H) && !defined(GFLAGS_HAVE_INTTYPES_H)
# define GFLAGS_HAVE_INTTYPES_H
#endif
#if defined(HAVE_SYS_STAT_H) && !defined(GFLAGS_HAVE_SYS_STAT_H)
# define GFLAGS_HAVE_SYS_STAT_H
#endif
#if defined(HAVE_UNISTD_H) && !defined(GFLAGS_HAVE_UNISTD_H)
# define GFLAGS_HAVE_UNISTD_H
#endif
#if defined(HAVE_FNMATCH_H) && !defined(GFLAGS_HAVE_FNMATCH_H)
# define GFLAGS_HAVE_FNMATCH_H
#endif
#if defined(HAVE_STRTOLL) && !defined(GFLAGS_HAVE_STRTOLL)
# define GFLAGS_HAVE_STRTOLL
#endif
#if defined(HAVE_STRTOLQ) && !defined(GFLAGS_HAVE_STRTOLQ)
# define GFLAGS_HAVE_STRTOLQ
#endif
#if defined(HAVE_PTHREAD) && !defined(GFLAGS_HAVE_PTHREAD)
# define GFLAGS_HAVE_PTHREAD
#endif
#if defined(HAVE_RWLOCK) && !defined(GFLAGS_HAVE_RWLOCK)
# define GFLAGS_HAVE_RWLOCK
#endif
// gcc requires this to get PRId64, etc.
#if defined(GFLAGS_HAVE_INTTYPES_H) && !defined(__STDC_FORMAT_MACROS)
# define __STDC_FORMAT_MACROS 1
#endif
// ---------------------------------------------------------------------------
// Package information
// Name of package.
#define PACKAGE @PROJECT_NAME@
......@@ -30,10 +106,42 @@
// ---------------------------------------------------------------------------
// Path separator
#define PATH_SEPARATOR '/'
#ifndef PATH_SEPARATOR
# if _WIN32
# define PATH_SEPARATOR '\\'
# else
# define PATH_SEPARATOR '/'
# endif
#endif
// ---------------------------------------------------------------------------
// Windows port
// Windows
// Always export symbols when compiling a shared library as this file is only
// included by internal modules when building the gflags library itself.
// The gflags_declare.h header file will set it to import these symbols otherwise.
#ifndef GFLAGS_DLL_DECL
# if GFLAGS_IS_A_DLL && defined(_MSC_VER)
# define GFLAGS_DLL_DECL __declspec(dllexport)
# else
# define GFLAGS_DLL_DECL
# endif
#endif
// Flags defined by the gflags library itself must be exported
#ifndef GFLAGS_DLL_DEFINE_FLAG
# define GFLAGS_DLL_DEFINE_FLAG GFLAGS_DLL_DECL
#endif
#ifdef _WIN32
// The unittests import the symbols of the shared gflags library
# if GFLAGS_IS_A_DLL && defined(_MSC_VER)
# define GFLAGS_DLL_DECL_FOR_UNITTESTS __declspec(dllimport)
# endif
# include "windows_port.h"
#endif
// Export of STL class instantiations -- no extern keyword to not trigger a warning
// \sa http://support.microsoft.com/default.aspx?scid=KB;EN-US;168958
#if GFLAGS_IS_A_DLL && defined(_MSC_VER) && _MSC_VER >= 1100
# define GFLAGS_EXTERN_STL
#endif
\ No newline at end of file
......@@ -93,8 +93,11 @@
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#ifdef GFLAGS_HAVE_FNMATCH_H
#if defined(GFLAGS_HAVE_FNMATCH_H)
# include <fnmatch.h>
#elif defined(GFLAGS_HAVE_SHLWAPI_H)
# include <shlwapi.h>
# pragma comment(lib, "shlwapi.lib")
#endif
#include <stdarg.h> // For va_list and related operations
#include <stdio.h>
......@@ -109,12 +112,6 @@
#include "mutex.h"
#include "util.h"
// Export the following flags only if the gflags library is a DLL
#ifndef GFLAGS_SHARED_LIBS
# undef GFLAGS_DLL_DEFINE_FLAG
# define GFLAGS_DLL_DEFINE_FLAG
#endif
// Special flags, type 1: the 'recursive' flags. They set another flag's val.
DEFINE_string(flagfile, "", "load flags from file");
DEFINE_string(fromenv, "", "set flags from the environment"
......@@ -1310,13 +1307,12 @@ string CommandLineFlagParser::ProcessOptionsFromStringLocked(
// We try matching both against the full argv0 and basename(argv0)
if (glob == ProgramInvocationName() // small optimization
|| glob == ProgramInvocationShortName()
#ifdef GFLAGS_HAVE_FNMATCH_H
|| fnmatch(glob.c_str(),
ProgramInvocationName(),
FNM_PATHNAME) == 0
|| fnmatch(glob.c_str(),
ProgramInvocationShortName(),
FNM_PATHNAME) == 0
#if defined(GFLAGS_HAVE_FNMATCH_H)
|| fnmatch(glob.c_str(), ProgramInvocationName(), FNM_PATHNAME) == 0
|| fnmatch(glob.c_str(), ProgramInvocationShortName(), FNM_PATHNAME) == 0
#elif defined(GFLAGS_HAVE_SHLWAPI_H)
|| PathMatchSpec(glob.c_str(), ProgramInvocationName())
|| PathMatchSpec(glob.c_str(), ProgramInvocationShortName())
#endif
) {
flags_are_relevant = true;
......
This diff is collapsed.
......@@ -47,9 +47,6 @@
#define GFLAGS_VERSION_MINOR @PACKAGE_VERSION_MINOR@ ///< Minor version number.
#define GFLAGS_VERSION_PATCH @PACKAGE_VERSION_PATCH@ ///< Version patch number.
// Whether gflags library is shared. Used for DLL import declaration.
#cmakedefine GFLAGS_SHARED_LIBS
// ---------------------------------------------------------------------------
// Namespace for gflags symbols.
#define GFLAGS_NAMESPACE @GFLAGS_NAMESPACE@
......@@ -60,148 +57,49 @@
// ---------------------------------------------------------------------------
// Windows DLL import/export.
// We always want to import the symbols of the gflags library
#ifndef GFLAGS_DLL_DECL
# if defined(_MSC_VER) && defined(GFLAGS_SHARED_LIBS)
# ifdef GFLAGS_DLL_EXPORT
# define GFLAGS_DLL_DECL __declspec(dllexport)
# else
# define GFLAGS_DLL_DECL __declspec(dllimport)
# endif
# if @GFLAGS_IS_A_DLL@ && defined(_MSC_VER)
# define GFLAGS_DLL_DECL __declspec(dllimport)
# else
# define GFLAGS_DLL_DECL
# endif
#endif
// By default, we always want to export defined variables, assuming
// that the DEFINE_FLAG macros are used within shared modules.
#ifndef GFLAGS_DLL_DEFINE_FLAG
# if defined(_MSC_VER)
# define GFLAGS_DLL_DEFINE_FLAG __declspec(dllexport)
# else
# define GFLAGS_DLL_DEFINE_FLAG
# endif
#endif
// By default, we always want to export defined variables, assuming
// that the DECLARE_FLAG macros are used within shared modules.
// We always want to import variables declared in user code
#ifndef GFLAGS_DLL_DECLARE_FLAG
# if defined(_MSC_VER)
# ifdef _MSC_VER
# define GFLAGS_DLL_DECLARE_FLAG __declspec(dllimport)
# else
# define GFLAGS_DLL_DECLARE_FLAG
# endif
#endif
// Export/import of STL class instantiations
// \sa http://support.microsoft.com/default.aspx?scid=KB;EN-US;168958
#if defined(GFLAGS_SHARED_LIBS) && defined(_MSC_VER) && _MSC_VER >= 1100
# ifdef GFLAGS_DLL_EXPORT
# define GFLAGS_EXTERN_STL
# else
# define GFLAGS_EXTERN_STL extern
# endif
#endif
// ---------------------------------------------------------------------------
// Available system headers
// Define if you have the <stdint.h> header file.
#cmakedefine GFLAGS_HAVE_STDINT_H
// Define if you have the <sys/types.h> header file.
#cmakedefine GFLAGS_HAVE_SYS_TYPES_H
// Define if you have the <inttypes.h> header file.
#cmakedefine GFLAGS_HAVE_INTTYPES_H
// Define if you have the <sys/stat.h> header file.
#cmakedefine GFLAGS_HAVE_SYS_STAT_H
// Define if you have the <unistd.h> header file.
#cmakedefine GFLAGS_HAVE_UNISTD_H
// Define if you have the <fnmatch.h> header file.
#cmakedefine GFLAGS_HAVE_FNMATCH_H
// Define if you have the strtoll function.
#cmakedefine GFLAGS_HAVE_STRTOLL
// Define if you have the strtoq function.
#cmakedefine GFLAGS_HAVE_STRTOQ
// Define if you have the <pthread.h> header file.
#cmakedefine GFLAGS_HAVE_PTHREAD
// Define if your pthread library defines the type pthread_rwlock_t
#cmakedefine GFLAGS_HAVE_RWLOCK
// Backwards compatibility in case users defined these macros themselves
// or allow users to use these more general macros if the gflags library
// is build as part of a user project, e.g., included as Git submodule
#if defined(HAVE_STDINT_H) && !defined(GFLAGS_HAVE_STDINT_H)
# define GFLAGS_HAVE_STDINT_H
#endif
#if defined(HAVE_SYS_TYPES_H) && !defined(GFLAGS_HAVE_SYS_TYPES_H)
# define GFLAGS_HAVE_SYS_TYPES_H
#endif
#if defined(HAVE_INTTYPES_H) && !defined(GFLAGS_HAVE_INTTYPES_H)
# define GFLAGS_HAVE_INTTYPES_H
#endif
#if defined(HAVE_SYS_STAT_H) && !defined(GFLAGS_HAVE_SYS_STAT_H)
# define GFLAGS_HAVE_SYS_STAT_H
#endif
#if defined(HAVE_UNISTD_H) && !defined(GFLAGS_HAVE_UNISTD_H)
# define GFLAGS_HAVE_UNISTD_H
#endif
#if defined(HAVE_FNMATCH_H) && !defined(GFLAGS_HAVE_FNMATCH_H)
# define GFLAGS_HAVE_FNMATCH_H
#endif
#if defined(HAVE_STRTOLL) && !defined(GFLAGS_HAVE_STRTOLL)
# define GFLAGS_HAVE_STRTOLL
#endif
#if defined(HAVE_STRTOLQ) && !defined(GFLAGS_HAVE_STRTOLQ)
# define GFLAGS_HAVE_STRTOLQ
#endif
#if defined(HAVE_PTHREAD) && !defined(GFLAGS_HAVE_PTHREAD)
# define GFLAGS_HAVE_PTHREAD
#endif
#if defined(HAVE_RWLOCK) && !defined(GFLAGS_HAVE_RWLOCK)
# define GFLAGS_HAVE_RWLOCK
#endif
// gcc requires this to get PRId64, etc.
#if defined(GFLAGS_HAVE_INTTYPES_H) && !defined(__STDC_FORMAT_MACROS)
# define __STDC_FORMAT_MACROS 1
#endif
// ---------------------------------------------------------------------------
// Flag types
#include <string>
#if defined(GFLAGS_HAVE_STDINT_H)
#if @GFLAGS_HAVE_STDINT_H@
# include <stdint.h> // the normal place uint32_t is defined
#elif defined(GFLAGS_HAVE_SYS_TYPES_H)
#elif @GFLAGS_HAVE_SYS_TYPES_H@
# include <sys/types.h> // the normal place u_int32_t is defined
#elif defined(GFLAGS_HAVE_INTTYPES_H)
#elif @GFLAGS_HAVE_INTTYPES_H@
# include <inttypes.h> // a third place for uint32_t or u_int32_t
#endif
#cmakedefine GFLAGS_INTTYPES_FORMAT_C99
#cmakedefine GFLAGS_INTTYPES_FORMAT_BSD
#cmakedefine GFLAGS_INTTYPES_FORMAT_VC7
namespace GFLAGS_NAMESPACE {
#if defined(GFLAGS_INTTYPES_FORMAT_C99)
#if @GFLAGS_INTTYPES_FORMAT_C99@ // C99
typedef int32_t int32;
typedef uint32_t uint32;
typedef int64_t int64;
typedef uint64_t uint64;
#elif defined(GFLAGS_INTTYPES_FORMAT_BSD)
#elif @GFLAGS_INTTYPES_FORMAT_BSD@ // BSD
typedef int32_t int32;
typedef u_int32_t uint32;
typedef int64_t int64;
typedef u_int64_t uint64;
#elif defined(GFLAGS_INTTYPES_FORMAT_VC7) // Windows
#elif @GFLAGS_INTTYPES_FORMAT_VC7@ // Windows
typedef __int32 int32;
typedef unsigned __int32 uint32;
typedef __int64 int64;
......
......@@ -246,7 +246,7 @@ static bool FileMatchesSubstring(const string& filename,
// the string to be at the beginning of a directory component.
// That should match the first directory component as well, so
// we allow '/foo' to match a filename of 'foo'.
if (!target->empty() && (*target)[0] == '/' &&
if (!target->empty() && (*target)[0] == PATH_SEPARATOR &&
strncmp(filename.c_str(), target->c_str() + 1,
strlen(target->c_str() + 1)) == 0)
return true;
......@@ -352,7 +352,8 @@ static void ShowVersion() {
static void AppendPrognameStrings(vector<string>* substrings,
const char* progname) {
string r("/");
string r("");
r += PATH_SEPARATOR;
r += progname;
substrings->push_back(r + ".");
substrings->push_back(r + "-main.");
......@@ -387,7 +388,7 @@ void HandleCommandLineHelpFlags() {
gflags_exitfunc(1);
} else if (!FLAGS_helpon.empty()) {
string restrict = "/" + FLAGS_helpon + ".";
string restrict = PATH_SEPARATOR + FLAGS_helpon + ".";
ShowUsageWithFlagsRestrict(progname, restrict.c_str());
gflags_exitfunc(1);
......@@ -409,7 +410,7 @@ void HandleCommandLineHelpFlags() {
++flag) {
if (!FileMatchesSubstring(flag->filename, substrings))
continue;
const string package = Dirname(flag->filename) + "/";
const string package = Dirname(flag->filename) + PATH_SEPARATOR;
if (package != last_package) {
ShowUsageWithFlagsRestrict(progname, package.c_str());
VLOG(7) << "Found package: " << package;
......
This diff is collapsed.
......@@ -55,9 +55,25 @@
#include "config.h"
#undef GFLAGS_DLL_DECL
#ifdef GFLAGS_DLL_DECL
# undef GFLAGS_DLL_DECL
#endif
#ifdef GFLAGS_DLL_DEFINE_FLAG
# undef GFLAGS_DLL_DEFINE_FLAG
#endif
#ifdef GFLAGS_DLL_DECLARE_FLAG
# undef GFLAGS_DLL_DECLARE_FLAG
#endif
#ifdef GFLAGS_DLL_DECL_FOR_UNITTESTS
# define GFLAGS_DLL_DECL GFLAGS_DLL_DECL_FOR_UNITTESTS
# define GFLAGS_DLL_DECL GFLAGS_DLL_DECL_FOR_UNITTESTS
#else
# define GFLAGS_DLL_DECL // if DLL_DECL_FOR_UNITTESTS isn't defined, use ""
# define GFLAGS_DLL_DECL // if DLL_DECL_FOR_UNITTESTS isn't defined, use ""
#endif
// Import flags defined by gflags.cc
#if GFLAGS_IS_A_DLL && defined(_MSC_VER)
# define GFLAGS_DLL_DECLARE_FLAG __declspec(dllimport)
#else
# define GFLAGS_DLL_DECLARE_FLAG
#endif
\ No newline at end of file
if (NOT BINARY)
message (FATAl_ERROR "BINARY file to check not specified!")
endif ()
file (STRINGS "${BINARY}" strings REGEX "This text should be stripped out")
if (strings)
message (FATAL_ERROR "Text not stripped from binary like it should be: ${BINARY}")
endif ()
\ No newline at end of file
#!/bin/sh
#
# Copyright (c) 2011, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# ---
# Author: csilvers@google.com (Craig Silverstein)
if [ -z "$1" ]; then
echo "USAGE: $0 <unittest exe>"
exit 1
fi
BINARY="$1"
# Make sure the binary exists...
if ! "$BINARY" >/dev/null 2>/dev/null
then
echo "Cannot run binary $BINARY"
exit 1
fi
# Make sure the --help output doesn't print the stripped text.
if "$BINARY" --help | grep "This text should be stripped out" >/dev/null 2>&1
then
echo "Text not stripped from --help like it should be: $BINARY"
exit 1
fi
# Make sure the stripped text isn't in the binary at all.
if strings --help >/dev/null 2>&1 # make sure the binary exists
then
# Unfortunately, for us, libtool can replace executables with a
# shell script that does some work before calling the 'real'
# executable under a different name. We need the 'real'
# executable name to run 'strings' on it, so we construct this
# binary to print the real name (argv[0]) on stdout when run.
REAL_BINARY=`"$BINARY"`
# On cygwin, we may need to add a '.exe' extension by hand.
[ -f "$REAL_BINARY.exe" ] && REAL_BINARY="$REAL_BINARY.exe"
if strings "$REAL_BINARY" | grep "This text should be stripped" >/dev/null 2>&1
then
echo "Text not stripped from binary like it should be: $BINARY"
exit 1
fi
# Let's also do a sanity check to make sure strings is working properly
if ! strings "$REAL_BINARY" | grep "Usage message" >/dev/null 2>&1
then
echo "Usage text not found in binary like it should be: $BINARY"
exit 1
fi
fi
echo "PASS"
......@@ -35,11 +35,6 @@
#include "config_for_unittests.h"
#include <gflags/gflags.h>
#ifndef GFLAGS_SHARED_LIBS
# undef GFLAGS_DLL_DECLARE_FLAG
# define GFLAGS_DLL_DECLARE_FLAG
#endif
#include <math.h> // for isinf() and isnan()
#include <stdio.h>
#include <stdlib.h>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment