瀏覽代碼

Document BUILD_DATE compile option

bel2125 4 年之前
父節點
當前提交
d2eb405b3e
共有 2 個文件被更改,包括 14 次插入10 次删除
  1. 3 0
      docs/Building.md
  2. 11 10
      src/civetweb.c

+ 3 - 0
docs/Building.md

@@ -179,6 +179,9 @@ make build COPT="-DNDEBUG -DNO_CGI"
 | `SSL_ALREADY_INITIALIZED`    | do not initialize libcrypto                                         |
 | `OPENSSL_API_1_0`            | Use OpenSSL V1.0.x interface                                        |
 | `OPENSSL_API_1_1`            | Use OpenSSL V1.1.x interface                                        |
+|                              |                                                                     |
+| `BUILD_DATE`                 | define as a string to be used as build id instead of __DATE__       |
+|                              |                                                                     |
 
 
 Note: If `make` is used (with this [Makefile](https://github.com/civetweb/civetweb/blob/master/Makefile)), you should not pass the `USE_<feature>` flags using `COPT`, but use the `WITH_<feature>` syntax above, since additional features may also use additional source code files.

+ 11 - 10
src/civetweb.c

@@ -20811,29 +20811,30 @@ mg_get_system_info(char *buffer, int buflen)
 #endif
 	}
 
-	/* Build date */
+	/* Build identifier. If BUILD_DATE is not set, __DATE__ will be used. */
 	{
+#if defined(BUILD_DATE)
+		const char *bd = BUILD_DATE;
+#else
 #if defined(GCC_DIAGNOSTIC)
 #if GCC_VERSION >= 40900
 #pragma GCC diagnostic push
-/* Disable bogus compiler warning -Wdate-time, appeared in gcc5 */
+		/* Disable idiotic compiler warning -Wdate-time, appeared in gcc5. This does not
+		* work in some versions. If "BUILD_DATE" is defined to some string, it is used
+		* instead of __DATE__. */
 #pragma GCC diagnostic ignored "-Wdate-time"
 #endif
 #endif
-#if defined(BUILD_DATE)
-		const char *bd = BUILD_DATE;
-#else
 		const char *bd = __DATE__;
-#endif
-
-		mg_snprintf(
-		    NULL, NULL, block, sizeof(block), ",%s\"build\" : \"%s\"", eol, bd);
-
 #if defined(GCC_DIAGNOSTIC)
 #if GCC_VERSION >= 40900
 #pragma GCC diagnostic pop
 #endif
 #endif
+#endif
+
+		mg_snprintf(
+		    NULL, NULL, block, sizeof(block), ",%s\"build\" : \"%s\"", eol, bd);
 
 		system_info_length += mg_str_append(&buffer, end, block);
 	}