Child Projects

Introduction

build-web provides a mechanism called Child Project which allows a the inclusion of multiple build-web projects into a Parent Project. Special considerations apply when developing a project which is able to be reused as a child project and when developing a project which is to reuse other projects as children.

This approach is most useful when:

Child Projects are an evolving concept in build-web and may not always be the best choice for combining projects. For the case where you wish to include other projects but wish to have a single template style, then either performing a soft link at the appropriate place in your parent project to the srce directory of the child project, may be a better approach to including the child project seamlessly into the parent.

Creating a Child Project

A Child Project is just like a normal Project with the addition of an additional make file which will be used by parent projects to invoke the Child Project's own make file. This make file must be named Makefile-child.

Example Makefile-child

#  Example Child Project Makefile-child 
#
#  This makefile is included in any project's Makefile
#  which wishes to include this project as a child.
#
childproject:
	$(MAKE) -f $(CHILDPROJECT_DIR)/Makefile \
	BUILDTYPE=$(BUILDTYPE) \
	MAKE=$(MAKE) \
	COPY=$(COPY) \
	CLEAN=$(CLEAN) \
	SSIPROCESS=$(SSIPROCESS) \
	DIRMAP=$(CHILDPROJECT_DIRMAP) \
	SRCEPHYSDIR=$(CHILDPROJECT_SRCEDIR) \
	DESTPHYSDIR=$(CHILDPROJECT_DESTDIR) \
	main

clean-childproject:
	$(MAKE) -f $(CHILDPROJECT_DIR)/Makefile \
	BUILDTYPE=$(BUILDTYPE) \
	SRCEPHYSDIR=$(CHILDPROJECT_SRCEDIR) \
	clean-main
    

The Makefile-child make file defines a target to build the child project and a target to clean the child project. You can name these targets anything you wish, however the convention in build-web is to use the project name in as in the above example. Make file variables for projects are by convention defined with the name of the project in ALL CAPS. You should modify the above example by replacing CHILDPROJECT with the name of your child project in ALL CAPs.

The Parent Project is responsible for defining the make variables which specify the Child Project's project directory, source directory and destination directory as well as the other make variables that are used by any build-web Makefile. The Parent Project also specifies custom directory remapping scripts, dirmap-childproject-prod.pl and dirmap-childproject-dev.pl which are passed to the child project via the CHILDPROJECT_DIRMAP make variables. This allows the parent project to tell the child project how the parent wishes the child's directories to be remapped.

Alternatives to using Child Projects

The effect of child projects can be obtained simply by combining the output of multiple build-web projects into separate directories on the hosting web server. This is in general the easiest approach and is most useful when synchronization of the building of the separate projects is not required.

Child Projects each can have their own templates. If you wish to only use the templates defined by the Parent Project, then the best approach is to physically combine the Parent and Child Projects srce directories and only build the Parent Project. This can be accomplished either via soft linking from the Parent Projects srce tree into the Child's srce tree or via combining the projects in another fashion such as using CVS to checkout the source of the Child into the appropriate place in the Parent.

The choice is left to the designer and their determination of the best approach for their particular project.

Build Web Home