Reminder: Look at <file:/home/jake/CSC/index.html> for updates or corrections!
Goal: An introduction to a release build tool
First, create a local copy of the exercise files.
cd
tar xf ~jake/CSC/exercise9.tar
cd exercise9
source setup.sh
Now we’ll create a very simple package, and explore its structure. We’ll start by creating a “test” package, and version “v1-0” of it:
cmt create test v1-0
This creates a “test” directory for the package, with a “v1-0” subdirectory for that version:
ls test
ls test/v1-0
cd test/v1-0
To save typing, we’ve made some sample source files available to you. Copy them into your new project now (normally, you’d write these with an editor, etc; you may want to cut&paste the following line from the electronic version of these instructions):
cp ~jake/CSC/exercise9/test/v1-0/*.* src/
You should look at these, but they’re pretty straight-forward. You also need to copy over the sample requirements file into the “cmt” control directory:
cp ~jake/CSC/exercise9/test/v1-0/requirements cmt/
You should now look at that requirements file. It contains three lines:
package test
author Vincent Garonne <garonne@lal.in2p3.fr>
application test main.cxx hello.cxx
The first one defines the name of the package; the second gives credit to the author. It’s the third line that controls the build, by telling CMT what it needs to know to build an “application” within this package.
Now build and run this little program from the “cmt” directory within the version:
cd cmt
cmt make
../Linux-i686/test.exe
You should see “Hello world”, indicating that this worked. Take a few moments to look around the directory structure and see where things have been created. Using a “Linux-i686” directory for object and binary files allows you to use the same source directories to build for different types of machines.
Now, in addition to the executable, we want to create a library for the “Hello” class, but without the “main” program in the library. CMT will again do this, we just have to tell it how by adding this line:
library hello hello.cxx
to the requirements file. Try that, remake the project, and check to make sure it’s been built. (Where is it stored? Why?)
Now we want to work with a pair of packages with a dependency. First, we create those:
cd ~/exercise9
cmt
create A v1-0
cmt
create B v1-0
Next, copy in some source & requirements files
(normally, you’d create these yourself):
cp ~jake/CSC/exercise9/A/v1-0/*.* A/v1-0/src/
cp ~jake/CSC/exercise9/A/v1-0/requirements A/v1-0/cmt/
cp ~jake/CSC/exercise9/B/v1-0/*.* B/v1-0/src/
cp ~jake/CSC/exercise9/B/v1-0/requirements B/v1-0/cmt/
Look at the header *.h files and you’ll see that the “A” package is complete by itself, but “B” depends on “A”. To make sure the right things are built and searched, CMT needs to know this:
cd B/v1-0/cmt
cmt show uses
There’s a new line in B’s
requirements file to express this.
Note that it specifies the version to use:
use A v1-0
We can ask CMT to build everything for us. If will figure
out that it needs to compile, then make libraries, before linking:
cmt broadcast
make
The “broadcast” modifier means to “build everything”. Now run that program:
../Linux-i686/main.exe
Finally, edit the requirements file to refer to another version such as “v2-0”, and remake the program. CMT will fail to find that version, resulting in a cascade of errors.
(This exercise is based on an example by V. Garonne; he deserves our thanks)