从源文件中提取版本号
在build软件的过程中,经常需要版本号(比如打标签,压缩包的时候),从代码中获取是最好的方法,shell命令就可以做到,比如代码中有这样的语句:
version = "1.0.2"
可以用这样的命令截取下来:
grep "version\s*=" sourcefile | cut -d \" -f 2
如果是在makefile中,就可以赋值给变量了:
VERSION := $(shell grep "version\s*=" sourcefile | cut -d \" -f 2)
version = "1.0.2"
可以用这样的命令截取下来:
grep "version\s*=" sourcefile | cut -d \" -f 2
如果是在makefile中,就可以赋值给变量了:
VERSION := $(shell grep "version\s*=" sourcefile | cut -d \" -f 2)

0 Comments:
发表评论
<< Home