FreeCalypso > hg > fc-selenite
annotate helpers/build-date.c @ 159:e8853af07f45
configure-tms470.sh: j100 target in m0-to-bin selection
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 17 Mar 2019 07:22:30 +0000 |
parents | f8fb2995eb3f |
children |
rev | line source |
---|---|
11
b493d3857f4e
helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
b493d3857f4e
helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * This program runs at firmware build time to produce a C file for the |
b493d3857f4e
helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * fw build that includes the build date and time stamp. |
b493d3857f4e
helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 */ |
b493d3857f4e
helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 |
b493d3857f4e
helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <stdio.h> |
b493d3857f4e
helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <stdlib.h> |
138
f8fb2995eb3f
helpers/build-date.c: extended like in Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
12
diff
changeset
|
8 #include <string.h> |
f8fb2995eb3f
helpers/build-date.c: extended like in Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
12
diff
changeset
|
9 #include <strings.h> |
11
b493d3857f4e
helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 #include <time.h> |
b493d3857f4e
helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 |
b493d3857f4e
helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 main(argc, argv) |
b493d3857f4e
helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 char **argv; |
b493d3857f4e
helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 { |
b493d3857f4e
helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 time_t now; |
b493d3857f4e
helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 struct tm *tm; |
b493d3857f4e
helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 |
138
f8fb2995eb3f
helpers/build-date.c: extended like in Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
12
diff
changeset
|
18 if (argc < 2 || argc > 4) { |
f8fb2995eb3f
helpers/build-date.c: extended like in Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
12
diff
changeset
|
19 fprintf(stderr, |
f8fb2995eb3f
helpers/build-date.c: extended like in Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
12
diff
changeset
|
20 "usage: %s config_name target_name src_version\n", |
f8fb2995eb3f
helpers/build-date.c: extended like in Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
12
diff
changeset
|
21 argv[0]); |
11
b493d3857f4e
helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 exit(1); |
b493d3857f4e
helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 } |
b493d3857f4e
helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 time(&now); |
b493d3857f4e
helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 tm = gmtime(&now); |
b493d3857f4e
helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 printf("const char firmware_version_str[] =\n"); |
138
f8fb2995eb3f
helpers/build-date.c: extended like in Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
12
diff
changeset
|
27 if (argc >= 3) |
f8fb2995eb3f
helpers/build-date.c: extended like in Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
12
diff
changeset
|
28 printf("\"FreeCalypso Selenite %s (%s), ", argv[1], argv[2]); |
f8fb2995eb3f
helpers/build-date.c: extended like in Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
12
diff
changeset
|
29 else |
f8fb2995eb3f
helpers/build-date.c: extended like in Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
12
diff
changeset
|
30 printf("\"FreeCalypso Selenite %s, ", argv[1]); |
f8fb2995eb3f
helpers/build-date.c: extended like in Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
12
diff
changeset
|
31 if (argc >= 4 && strcmp(argv[3], "unknown")) |
f8fb2995eb3f
helpers/build-date.c: extended like in Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
12
diff
changeset
|
32 printf("source version %s, ", argv[3]); |
11
b493d3857f4e
helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 printf("build date %d-%02d-%02dT%02d:%02d:%02dZ\";\n", |
b493d3857f4e
helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday, |
b493d3857f4e
helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 tm->tm_hour, tm->tm_min, tm->tm_sec); |
b493d3857f4e
helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 exit(0); |
b493d3857f4e
helpers: initial import from Magnetite (pruned)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 } |