First of all, cbuild does not create an explicit header directory,
so
>mkdir mypackagectb/mypackage
(When we're done we'll get rid of mypackage and rename mypackagectb
to mypackage, so I'm giving the right name to the header directory now).
If your package has its header files in mypackage/src, it's a good idea
to change that now to mypackage/mypackage anyway.
Copy over all the .hpp/.h/.cpp/.cc/etc. files:
>cp mypackage/mypackage/*.hpp mypackagectb/mypackage/.
>cp mypackage/src/*.cpp mypackagectb/src/.
And the same for .h files etc.
Now change the include link:
>cd include
>ls -l mypackage
This should lead to something like:
lrwxr-xr-x 1 gusbroo D0
24 Jan xx xx:xx mypackage -> ../mypackage/mypackage
Remove the existing link and replace with a link to the cbuild version
of the package:
>rm mypackage
>ln -sf ../mypackagectb/mypackage mypackage
>ls -l mypackage
should now result in:
lrwxr-xr-x 1 gusbroo D0
24 Jan yy yy:yy mypackage -> ../mypackagectb/mypackage
It's time to make the necessary modifications to the src directory:
>cd ../mypackagectb/src
>xemacs COMPONENTS &
Use whichever editor if you prefer. In COMPONENTS, list
the .cpp files (without the .cpp extension) in order of dependency - the
one that doesn't depend on the others first (this can usually be infered
from the #include statements).
Exception: any file which has to
go directly on the linkline (not in a library) should go in OBJECT_COMPONENTS
(create
this file - it's not there unless you used the -o flag with
ctnewpkg)
-
one
specific example of this is the framework registration FWK_REGISTRY(mypackage,
dummy) - this has to go in a separate file (not with
the rest of the code) and this file should be listed in OBJECT_COMPONENTS,
not COMPONENTS. This is done in package analyze for example.
If you have d0om stuff, please read the episode on d0om.
Now we need the list of needed libraries:
>xemacs ../LIBDEPS &
You have to find the GNUmakefile in your (old) package which has the
list of libraries. If there's a bin directory to your package there's
a good chance that's the one you want - just try them until you have it:
>more ../../mypackage/src/GNUmakefile
>more ../../mypackage/bin/GNUmakefile
etc.
until you find something like:
...
libs := \
-ld0_mcpp \
-lenergycluster \
-lmcpp \
-lisajet \
-lio_packages \
-lframework \
-ledm \
-lrcp \
-lstream_ds \
-ld0om_ds \
-lidentifiers \
-lstream \
-ld0om \
-lcint-lite \
-lNameTrans \
-ld0_util \
-ldspack \
-lHepTuple -lErrorLogger
-lExceptions -lZMtools -lZMutility -lCLHEP
...
Now cut-and-paste this list into ../LIBDEPS, and delete all
the -l flags (i.e. only the packagenames should remain, one per line).
Note that in the LIBDEPS file, you only need the packages on which you
depend directly. In other words, if you use d0om, but nothing
from cint-lite in your code, you only need d0om, and cint-lite will be
included automatically when you issue gmake.
The last step is to make the component tests. These might exist
in a slightly different form in
>ls ../../mypackage/test
If there is a test file for each of the .cpp files in the src directory
(let's say they're called testxxx.cpp), copy them over in the following
way:
>cp ../../mypackage/test/testxxx.cpp xxx_t.cpp
etc.
If there are no test files, you can either create them (the spirit
of the component tests is to check if the methods work individually - not
if they work together - so in the test file you should call each method
with some dummy but reasonable arguments), or you can temporarily create
"dummy tests":
>xemacs xxx_t.cpp
and fill this with
#include <iostream>
#include "mypackage/xxx.hpp" // this is in anticipation of
a real test to be written later
int main()
{exit(0);}
When you create a component test, if it's successful it should finish
with exit(0).
Note: if testing
any of the components requires the presence of other files (.rcp,...),
you have to
>cp $BFDIST/releases/$BFCURRENT/ctbuild/bin/run_component_test.sh
xxx.sh
where xxx is the component name.
Uncomment and edit the line
# cp $SRCDIR/input.dat .
to make sure all the files needed for the test
are copied over (or linked in the case of big files). If you do this,
to run the component test it will use xxx.sh instead of the default
file.
Ok - now test the stuff:
>cd ../..
>gmake mypackagectb.test
And in principle this should compile all the components, build the
library and test each of the components. The object_components are
compiled but not tested.