mirror of
				https://github.com/privacore/open-source-search-engine.git
				synced 2025-10-31 16:36:13 -04:00 
			
		
		
		
	
		
			
				
	
	
		
			70 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			70 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
| 
 | |
| // automated versioning for gigablast
 | |
| #include <stdio.h>
 | |
| #include "Mem.h"
 | |
| #include "Log.h"
 | |
| #include "Process.h"
 | |
| #include <string.h>
 | |
| 
 | |
| #ifndef STRINGIFY
 | |
| #define STRINGIFY(x) #x
 | |
| #define TO_STRING(x) STRINGIFY(x)
 | |
| #endif
 | |
| 
 | |
| #ifndef GIT_COMMIT_ID
 | |
| #define GIT_COMMIT_ID unknown
 | |
| #endif
 | |
| 
 | |
| #ifndef GIT_BRANCH
 | |
| #define GIT_BRANCH unknown
 | |
| #endif
 | |
| 
 | |
| #ifndef BUILD_CONFIG
 | |
| #define BUILD_CONFIG unknown
 | |
| #endif
 | |
| 
 | |
| static char s_vbuf[32];
 | |
| 
 | |
| // includes \0
 | |
| // "Sep 19 2014 12:10:58\0"
 | |
| unsigned getVersionSize () {
 | |
| 	return 20 + 1;
 | |
| }
 | |
| 
 | |
| char *getVersion ( ) {
 | |
| 	static bool s_init = false;
 | |
| 	if ( s_init ) {
 | |
| 		return s_vbuf;
 | |
| 	}
 | |
| 
 | |
| 	sprintf(s_vbuf,"%s %s", __DATE__, __TIME__ );
 | |
| 	s_init = true;
 | |
| 
 | |
| 	// PingServer.cpp needs this exactly to be 24
 | |
| 	if ( strlen(s_vbuf) != getVersionSize() - 1 ) { 
 | |
| 		log( LOG_ERROR, "getVersion: %s %" PRId32" != %" PRId32, s_vbuf, (int32_t)strlen(s_vbuf), getVersionSize() - 1);
 | |
| 		g_process.shutdownAbort(true); 
 | |
| 	}
 | |
| 
 | |
| 	return s_vbuf;
 | |
| }
 | |
| 
 | |
| const char* getBuildConfig() {
 | |
| 	return TO_STRING(BUILD_CONFIG);
 | |
| }
 | |
| 
 | |
| const char* getCommitId() {
 | |
| 	return TO_STRING(GIT_COMMIT_ID);
 | |
| }
 | |
| 
 | |
| const char* getBranch() {
 | |
| 	return TO_STRING(GIT_BRANCH);
 | |
| }
 | |
| 
 | |
| void printVersion(const char *name) {
 | |
| 	fprintf(stdout,"%s Version      : %s\n", name, getVersion());
 | |
| 	fprintf(stdout,"%s Build config : %s\n", name, getBuildConfig());
 | |
| 	fprintf(stdout,"%s Git branch   : %s\n", name, getBranch());
 | |
| 	fprintf(stdout,"%s Git commit   : %s\n", name, getCommitId());
 | |
| }
 |