Re: [PATCH 11/13] Makefile: auto-build C strings from make variables
Jeff King p...@peff.net writes: diff --git a/script/mkcstring b/script/mkcstring new file mode 100644 index 000..c01f430 --- /dev/null +++ b/script/mkcstring @@ -0,0 +1,18 @@ +#!/bin/sh + +name=$1; shift + +c_quote() { + sed 's/\\//g; s//\\/' No 'g' for the second one? +} + +cat -EOF +#ifndef MAKE_${name}_H +#define MAKE_${name}_H + +/* Auto-generated by mkcstring */ + +#define MAKE_${name} $(c_quote) + +#endif /* MAKE_${name}_H */ +EOF diff --git a/version.c b/version.c index 6106a80..f68a93b 100644 --- a/version.c +++ b/version.c @@ -1,8 +1,10 @@ #include git-compat-util.h #include version.h #include strbuf.h +#include MAKE/USER-AGENT-string.h +#include MAKE/VERSION-string.h -const char git_version_string[] = GIT_VERSION; +const char git_version_string[] = MAKE_VERSION; const char *git_user_agent(void) { @@ -11,7 +13,7 @@ const char *git_user_agent(void) if (!agent) { agent = getenv(GIT_USER_AGENT); if (!agent) - agent = GIT_USER_AGENT; + agent = MAKE_USER_AGENT; } return agent; -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 11/13] Makefile: auto-build C strings from make variables
On Wed, Feb 05, 2014 at 11:17:13AM -0800, Junio C Hamano wrote: Jeff King p...@peff.net writes: diff --git a/script/mkcstring b/script/mkcstring new file mode 100644 index 000..c01f430 --- /dev/null +++ b/script/mkcstring @@ -0,0 +1,18 @@ +#!/bin/sh + +name=$1; shift + +c_quote() { + sed 's/\\//g; s//\\/' No 'g' for the second one? That's a bug. Thanks for catching. I tested most of these changes manually, but I missed this one by only testing a value with a single quote. At one point I had introduced: $(eval $(call make-var,FOO,debug variable,$(FOO))) so you could do make MAKE/FOO and make MAKE/foo-string.c, but I did not include it in the series. Adding a test suite to our Makefile kind of seems like overkill, but as it gets complex, maybe some simple sanity checks are worthwhile (not part of the regular test suite, but maybe just a ./test-make script to make sure it behaves). I dunno. -Peff -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html