ARC1/Howto

From NorduGrid

Jump to: navigation, search

Adding a new component

Starting a new component be it a new service or new protocol etc. Is quite easy though there are some rules / guideline one must follow. We will use an example of a new service but the instructions here can be applied to most other parts of the code. First find the appropriate location (for services it is in src/services):

 cd src/services
 mkdir myservice
 cd myservice

The first thing you should do is to add a README file. The README file should give a short explanation about the services. The README file is mandatory. The second file you should add is Makefile.am. This file is used by Automake (part of Autotools) and is a recipe for how to build your component. Here is a good starting template:

 # For Unit testing
 SUBDIRS = $(TEST_DIR)
 DIST_SUBDIRS = test
 
 # The service
 pkglib_LTLIBRARIES = libmyservice.la
 libmyservice_la_SOURCES  = myservice.cpp myservice.h
 libmyservice_la_CXXFLAGS = $(GLIBMM_CFLAGS) $(LIBXML2_CFLAGS) -I$(top_srcdir)/include
 libmyservice_la_LIBADD   = $(top_srcdir)/src/hed/libs/loader/libarcloader.la $(top_srcdir)/src/hed/libs/message/libarcmessage.la $(top_srcdir)/src/hed/libs/security/libarcsecurity.la \
                             $(top_srcdir)/src/hed/libs/common/libarccommon.la $(GLIBMM_LIBS) $(LIBXML2_LIBS)
 libmyservice_la_LDFLAGS  = -no-undefined -avoid-version -module

The first paragraph is needed for unit testing which is explained on ARC1/Unit Testing. The second paragraph is the recipe for creating the "myservice" service plugin.

Once we are ready to build the service we must inform Autotools about the new component. This is done in the toplevel configure.ac. Towards the bottom of this file there is a line starting with

 AC_CONFIG_FILES

List your directories with appended "/Makefile" below in the list:

 ...
 src/services/Makefile
 src/services/test/Makefile
 ...

Autotools will create Makefile.in and Makefile from your Makefile.am recipe.

We have created a service which installs a file through the line:

 pkglib_LTLIBRARIES = libmyservice.la

We need to explicitly tell the packaging tools about this file. For RPM packaging this is done in the toplevel:

 arc.spec.in

while for DEB packaging it is in:

 debian/nordugrid-arc1-server.install

We should now be ready to test that our service is properly integrated in the build structure. Go to the top-level directory and do:

 ./autogen.sh  # Needed if you modify Makefile.am
 ./configure
 make
 make check    # Run the Unit tests
 make install DESTDIR=/tmp/myinstall

If all went well you should be able to find your new service installed under /tmp/myinstall.

Please respect your fellow coders and make sure that your service compiles correctly.

Instructions for checking if the packaging works is out of the scope of this document.

Personal tools