git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 1/2] git version --build-options: report the build platform, too

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 8, 2017, 17:43 UTC
Message-ID
<xmqq374l9kti.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<20171208172324.GB14261@aiede.mtv.corp.google.com>
Jonathan Nieder <jrnieder@gmail.com> writes:
Show 18 quoted lines
>> @@ -390,6 +390,7 @@ const char *help_unknown_cmd(const char *cmd)
>>  
>>  int cmd_version(int argc, const char **argv, const char *prefix)
>>  {
>> +	static char build_platform[] = GIT_BUILD_PLATFORM;
>>  	int build_options = 0;
>>  	const char * const usage[] = {
>>  		N_("git version [<options>]"),
>> @@ -413,6 +414,7 @@ int cmd_version(int argc, const char **argv, const char *prefix)
>>  
>>  	if (build_options) {
>>  		printf("sizeof-long: %d\n", (int)sizeof(long));
>> +		printf("machine: %s\n", build_platform);
>
> Can this use GIT_BUILD_PLATFORM directly instead of going via the indirection
> of a mutable static string?  That is, something like
>
> 		printf("machine: %s\n", GIT_BUILD_PLATFORM);

Good point. And if this is externally identified as "machine", probably the macro should also use the same word, not "platform". We can go either way, as long as we are consistent, though.

Show 21 quoted lines
>> --- a/help.h
>> +++ b/help.h
>> @@ -33,3 +33,16 @@ extern void list_commands(unsigned int colopts, struct cmdnames *main_cmds, stru
>>   */
>>  extern void help_unknown_ref(const char *ref, const char *cmd, const char *error);
>>  #endif /* HELP_H */
>> +
>> +/*
>> + * identify build platform
>> + */
>> +#ifndef GIT_BUILD_PLATFORM
>> +	#if defined __x86__ || defined __i386__ || defined __i586__ || defined __i686__
>> +		#define GIT_BUILD_PLATFORM "x86"
>> +	#elif defined __x86_64__
>> +		#define GIT_BUILD_PLATFORM "x86_64"
>> +	#else
>> +		#define GIT_BUILD_PLATFORM "unknown"
>> +	#endif
>> +#endif
>
> This code needs to be inside the HELP_H header guard.
Certainly.
Thanks.
Previous: Jonathan NiederNext: Eric Sunshine
Message 4 of 19 in “Offer more information in `git version --build-options`'s output”
  1. 0/2 Offer more information in `git version --build-options`'s outputJohannes Schindelin, Dec 8, 2017
  2. 1/2 git version --build-options: report the build platform, tooJohannes Schindelin, Dec 8, 2017
  3. Jonathan NiederDec 8, 2017
  4. Junio C HamanoDec 8, 2017
  5. Eric SunshineDec 8, 2017
  6. Eric SunshineDec 8, 2017
  7. Eric SunshineDec 9, 2017
  8. Johannes SchindelinDec 9, 2017
  9. 2/2 version --build-options: report commit, too, if possibleJohannes Schindelin, Dec 8, 2017
  10. Jonathan NiederDec 8, 2017
  11. Junio C HamanoDec 8, 2017
  12. Johannes SchindelinDec 14, 2017
  13. Johannes SchindelinDec 14, 2017
  14. 0/2 Offer more information in `git version --build-options`'s outputJohannes Schindelin, Dec 14, 2017
  15. 1/2 version --build-options: also report host CPUJohannes Schindelin, Dec 14, 2017
  16. 2/2 version --build-options: report commit, too, if possibleJohannes Schindelin, Dec 14, 2017
  17. Junio C HamanoDec 15, 2017
  18. Eric SunshineDec 15, 2017
  19. Junio C HamanoDec 15, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.