8.5 Partial Source Trees

     

On really large projects, just checking out and maintaining the source can be a burden on developers. If a system consists of many modules and a particular developer is modifying only a localized part of it, checking out and compiling the entire project can be a large time sink. Instead, a centrally managed build, performed nightly, can be used to fill in the holes in a developer's source and binary trees.

Doing so requires two types of search. First, when a missing header file is required by the compiler, it must be instructed to search in the reference source tree. Second, when the makefile requires a missing library, it must be told to search in the reference binary tree. To help the compiler find source, we can simply add additional -I options after the -I options specifying local directories. To help make find libraries, we can add additional directories to the vpath .

 SOURCE_DIR     := ../mp3_player REF_SOURCE_DIR := /reftree/src/mp3_player REF_BINARY_DIR := /binaries/mp3_player ... include_dirs := lib $(SOURCE_DIR)/lib $(SOURCE_DIR)/include CPPFLAGS     += $(addprefix -I ,$(include_dirs))                  \                 $(addprefix -I $(REF_SOURCE_DIR)/,$(include_dirs)) vpath %.h       $(include_dirs)                                   \                 $(addprefix $(REF_SOURCE_DIR)/,$(include_dirs)) vpath %.a       $(addprefix $(REF_BINARY_DIR)/lib/, codec db ui) 

This approach assumes that the "granularity" of a CVS check out is a library or program module. In this case, the make can be contrived to skip missing library and program directories if a developer has chosen not to check them out. When it comes time to use these libraries, the search path will automatically fill in the missing files.

In the makefile , the modules variable lists the set of subdirectories to be searched for module.mk files. If a subdirectory is not checked out, this list must be edited to remove the subdirectory. Alternatively, the modules variable can be set by wildcard:

 modules := $(dir $(wildcard lib/*/module.mk)) 

This expression will find all the subdirectories containing a module.mk file and return the directory list. Note that because of how the dir function works, each directory will contain a trailing slash.

It is also possible for make to manage partial source trees at the individual file level, building libraries by gathering some object files from a local developer tree and missing files from a reference tree. However, this is quite messy and developers are not happy with it, in my experience.



Managing Projects with GNU make
Managing Projects with GNU Make (Nutshell Handbooks)
ISBN: 0596006101
EAN: 2147483647
Year: 2003
Pages: 131

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net