Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automatic Version Incrementation in Eclipse CDT (C++)

Tags:

eclipse-cdt

Is there anyway to get Eclipse CDT to automatically increment your build version number every time you build your project? I can find solutions for ANT, but I understand that is only for Java projects.

like image 295
Tom Johnson Avatar asked Nov 05 '22 05:11

Tom Johnson


1 Answers

No, ANT isn't only for java projects. It is mainly used for them, but you are confusing ANT for maven. Ant can be used with GCC and such, but then you can't use the eclipse build system.

Actually, there are a few commands that you can use with ant (use this inside a target):

<delete file="buildnumber.h"/>
<buildnumber file="ant-build-number.n"/>
<echo file="buildnumber.h">
#ifndef BUILDNUMBER_H_
#define BUILDNUMBER_H_

#define BUILD_NUMBER ${build.number}

#endif
</echo>

This will create a file named buildnumber.h and ant-build-number.n. Don't touch ant-build-number.n (it includes the build number for future builds). Then you may include buildnumber.h.

You can also use the exec task to execute gcc (see http://ant.apache.org/manual/Tasks/exec.html)

like image 175
Sam Bloomberg Avatar answered Nov 09 '22 03:11

Sam Bloomberg