Commit 24b4c59e authored by Craig Silverstein's avatar Craig Silverstein

Mon Jan 24 16:11:35 2011 Google Inc. <opensource@google.com>

	* google-gflags: version 1.5
	* Better reporting of current vs default value (handler)
	* Add API for cleaning up of memory at program-exit (jmarantz)
	* Fix macros to work inside namespaces (csilvers)
	* Use our own string typedef in case string is redefined (csilvers)
	* Updated to autoconf 2.65


git-svn-id: https://gflags.googlecode.com/svn/trunk@44 6586e3c6-dcc4-952a-343f-ff74eb82781d
parent 0baf4ab4
Mon Jan 24 16:11:35 2011 Google Inc. <opensource@google.com>
* google-gflags: version 1.5
* Better reporting of current vs default value (handler)
* Add API for cleaning up of memory at program-exit (jmarantz)
* Fix macros to work inside namespaces (csilvers)
* Use our own string typedef in case string is redefined (csilvers)
* Updated to autoconf 2.65
Wed Oct 13 17:40:12 2010 Google Inc. <opensource@google.com>
* google-gflags: version 1.4
......
......@@ -120,6 +120,21 @@ gflags_unittest_sh: gflags_unittest$(EXEEXT) \
$$SH "$(top_srcdir)/src/gflags_unittest.sh" \
"`pwd`/gflags_unittest" "$(top_srcdir)" "@TEST_TMPDIR@"
# Test the STRIP_FLAGS #define.
TESTS += gflags_strip_flags_test
gflags_strip_flags_test_SOURCES = $(gflagsinclude_HEADERS) \
src/config_for_unittests.h \
src/gflags_strip_flags_test.cc
gflags_strip_flags_test_CXXFLAGS = $(PTHREAD_CFLAGS)
gflags_strip_flags_test_LDFLAGS = $(PTHREAD_CFLAGS)
gflags_strip_flags_test_LDADD = libgflags.la
check_SCRIPTS += gflags_strip_flags_test_sh
noinst_SCRIPTS += src/gflags_strip_flags_test.sh
gflags_strip_flags_test_sh: gflags_strip_flags_test$(EXEEXT)
sh "$(top_srcdir)/src/gflags_strip_flags_test.sh" \
"`pwd`/gflags_strip_flags_test$(EXEEXT)"
# These are negative-compilation tests. We want to make sure these
# erroneous use of the flags macros correctly fail to compile.
# Again, we just bother testing with the no-threads version of the library.
......
......@@ -98,13 +98,18 @@ am_libgflags_nothreads_la_OBJECTS = $(am__objects_3)
libgflags_nothreads_la_OBJECTS = $(am_libgflags_nothreads_la_OBJECTS)
am__EXEEXT_1 = gflags_unittest$(EXEEXT) \
gflags_nothreads_unittest$(EXEEXT) gflags_unittest2$(EXEEXT) \
gflags_unittest3$(EXEEXT)
gflags_unittest3$(EXEEXT) gflags_strip_flags_test$(EXEEXT)
PROGRAMS = $(noinst_PROGRAMS)
am__objects_4 = $(am__objects_1) gflags_unittest.$(OBJEXT)
am_gflags_nothreads_unittest_OBJECTS = $(am__objects_4)
gflags_nothreads_unittest_OBJECTS = \
$(am_gflags_nothreads_unittest_OBJECTS)
gflags_nothreads_unittest_DEPENDENCIES = libgflags_nothreads.la
am_gflags_strip_flags_test_OBJECTS = $(am__objects_1) \
gflags_strip_flags_test-gflags_strip_flags_test.$(OBJEXT)
gflags_strip_flags_test_OBJECTS = \
$(am_gflags_strip_flags_test_OBJECTS)
gflags_strip_flags_test_DEPENDENCIES = libgflags.la
am_gflags_unittest_OBJECTS = $(am__objects_1) \
gflags_unittest-gflags_unittest.$(OBJEXT)
gflags_unittest_OBJECTS = $(am_gflags_unittest_OBJECTS)
......@@ -140,13 +145,13 @@ LINK = $(LIBTOOL) --tag=CC --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(AM_LDFLAGS) $(LDFLAGS) -o $@
SOURCES = $(libgflags_la_SOURCES) $(libgflags_nothreads_la_SOURCES) \
$(gflags_nothreads_unittest_SOURCES) \
$(gflags_unittest_SOURCES) $(gflags_unittest2_SOURCES) \
$(gflags_unittest3_SOURCES)
$(gflags_strip_flags_test_SOURCES) $(gflags_unittest_SOURCES) \
$(gflags_unittest2_SOURCES) $(gflags_unittest3_SOURCES)
DIST_SOURCES = $(libgflags_la_SOURCES) \
$(libgflags_nothreads_la_SOURCES) \
$(gflags_nothreads_unittest_SOURCES) \
$(gflags_unittest_SOURCES) $(gflags_unittest2_SOURCES) \
$(gflags_unittest3_SOURCES)
$(gflags_strip_flags_test_SOURCES) $(gflags_unittest_SOURCES) \
$(gflags_unittest2_SOURCES) $(gflags_unittest3_SOURCES)
dist_docDATA_INSTALL = $(INSTALL_DATA)
pkgconfigDATA_INSTALL = $(INSTALL_DATA)
DATA = $(dist_doc_DATA) $(dist_noinst_DATA) $(pkgconfig_DATA)
......@@ -330,8 +335,10 @@ WINDOWS_PROJECTS = google-gflags.sln \
# We also want to test that things work properly when the file that
# holds main() has a name ending with -main or _main. To keep the
# Makefile small :-), we test the no-threads version of these.
# Test the STRIP_FLAGS #define.
TESTS = gflags_unittest gflags_nothreads_unittest gflags_unittest2 \
gflags_unittest3
gflags_unittest3 gflags_strip_flags_test
TESTS_ENVIRONMENT = SRCDIR="$(top_srcdir)"
# Some buggy sh's ignore "" instead of treating it as a positional
......@@ -343,10 +350,11 @@ TESTS_ENVIRONMENT = SRCDIR="$(top_srcdir)"
# Again, we just bother testing with the no-threads version of the library.
# This one, on the other hand, should succeed.
check_SCRIPTS = gflags_unittest_sh gflags_nc_test1 gflags_nc_test2 \
gflags_nc_test3 gflags_nc_test4
check_SCRIPTS = gflags_unittest_sh gflags_strip_flags_test_sh \
gflags_nc_test1 gflags_nc_test2 gflags_nc_test3 \
gflags_nc_test4
# Every time you add a unittest to check_SCRIPTS, add it here too
noinst_SCRIPTS = src/gflags_unittest.sh
noinst_SCRIPTS = src/gflags_unittest.sh src/gflags_strip_flags_test.sh
# Used for auto-generated source files
CLEANFILES = src/gflags_unittest-main.cc src/gflags_unittest_main.cc \
$(pkgconfig_DATA)
......@@ -382,6 +390,13 @@ gflags_unittest3_LDADD = libgflags_nothreads.la
# This file isn't covered under any rule that would cause it to be distributed.
dist_noinst_DATA = src/gflags_unittest_flagfile src/gflags_nc.cc
gflags_strip_flags_test_SOURCES = $(gflagsinclude_HEADERS) \
src/config_for_unittests.h \
src/gflags_strip_flags_test.cc
gflags_strip_flags_test_CXXFLAGS = $(PTHREAD_CFLAGS)
gflags_strip_flags_test_LDFLAGS = $(PTHREAD_CFLAGS)
gflags_strip_flags_test_LDADD = libgflags.la
# http://linux.die.net/man/1/pkg-config, http://pkg-config.freedesktop.org/wiki
pkgconfigdir = $(libdir)/pkgconfig
......@@ -492,6 +507,9 @@ clean-noinstPROGRAMS:
gflags_nothreads_unittest$(EXEEXT): $(gflags_nothreads_unittest_OBJECTS) $(gflags_nothreads_unittest_DEPENDENCIES)
@rm -f gflags_nothreads_unittest$(EXEEXT)
$(CXXLINK) $(gflags_nothreads_unittest_LDFLAGS) $(gflags_nothreads_unittest_OBJECTS) $(gflags_nothreads_unittest_LDADD) $(LIBS)
gflags_strip_flags_test$(EXEEXT): $(gflags_strip_flags_test_OBJECTS) $(gflags_strip_flags_test_DEPENDENCIES)
@rm -f gflags_strip_flags_test$(EXEEXT)
$(CXXLINK) $(gflags_strip_flags_test_LDFLAGS) $(gflags_strip_flags_test_OBJECTS) $(gflags_strip_flags_test_LDADD) $(LIBS)
gflags_unittest$(EXEEXT): $(gflags_unittest_OBJECTS) $(gflags_unittest_DEPENDENCIES)
@rm -f gflags_unittest$(EXEEXT)
$(CXXLINK) $(gflags_unittest_LDFLAGS) $(gflags_unittest_OBJECTS) $(gflags_unittest_LDADD) $(LIBS)
......@@ -527,6 +545,7 @@ mostlyclean-compile:
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gflags_strip_flags_test-gflags_strip_flags_test.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gflags_unittest-gflags_unittest.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gflags_unittest-main.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gflags_unittest.Po@am__quote@
......@@ -615,6 +634,20 @@ gflags_unittest.obj: src/gflags_unittest.cc
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o gflags_unittest.obj `if test -f 'src/gflags_unittest.cc'; then $(CYGPATH_W) 'src/gflags_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/src/gflags_unittest.cc'; fi`
gflags_strip_flags_test-gflags_strip_flags_test.o: src/gflags_strip_flags_test.cc
@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(gflags_strip_flags_test_CXXFLAGS) $(CXXFLAGS) -MT gflags_strip_flags_test-gflags_strip_flags_test.o -MD -MP -MF "$(DEPDIR)/gflags_strip_flags_test-gflags_strip_flags_test.Tpo" -c -o gflags_strip_flags_test-gflags_strip_flags_test.o `test -f 'src/gflags_strip_flags_test.cc' || echo '$(srcdir)/'`src/gflags_strip_flags_test.cc; \
@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/gflags_strip_flags_test-gflags_strip_flags_test.Tpo" "$(DEPDIR)/gflags_strip_flags_test-gflags_strip_flags_test.Po"; else rm -f "$(DEPDIR)/gflags_strip_flags_test-gflags_strip_flags_test.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='src/gflags_strip_flags_test.cc' object='gflags_strip_flags_test-gflags_strip_flags_test.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(gflags_strip_flags_test_CXXFLAGS) $(CXXFLAGS) -c -o gflags_strip_flags_test-gflags_strip_flags_test.o `test -f 'src/gflags_strip_flags_test.cc' || echo '$(srcdir)/'`src/gflags_strip_flags_test.cc
gflags_strip_flags_test-gflags_strip_flags_test.obj: src/gflags_strip_flags_test.cc
@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(gflags_strip_flags_test_CXXFLAGS) $(CXXFLAGS) -MT gflags_strip_flags_test-gflags_strip_flags_test.obj -MD -MP -MF "$(DEPDIR)/gflags_strip_flags_test-gflags_strip_flags_test.Tpo" -c -o gflags_strip_flags_test-gflags_strip_flags_test.obj `if test -f 'src/gflags_strip_flags_test.cc'; then $(CYGPATH_W) 'src/gflags_strip_flags_test.cc'; else $(CYGPATH_W) '$(srcdir)/src/gflags_strip_flags_test.cc'; fi`; \
@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/gflags_strip_flags_test-gflags_strip_flags_test.Tpo" "$(DEPDIR)/gflags_strip_flags_test-gflags_strip_flags_test.Po"; else rm -f "$(DEPDIR)/gflags_strip_flags_test-gflags_strip_flags_test.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='src/gflags_strip_flags_test.cc' object='gflags_strip_flags_test-gflags_strip_flags_test.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(gflags_strip_flags_test_CXXFLAGS) $(CXXFLAGS) -c -o gflags_strip_flags_test-gflags_strip_flags_test.obj `if test -f 'src/gflags_strip_flags_test.cc'; then $(CYGPATH_W) 'src/gflags_strip_flags_test.cc'; else $(CYGPATH_W) '$(srcdir)/src/gflags_strip_flags_test.cc'; fi`
gflags_unittest-gflags_unittest.o: src/gflags_unittest.cc
@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(gflags_unittest_CXXFLAGS) $(CXXFLAGS) -MT gflags_unittest-gflags_unittest.o -MD -MP -MF "$(DEPDIR)/gflags_unittest-gflags_unittest.Tpo" -c -o gflags_unittest-gflags_unittest.o `test -f 'src/gflags_unittest.cc' || echo '$(srcdir)/'`src/gflags_unittest.cc; \
@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/gflags_unittest-gflags_unittest.Tpo" "$(DEPDIR)/gflags_unittest-gflags_unittest.Po"; else rm -f "$(DEPDIR)/gflags_unittest-gflags_unittest.Tpo"; exit 1; fi
......@@ -1110,6 +1143,9 @@ gflags_unittest_sh: gflags_unittest$(EXEEXT) \
bash --version >/dev/null 2>&1 && export SH=bash || export SH=sh; \
$$SH "$(top_srcdir)/src/gflags_unittest.sh" \
"`pwd`/gflags_unittest" "$(top_srcdir)" "@TEST_TMPDIR@"
gflags_strip_flags_test_sh: gflags_strip_flags_test$(EXEEXT)
sh "$(top_srcdir)/src/gflags_strip_flags_test.sh" \
"`pwd`/gflags_strip_flags_test$(EXEEXT)"
gflags_nc_test1: $(gflagsinclude_HEADERS) src/gflags_nc.cc
if $(CXX) -DTEST_SWAPPED_ARGS $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o gflags_nc_test1.o $(srcdir)/src/gflags_nc.cc; then echo "Compile succeeded but should have failed"; exit 1; else echo "Compile failed, like it was supposed to"; fi
gflags_nc_test2: $(gflagsinclude_HEADERS) src/gflags_nc.cc
......
==11 October 2010==
== 24 January 2011 ==
I've just released gflags 1.5. This release has only minor changes
from 1.4, including some slightly better reporting in --help, and
an new memory-cleanup function that can help when running gflags-using
libraries under valgrind. The major change is to fix up the macros
(`DEFINE_bool` and the like) to work more reliably inside namespaces.
If you have not had a problem with these macros, and don't need any of
the other changes described, there is no need to upgrade. See the
[http://code.google.com/p/google-gflags/source/browse/tags/gflags-1.5/ChangeLog ChangeLog]
for a full list of changes for this release.
=== 11 October 2010 ===
I've just released gflags 1.4. This release has only minor changes
from 1.3, including some documentation tweaks and some work to make
the library smaller. If 1.3 is working well for you, there's no
particular reason to upgrade.
===4 January 2010===
=== 4 January 2010 ===
I've just released gflags 1.3. gflags now compiles under MSVC, and
all tests pass. I *really* never thought non-unix-y Windows folks
......@@ -16,7 +29,7 @@ into its own library, [http://code.google.com/p/python-gflags python-gflags].
If you're interested in the Python version of gflags, that's the place to
get it now.
===10 September 2009==
=== 10 September 2009 ==
I've just released gflags 1.2. The major change from gflags 1.1 is it
now compiles under MinGW (as well as cygwin), and all tests pass. I
......@@ -27,12 +40,12 @@ wrong!
The other changes are minor, such as support for --htmlxml in the
python version of gflags.
===15 April 2009===
=== 15 April 2009 ===
I've just released gflags 1.1. It has only minor changes fdrom gflags
1.0 (see the
[http://code.google.com/p/google-gflags/source/browse/tags/gflags-1.1/ChangeLog
ChangeLog] for details). The major change is that I moved to a new
[http://code.google.com/p/google-gflags/source/browse/tags/gflags-1.1/ChangeLog ChangeLog]
for details). The major change is that I moved to a new
system for creating .deb and .rpm files. This allows me to create
x86_64 deb and rpm files.
......
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.65 for gflags 1.4.
# Generated by GNU Autoconf 2.65 for gflags 1.5.
#
# Report bugs to <opensource@google.com>.
#
......@@ -701,8 +701,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='gflags'
PACKAGE_TARNAME='gflags'
PACKAGE_VERSION='1.4'
PACKAGE_STRING='gflags 1.4'
PACKAGE_VERSION='1.5'
PACKAGE_STRING='gflags 1.5'
PACKAGE_BUGREPORT='opensource@google.com'
PACKAGE_URL=''
......@@ -1441,7 +1441,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures gflags 1.4 to adapt to many kinds of systems.
\`configure' configures gflags 1.5 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
......@@ -1511,7 +1511,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of gflags 1.4:";;
short | recursive ) echo "Configuration of gflags 1.5:";;
esac
cat <<\_ACEOF
......@@ -1617,7 +1617,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
gflags configure 1.4
gflags configure 1.5
generated by GNU Autoconf 2.65
Copyright (C) 2009 Free Software Foundation, Inc.
......@@ -2163,7 +2163,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by gflags $as_me 1.4, which was
It was created by gflags $as_me 1.5, which was
generated by GNU Autoconf 2.65. Invocation command line was
$ $0 $@
......@@ -2512,7 +2512,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
# Update this value for every release! (A:B:C will map to foo.so.(A-C).C.B)
# http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
SO_VERSION=0:1:0
SO_VERSION=1:0:1
# The argument here is just something that should be in the current directory
# (for sanity checking)
......@@ -2830,7 +2830,7 @@ fi
# Define the identity of the package.
PACKAGE='gflags'
VERSION='1.4'
VERSION='1.5'
cat >>confdefs.h <<_ACEOF
......@@ -15827,7 +15827,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by gflags $as_me 1.4, which was
This file was extended by gflags $as_me 1.5, which was
generated by GNU Autoconf 2.65. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
......@@ -15893,7 +15893,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
gflags config.status 1.4
gflags config.status 1.5
configured by $0, generated by GNU Autoconf 2.65,
with options \\"\$ac_cs_config\\"
......
......@@ -4,10 +4,10 @@
# make sure we're interpreted by some minimal autoconf
AC_PREREQ(2.57)
AC_INIT(gflags, 1.4, opensource@google.com)
AC_INIT(gflags, 1.5, opensource@google.com)
# Update this value for every release! (A:B:C will map to foo.so.(A-C).C.B)
# http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
SO_VERSION=0:1:0
SO_VERSION=1:0:1
# The argument here is just something that should be in the current directory
# (for sanity checking)
......
......@@ -369,11 +369,12 @@ commandline, but if they do not, the flag's value will default to
true.</p>
<h2> <A name="special">Special Flags</code> </h2>
<h2> <A name="special">Special Flags</a> </h2>
<p>There are a few flags defined by the commandlineflags module
itself, and are available to all applications. These fall into three
categories. First are the 'reporting' flags that, when found, cause
itself, and are available to all applications that use
commandlineflags. These fall into
three categories. First are the 'reporting' flags that, when found, cause
the application to print some information about itself and exit.</p>
<table><tr valign=top>
......@@ -504,7 +505,7 @@ and then processing continues with remaining flags from the command
line.</p>
<h2> <A name="api">The API</code> </h2>
<h2> <A name="api">The API</a> </h2>
<p>In addition to accessing <code>FLAGS_foo</code> directly, it is
possible to access the flags programmatically, through an API. It is
......
gflags (1.5-1) unstable; urgency=low
* New upstream release.
-- Google Inc. <opensource@google.com> Mon, 24 Jan 2011 16:11:35 -0800
gflags (1.4-2) unstable; urgency=low
* Accidentally uploaded an outdated .deb to Google Code; this is the right one
......
......@@ -347,7 +347,8 @@ extern void SetUsageMessage(const std::string& usage);
// Looks for flags in argv and parses them. Rearranges argv to put
// flags first, or removes them entirely if remove_flags is true.
// If a flag is defined more than once in the command line or flag
// file, the last definition is used.
// file, the last definition is used. Returns the index (into argv)
// of the first non-flag argument.
// See top-of-file for more details on this function.
#ifndef SWIG // In swig, use ParseCommandLineFlagsScript() instead.
extern uint32 ParseCommandLineFlags(int *argc, char*** argv,
......@@ -361,9 +362,10 @@ extern uint32 ParseCommandLineFlags(int *argc, char*** argv,
// changing default values for some FLAGS (via
// e.g. SetCommandLineOptionWithMode calls) between the time of
// command line parsing and the time of dumping help information for
// the flags as a result of command line parsing.
// If a flag is defined more than once in the command line or flag
// file, the last definition is used.
// the flags as a result of command line parsing. If a flag is
// defined more than once in the command line or flag file, the last
// definition is used. Returns the index (into argv) of the first
// non-flag argument. (If remove_flags is true, will always return 1.)
extern uint32 ParseCommandLineNonHelpFlags(int *argc, char*** argv,
bool remove_flags);
// This is actually defined in commandlineflags_reporting.cc.
......@@ -377,12 +379,14 @@ extern void HandleCommandLineHelpFlags(); // in commandlineflags_reporting.cc
// are spawned.
extern void AllowCommandLineReparsing();
// Reparse the flags that have not yet been recognized.
// Only flags registered since the last parse will be recognized.
// Any flag value must be provided as part of the argument using "=",
// not as a separate command line argument that follows the flag argument.
// Reparse the flags that have not yet been recognized. Only flags
// registered since the last parse will be recognized. Any flag value
// must be provided as part of the argument using "=", not as a
// separate command line argument that follows the flag argument.
// Intended for handling flags from dynamically loaded libraries,
// since their flags are not registered until they are loaded.
// Returns the index (into the original argv) of the first non-flag
// argument. (If remove_flags is true, will always return 1.)
extern uint32 ReparseCommandLineNonHelpFlags();
// Clean up memory allocated by flags. This is only needed to reduce
......@@ -455,7 +459,7 @@ extern const char kStrippedFlagHelp[];
#if defined(STRIP_FLAG_HELP) && STRIP_FLAG_HELP > 0
// Need this construct to avoid the 'defined but not used' warning.
#define MAYBE_STRIPPED_HELP(txt) (false ? (txt) : kStrippedFlagHelp)
#define MAYBE_STRIPPED_HELP(txt) (false ? (txt) : @ac_google_namespace@::kStrippedFlagHelp)
#else
#define MAYBE_STRIPPED_HELP(txt) txt
#endif
......
// 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: Craig Silverstein
//
// A simple program that uses STRIP_FLAG_HELP. We'll have a shell
// script that runs 'strings' over this program and makes sure
// that the help string is not in there.
#include "config_for_unittests.h"
#include <stdio.h>
#define STRIP_FLAG_HELP 1
#include "gflags/gflags.h"
using GOOGLE_NAMESPACE::SetUsageMessage;
using GOOGLE_NAMESPACE::ParseCommandLineFlags;
DEFINE_bool(test, true, "This text should be stripped out");
int main(int argc, char** argv) {
SetUsageMessage("Usage message");
ParseCommandLineFlags(&argc, &argv, false);
// 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.
printf("%s\n", argv[0]);
return 0;
}
#!/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: 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 out" >/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"
......@@ -1162,7 +1162,8 @@ TEST(DeprecatedFunctionsTest, AppendFlagsIntoFile) {
FILE* fp = fopen(filename.c_str(), "r");
EXPECT_TRUE(fp != NULL);
char line[8192];
fgets(line, sizeof(line)-1, fp); // first line should be progname
EXPECT_TRUE(fgets(line, sizeof(line)-1, fp) != NULL); // get the first line
// First line should be progname.
EXPECT_STREQ("not the real argv0\n", line);
bool found_bool = false, found_int32 = false;
......
......@@ -416,7 +416,7 @@ extern GFLAGS_DLL_DECL uint32 ReparseCommandLineNonHelpFlags();
// access flags are quiescent. Referencing flags after this is called
// will have unexpected consequences. This is not safe to run when
// multiple threads might be running: the function is thread-hostile.
extern void ShutDownCommandLineFlags();
extern GFLAGS_DLL_DECL void ShutDownCommandLineFlags();
// --------------------------------------------------------------------
......@@ -575,16 +575,13 @@ inline clstring* dont_pass0toDEFINE_string(char *stringspot,
int value);
} // namespace fLS
#define DECLARE_string(name) namespace fLS { extern ::fLS::clstring& FLAGS_##name; } \
#define DECLARE_string(name) namespace fLS { extern GFLAGS_DLL_DECLARE_FLAG ::fLS::clstring& FLAGS_##name; } \
using fLS::FLAGS_##name
// We need to define a var named FLAGS_no##name so people don't define
// --string and --nostring. And we need a temporary place to put val
// so we don't have to evaluate it twice. Two great needs that go
// great together!
// The weird 'using' + 'extern' inside the fLS namespace is to work around
// an unknown compiler bug/issue with the gcc 4.2.1 on SUSE 10. See
// http://code.google.com/p/google-gflags/issues/detail?id=20
#define DEFINE_string(name, val, txt) \
namespace fLS { \
using ::fLS::clstring; \
......@@ -595,9 +592,7 @@ inline clstring* dont_pass0toDEFINE_string(char *stringspot,
static ::google::FlagRegisterer o_##name( \
#name, "string", MAYBE_STRIPPED_HELP(txt), __FILE__, \
s_##name[0].s, new (s_##name[1].s) clstring(*FLAGS_no##name)); \
extern clstring& FLAGS_##name; \
using fLS::FLAGS_##name; \
clstring& FLAGS_##name = *FLAGS_no##name; \
GFLAGS_DLL_DEFINE_FLAG clstring& FLAGS_##name = *FLAGS_no##name; \
} \
using fLS::FLAGS_##name
......
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