Fossil SCM

Add support for the FOSSIL_BUILD_EPOCH compile-time option. Ticket [99038b83b489dddb]

drh 2020-06-11 14:13 trunk
Commit 1a894c08206f4c71bcc37bc85a8525632ff45c2d677d1e0a0801ce56c578bfee
1 file changed +33
--- src/mkversion.c
+++ src/mkversion.c
@@ -4,10 +4,38 @@
44
** Call this program with three arguments:
55
**
66
** ./a.out manifest.uuid manifest VERSION
77
**
88
** Note that the manifest.uuid and manifest files are generated by Fossil.
9
+**
10
+** The output becomes the "VERSION.h" file. The output is a C-language
11
+** header that contains #defines for various properties of the build:
12
+**
13
+** MANIFEST_UUID These values are text strings that
14
+** MANIFEST_VERSION identify the Fossil check-in to which
15
+** the source tree belongs. They do not
16
+** take into account any uncommitted edits.
17
+**
18
+** FOSSIL_BUILD_HASH A hexadecimal string that is a strong hash
19
+** of the MANIFEST_UUID together with the
20
+** current time of the build. We normally want
21
+** this to be different on each build, as the
22
+** value is used to expire ETag: fields in
23
+** HTTP requests. But if you need to do
24
+** repeatable byte-for-byte identical builds,
25
+** add the -DFOSSIL_BUILD_EPOCH=n option.
26
+**
27
+** MANIFEST_DATE The date/time of the source-code check-in
28
+** MANIFEST_YEAR in various formats.
29
+** MANIFEST_NUMERIC_DATE
30
+** MANIFEST_NUMERIC_TIME
31
+**
32
+** RELEASE_VERSION The version number (from the VERSION source
33
+** RELEASE_VERSION_NUMBER file) in various format.
34
+** RELEASE_RESOURCE_VERSION
35
+**
36
+** New #defines may be added in the future.
937
*/
1038
#include <stdio.h>
1139
#include <string.h>
1240
#include <stdlib.h>
1341
#include <ctype.h>
@@ -79,11 +107,16 @@
79107
*z = 0;
80108
printf("#define MANIFEST_UUID \"%s\"\n",b);
81109
printf("#define MANIFEST_VERSION \"[%10.10s]\"\n",b);
82110
n = strlen(b);
83111
if( n + 50 < sizeof(b) ){
112
+#ifdef FOSSIL_BUILD_EPOCH
113
+#define str(s) #s
114
+ sprintf(b+n, "%d", (int)strtoll(str(FOSSIL_BUILD_EPOCH), 0, 10));
115
+#else
84116
sprintf(b+n, "%d", (int)time(0));
117
+#endif
85118
hash(b,33,vx);
86119
printf("#define FOSSIL_BUILD_HASH \"%s\"\n", vx);
87120
}
88121
m = open_for_reading(argv[2]);
89122
while(b == fgets(b, sizeof(b)-1,m)){
90123
--- src/mkversion.c
+++ src/mkversion.c
@@ -4,10 +4,38 @@
4 ** Call this program with three arguments:
5 **
6 ** ./a.out manifest.uuid manifest VERSION
7 **
8 ** Note that the manifest.uuid and manifest files are generated by Fossil.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9 */
10 #include <stdio.h>
11 #include <string.h>
12 #include <stdlib.h>
13 #include <ctype.h>
@@ -79,11 +107,16 @@
79 *z = 0;
80 printf("#define MANIFEST_UUID \"%s\"\n",b);
81 printf("#define MANIFEST_VERSION \"[%10.10s]\"\n",b);
82 n = strlen(b);
83 if( n + 50 < sizeof(b) ){
 
 
 
 
84 sprintf(b+n, "%d", (int)time(0));
 
85 hash(b,33,vx);
86 printf("#define FOSSIL_BUILD_HASH \"%s\"\n", vx);
87 }
88 m = open_for_reading(argv[2]);
89 while(b == fgets(b, sizeof(b)-1,m)){
90
--- src/mkversion.c
+++ src/mkversion.c
@@ -4,10 +4,38 @@
4 ** Call this program with three arguments:
5 **
6 ** ./a.out manifest.uuid manifest VERSION
7 **
8 ** Note that the manifest.uuid and manifest files are generated by Fossil.
9 **
10 ** The output becomes the "VERSION.h" file. The output is a C-language
11 ** header that contains #defines for various properties of the build:
12 **
13 ** MANIFEST_UUID These values are text strings that
14 ** MANIFEST_VERSION identify the Fossil check-in to which
15 ** the source tree belongs. They do not
16 ** take into account any uncommitted edits.
17 **
18 ** FOSSIL_BUILD_HASH A hexadecimal string that is a strong hash
19 ** of the MANIFEST_UUID together with the
20 ** current time of the build. We normally want
21 ** this to be different on each build, as the
22 ** value is used to expire ETag: fields in
23 ** HTTP requests. But if you need to do
24 ** repeatable byte-for-byte identical builds,
25 ** add the -DFOSSIL_BUILD_EPOCH=n option.
26 **
27 ** MANIFEST_DATE The date/time of the source-code check-in
28 ** MANIFEST_YEAR in various formats.
29 ** MANIFEST_NUMERIC_DATE
30 ** MANIFEST_NUMERIC_TIME
31 **
32 ** RELEASE_VERSION The version number (from the VERSION source
33 ** RELEASE_VERSION_NUMBER file) in various format.
34 ** RELEASE_RESOURCE_VERSION
35 **
36 ** New #defines may be added in the future.
37 */
38 #include <stdio.h>
39 #include <string.h>
40 #include <stdlib.h>
41 #include <ctype.h>
@@ -79,11 +107,16 @@
107 *z = 0;
108 printf("#define MANIFEST_UUID \"%s\"\n",b);
109 printf("#define MANIFEST_VERSION \"[%10.10s]\"\n",b);
110 n = strlen(b);
111 if( n + 50 < sizeof(b) ){
112 #ifdef FOSSIL_BUILD_EPOCH
113 #define str(s) #s
114 sprintf(b+n, "%d", (int)strtoll(str(FOSSIL_BUILD_EPOCH), 0, 10));
115 #else
116 sprintf(b+n, "%d", (int)time(0));
117 #endif
118 hash(b,33,vx);
119 printf("#define FOSSIL_BUILD_HASH \"%s\"\n", vx);
120 }
121 m = open_for_reading(argv[2]);
122 while(b == fgets(b, sizeof(b)-1,m)){
123

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button