FreeCalypso > hg > fc-magnetite
comparison helpers/build-date.c @ 577:adf7a4281fd7
helpers/build-date.c: added support for including source version ID
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 27 Jan 2019 22:35:04 +0000 |
parents | 074e24776948 |
children |
comparison
equal
deleted
inserted
replaced
576:3cb2ce6e996a | 577:adf7a4281fd7 |
---|---|
3 * fw build that includes the build date and time stamp. | 3 * fw build that includes the build date and time stamp. |
4 */ | 4 */ |
5 | 5 |
6 #include <stdio.h> | 6 #include <stdio.h> |
7 #include <stdlib.h> | 7 #include <stdlib.h> |
8 #include <string.h> | |
9 #include <strings.h> | |
8 #include <time.h> | 10 #include <time.h> |
9 | 11 |
10 main(argc, argv) | 12 main(argc, argv) |
11 char **argv; | 13 char **argv; |
12 { | 14 { |
13 time_t now; | 15 time_t now; |
14 struct tm *tm; | 16 struct tm *tm; |
15 | 17 |
16 if (argc < 2 || argc > 3) { | 18 if (argc < 2 || argc > 4) { |
17 fprintf(stderr, "usage: %s config_name [target_name]\n", | 19 fprintf(stderr, |
20 "usage: %s config_name target_name src_version\n", | |
18 argv[0]); | 21 argv[0]); |
19 exit(1); | 22 exit(1); |
20 } | 23 } |
21 time(&now); | 24 time(&now); |
22 tm = gmtime(&now); | 25 tm = gmtime(&now); |
23 printf("const char firmware_version_str[] =\n"); | 26 printf("const char firmware_version_str[] =\n"); |
24 if (argv[2]) | 27 if (argc >= 3) |
25 printf("\"FreeCalypso Magnetite %s (%s), ", argv[1], argv[2]); | 28 printf("\"FreeCalypso Magnetite %s (%s), ", argv[1], argv[2]); |
26 else | 29 else |
27 printf("\"FreeCalypso Magnetite %s, ", argv[1]); | 30 printf("\"FreeCalypso Magnetite %s, ", argv[1]); |
31 if (argc >= 4 && strcmp(argv[3], "unknown")) | |
32 printf("source version %s, ", argv[3]); | |
28 printf("build date %d-%02d-%02dT%02d:%02d:%02dZ\";\n", | 33 printf("build date %d-%02d-%02dT%02d:%02d:%02dZ\";\n", |
29 tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday, | 34 tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday, |
30 tm->tm_hour, tm->tm_min, tm->tm_sec); | 35 tm->tm_hour, tm->tm_min, tm->tm_sec); |
31 exit(0); | 36 exit(0); |
32 } | 37 } |