The viewpath defines a virtual directory structure, which allows multiple, parallel trees to be viewed as a single tree. Only the topmost node is writable, other nodes are read only. The viewpath allows developers to share code and object files and reference a common base while maintaining private development areas that contain only the files being modified. It allows projects to easily scale to hundreds of users with minimal overhead - each user can have their own viewpath.
The viewpath is often used to separate generated files from
source files. This is useful for building on multiple platforms, for
working with more then one compiler and for building with different
compiler options (eg.
-p) while distributing
existing generated targets.
Unlike other SCM tools, viewpathing is implemented completely at application level and uses unmodified native file systems.
The viewpath is defined by the
VPATH environment variable,
which contains a colon separated list of nodes. Each node is the root
of a parallel tree structure. In the following example the current
working directory is under the first node (as it must be for the viewpath
to be in affect) and all the source code is in the second node. The
current directory is initially empty. We copy
from the second node to our work node, make a change, and then rebuild it.
hello.c is compiled from our work node but
is reused from the second node. The viewpathing is completely automatic
after defining the
VPATH variable. The Makefile author need
not do anything special.
$ pwd /home/richb/work/src $ export VPATH=/home/richb/work:/build/official $ ls -l total 0 $ ls -l /build/official/src total 44 -rw-r--r-- 1 richb richb 24 Aug 19 15:07 Makefile -rw-r--r-- 1 richb richb 5911 Aug 19 15:25 Makefile.mo -rw-r--r-- 1 richb richb 14324 Aug 19 15:25 Makefile.ms -rwxr-xr-x 1 richb richb 7180 Aug 19 15:25 hello -rw-r--r-- 1 richb richb 79 Aug 19 15:07 hello.c -rw-r--r-- 1 richb richb 1280 Aug 19 15:25 hello.o -rw-r--r-- 1 richb richb 42 Aug 19 15:06 main.c -rw-r--r-- 1 richb richb 1128 Aug 19 15:25 main.o $ cat /build/official/src/Makefile hello :: main.c hello.c $ cp /build/official/src/hello.c . $ vi hello.c $ nmake + cc -O -I- -c hello.c + cc -O -o hello /build/official/src/main.o hello.o
Standard make tools do not have the notion of the viewpath. Note, the GNU
VPATH is quite different since it specifies a list of
regular directories to search for prerequisite files, where nmake
specifies a list of parallel trees to treat as a single virtual tree.