Skip to content

Commit 7cba176

Browse files
landstander668Git for Windows Build Agent
authored andcommitted
Preliminary support for reporting build platform
Add preliminary support for detection of the build plaform, and reporting of same with the `git version --build-options' command. This can be useful for bug reporting, to distinguish between 32 and 64-bit builds for example. The current implementation can only distinguish between x86 and x86_64. This will be extended in future patches. In addition, all 32-bit variants (i686, i586, etc.) are collapsed into `x86'. An example of the output is: $ git version --build-options git version 2.9.3.windows.2.826.g06c0f2f sizeof-long: 4 machine: x86_64 The label of `machine' was chosen so the new information will approximate the output of `uname -m'. Signed-off-by: Adric Norris <[email protected]>
1 parent da2819d commit 7cba176

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

help.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,7 @@ const char *help_unknown_cmd(const char *cmd)
390390

391391
int cmd_version(int argc, const char **argv, const char *prefix)
392392
{
393+
static char build_platform[] = GIT_BUILD_PLATFORM;
393394
int build_options = 0;
394395
const char * const usage[] = {
395396
N_("git version [<options>]"),
@@ -413,6 +414,7 @@ int cmd_version(int argc, const char **argv, const char *prefix)
413414

414415
if (build_options) {
415416
printf("sizeof-long: %d\n", (int)sizeof(long));
417+
printf("machine: %s\n", build_platform);
416418
/* NEEDSWORK: also save and output GIT-BUILD_OPTIONS? */
417419
}
418420
return 0;

help.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,16 @@ extern void list_commands(unsigned int colopts, struct cmdnames *main_cmds, stru
3333
*/
3434
extern void help_unknown_ref(const char *ref, const char *cmd, const char *error);
3535
#endif /* HELP_H */
36+
37+
/*
38+
* identify build platform
39+
*/
40+
#ifndef GIT_BUILD_PLATFORM
41+
#if defined __x86__ || defined __i386__ || defined __i586__ || defined __i686__
42+
#define GIT_BUILD_PLATFORM "x86"
43+
#elif defined __x86_64__
44+
#define GIT_BUILD_PLATFORM "x86_64"
45+
#else
46+
#define GIT_BUILD_PLATFORM "unknown"
47+
#endif
48+
#endif

0 commit comments

Comments
 (0)