Monday, January 4, 2010

Importance Of A Build Utility -1

Build utilities are essential ingredients in a software developmental life cycle. In order to create and streamline your production process in a modern project, you need to know and use build tools to automate the repetitive tasks.It is unthinkable to work upon a large program (usually with a large number and types of files) without using a build tool, which helps you to :-
Eliminate repetitive tasks
Manage the project
Focus on code, not on peripheral issues
Manage the libraries, or dependencies
Package the project , and deploy into a necessary environment, if needed
Run tests and other routines on the project
Ease of use

I'll start from one of the most popular build utility, make (www.gnu.org/software/make/). Make is a utility for automatically building executable programs and libraries from source code. Here, we can perform various tasks such as dependency management, file structure handling, compiling, packaging, etc to build a program. Although used much in Unix based projects, in its heyday, make was also the build utility to be used in windows using the Microsoft's nmake utility. Eg :
# gnumake file

.build: .clean
gcc -o *.c

clean:
/bin/rm -f *.o

A makefile is tab indented, which means that certain commands like c and c++ compiler need to be stated after a tab.
For example, the postgres database performs the following to package itself
...
distdir := postgresql-$(VERSION)
dummy := =install=
garbage := =* "#"* ."#"* *~* *.orig *.rej core postgresql-*

dist: $(distdir).tar.gz
ifeq ($(split-dist), yes)
dist: postgresql-base-$(VERSION).tar.gz postgresql-docs-$(VERSION).tar.gz postgresql-opt-$(VERSION).tar.gz postgresql-test-$(VERSION).tar.gz
endif
dist:
-rm -rf $(distdir)

$(distdir).tar: distdir
$(TAR) chf $@ $(distdir)
......

This makes our life easier as we now do not have to explicitly specify the commands for packaging i.e. tar ProgramName- and so on manually.

The Java Build Tools
The needs of large scale application also come in java technology. While you can create a .sh or a .bat file for simple commands like javac, java, etc, but this is'nt good from scalability point of view also, this is'nt portable, which eliminates the entire platform neutral nature of java.
So, we need something to get our projects going.
For this, ant(http://ant.apache.org) is the de-facto utility used in all projects. As an ant file is a xml file, it can be easily be ported, extended, tweaked, etc which increases the flexibility of this tool.
However, in large scale projects, even ant can't be used to ease the build process. Here, when we are facing dependency problems, we need more automation and a greater degree of reuse. For this, we use Maven as a key build utility (http://maven.apache.org). This not only promotes build process reuse, but also handles dependency management.

Thus, in order to focus more on other aspects of software development, you must have a clear plan and a solid platform for your application.Altough, it might seem as eccentric to you first, but such utility pays off in the longer run when you consider the development headaches and delays. What's your take on this?, I'd love to have your opinion.

No comments: