开发者

How to write a build script for a C++ project

开发者 https://www.devze.com 2022-12-29 19:11 出处:网络
I am developing a C++ application on Ubuntu. The application consists of several modules, each with its makefile.

I am developing a C++ application on Ubuntu. The application consists of several modules, each with its makefile.

I want to have a customised comma开发者_如何转开发nd line build process that does the following:

  1. checks code out from a repository (for specified branch/tag)
  2. builds the app (release or debug as specified)
  3. logs any errors etc

I am too lazy to learn Perl (I tried before, but cant seem to get my head around it). Are there any (preferably open source) tools anyone can suggest, or maybe a simpler scripting languuage - or do I really have to learn Perl?


Have a look at Hudson (or any other Continuous Integration tool).


You could try out Scons. It is pretty straightforward if you know a little Python (and if you don't Python is pretty easy to pick up).


A shell script should do for your immediate needs.

bash is pretty powerful, and I think that's what I would use.


You can use GNU make for that.
Basically, something like:

all: update compile

update:
    svn update

compile:
    gcc ...

The target all depends on update (which updates the working copy from the repository), and on compile, which will be the target for compiling your code.

You can also use a variable to specify the compile type (debug or release), that you will use to change the way your files are compiled.
Make variables can be overrided from the commande line, when you invoke make.
So for instance, "make" will build the debug version, and "make TYPE=release" will build the release version, assuming you defined a variable named "TYPE" for that. the targets.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号