CSC/ECE 517 Fall 2012/ch2a 2w12 sv: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
Line 24: Line 24:
           commands…
           commands…


When executing make the target needs to be specified else it updates the first target mentioned in the Makefile. The intermediate targets are updated before the updation of the final target.
Code can be built by typing '''make''' on the command prompt which looks for a Makefile in the present directory and executes it.The build process has two steps in which the compiler first takes the source code and creates object files. The linker then takes the object files and generates an executable.
The target files should always be up to date. If dependencies are older than the target file, then the target file is already up to date, and it needn’t be generated again.
When executing make the target needs to be specified else it updates the first target mentioned in the Makefile. The intermediate targets are updated before the updation of the final target.The target files should always be up to date. If dependencies are older than the target file, then the target file is already up to date, and it needn’t be generated again.


Here is how a Makefile is
Here is how a Makefile for compiling kernel modules is
  obj-m += helloWorld.o
  obj-m += helloWorld.o
  all:
  all:
Line 33: Line 33:
  clean:
  clean:
  make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
  make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
The above Makefile compiles a kernel module helloWorld.c .'''all:''' is the default target for all files and make utility executes this if no other target is specified. The '''clean:''' target clears all the compiled code.


==='''Ant'''===
==='''Ant'''===

Revision as of 20:38, 27 October 2012

Build Management

Introduction

Build Management is the process of delivering the software in an executable format .The final deliverables are known as software builds . For simple programs one single file is used for compilation but for complex software there will be a main file which in turn will invoke several other files for code compilation.

Consider the following example

A software build may consist of several ‘.c’ and ‘.h’ files. There will be number of make files which will compile the code files. For building the entire software one main Makefile is written which will call other make files for generating the executable. The files are compiled and linked in order by the Build Utility. If there are no code changes in a file then recompilation is not required. Moreover complicated build utilities and linkers do not recompile the code to save time required for the entire build generation.

Build Automation is a component of Build Management and involves automating the activities that developers perform regularly such as compiling source code into binary code and packaging them, running tests and deploying code at the production site and create documentation related to the same.

History and the need for development

Build Management Tools

Make

The make command makes use of the Makefile for compiling the code. The Makefile is generally written in Perl or some other scripting language. The wrapper script takes into account the tasks needed for build automation i.e. source code check out, unit tests execution and deployment of the code by placing it in the suitable directory.

A rule in make file specifies how set of instructions should be executed to generate target files from source files.

A simple rule is of the form
 target: dependencies…
         commands…

Code can be built by typing make on the command prompt which looks for a Makefile in the present directory and executes it.The build process has two steps in which the compiler first takes the source code and creates object files. The linker then takes the object files and generates an executable. When executing make the target needs to be specified else it updates the first target mentioned in the Makefile. The intermediate targets are updated before the updation of the final target.The target files should always be up to date. If dependencies are older than the target file, then the target file is already up to date, and it needn’t be generated again.

Here is how a Makefile for compiling kernel modules is

obj-m += helloWorld.o
all:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean

The above Makefile compiles a kernel module helloWorld.c .all: is the default target for all files and make utility executes this if no other target is specified. The clean: target clears all the compiled code.

Ant

Acronym for Another Neat Tool, ant was developed on a Windows Laptop and now owned by Apache. Ant makes use of XML to describe build processes and corresponding dependencies. By default the build file is given the name build.xml. Ant is useful in building Java applications. Ant can also be used for building non-Java application like C and C++. Ant uses Java to specify the types and tasks to be performed which are stored in “antlibs” . Ant is quite flexible and does not enforce the usage of coding convention and directory layouts to the Java projects which use it as a build tool.

Maven

Apache Maven is a software project management and comprehension tool. Derived from the project object model (POM), Maven manages project's build, reports and documentation from a central piece of information.

Maven configuration is effusive, difficult to read and write. Tasks which can be done in one or two lines of Ruby or XML with Rake or Ant require six or seven lines of pom.xml configuration (assuming it’s possible to write it in Maven).

In Maven certain things are configured as classpath references to .properties files bundled in .jar files configured as dependencies, some things are configured as absolute or relative paths to files on disk, and some things are configured as system properties in the JVM running Maven. Sometimes Maven can recursively build projects in the correct order, but sometimes it’s not.

Rake

Rake is the best build tool for Java Projects. The common build tasks in Rake are performed using certain standard methods and can be implemented in Ruby.


Scons

Scons is a Python based language and is acronym for Software Construction.SConstruct files which are similar to Makefiles are easier to maintain.SCons also supports C/C++ and Java™ files, and as compared to make Scons needs a lot lesser code.

References