FreeCalypso > hg > fc-tourmaline
comparison helpers/build-date.c @ 9:1fb47f5b597a
helpers: import from Magnetite
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 16 Oct 2020 07:01:13 +0000 |
parents | |
children | 775dba605f33 |
comparison
equal
deleted
inserted
replaced
8:99ae5bf8cab5 | 9:1fb47f5b597a |
---|---|
1 /* | |
2 * This program runs at firmware build time to produce a C file for the | |
3 * fw build that includes the build date and time stamp. | |
4 */ | |
5 | |
6 #include <stdio.h> | |
7 #include <stdlib.h> | |
8 #include <string.h> | |
9 #include <strings.h> | |
10 #include <time.h> | |
11 | |
12 main(argc, argv) | |
13 char **argv; | |
14 { | |
15 time_t now; | |
16 struct tm *tm; | |
17 | |
18 if (argc < 2 || argc > 4) { | |
19 fprintf(stderr, | |
20 "usage: %s config_name target_name src_version\n", | |
21 argv[0]); | |
22 exit(1); | |
23 } | |
24 time(&now); | |
25 tm = gmtime(&now); | |
26 printf("const char firmware_version_str[] =\n"); | |
27 if (argc >= 3) | |
28 printf("\"FreeCalypso Magnetite %s (%s), ", argv[1], argv[2]); | |
29 else | |
30 printf("\"FreeCalypso Magnetite %s, ", argv[1]); | |
31 if (argc >= 4 && strcmp(argv[3], "unknown")) | |
32 printf("source version %s, ", argv[3]); | |
33 printf("build date %d-%02d-%02dT%02d:%02d:%02dZ\";\n", | |
34 tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday, | |
35 tm->tm_hour, tm->tm_min, tm->tm_sec); | |
36 exit(0); | |
37 } |