Message ID | 1362590578.1759.48.camel@joe-AO722 (mailing list archive) |
---|---|
State | Mainlined, archived |
Headers | show |
On Wed, Mar 6, 2013 at 9:22 AM, Joe Perches <joe@perches.com> wrote: > There's no current way to know the version > of sparse. Add --version to see it. Hi Joe, Thanks for the patch. I agree that this the "--version" switch has its value. However, I don't like using "die" to print out the version string. I see no reason why sparse should exit with error for printing out version string. For example, gcc does not do that. If you don't want to recompile lib.c every time, you can make a version.c to store the version string. Another thing is nice to have, but not required. You consider to give "--" its own handing function. It is bit odd seeing the "-version" mix with other switch command. The patch is simpler. Either way is fine with me. The exit code need to be fixed. I will apply the patch once you fix the exit code. Chris -- To unsubscribe from this list: send the line "unsubscribe linux-sparse" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Wed, Mar 06, 2013 at 09:22:58AM -0800, Joe Perches wrote: > --- a/Makefile > +++ b/Makefile > @@ -1,5 +1,12 @@ > VERSION=0.4.4 > > +HAVE_GIT:=$(shell git describe >/dev/null 2>&1 && echo 'yes') > +ifeq ($(HAVE_GIT),yes) > +SPARSE_VERSION=$(shell git describe) > +else > +SPARSE_VERSION=$(VERSION) > +endif > + The "dist" target already has a call to "git describe"; could you unify the two? (And, ideally, avoid calling git describe twice, once for HAVE_GIT and once for SPARSE_VERSION?) - Josh Triplett -- To unsubscribe from this list: send the line "unsubscribe linux-sparse" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Wed, 2013-03-06 at 13:45 -0800, Josh Triplett wrote: > On Wed, Mar 06, 2013 at 09:22:58AM -0800, Joe Perches wrote: > > --- a/Makefile > > +++ b/Makefile > > @@ -1,5 +1,12 @@ > > VERSION=0.4.4 > > > > +HAVE_GIT:=$(shell git describe >/dev/null 2>&1 && echo 'yes') > > +ifeq ($(HAVE_GIT),yes) > > +SPARSE_VERSION=$(shell git describe) > > +else > > +SPARSE_VERSION=$(VERSION) > > +endif > > + > > The "dist" target already has a call to "git describe"; could you unify > the two? (And, ideally, avoid calling git describe twice, once for > HAVE_GIT and once for SPARSE_VERSION?) I think the overhead is low and not worth the bother. Go for it if it bothers you. -- To unsubscribe from this list: send the line "unsubscribe linux-sparse" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/Makefile b/Makefile index b195528..8d2ffea 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,12 @@ VERSION=0.4.4 +HAVE_GIT:=$(shell git describe >/dev/null 2>&1 && echo 'yes') +ifeq ($(HAVE_GIT),yes) +SPARSE_VERSION=$(shell git describe) +else +SPARSE_VERSION=$(VERSION) +endif + OS = linux @@ -27,7 +34,8 @@ HAVE_LLVM_VERSION:=$(shell llvm-config --version | grep "^[3-9].*" >/dev/null 2> LLVM_VERSION=$(shell llvm-config --version) GCC_BASE = $(shell $(CC) --print-file-name=) -BASIC_CFLAGS = -DGCC_BASE=\"$(GCC_BASE)\" +BASIC_CFLAGS = -DGCC_BASE=\"$(GCC_BASE)\" \ + -DSPARSE_VERSION=\"$(SPARSE_VERSION)\" ifeq ($(HAVE_GCC_DEP),yes) BASIC_CFLAGS += -Wp,-MD,$(@D)/.$(@F).d @@ -160,7 +168,6 @@ install: all-installable sparse.pc: sparse.pc.in $(QUIET_GEN)sed $(SED_PC_CMD) sparse.pc.in > sparse.pc - compile_EXTRA_DEPS = compile-i386.o $(foreach p,$(PROGRAMS),$(eval $(p): $($(p)_EXTRA_DEPS) $(LIBS))) diff --git a/lib.c b/lib.c index 4f69e11..ddc9a93 100644 --- a/lib.c +++ b/lib.c @@ -646,6 +646,12 @@ static char **handle_base_dir(char *arg, char **next) return next; } +static char **handle_version(char *arg, char **next) +{ + die("%s", SPARSE_VERSION); + return next; +} + struct switches { const char *name; char **(*fn)(char *, char **); @@ -656,6 +662,7 @@ static char **handle_switch(char *arg, char **next) static struct switches cmd[] = { { "nostdinc", handle_nostdinc }, { "gcc-base-dir", handle_base_dir}, + { "-version", handle_version }, { NULL, NULL } }; struct switches *s;