編譯 binary 的時候自動加入 release version 與 date

Makefile 
1
2
3
4
SVN_VERSION = "\"`svn info | grep Revision | sed 's/Revision: //g'`\""
BUILD_TIME = "\"`date '+%Y/%m/%d %H:%M:%S'`\""
 
CFLAGS += -DSVN_VERSION=$(SVN_VERSION) -DBUILD_TIME=$(BUILD_TIME)

.c 檔 
1
2
3
4
void show_version (void)
{
    printf("SVN Version: %s, Bulid time: %s\n", SVN_VERSION, BUILD_TIME);
}
Preprocessing 的時候 macro 會自動被帶換掉啦!
 
 
reference: http://blog.yslin.tw/2012/03/binary-release-version-date.html

留言

這個網誌中的熱門文章

NMEA標準格式 -- GPS

網路 Transformer 的用途

cut,sed,awk 字串處理