From c79c32d98c4dc705ecc2fea2d7e8712afb6938fb Mon Sep 17 00:00:00 2001
From: Craig Silverstein
Date: Tue, 22 Jul 2008 23:29:39 +0000
Subject: [PATCH] Mon Jul 21 23:01:38 2008 Google Inc.
* google-gflags: version 0.9
* Add the ability to validate a command-line flag (csilvers)
* Add completion support for commandline flags in bash (daven)
* Add -W compile flags to Makefile, when using gcc (csilvers)
* Allow helpstring to be NULL (cristianoc)
* Improved documentation of classes in the .cc file (csilvers)
* Fix python bug with AppendFlagValues + shortnames (jjtswan)
* Use bool instead of int for boolean flags in gflags.py (bcmills)
* Simplify the way we declare flags, now more foolproof (csilvers)
* Better error messages when bool flags collide (colohan)
* Only evaluate DEFINE_foo macro args once (csilvers)
git-svn-id: https://gflags.googlecode.com/svn/trunk@23 6586e3c6-dcc4-952a-343f-ff74eb82781d
---
ChangeLog | 14 +
Makefile.am | 19 +-
Makefile.in | 93 +++--
configure | 325 ++++++++------
configure.ac | 5 +-
doc/gflags.html | 32 ++
m4/acx_pthread.m4 | 218 +++++-----
m4/google_namespace.m4 | 8 +-
packages/deb/changelog | 6 +
packages/deb/libgoogle-gflags0.dirs | 1 +
packages/deb/libgoogle-gflags0.install | 2 +
packages/rpm/rpm.spec | 1 +
python/gflags.py | 67 +--
python/gflags_unittest.py | 125 +++---
src/gflags.cc | 743 +++++++++++++++++++++++----------
src/gflags_completions.cc | 743 +++++++++++++++++++++++++++++++++
src/gflags_completions.sh | 117 ++++++
src/gflags_reporting.cc | 3 +
src/gflags_unittest.cc | 279 ++++++++++++-
src/gflags_unittest.sh | 13 +-
src/google/gflags.h.in | 202 +++++----
src/google/gflags_completions.h.in | 121 ++++++
22 files changed, 2494 insertions(+), 643 deletions(-)
create mode 100644 src/gflags_completions.cc
create mode 100755 src/gflags_completions.sh
create mode 100644 src/google/gflags_completions.h.in
diff --git a/ChangeLog b/ChangeLog
index af505ab..24d9931 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+Mon Jul 21 23:01:38 2008 Google Inc.
+
+ * google-gflags: version 0.9
+ * Add the ability to validate a command-line flag (csilvers)
+ * Add completion support for commandline flags in bash (daven)
+ * Add -W compile flags to Makefile, when using gcc (csilvers)
+ * Allow helpstring to be NULL (cristianoc)
+ * Improved documentation of classes in the .cc file (csilvers)
+ * Fix python bug with AppendFlagValues + shortnames (jjtswan)
+ * Use bool instead of int for boolean flags in gflags.py (bcmills)
+ * Simplify the way we declare flags, now more foolproof (csilvers)
+ * Better error messages when bool flags collide (colohan)
+ * Only evaluate DEFINE_foo macro args once (csilvers)
+
Wed Mar 26 15:20:18 2008 Google Inc.
* google-gflags: version 0.8
diff --git a/Makefile.am b/Makefile.am
index 7173895..71c7c2b 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -11,10 +11,20 @@ ACLOCAL_AMFLAGS = -I m4
# This is so we can #include
AM_CPPFLAGS = -I$(top_srcdir)/src
+# This is mostly based on configure options
+AM_CXXFLAGS =
+
+# These are good warnings to turn on by default,
+if GCC
+AM_CXXFLAGS += -Wall -Wwrite-strings -Woverloaded-virtual -Wno-sign-compare
+endif
+
googleincludedir = $(includedir)/google
## The .h files you want to install (that is, .h files that people
## who install this package can include in their own applications.)
-googleinclude_HEADERS = src/google/gflags.h
+googleinclude_HEADERS = src/google/gflags.h src/google/gflags_completions.h
+
+bin_SCRIPTS = src/gflags_completions.sh
docdir = $(prefix)/share/doc/$(PACKAGE)-$(VERSION)
## This is for HTML and other documentation you want to install.
@@ -42,9 +52,10 @@ CLEANFILES =
lib_LTLIBRARIES += libgflags.la
libgflags_la_SOURCES = $(googleinclude_HEADERS) src/config.h \
- src/gflags.cc src/gflags_reporting.cc
-libgflags_la_CXXFLAGS = $(PTRHEAD_CFLAGS) -DNDEBUG
-libgflags_la_LDFLAGS = $(PTRHEAD_CFLAGS)
+ src/gflags.cc src/gflags_reporting.cc \
+ src/gflags_completions.cc
+libgflags_la_CXXFLAGS = $(PTHREAD_CFLAGS) -DNDEBUG
+libgflags_la_LDFLAGS = $(PTHREAD_CFLAGS)
libgflags_la_LIBADD = $(PTHREAD_LIBS)
TESTS += gflags_unittest
diff --git a/Makefile.in b/Makefile.in
index 727e672..b353fca 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -40,14 +40,18 @@ PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
+
+# These are good warnings to turn on by default,
+@GCC_TRUE@am__append_1 = -Wall -Wwrite-strings -Woverloaded-virtual -Wno-sign-compare
noinst_PROGRAMS = $(am__EXEEXT_1)
DIST_COMMON = README $(am__configure_deps) $(dist_doc_DATA) \
$(dist_noinst_DATA) $(googleinclude_HEADERS) \
$(srcdir)/Makefile.am $(srcdir)/Makefile.in \
$(top_srcdir)/configure $(top_srcdir)/src/config.h.in \
- $(top_srcdir)/src/google/gflags.h.in AUTHORS COPYING ChangeLog \
- INSTALL NEWS compile config.guess config.sub depcomp \
- install-sh ltmain.sh missing mkinstalldirs
+ $(top_srcdir)/src/google/gflags.h.in \
+ $(top_srcdir)/src/google/gflags_completions.h.in AUTHORS \
+ COPYING ChangeLog INSTALL NEWS compile config.guess config.sub \
+ depcomp install-sh ltmain.sh missing mkinstalldirs
subdir = .
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ac_have_attribute.m4 \
@@ -61,22 +65,24 @@ am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
configure.lineno configure.status.lineno
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = $(top_builddir)/src/config.h
-CONFIG_CLEAN_FILES = src/google/gflags.h
+CONFIG_CLEAN_FILES = src/google/gflags.h \
+ src/google/gflags_completions.h
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
am__vpath_adj = case $$p in \
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
*) f=$$p;; \
esac;
am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
-am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(docdir)" \
- "$(DESTDIR)$(googleincludedir)"
+am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" \
+ "$(DESTDIR)$(docdir)" "$(DESTDIR)$(googleincludedir)"
libLTLIBRARIES_INSTALL = $(INSTALL)
LTLIBRARIES = $(lib_LTLIBRARIES)
am__DEPENDENCIES_1 =
libgflags_la_DEPENDENCIES = $(am__DEPENDENCIES_1)
am__objects_1 =
am_libgflags_la_OBJECTS = $(am__objects_1) libgflags_la-gflags.lo \
- libgflags_la-gflags_reporting.lo
+ libgflags_la-gflags_reporting.lo \
+ libgflags_la-gflags_completions.lo
libgflags_la_OBJECTS = $(am_libgflags_la_OBJECTS)
am__EXEEXT_1 = gflags_unittest$(EXEEXT) \
gflags_nothreads_unittest$(EXEEXT) gflags_unittest2$(EXEEXT) \
@@ -99,7 +105,8 @@ am_gflags_unittest3_OBJECTS = $(am__objects_1) \
gflags_unittest_main.$(OBJEXT)
gflags_unittest3_OBJECTS = $(am_gflags_unittest3_OBJECTS)
gflags_unittest3_DEPENDENCIES = libgflags.la
-SCRIPTS = $(noinst_SCRIPTS)
+binSCRIPT_INSTALL = $(INSTALL_SCRIPT)
+SCRIPTS = $(bin_SCRIPTS) $(noinst_SCRIPTS)
DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)/src
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
@@ -172,6 +179,8 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
F77 = @F77@
FFLAGS = @FFLAGS@
+GCC_FALSE = @GCC_FALSE@
+GCC_TRUE = @GCC_TRUE@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
@@ -260,8 +269,12 @@ ACLOCAL_AMFLAGS = -I m4
# This is so we can #include
AM_CPPFLAGS = -I$(top_srcdir)/src
+
+# This is mostly based on configure options
+AM_CXXFLAGS = $(am__append_1)
googleincludedir = $(includedir)/google
-googleinclude_HEADERS = src/google/gflags.h
+googleinclude_HEADERS = src/google/gflags.h src/google/gflags_completions.h
+bin_SCRIPTS = src/gflags_completions.sh
docdir = $(prefix)/share/doc/$(PACKAGE)-$(VERSION)
dist_doc_DATA = AUTHORS COPYING ChangeLog INSTALL NEWS README \
doc/designstyle.css doc/gflags.html
@@ -282,10 +295,11 @@ noinst_SCRIPTS = src/gflags_unittest.sh
# Used for auto-generated source files
CLEANFILES = src/gflags_unittest-main.cc src/gflags_unittest_main.cc
libgflags_la_SOURCES = $(googleinclude_HEADERS) src/config.h \
- src/gflags.cc src/gflags_reporting.cc
+ src/gflags.cc src/gflags_reporting.cc \
+ src/gflags_completions.cc
-libgflags_la_CXXFLAGS = $(PTRHEAD_CFLAGS) -DNDEBUG
-libgflags_la_LDFLAGS = $(PTRHEAD_CFLAGS)
+libgflags_la_CXXFLAGS = $(PTHREAD_CFLAGS) -DNDEBUG
+libgflags_la_LDFLAGS = $(PTHREAD_CFLAGS)
libgflags_la_LIBADD = $(PTHREAD_LIBS)
gflags_unittest_SOURCES = $(googleinclude_HEADERS) src/config.h \
src/gflags_unittest.cc
@@ -370,6 +384,8 @@ distclean-hdr:
-rm -f src/config.h src/stamp-h1
src/google/gflags.h: $(top_builddir)/config.status $(top_srcdir)/src/google/gflags.h.in
cd $(top_builddir) && $(SHELL) ./config.status $@
+src/google/gflags_completions.h: $(top_builddir)/config.status $(top_srcdir)/src/google/gflags_completions.h.in
+ cd $(top_builddir) && $(SHELL) ./config.status $@
install-libLTLIBRARIES: $(lib_LTLIBRARIES)
@$(NORMAL_INSTALL)
test -z "$(libdir)" || $(mkdir_p) "$(DESTDIR)$(libdir)"
@@ -418,6 +434,25 @@ gflags_unittest2$(EXEEXT): $(gflags_unittest2_OBJECTS) $(gflags_unittest2_DEPEND
gflags_unittest3$(EXEEXT): $(gflags_unittest3_OBJECTS) $(gflags_unittest3_DEPENDENCIES)
@rm -f gflags_unittest3$(EXEEXT)
$(CXXLINK) $(gflags_unittest3_LDFLAGS) $(gflags_unittest3_OBJECTS) $(gflags_unittest3_LDADD) $(LIBS)
+install-binSCRIPTS: $(bin_SCRIPTS)
+ @$(NORMAL_INSTALL)
+ test -z "$(bindir)" || $(mkdir_p) "$(DESTDIR)$(bindir)"
+ @list='$(bin_SCRIPTS)'; for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ if test -f $$d$$p; then \
+ f=`echo "$$p" | sed 's|^.*/||;$(transform)'`; \
+ echo " $(binSCRIPT_INSTALL) '$$d$$p' '$(DESTDIR)$(bindir)/$$f'"; \
+ $(binSCRIPT_INSTALL) "$$d$$p" "$(DESTDIR)$(bindir)/$$f"; \
+ else :; fi; \
+ done
+
+uninstall-binSCRIPTS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(bin_SCRIPTS)'; for p in $$list; do \
+ f=`echo "$$p" | sed 's|^.*/||;$(transform)'`; \
+ echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
+ rm -f "$(DESTDIR)$(bindir)/$$f"; \
+ done
mostlyclean-compile:
-rm -f *.$(OBJEXT)
@@ -430,6 +465,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/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)/libgflags_la-gflags.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgflags_la-gflags_completions.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgflags_la-gflags_reporting.Plo@am__quote@
.cc.o:
@@ -467,6 +503,13 @@ libgflags_la-gflags_reporting.lo: src/gflags_reporting.cc
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgflags_la_CXXFLAGS) $(CXXFLAGS) -c -o libgflags_la-gflags_reporting.lo `test -f 'src/gflags_reporting.cc' || echo '$(srcdir)/'`src/gflags_reporting.cc
+libgflags_la-gflags_completions.lo: src/gflags_completions.cc
+@am__fastdepCXX_TRUE@ if $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgflags_la_CXXFLAGS) $(CXXFLAGS) -MT libgflags_la-gflags_completions.lo -MD -MP -MF "$(DEPDIR)/libgflags_la-gflags_completions.Tpo" -c -o libgflags_la-gflags_completions.lo `test -f 'src/gflags_completions.cc' || echo '$(srcdir)/'`src/gflags_completions.cc; \
+@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libgflags_la-gflags_completions.Tpo" "$(DEPDIR)/libgflags_la-gflags_completions.Plo"; else rm -f "$(DEPDIR)/libgflags_la-gflags_completions.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='src/gflags_completions.cc' object='libgflags_la-gflags_completions.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgflags_la_CXXFLAGS) $(CXXFLAGS) -c -o libgflags_la-gflags_completions.lo `test -f 'src/gflags_completions.cc' || echo '$(srcdir)/'`src/gflags_completions.cc
+
gflags_unittest.o: src/gflags_unittest.cc
@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT gflags_unittest.o -MD -MP -MF "$(DEPDIR)/gflags_unittest.Tpo" -c -o gflags_unittest.o `test -f 'src/gflags_unittest.cc' || echo '$(srcdir)/'`src/gflags_unittest.cc; \
@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/gflags_unittest.Tpo" "$(DEPDIR)/gflags_unittest.Po"; else rm -f "$(DEPDIR)/gflags_unittest.Tpo"; exit 1; fi
@@ -822,7 +865,7 @@ check: check-am
all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) $(SCRIPTS) $(DATA) \
$(HEADERS)
installdirs:
- for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(docdir)" "$(DESTDIR)$(googleincludedir)"; do \
+ for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" "$(DESTDIR)$(docdir)" "$(DESTDIR)$(googleincludedir)"; do \
test -z "$$dir" || $(mkdir_p) "$$dir"; \
done
install: install-am
@@ -874,7 +917,7 @@ info-am:
install-data-am: install-dist_docDATA install-googleincludeHEADERS
-install-exec-am: install-libLTLIBRARIES
+install-exec-am: install-binSCRIPTS install-libLTLIBRARIES
install-info: install-info-am
@@ -902,8 +945,9 @@ ps: ps-am
ps-am:
-uninstall-am: uninstall-dist_docDATA uninstall-googleincludeHEADERS \
- uninstall-info-am uninstall-libLTLIBRARIES
+uninstall-am: uninstall-binSCRIPTS uninstall-dist_docDATA \
+ uninstall-googleincludeHEADERS uninstall-info-am \
+ uninstall-libLTLIBRARIES
.PHONY: CTAGS GTAGS all all-am am--refresh check check-TESTS check-am \
clean clean-generic clean-libLTLIBRARIES clean-libtool \
@@ -912,14 +956,15 @@ uninstall-am: uninstall-dist_docDATA uninstall-googleincludeHEADERS \
distclean-compile distclean-generic distclean-hdr \
distclean-libtool distclean-tags distcleancheck distdir \
distuninstallcheck dvi dvi-am html html-am info info-am \
- install install-am install-data install-data-am \
- install-dist_docDATA install-exec install-exec-am \
- install-googleincludeHEADERS install-info install-info-am \
- install-libLTLIBRARIES install-man install-strip installcheck \
- installcheck-am installdirs maintainer-clean \
- maintainer-clean-generic mostlyclean mostlyclean-compile \
- mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
- tags uninstall uninstall-am uninstall-dist_docDATA \
+ install install-am install-binSCRIPTS install-data \
+ install-data-am install-dist_docDATA install-exec \
+ install-exec-am install-googleincludeHEADERS install-info \
+ install-info-am install-libLTLIBRARIES install-man \
+ install-strip installcheck installcheck-am installdirs \
+ maintainer-clean maintainer-clean-generic mostlyclean \
+ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
+ pdf pdf-am ps ps-am tags uninstall uninstall-am \
+ uninstall-binSCRIPTS uninstall-dist_docDATA \
uninstall-googleincludeHEADERS uninstall-info-am \
uninstall-libLTLIBRARIES
diff --git a/configure b/configure
index fd5a2d9..29b59c0 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.59 for gflags 0.8.
+# Generated by GNU Autoconf 2.59 for gflags 0.9.
#
# Report bugs to .
#
@@ -423,8 +423,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
# Identity of this package.
PACKAGE_NAME='gflags'
PACKAGE_TARNAME='gflags'
-PACKAGE_VERSION='0.8'
-PACKAGE_STRING='gflags 0.8'
+PACKAGE_VERSION='0.9'
+PACKAGE_STRING='gflags 0.9'
PACKAGE_BUGREPORT='opensource@google.com'
ac_unique_file="README"
@@ -465,7 +465,7 @@ ac_includes_default="\
# include
#endif"
-ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE CPP CXX CXXFLAGS ac_ct_CXX CXXDEPMODE am__fastdepCXX_TRUE am__fastdepCXX_FALSE build build_cpu build_vendor build_os host host_cpu host_vendor host_os EGREP LN_S ECHO AR ac_ct_AR RANLIB ac_ct_RANLIB CXXCPP F77 FFLAGS ac_ct_F77 LIBTOOL LIBTOOL_DEPS acx_pthread_config PTHREAD_CC PTHREAD_LIBS PTHREAD_CFLAGS ac_google_start_namespace ac_google_end_namespace ac_google_namespace ac_cv___attribute__unused ac_cv_have_stdint_h ac_cv_have_systypes_h ac_cv_have_inttypes_h ac_cv_have_uint16_t ac_cv_have_u_int16_t ac_cv_have___uint16 LIBOBJS LTLIBOBJS'
+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE CPP CXX CXXFLAGS ac_ct_CXX CXXDEPMODE am__fastdepCXX_TRUE am__fastdepCXX_FALSE GCC_TRUE GCC_FALSE build build_cpu build_vendor build_os host host_cpu host_vendor host_os EGREP LN_S ECHO AR ac_ct_AR RANLIB ac_ct_RANLIB CXXCPP F77 FFLAGS ac_ct_F77 LIBTOOL LIBTOOL_DEPS acx_pthread_config PTHREAD_CC PTHREAD_LIBS PTHREAD_CFLAGS ac_google_start_namespace ac_google_end_namespace ac_google_namespace ac_cv___attribute__unused ac_cv_have_stdint_h ac_cv_have_systypes_h ac_cv_have_inttypes_h ac_cv_have_uint16_t ac_cv_have_u_int16_t ac_cv_have___uint16 LIBOBJS LTLIBOBJS'
ac_subst_files=''
# Initialize some variables set by options.
@@ -954,7 +954,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 0.8 to adapt to many kinds of systems.
+\`configure' configures gflags 0.9 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1020,7 +1020,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of gflags 0.8:";;
+ short | recursive ) echo "Configuration of gflags 0.9:";;
esac
cat <<\_ACEOF
@@ -1163,7 +1163,7 @@ fi
test -n "$ac_init_help" && exit 0
if $ac_init_version; then
cat <<\_ACEOF
-gflags configure 0.8
+gflags configure 0.9
generated by GNU Autoconf 2.59
Copyright (C) 2003 Free Software Foundation, Inc.
@@ -1177,7 +1177,7 @@ cat >&5 <<_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 0.8, which was
+It was created by gflags $as_me 0.9, which was
generated by GNU Autoconf 2.59. Invocation command line was
$ $0 $@
@@ -1823,7 +1823,7 @@ fi
# Define the identity of the package.
PACKAGE='gflags'
- VERSION='0.8'
+ VERSION='0.9'
cat >>confdefs.h <<_ACEOF
@@ -3750,6 +3750,16 @@ fi
+
+if test "$GCC" = yes; then
+ GCC_TRUE=
+ GCC_FALSE='#'
+else
+ GCC_TRUE='#'
+ GCC_FALSE=
+fi
+ # let the Makefile know if we're gcc
+
# Uncomment this if you'll be exporting libraries (.so's)
# Check whether --enable-shared or --disable-shared was given.
if test "${enable_shared+set}" = set; then
@@ -4371,7 +4381,7 @@ ia64-*-hpux*)
;;
*-*-irix6*)
# Find out which ABI we are using.
- echo '#line 4374 "configure"' > conftest.$ac_ext
+ echo '#line 4384 "configure"' > conftest.$ac_ext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>&5
ac_status=$?
@@ -5268,7 +5278,7 @@ fi
# Provide some information about the compiler.
-echo "$as_me:5271:" \
+echo "$as_me:5281:" \
"checking for Fortran 77 compiler version" >&5
ac_compiler=`set X $ac_compile; echo $2`
{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version &5\"") >&5
@@ -6329,11 +6339,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:6332: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:6342: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:6336: \$? = $ac_status" >&5
+ echo "$as_me:6346: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
@@ -6597,11 +6607,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:6600: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:6610: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:6604: \$? = $ac_status" >&5
+ echo "$as_me:6614: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
@@ -6701,11 +6711,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:6704: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:6714: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
- echo "$as_me:6708: \$? = $ac_status" >&5
+ echo "$as_me:6718: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
@@ -9059,7 +9069,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext < conftest.$ac_ext <&5)
+ (eval echo "\"\$as_me:11510: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:11504: \$? = $ac_status" >&5
+ echo "$as_me:11514: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
@@ -11601,11 +11611,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:11604: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:11614: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
- echo "$as_me:11608: \$? = $ac_status" >&5
+ echo "$as_me:11618: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
@@ -13189,11 +13199,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:13192: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:13202: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:13196: \$? = $ac_status" >&5
+ echo "$as_me:13206: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
@@ -13293,11 +13303,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:13296: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:13306: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
- echo "$as_me:13300: \$? = $ac_status" >&5
+ echo "$as_me:13310: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
@@ -15516,11 +15526,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:15519: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:15529: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:15523: \$? = $ac_status" >&5
+ echo "$as_me:15533: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
@@ -15784,11 +15794,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:15787: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:15797: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:15791: \$? = $ac_status" >&5
+ echo "$as_me:15801: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
@@ -15888,11 +15898,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:15891: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:15901: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
- echo "$as_me:15895: \$? = $ac_status" >&5
+ echo "$as_me:15905: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
@@ -20039,50 +20049,99 @@ test -n "$PTHREAD_CC" || PTHREAD_CC="${CC}"
PTHREAD_CC=$CC
fi
- # The next part tries to detect GCC inconsistency with -shared on some
- # architectures and systems. The problem is that in certain
- # configurations, when -shared is specified, GCC "forgets" to
- # internally use various flags which are still necessary.
+ # The next part tries to detect GCC inconsistency with -shared on some
+ # architectures and systems. The problem is that in certain
+ # configurations, when -shared is specified, GCC "forgets" to
+ # internally use various flags which are still necessary.
- echo "$as_me:$LINENO: checking whether to check for GCC pthread/shared inconsistencies" >&5
+ #
+ # Prepare the flags
+ #
+ save_CFLAGS="$CFLAGS"
+ save_LIBS="$LIBS"
+ save_CC="$CC"
+
+ # Try with the flags determined by the earlier checks.
+ #
+ # -Wl,-z,defs forces link-time symbol resolution, so that the
+ # linking checks with -shared actually have any value
+ #
+ # FIXME: -fPIC is required for -shared on many architectures,
+ # so we specify it here, but the right way would probably be to
+ # properly detect whether it is actually required.
+ CFLAGS="-shared -fPIC -Wl,-z,defs $CFLAGS $PTHREAD_CFLAGS"
+ LIBS="$PTHREAD_LIBS $LIBS"
+ CC="$PTHREAD_CC"
+
+ # In order not to create several levels of indentation, we test
+ # the value of "$done" until we find the cure or run out of ideas.
+ done="no"
+
+ # First, make sure the CFLAGS we added are actually accepted by our
+ # compiler. If not (and OS X's ld, for instance, does not accept -z),
+ # then we can't do this test.
+ if test x"$done" = xno; then
+ echo "$as_me:$LINENO: checking whether to check for GCC pthread/shared inconsistencies" >&5
echo $ECHO_N "checking whether to check for GCC pthread/shared inconsistencies... $ECHO_C" >&6
- check_inconsistencies=yes
- case "${host_cpu}-${host_os}" in
- *-darwin*) check_inconsistencies=no ;;
- esac
- if test x"$GCC" != xyes -o "x$check_inconsistencies" != xyes ; then
- echo "$as_me:$LINENO: result: no" >&5
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ :
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+done=yes
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+
+ if test "x$done" = xyes ; then
+ echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6
- else
- echo "$as_me:$LINENO: result: yes" >&5
+ else
+ echo "$as_me:$LINENO: result: yes" >&5
echo "${ECHO_T}yes" >&6
+ fi
+ fi
- # In order not to create several levels of indentation, we test
- # the value of "$ok" until we find out the cure or run out of
- # ideas.
- ok="no"
-
- #
- # Prepare the flags
- #
- save_CFLAGS="$CFLAGS"
- save_LIBS="$LIBS"
- save_CC="$CC"
- # Try with the flags determined by the earlier checks.
- #
- # -Wl,-z,defs forces link-time symbol resolution, so that the
- # linking checks with -shared actually have any value
- #
- # FIXME: -fPIC is required for -shared on many architectures,
- # so we specify it here, but the right way would probably be to
- # properly detect whether it is actually required.
- CFLAGS="-shared -fPIC -Wl,-z,defs $CFLAGS $PTHREAD_CFLAGS"
- LIBS="$PTHREAD_LIBS $LIBS"
- CC="$PTHREAD_CC"
-
- echo "$as_me:$LINENO: checking whether -pthread is sufficient with -shared" >&5
+ if test x"$done" = xno; then
+ echo "$as_me:$LINENO: checking whether -pthread is sufficient with -shared" >&5
echo $ECHO_N "checking whether -pthread is sufficient with -shared... $ECHO_C" >&6
- cat >conftest.$ac_ext <<_ACEOF
+ cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
@@ -20093,8 +20152,8 @@ int
main ()
{
pthread_t th; pthread_join(th, 0);
- pthread_attr_init(0); pthread_cleanup_push(0, 0);
- pthread_create(0,0,0,0); pthread_cleanup_pop(0);
+ pthread_attr_init(0); pthread_cleanup_push(0, 0);
+ pthread_create(0,0,0,0); pthread_cleanup_pop(0);
;
return 0;
}
@@ -20120,7 +20179,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
- ok=yes
+ done=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
@@ -20129,23 +20188,24 @@ fi
rm -f conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
- if test "x$ok" = xyes; then
- echo "$as_me:$LINENO: result: yes" >&5
+ if test "x$done" = xyes; then
+ echo "$as_me:$LINENO: result: yes" >&5
echo "${ECHO_T}yes" >&6
- else
- echo "$as_me:$LINENO: result: no" >&5
+ else
+ echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6
- fi
+ fi
+ fi
- #
- # Linux gcc on some architectures such as mips/mipsel forgets
- # about -lpthread
- #
- if test x"$ok" = xno; then
- echo "$as_me:$LINENO: checking whether -lpthread fixes that" >&5
+ #
+ # Linux gcc on some architectures such as mips/mipsel forgets
+ # about -lpthread
+ #
+ if test x"$done" = xno; then
+ echo "$as_me:$LINENO: checking whether -lpthread fixes that" >&5
echo $ECHO_N "checking whether -lpthread fixes that... $ECHO_C" >&6
- LIBS="-lpthread $PTHREAD_LIBS $save_LIBS"
- cat >conftest.$ac_ext <<_ACEOF
+ LIBS="-lpthread $PTHREAD_LIBS $save_LIBS"
+ cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
@@ -20156,8 +20216,8 @@ int
main ()
{
pthread_t th; pthread_join(th, 0);
- pthread_attr_init(0); pthread_cleanup_push(0, 0);
- pthread_create(0,0,0,0); pthread_cleanup_pop(0);
+ pthread_attr_init(0); pthread_cleanup_push(0, 0);
+ pthread_create(0,0,0,0); pthread_cleanup_pop(0);
;
return 0;
}
@@ -20183,7 +20243,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
- ok=yes
+ done=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
@@ -20192,23 +20252,23 @@ fi
rm -f conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
- if test "x$ok" = xyes; then
- echo "$as_me:$LINENO: result: yes" >&5
+ if test "x$done" = xyes; then
+ echo "$as_me:$LINENO: result: yes" >&5
echo "${ECHO_T}yes" >&6
- PTHREAD_LIBS="-lpthread $PTHREAD_LIBS"
- else
- echo "$as_me:$LINENO: result: no" >&5
+ PTHREAD_LIBS="-lpthread $PTHREAD_LIBS"
+ else
+ echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6
- fi
- fi
- #
- # FreeBSD 4.10 gcc forgets to use -lc_r instead of -lc
- #
- if test x"$ok" = xno; then
- echo "$as_me:$LINENO: checking whether -lc_r fixes that" >&5
+ fi
+ fi
+ #
+ # FreeBSD 4.10 gcc forgets to use -lc_r instead of -lc
+ #
+ if test x"$done" = xno; then
+ echo "$as_me:$LINENO: checking whether -lc_r fixes that" >&5
echo $ECHO_N "checking whether -lc_r fixes that... $ECHO_C" >&6
- LIBS="-lc_r $PTHREAD_LIBS $save_LIBS"
- cat >conftest.$ac_ext <<_ACEOF
+ LIBS="-lc_r $PTHREAD_LIBS $save_LIBS"
+ cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
@@ -20219,8 +20279,8 @@ int
main ()
{
pthread_t th; pthread_join(th, 0);
- pthread_attr_init(0); pthread_cleanup_push(0, 0);
- pthread_create(0,0,0,0); pthread_cleanup_pop(0);
+ pthread_attr_init(0); pthread_cleanup_push(0, 0);
+ pthread_create(0,0,0,0); pthread_cleanup_pop(0);
;
return 0;
}
@@ -20246,7 +20306,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
- ok=yes
+ done=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
@@ -20255,28 +20315,27 @@ fi
rm -f conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
- if test "x$ok" = xyes; then
- echo "$as_me:$LINENO: result: yes" >&5
+ if test "x$done" = xyes; then
+ echo "$as_me:$LINENO: result: yes" >&5
echo "${ECHO_T}yes" >&6
- PTHREAD_LIBS="-lc_r $PTHREAD_LIBS"
- else
- echo "$as_me:$LINENO: result: no" >&5
+ PTHREAD_LIBS="-lc_r $PTHREAD_LIBS"
+ else
+ echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6
- fi
- fi
- if test x"$ok" = xno; then
- # OK, we have run out of ideas
- { echo "$as_me:$LINENO: WARNING: Impossible to determine how to use pthreads with shared libraries" >&5
+ fi
+ fi
+ if test x"$done" = xno; then
+ # OK, we have run out of ideas
+ { echo "$as_me:$LINENO: WARNING: Impossible to determine how to use pthreads with shared libraries" >&5
echo "$as_me: WARNING: Impossible to determine how to use pthreads with shared libraries" >&2;}
- # so it's not safe to assume that we may use pthreads
- acx_pthread_ok=no
- fi
+ # so it's not safe to assume that we may use pthreads
+ acx_pthread_ok=no
+ fi
- CFLAGS="$save_CFLAGS"
- LIBS="$save_LIBS"
- CC="$save_CC"
- fi
+ CFLAGS="$save_CFLAGS"
+ LIBS="$save_LIBS"
+ CC="$save_CC"
else
PTHREAD_CC="$CC"
fi
@@ -20518,7 +20577,7 @@ else
google_namespace="$google_namespace_default"
fi;
if test -n "$google_namespace"; then
- ac_google_namespace="$google_namespace"
+ ac_google_namespace="::$google_namespace"
ac_google_start_namespace="namespace $google_namespace {"
ac_google_end_namespace="}"
else
@@ -20558,7 +20617,7 @@ _ACEOF
## Check out ../autoconf/ for other macros you can call to do useful stuff
# Write generated configuration file, and also .h files
- ac_config_files="$ac_config_files Makefile src/google/gflags.h"
+ ac_config_files="$ac_config_files Makefile src/google/gflags.h src/google/gflags_completions.h"
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
@@ -20672,6 +20731,13 @@ echo "$as_me: error: conditional \"am__fastdepCXX\" was never defined.
Usually this means the macro was only invoked conditionally." >&2;}
{ (exit 1); exit 1; }; }
fi
+if test -z "${GCC_TRUE}" && test -z "${GCC_FALSE}"; then
+ { { echo "$as_me:$LINENO: error: conditional \"GCC\" was never defined.
+Usually this means the macro was only invoked conditionally." >&5
+echo "$as_me: error: conditional \"GCC\" was never defined.
+Usually this means the macro was only invoked conditionally." >&2;}
+ { (exit 1); exit 1; }; }
+fi
: ${CONFIG_STATUS=./config.status}
ac_clean_files_save=$ac_clean_files
@@ -20943,7 +21009,7 @@ _ASBOX
} >&5
cat >&5 <<_CSEOF
-This file was extended by gflags $as_me 0.8, which was
+This file was extended by gflags $as_me 0.9, which was
generated by GNU Autoconf 2.59. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -21006,7 +21072,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF
ac_cs_version="\\
-gflags config.status 0.8
+gflags config.status 0.9
configured by $0, generated by GNU Autoconf 2.59,
with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
@@ -21118,6 +21184,7 @@ do
# Handling of arguments.
"Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;;
"src/google/gflags.h" ) CONFIG_FILES="$CONFIG_FILES src/google/gflags.h" ;;
+ "src/google/gflags_completions.h" ) CONFIG_FILES="$CONFIG_FILES src/google/gflags_completions.h" ;;
"depfiles" ) CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;;
"src/config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS src/config.h" ;;
*) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
@@ -21250,6 +21317,8 @@ s,@ac_ct_CXX@,$ac_ct_CXX,;t t
s,@CXXDEPMODE@,$CXXDEPMODE,;t t
s,@am__fastdepCXX_TRUE@,$am__fastdepCXX_TRUE,;t t
s,@am__fastdepCXX_FALSE@,$am__fastdepCXX_FALSE,;t t
+s,@GCC_TRUE@,$GCC_TRUE,;t t
+s,@GCC_FALSE@,$GCC_FALSE,;t t
s,@build@,$build,;t t
s,@build_cpu@,$build_cpu,;t t
s,@build_vendor@,$build_vendor,;t t
diff --git a/configure.ac b/configure.ac
index e0e5511..c0a8e03 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4,7 +4,7 @@
# make sure we're interpreted by some minimal autoconf
AC_PREREQ(2.57)
-AC_INIT(gflags, 0.8, opensource@google.com)
+AC_INIT(gflags, 0.9, opensource@google.com)
# The argument here is just something that should be in the current directory
# (for sanity checking)
AC_CONFIG_SRCDIR(README)
@@ -15,6 +15,7 @@ AM_CONFIG_HEADER(src/config.h)
AC_PROG_CC
AC_PROG_CPP
AC_PROG_CXX
+AM_CONDITIONAL(GCC, test "$GCC" = yes) # let the Makefile know if we're gcc
# Uncomment this if you'll be exporting libraries (.so's)
AC_PROG_LIBTOOL
@@ -67,5 +68,5 @@ AC_SUBST(ac_cv_have___uint16)
## Check out ../autoconf/ for other macros you can call to do useful stuff
# Write generated configuration file, and also .h files
-AC_CONFIG_FILES([Makefile src/google/gflags.h])
+AC_CONFIG_FILES([Makefile src/google/gflags.h src/google/gflags_completions.h])
AC_OUTPUT
diff --git a/doc/gflags.html b/doc/gflags.html
index e059a7b..5ac362b 100644
--- a/doc/gflags.html
+++ b/doc/gflags.html
@@ -189,6 +189,38 @@ file.
#include
will make explicit the dependency between the
two files. This causes the flag to be a global variable.
+
+
+
+After DEFINE-ing a flag, you may optionally register a validator
+function with the flag. If you do this, after the flag is parsed from
+the commandline, and whenever its value is changes via a call to
+SetCommandLineOption()
, the validator function is called
+with the new value as an argument. The validator function should
+return 'true' if the flag value is valid, and false otherwise.
+
+
Here is an example use of this functionality:
+
+static bool ValidatePort(const char* flagname, int32 value) {
+ if (value > 0 && value < 32768) // value is ok
+ return true;
+ printf("Invalid value for --%s: %d\n", flagname, (int)value);
+ return false;
+}
+DEFINE_int32(port, 0, "What port to listen on");
+static const bool port_dummy = RegisterFlagValidator(&FLAGS_port, &ValidatePort);
+
+
+By doing the registration at global initialization time (right
+after the DEFINE), we ensure that the registration happens before
+the commandline is parsed at the beginning of main()
.
+
+RegisterFlagValidator()
returns true if the
+registration is successful. It return false if the registration fails
+because a) the first argument does not refer to a commandline flag, or
+b) a different validator has already been registered for this flag.
+
+
The final piece is the one that tells the executable to process the
diff --git a/m4/acx_pthread.m4 b/m4/acx_pthread.m4
index f5db4f0..2cf20de 100644
--- a/m4/acx_pthread.m4
+++ b/m4/acx_pthread.m4
@@ -1,7 +1,12 @@
# This was retrieved from
-# http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/common/acx_pthread.m4?rev=1227
+# http://svn.0pointer.de/viewvc/trunk/common/acx_pthread.m4?revision=1277&root=avahi
# See also (perhaps for new versions?)
-# http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/common/acx_pthread.m4
+# http://svn.0pointer.de/viewvc/trunk/common/acx_pthread.m4?root=avahi
+#
+# We've rewritten the inconsistency check code (from avahi), to work
+# more broadly. In particular, it no longer assumes ld accepts -zdefs.
+# This caused a restructing of the code, but the functionality has only
+# changed a little.
dnl @synopsis ACX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
dnl
@@ -231,108 +236,113 @@ if test "x$acx_pthread_ok" = xyes; then
PTHREAD_CC=$CC
fi
- # The next part tries to detect GCC inconsistency with -shared on some
- # architectures and systems. The problem is that in certain
- # configurations, when -shared is specified, GCC "forgets" to
- # internally use various flags which are still necessary.
-
- AC_MSG_CHECKING([whether to check for GCC pthread/shared inconsistencies])
- check_inconsistencies=yes
- case "${host_cpu}-${host_os}" in
- *-darwin*) check_inconsistencies=no ;;
- esac
- if test x"$GCC" != xyes -o "x$check_inconsistencies" != xyes ; then
- AC_MSG_RESULT([no])
- else
- AC_MSG_RESULT([yes])
-
- # In order not to create several levels of indentation, we test
- # the value of "$ok" until we find out the cure or run out of
- # ideas.
- ok="no"
-
- #
- # Prepare the flags
- #
- save_CFLAGS="$CFLAGS"
- save_LIBS="$LIBS"
- save_CC="$CC"
- # Try with the flags determined by the earlier checks.
- #
- # -Wl,-z,defs forces link-time symbol resolution, so that the
- # linking checks with -shared actually have any value
- #
- # FIXME: -fPIC is required for -shared on many architectures,
- # so we specify it here, but the right way would probably be to
- # properly detect whether it is actually required.
- CFLAGS="-shared -fPIC -Wl,-z,defs $CFLAGS $PTHREAD_CFLAGS"
- LIBS="$PTHREAD_LIBS $LIBS"
- CC="$PTHREAD_CC"
-
- AC_MSG_CHECKING([whether -pthread is sufficient with -shared])
- AC_TRY_LINK([#include ],
- [pthread_t th; pthread_join(th, 0);
- pthread_attr_init(0); pthread_cleanup_push(0, 0);
- pthread_create(0,0,0,0); pthread_cleanup_pop(0); ],
- [ok=yes])
-
- if test "x$ok" = xyes; then
- AC_MSG_RESULT([yes])
- else
- AC_MSG_RESULT([no])
- fi
-
- #
- # Linux gcc on some architectures such as mips/mipsel forgets
- # about -lpthread
- #
- if test x"$ok" = xno; then
- AC_MSG_CHECKING([whether -lpthread fixes that])
- LIBS="-lpthread $PTHREAD_LIBS $save_LIBS"
- AC_TRY_LINK([#include ],
- [pthread_t th; pthread_join(th, 0);
- pthread_attr_init(0); pthread_cleanup_push(0, 0);
- pthread_create(0,0,0,0); pthread_cleanup_pop(0); ],
- [ok=yes])
-
- if test "x$ok" = xyes; then
- AC_MSG_RESULT([yes])
- PTHREAD_LIBS="-lpthread $PTHREAD_LIBS"
- else
- AC_MSG_RESULT([no])
- fi
- fi
- #
- # FreeBSD 4.10 gcc forgets to use -lc_r instead of -lc
- #
- if test x"$ok" = xno; then
- AC_MSG_CHECKING([whether -lc_r fixes that])
- LIBS="-lc_r $PTHREAD_LIBS $save_LIBS"
- AC_TRY_LINK([#include ],
- [pthread_t th; pthread_join(th, 0);
- pthread_attr_init(0); pthread_cleanup_push(0, 0);
- pthread_create(0,0,0,0); pthread_cleanup_pop(0); ],
- [ok=yes])
-
- if test "x$ok" = xyes; then
- AC_MSG_RESULT([yes])
- PTHREAD_LIBS="-lc_r $PTHREAD_LIBS"
- else
- AC_MSG_RESULT([no])
- fi
- fi
- if test x"$ok" = xno; then
- # OK, we have run out of ideas
- AC_MSG_WARN([Impossible to determine how to use pthreads with shared libraries])
-
- # so it's not safe to assume that we may use pthreads
- acx_pthread_ok=no
- fi
-
- CFLAGS="$save_CFLAGS"
- LIBS="$save_LIBS"
- CC="$save_CC"
- fi
+ # The next part tries to detect GCC inconsistency with -shared on some
+ # architectures and systems. The problem is that in certain
+ # configurations, when -shared is specified, GCC "forgets" to
+ # internally use various flags which are still necessary.
+
+ #
+ # Prepare the flags
+ #
+ save_CFLAGS="$CFLAGS"
+ save_LIBS="$LIBS"
+ save_CC="$CC"
+
+ # Try with the flags determined by the earlier checks.
+ #
+ # -Wl,-z,defs forces link-time symbol resolution, so that the
+ # linking checks with -shared actually have any value
+ #
+ # FIXME: -fPIC is required for -shared on many architectures,
+ # so we specify it here, but the right way would probably be to
+ # properly detect whether it is actually required.
+ CFLAGS="-shared -fPIC -Wl,-z,defs $CFLAGS $PTHREAD_CFLAGS"
+ LIBS="$PTHREAD_LIBS $LIBS"
+ CC="$PTHREAD_CC"
+
+ # In order not to create several levels of indentation, we test
+ # the value of "$done" until we find the cure or run out of ideas.
+ done="no"
+
+ # First, make sure the CFLAGS we added are actually accepted by our
+ # compiler. If not (and OS X's ld, for instance, does not accept -z),
+ # then we can't do this test.
+ if test x"$done" = xno; then
+ AC_MSG_CHECKING([whether to check for GCC pthread/shared inconsistencies])
+ AC_TRY_LINK(,, , [done=yes])
+
+ if test "x$done" = xyes ; then
+ AC_MSG_RESULT([no])
+ else
+ AC_MSG_RESULT([yes])
+ fi
+ fi
+
+ if test x"$done" = xno; then
+ AC_MSG_CHECKING([whether -pthread is sufficient with -shared])
+ AC_TRY_LINK([#include ],
+ [pthread_t th; pthread_join(th, 0);
+ pthread_attr_init(0); pthread_cleanup_push(0, 0);
+ pthread_create(0,0,0,0); pthread_cleanup_pop(0); ],
+ [done=yes])
+
+ if test "x$done" = xyes; then
+ AC_MSG_RESULT([yes])
+ else
+ AC_MSG_RESULT([no])
+ fi
+ fi
+
+ #
+ # Linux gcc on some architectures such as mips/mipsel forgets
+ # about -lpthread
+ #
+ if test x"$done" = xno; then
+ AC_MSG_CHECKING([whether -lpthread fixes that])
+ LIBS="-lpthread $PTHREAD_LIBS $save_LIBS"
+ AC_TRY_LINK([#include ],
+ [pthread_t th; pthread_join(th, 0);
+ pthread_attr_init(0); pthread_cleanup_push(0, 0);
+ pthread_create(0,0,0,0); pthread_cleanup_pop(0); ],
+ [done=yes])
+
+ if test "x$done" = xyes; then
+ AC_MSG_RESULT([yes])
+ PTHREAD_LIBS="-lpthread $PTHREAD_LIBS"
+ else
+ AC_MSG_RESULT([no])
+ fi
+ fi
+ #
+ # FreeBSD 4.10 gcc forgets to use -lc_r instead of -lc
+ #
+ if test x"$done" = xno; then
+ AC_MSG_CHECKING([whether -lc_r fixes that])
+ LIBS="-lc_r $PTHREAD_LIBS $save_LIBS"
+ AC_TRY_LINK([#include ],
+ [pthread_t th; pthread_join(th, 0);
+ pthread_attr_init(0); pthread_cleanup_push(0, 0);
+ pthread_create(0,0,0,0); pthread_cleanup_pop(0); ],
+ [done=yes])
+
+ if test "x$done" = xyes; then
+ AC_MSG_RESULT([yes])
+ PTHREAD_LIBS="-lc_r $PTHREAD_LIBS"
+ else
+ AC_MSG_RESULT([no])
+ fi
+ fi
+ if test x"$done" = xno; then
+ # OK, we have run out of ideas
+ AC_MSG_WARN([Impossible to determine how to use pthreads with shared libraries])
+
+ # so it's not safe to assume that we may use pthreads
+ acx_pthread_ok=no
+ fi
+
+ CFLAGS="$save_CFLAGS"
+ LIBS="$save_LIBS"
+ CC="$save_CC"
else
PTHREAD_CC="$CC"
fi
diff --git a/m4/google_namespace.m4 b/m4/google_namespace.m4
index 79e0a6d..7f244cc 100644
--- a/m4/google_namespace.m4
+++ b/m4/google_namespace.m4
@@ -6,6 +6,12 @@
# when it makes sense -- for instance, when publishing stl-like code -- you
# may want to go with a different default, like 'std'.
+# We guarantee the invariant that GOOGLE_NAMESPACE starts with ::,
+# unless it's the empty string. Thus, it's always safe to do
+# GOOGLE_NAMESPACE::foo and be sure you're getting the foo that's
+# actually in the google namespace, and not some other namespace that
+# the namespace rules might kick in.
+
AC_DEFUN([AC_DEFINE_GOOGLE_NAMESPACE],
[google_namespace_default=[$1]
AC_ARG_ENABLE(namespace, [ --enable-namespace=FOO to define these Google
@@ -19,7 +25,7 @@ AC_DEFUN([AC_DEFINE_GOOGLE_NAMESPACE],
esac],
[google_namespace="$google_namespace_default"])
if test -n "$google_namespace"; then
- ac_google_namespace="$google_namespace"
+ ac_google_namespace="::$google_namespace"
ac_google_start_namespace="namespace $google_namespace {"
ac_google_end_namespace="}"
else
diff --git a/packages/deb/changelog b/packages/deb/changelog
index fcdbd3c..361b387 100644
--- a/packages/deb/changelog
+++ b/packages/deb/changelog
@@ -1,3 +1,9 @@
+google-gflags (0.9-1) unstable; urgency=low
+
+ * New upstream release.
+
+ -- Google Inc. Mon, 21 Jul 2008 23:01:38 -0700
+
google-gflags (0.8-1) unstable; urgency=low
* New upstream release.
diff --git a/packages/deb/libgoogle-gflags0.dirs b/packages/deb/libgoogle-gflags0.dirs
index 6845771..14f5b95 100644
--- a/packages/deb/libgoogle-gflags0.dirs
+++ b/packages/deb/libgoogle-gflags0.dirs
@@ -1 +1,2 @@
usr/lib
+usr/bin
diff --git a/packages/deb/libgoogle-gflags0.install b/packages/deb/libgoogle-gflags0.install
index 704ea87..434db32 100644
--- a/packages/deb/libgoogle-gflags0.install
+++ b/packages/deb/libgoogle-gflags0.install
@@ -1,2 +1,4 @@
usr/lib/lib*.so.*
debian/tmp/usr/lib/lib*.so.*
+usr/bin/*
+debian/tmp/usr/bin/*
diff --git a/packages/rpm/rpm.spec b/packages/rpm/rpm.spec
index fa68885..f2259cc 100644
--- a/packages/rpm/rpm.spec
+++ b/packages/rpm/rpm.spec
@@ -56,6 +56,7 @@ rm -rf $RPM_BUILD_ROOT
%{prefix}/lib/libgflags.so.0
%{prefix}/lib/libgflags.so.0.0.0
+%{prefix}/bin/gflags_completions.sh
%files devel
%defattr(-,root,root)
diff --git a/python/gflags.py b/python/gflags.py
index bd35d81..32fb1e1 100755
--- a/python/gflags.py
+++ b/python/gflags.py
@@ -190,13 +190,18 @@ try:
except AttributeError: # a very old python, that lacks sys.version_info
raise NotImplementedError("requires python 2.2.0 or later")
-# If we're not running at least python 2.3, define True and False
+# If we're not running at least python 2.2.1, define True, False, and bool.
# Thanks, Guido, for the code.
try:
- True, False
+ True, False, bool
except NameError:
False = 0
True = 1
+ def bool(x):
+ if x:
+ return True
+ else:
+ return False
# Are we running under pychecker?
_RUNNING_PYCHECKER = 'pychecker.python' in sys.modules
@@ -219,7 +224,7 @@ class FlagsError(Exception):
"""The base class for all flags errors"""
class DuplicateFlag(FlagsError):
- """"Raised if there is a flag naming conflict"""
+ """Raised if there is a flag naming conflict"""
# A DuplicateFlagError conveys more information than
# a DuplicateFlag. Since there are external modules
@@ -519,7 +524,13 @@ class FlagValues:
flag_values: registry to copy from
"""
for flag_name, flag in flag_values.FlagDict().iteritems():
- self[flag_name] = flag
+ # Flags with shortnames will appear here twice (once with under
+ # its normal name, and again with its short name). To prevent
+ # problems (DuplicateFlagError) that occur when doubly
+ # registering flags, we perform a check to make sure that the
+ # entry we're looking at is for its normal name.
+ if flag_name == flag.name:
+ self[flag_name] = flag
def __setitem__(self, name, flag):
"""
@@ -1103,7 +1114,6 @@ class Flag:
def __init__(self, parser, serializer, name, default, help_string,
short_name=None, boolean=0, allow_override=0):
self.name = name
- self.default = default
if not help_string:
help_string = '(no help available)'
@@ -1117,17 +1127,7 @@ class Flag:
self.allow_override = allow_override
self.value = None
- # We can't allow a None override because it may end up not being
- # passed to C++ code when we're overriding C++ flags. So we
- # cowardly bail out until someone fixes the semantics of trying to
- # pass None to a C++ flag. See swig_flags.Init() for details on
- # this behavior.
- if default is None and allow_override:
- raise DuplicateFlag, name
-
- self.Unparse()
-
- self.default_as_str = self.__GetParsedValueAsString(self.value)
+ self.SetDefault(default)
def __GetParsedValueAsString(self, value):
if value is None:
@@ -1172,13 +1172,17 @@ class Flag:
"""
Change the default value, and current value, of this flag object
"""
- if value is not None: # See __init__ for logic details
- self.Parse(value)
- self.present -= 1 # reset .present after parsing new default value
- else:
- self.value = None
+ # We can't allow a None override because it may end up not being
+ # passed to C++ code when we're overriding C++ flags. So we
+ # cowardly bail out until someone fixes the semantics of trying to
+ # pass None to a C++ flag. See swig_flags.Init() for details on
+ # this behavior.
+ if value is None and self.allow_override:
+ raise DuplicateFlag, self.name
+
self.default = value
- self.default_as_str = self.__GetParsedValueAsString(value)
+ self.Unparse()
+ self.default_as_str = self.__GetParsedValueAsString(self.value)
# End of Flag definition
class ArgumentParser:
@@ -1284,14 +1288,21 @@ class BooleanParser(ArgumentParser):
def Convert(self, argument):
"""
- convert the argument to a boolean (integer); raise ValueError on errors
+ convert the argument to a boolean; raise ValueError on errors
"""
if type(argument) == str:
if argument.lower() in ['true', 't', '1']:
- return 1
+ return True
elif argument.lower() in ['false', 'f', '0']:
- return 0
- return int(argument)
+ return False
+
+ bool_argument = bool(argument)
+ if argument == bool_argument:
+ # The argument is a valid boolean (True, False, 0, or 1), and not just
+ # something that always converts to bool (list, string, int, etc.).
+ return bool_argument
+
+ raise ValueError('Non-boolean argument to boolean flag', argument)
def Parse(self, argument):
val = self.Convert(argument)
@@ -1300,7 +1311,7 @@ class BooleanParser(ArgumentParser):
class BooleanFlag(Flag):
"""
A basic boolean flag. Boolean flags do not take any arguments, and
- their value is either 0 (false) or 1 (true). The false value is
+ their value is either True (1) or False (0). The false value is
specified on the command line by prepending the word 'no' to either
the long or short flag name.
@@ -1319,7 +1330,7 @@ def DEFINE_boolean(name, default, help, flag_values=FLAGS, **args):
If a user wants to specify a false value explicitly, the long option
beginning with 'no' must be used: i.e. --noflag
- This flag will have a value of None, 0 or 1. None is possible if
+ This flag will have a value of None, True or False. None is possible if
default=None and the user does not specify the flag on the command
line.
"""
diff --git a/python/gflags_unittest.py b/python/gflags_unittest.py
index c574070..1661440 100755
--- a/python/gflags_unittest.py
+++ b/python/gflags_unittest.py
@@ -44,14 +44,50 @@ import unittest
import gflags as flags
FLAGS=flags.FLAGS
-# If we're not running at least python 2.3, as is the case when
-# invoked from flags_unittest_2_2, define True and False.
-# Thanks, Guido, for the code.
-try:
- True, False
-except NameError:
- False = 0
- True = 1
+def MultiLineEqual(expected_help, help):
+ """Returns True if expected_help == help. Otherwise returns False
+ and logs the difference in a human-readable way.
+ """
+ if help == expected_help:
+ return True
+
+ print "Error: FLAGS.MainModuleHelp() didn't return the expected result."
+ print "Got:"
+ print help
+ print "[End of got]"
+
+ help_lines = help.split('\n')
+ expected_help_lines = expected_help.split('\n')
+
+ num_help_lines = len(help_lines)
+ num_expected_help_lines = len(expected_help_lines)
+
+ if num_help_lines != num_expected_help_lines:
+ print "Number of help lines = %d, expected %d" % (
+ num_help_lines, num_expected_help_lines)
+
+ num_to_match = min(num_help_lines, num_expected_help_lines)
+
+ for i in range(num_to_match):
+ if help_lines[i] != expected_help_lines[i]:
+ print "One discrepancy: Got:"
+ print help_lines[i]
+ print "Expected:"
+ print expected_help_lines[i]
+ break
+ else:
+ # If we got here, found no discrepancy, print first new line.
+ if num_help_lines > num_expected_help_lines:
+ print "New help line:"
+ print help_lines[num_expected_help_lines]
+ elif num_expected_help_lines > num_help_lines:
+ print "Missing expected help line:"
+ print expected_help_lines[num_help_lines]
+ else:
+ print "Bug in this test -- discrepancy detected but not found."
+
+ return False
+
class FlagsUnitTest(unittest.TestCase):
"Flags Unit Test"
@@ -551,6 +587,20 @@ class FlagsUnitTest(unittest.TestCase):
self.assertEqual("new1" in FLAGS.FlagDict(), True)
self.assertEqual("new2" in FLAGS.FlagDict(), True)
+ # Make sure AppendFlagValues works with flags with shortnames.
+ new_flags = flags.FlagValues()
+ flags.DEFINE_boolean("new3", 0, "runhelp n3", flag_values=new_flags)
+ flags.DEFINE_boolean("new4", 0, "runhelp n4", flag_values=new_flags,
+ short_name="n4")
+ self.assertEqual(len(new_flags.FlagDict()), 3)
+ old_len = len(FLAGS.FlagDict())
+ FLAGS.AppendFlagValues(new_flags)
+ self.assertEqual(len(FLAGS.FlagDict())-old_len, 3)
+ self.assertTrue("new3" in FLAGS.FlagDict())
+ self.assertTrue("new4" in FLAGS.FlagDict())
+ self.assertTrue("n4" in FLAGS.FlagDict())
+ self.assertEqual(FLAGS.FlagDict()['n4'], FLAGS.FlagDict()['new4'])
+
# Make sure AppendFlagValues fails on duplicates
flags.DEFINE_boolean("dup4", 0, "runhelp d41")
new_flags = flags.FlagValues()
@@ -586,12 +636,19 @@ class FlagsUnitTest(unittest.TestCase):
except flags.FlagsError:
pass
- # Argument erroneously supplied for boolean
+ # Non-boolean arguments for boolean
try:
argv = ('./program', '--debug=goofup')
FLAGS(argv)
- raise AssertionError("No argument allowed exception not raised")
- except flags.FlagsError:
+ raise AssertionError("Illegal flag value exception not raised")
+ except flags.IllegalFlagValue:
+ pass
+
+ try:
+ argv = ('./program', '--debug=42')
+ FLAGS(argv)
+ raise AssertionError("Illegal flag value exception not raised")
+ except flags.IllegalFlagValue:
pass
@@ -667,12 +724,14 @@ class FlagsUnitTest(unittest.TestCase):
flags.DEFINE_boolean('UnitTestBoolFlag', 0, 'Some Boolean thing')
flags.DEFINE_integer('UnitTestNumber', 12345, 'Some integer',
lower_bound=0)
+ flags.DEFINE_list('UnitTestList', "1,2,3", 'Some list')
def _UndeclareSomeFlags(self):
FLAGS.__delattr__('UnitTestMessage1')
FLAGS.__delattr__('UnitTestMessage2')
FLAGS.__delattr__('UnitTestBoolFlag')
FLAGS.__delattr__('UnitTestNumber')
+ FLAGS.__delattr__('UnitTestList')
#### Flagfile Unit Tests ####
def testMethod_flagfiles_1(self):
@@ -825,6 +884,13 @@ class FlagsUnitTest(unittest.TestCase):
FLAGS([ 'dummyscript', '--UnitTestBoolFlag=true' ])
self.assertEqual(FLAGS.UnitTestBoolFlag, True)
+ # Test that setting a list default works correctly.
+ FLAGS['UnitTestList'].SetDefault('4,5,6')
+ self.assertEqual(FLAGS.UnitTestList, ['4', '5', '6'])
+ self.assertEqual(FLAGS['UnitTestList'].default_as_str, "'4,5,6'")
+ FLAGS([ 'dummyscript', '--UnitTestList=7,8,9' ])
+ self.assertEqual(FLAGS.UnitTestList, ['7', '8', '9'])
+
# Test that setting invalid defaults raises exceptions
self.assertRaises(flags.IllegalFlagValue,
FLAGS['UnitTestNumber'].SetDefault, 'oops')
@@ -1120,42 +1186,7 @@ class FlagsUnitTest(unittest.TestCase):
-z,--[no]zoom1: runhelp z1
(default: 'false')"""
- if help != expected_help:
- print "Error: FLAGS.MainModuleHelp() didn't return the expected result."
- print "Got:"
- print help
- print "[End of got]"
-
- help_lines = help.split('\n')
- expected_help_lines = expected_help.split('\n')
-
- num_help_lines = len(help_lines)
- num_expected_help_lines = len(expected_help_lines)
-
- if num_help_lines != num_expected_help_lines:
- print "Number of help lines = %d, expected %d" % (
- num_help_lines, num_expected_help_lines)
-
- num_to_match = min(num_help_lines, num_expected_help_lines)
-
- for i in range(num_to_match):
- if help_lines[i] != expected_help_lines[i]:
- print "One discrepancy: Got:"
- print help_lines[i]
- print "Expected:"
- print expected_help_lines[i]
- break
- else:
- # If we got here, found no discrepancy, print first new line.
- if num_help_lines > num_expected_help_lines:
- print "New help line:"
- print help_lines[num_expected_help_lines]
- elif num_expected_help_lines > num_help_lines:
- print "Missing expected help line:"
- print expected_help_lines[num_help_lines]
- else:
- print "Bug in this test -- discrepancy detected but not found."
-
+ if not MultiLineEqual(expected_help, help):
self.fail()
def test_create_flag_errors(self):
diff --git a/src/gflags.cc b/src/gflags.cc
index 78aad91..3d4881a 100644
--- a/src/gflags.cc
+++ b/src/gflags.cc
@@ -32,7 +32,61 @@
// Revamped and reorganized by Craig Silverstein
//
// This file contains the implementation of all our command line flags
-// stuff.
+// stuff. Here's how everything fits together
+//
+// * FlagRegistry owns CommandLineFlags owns FlagValue.
+// * FlagSaver holds a FlagRegistry (saves it at construct time,
+// restores it at destroy time).
+// * CommandLineFlagParser lives outside that hierarchy, but works on
+// CommandLineFlags (modifying the FlagValues).
+// * Free functions like SetCommandLineOption() work via one of the
+// above (such as CommandLineFlagParser).
+//
+// In more detail:
+//
+// -- The main classes that hold flag data:
+//
+// FlagValue holds the current value of a flag. It's
+// pseudo-templatized: every operation on a FlagValue is typed. It
+// also deals with storage-lifetime issues (so flag values don't go
+// away in a destructor), which is why we need a whole class to hold a
+// variable's value.
+//
+// CommandLineFlag is all the information about a single command-line
+// flag. It has a FlagValue for the flag's current value, but also
+// the flag's name, type, etc.
+//
+// FlagRegistry is a collection of CommandLineFlags. There's the
+// global registry, which is where flags defined via DEFINE_foo()
+// live. But it's possible to define your own flag, manually, in a
+// different registry you create. (In practice, multiple registries
+// are used only by FlagSaver).
+//
+// A given FlagValue is owned by exactly one CommandLineFlag. A given
+// CommandLineFlag is owned by exactly one FlagRegistry. FlagRegistry
+// has a lock; any operation that writes to a FlagValue or
+// CommandLineFlag owned by that registry must acquire the
+// FlagRegistry lock before doing so.
+//
+// --- Some other classes and free functions:
+//
+// CommandLineFlagInfo is a client-exposed version of CommandLineFlag.
+// Once it's instantiated, it has no dependencies or relationships
+// with any other part of this file.
+//
+// FlagRegisterer is the helper class used by the DEFINE_* macros to
+// allow work to be done at global initialization time.
+//
+// CommandLineFlagParser is the class that reads from the commandline
+// and instantiates flag values based on that. It needs to poke into
+// the innards of the FlagValue->CommandLineFlag->FlagRegistry class
+// hierarchy to do that. It's careful to acquire the FlagRegistry
+// lock before doing any writing or other non-const actions.
+//
+// GetCommandLineOption is just a hook into registry routines to
+// retrieve a flag based on its name. SetCommandLineOption, on the
+// other hand, hooks into CommandLineFlagParser. Other API functions
+// are, similarly, mostly hooks into the functionality described above.
#include "config.h"
#include // for snprintf
@@ -42,6 +96,7 @@
#include
#include
#include
+#include // for cerr
#include
#include