ccbuild - A strict developer's build utility - Moving to ccbuild

[ previous ] [ Contents ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] [ A ] [ B ] [ next ]

# `ccbuild` - A strict developer's build utility
Chapter 4 - Moving to `ccbuild`

To be able to use `ccbuild`, you as a developer will have to adhere to some strict(er) rules then using something like autotools. Here is a list of things you should keep in mind when moving to `ccbuild`.

## 4.1 Strictness to adhere to

- `ccbuild` only reads local includes

  When creating your source, make sure that all sources that `ccbuild` should care about can be found using local includes. This means you should strictly use system wide includes only for actual system wide include files. So any header file which is part or your packages should be included using a local include statement.

- Preprocessing isn't helping

  To speed up `ccbuild`, it does not go around looking for system wide headers. This also means that it won't know all the preprocessing directives from these headers. This results in preprocessor excludes of local headers cannot be used. This is no problem if you are compiling for a single platform, but when you need configuration using preprocessor directives, you're going to get into trouble.

  The only way to keep `ccbuild` from reading these sources is by making sure there is a single space between the `#` and the `include` statement. So the include `# include "something/hello.hh"` will be ignored by `ccbuild`. To test this, run `ccbuild` in verbose mode (`--verbose`) and watch for the warning which state that the file in not included. You can also use the `deps` command to get a list for all binary targets.

## 4.2 Setting up your configuration file

To set up your ccResolutions file, it's best to do the following steps:

1. Check your local includes span over your whole source

   To make sure `ccbuild` was able to follow your local includes, use the `deps` command. This will list all the local and global dependencies of a file. You may also use the dot command to get a graphical interpretation of the same information.

   All paths that `ccbuild` needs to search for local includes should be added to the first line of your ccResolutions file. Using `-l` in this first line will make `ccbuild` highlight all compiler output.

            	#& -I../tools -I. -l

2. Add packages to your global ccResolutions

   You can add a package to your global resolution configuration using the genPkgconfigList.sh tool. This will find all files in the include path of a package's include paths and add them to a resolution file. See the Tools section for more information.

3. Check the global includes are resolved

   To make sure the global includes are resolved, use the resolve command.

            	ccbuild resolve |sort >> ccResolutions

   Now all unresolved global headers are listed in your ccResolutions file. When you run `ccbuild` now, it won't complain about any global includes missing. However, g++ might complain because the needed extra arguments are not in place. You should now add the needed arguments to your ccResolutions file by using, for example, ``pkg-config --cflags --libs <packagename>`` with the needed package in place.

   If you have a lot of resolution rules in your defaults (`~/.ccbuild/`), then it might be hard to see what your project actually depends on. Passing `ccbuild` the option `--nodefres` will cause it to skip loading these files and will allow you to see which resolutions fail. This might give you some hints on what packages your program depends on.

[ previous ] [ Contents ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] [ A ] [ B ] [ next ]

`ccbuild` - A strict developer's build utility