ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/doc/tex/manual/CreatingProjects.tex
Revision: 1.4
Committed: Mon Sep 11 13:37:36 2006 UTC (18 years, 8 months ago) by sashby
Content type: application/x-tex
Branch: MAIN
CVS Tags: V1_0_3-p4, V1_0_3-p3, V1_0_3-p2, V1_0_3-p1, V1_0_3
Branch point for: v103_with_xml
Changes since 1.3: +7 -7 lines
Log Message:
Merged from v103_branch

File Contents

# User Rev Content
1 sashby 1.1 %%____________________________________________________________________
2     %% File: CreatingProjects.tex
3     %%____________________________________________________________________
4     %%
5     %% Author: Shaun ASHBY <Shaun.Ashby@cern.ch>
6     %% Update: 2005-11-02 17:05:54+0100
7 sashby 1.4 %% Revision: $Id: CreatingProjects.tex,v 1.3.2.1 2006/09/04 12:59:01 sashby Exp $
8 sashby 1.1 %%
9     %% Copyright: 2005 (C) Shaun ASHBY
10     %%
11     %%--------------------------------------------------------------------
12     \renewcommand{\descriptionlabel}[1]{
13     \setlength{\evensidemargin}{\oddsidemargin}
14     \rm{#1}}% We want description items to be normal
15     % text, not bold. Margins adjusted.
16 sashby 1.2 \chapter{Creating SCRAM-Managed Projects}\label{ch:creatingprojects}
17 sashby 1.1 \index{SCRAM!creating projects}
18     \index{creating SCRAM projects}
19    
20     A \scram\ project is a releasable unit covering a particular software
21     domain, for example an analysis framework, event simulation or reconstruction.
22     Libraries and binary executables are the typical basic build products and these
23     can have separate storage areas. A configuration directory contains all the
24     files necessary to allow \scram\ to configure a dedicated project
25     release area for a version of the project. External requirements are
26     configured automatically.
27     The structure of a project can be freely chosen since \scram\ does not
28     impose restrictions on project structure: it is
29     easy to modify \scram\ build behaviour according to site conventions.
30    
31     \ni Generally, a project is subdivided into \texttt{subsystems} and
32     \texttt{packages} according to the tree structure of the source code
33     directory. Dependencies are expressed in terms of packages
34     where a package is typically built into a shared library: in fact,
35     the build products that correspond to a certain set of source files in
36     a certain location can be freely modified to suit the project.
37     The principal reason for assuming (or enforcing in some cases) that
38     packages map to libraries is to enable proper dependency tracking and
39     automatic ordering of build operations. From Version 1.0 of \scram,
40     this feature is fully supported both internally (to establish correct library
41     ordering in linker information) and via \texttt{gmake} which controls
42     the build ordering once the dependency information is correctly
43     obtained by \scram.
44    
45     \ni Source files and header files have separate directories appearing under
46     \texttt{src} and \texttt{interface} or \texttt{include} respectively.
47     An additional directory called \texttt{test} can be used as a location
48     to build binary executables for testing. Likewise, other directories
49     can be used as locations to define other build products, for example
50     \texttt{bin} or \texttt{app} for binary executables and applications
51     which should be released as project deliverables.
52    
53     \begin{figure}[htb]\index{project structure!recommended}
54     \begin{center}
55     \leavevmode \epsfig{file=images/projectstructure.eps, width=\linewidth}
56     \caption{Recommended \scram\ project structure. The directories
57     \texttt{tmp} and \texttt{logs} are created
58     automatically and directories for build products
59     like \texttt{lib} and \texttt{bin}
60     are created as appropriate given instructions
61     read from a project build file.}
62     \label{fig:recprojstruct}
63     \end{center}
64     \end{figure}
65    
66     \ni The corresponding \scram\ project structure consists of a directory
67     tree like that shown in Figure~\ref{fig:recprojstruct}.
68    
69     \ni This chapter describes some of the important internal configuration aspects of
70     \scram\ that are used to define projects and should provide all the
71     information required for administrators and developers alike to
72     configure a \scram-managed project.
73    
74     \section{SCRAM Project Components}
75    
76     Every \scram\ project has documents to describe it and a code
77     repository from where these documents, and project source code, can be
78     accessed using a version management system.
79     The two elements are described in the following sections.
80    
81     \subsection{Configuration Documents}\label{sec:scramconfigdocs}
82     \index{SCRAM!project configuration files}
83    
84     \ni There are two types of project areas:
85     \begin{itemize}
86     \item \texttt{Releases} which are normally installed in a central location.
87     \item \texttt{Developer Areas} which are areas that are cloned from
88     centrally installed releases but allow private access for software
89     development with the same controlled configuration as the release.
90     \end{itemize}
91    
92     \ni The processes for initialising areas in each of these cases is different.
93     Each project must have a unique version, a name and a tool
94     configuration from which interfaces to external software can be
95     established. These interfaces express external dependencies in the
96     same way as individual packages in the project or release area of the
97     project. Their definitions are contained inside a toolbox and
98     list all settings needed by the \scram\ build or runtime environments (for
99     example, \texttt{INCLUDE} paths, libraries provided by the tools or \texttt{PATH} elements
100     which should be added to the user environment).
101    
102     \ni Configuration instructions for \scram\ are passed using documents called
103     \texttt{ActiveDocs} which are written in a syntax that closely\index{\texttt{ActiveDoc}s}
104     resembles \texttt{XML}. These are web-enabled mark-up documents, each
105     being associated with a download and cacheing mechanism that is accessed using a \texttt{URL}. This
106     \texttt{URL} can behave like a normal \texttt{WWW} \texttt{URL} or can be a file or a
107     path to a \texttt{CVS} server. A number of \texttt{ActiveDoc} markup tags are
108     defined, some of which are common to all types of document; some tags
109     are specific for their application and only used in a particular class
110     of document. An \texttt{ActiveDoc} document must begin with a special
111     statement that informs \scram\ what sort of document it is and how it
112     should be parsed; each type of statement is specific to a class of
113     functionality. The tag
114     \begin{tagprint}
115     \lbkt\texttt{doc} type=\textit{type} version=\textit{version}\rbkt
116     \end{tagprint}
117     \ni is always the first line of the document. The type entry is set
118     according to the \scram\ parsing class.
119    
120     \ni There are three main different classes of \texttt{ActiveDoc} document
121     that are needed to configure a project: \texttt{BootStrapProject},
122     \texttt{RequirementsDoc} and \texttt{ToolDoc}. These classes are
123     described next.
124    
125     \subsubsection{The BootStrapProject Class}\label{sec:bootstrapclass}
126     \index{\texttt{BootStrapProject} class}
127     A single document describes how the project should be structured and
128     which tools should be configured. Usually referred to as a \texttt{bootstrap} file, it must start with
129     the statement\index{project \texttt{BootStrapFile}}
130     \index{bootstrap file}
131     \begin{tagprint}
132     \lbkt\texttt{doc} type=\texttt{Configuration::BootStrapProject}
133     version=\textit{1.0}\rbkt
134     \end{tagprint}
135     \ni The name of this file is completely arbitrary. The function of
136     the bootstrap document is to define the name and version of a project
137     and to tell \scram\ from where it can download the configuration and
138     source code files, and where to put them inside the project release
139     area. There must be a bootstrap file in every \scram\ project.
140    
141     \ni The markup tags specify a path to a \texttt{CVS} server, the name of the
142     project requirements document and the location of the project
143     configuration directory within the project area. The available markup
144     tags are as follows--
145     \index{\texttt{BootStrapProject} markup tags}
146     \index{\texttt{BootStrapFile} markup tags}
147     \begin{description}
148     \item[\lbkt\texttt{project} name=\textit{name} version=\textit{version}\rbkt~\tagend{project}]\mbox{}\\
149     Specify the name an version of the project. The version should be a
150     valid \texttt{CVS} symbolic tag which must exist on all files in the
151     configuration directory and the project source code. Explanatory
152     text can be put between the \lbkt\texttt{project}\dots\rbkt tags: this
153     text will be printed to the screen when bootstrapping the project.
154     \item[\lbkt\texttt{config} dir=\textit{dirname}\rbkt]\mbox{}\\
155     Specify the name of a directory relative to the top of the project
156     area where the configuration files can be found.
157     \item[\lbkt\texttt{base} url=\textit{baseurl}\rbkt~\tagend{base}]\mbox{}\\
158     A common element in multiple \texttt{URL}s, such as a \texttt{CVS} server name, is
159     supplied using the base tag. The \texttt{URL} type can be \texttt{cvs:}
160     (using a \texttt{CVS} repository) or \texttt{file:} (a standalone file). Any
161     \texttt{URL} specified between the start and end base tags will be merged
162     with the \texttt{URL} \textit{baseurl} according to the following merge
163     rules:
164     \begin{itemize}
165     \item A merge will only take place if the \texttt{URL} and \textit{baseurl}
166     types match, \eg both have type \texttt{cvs:} or \texttt{file:}
167     \item The base server name is taken if it isn't already defined
168     \item The \textit{baseurl} path is prepended to any \texttt{URL} specified
169     \item Variables provided in the base parameter list are only added
170     if not already defined, \eg definition of the directory name when
171     downloading the configuration files
172     \end{itemize}
173     \item[\lbkt\texttt{download} url=\textit{url} name=\textit{dirname}\rbkt]\mbox{}\\
174     Each \texttt{URL} will be merged with the base \texttt{URL} defined in a
175     \tagstart{base} tag and treated as a download location which is
176     passed to \texttt{CVS} for checking out files from a repository. The name of
177     the destination directory will be \textit{dirname}, and will be
178     located relative to the top of the project area.
179     \item[\lbkt\texttt{requirementsdoc} name=\textit{docname}\rbkt]\mbox{}\\
180     Specify the name of the project requirements document. The path is
181     relative to the top of the project area.
182     \item[\lbkt\texttt{SourceCode} dir=\textit{dirname} \rbkt]\mbox{}\\
183     Normally, the directory where the project sources are located is
184     called \texttt{src}. This default can be changed by using this
185     tag. {\em This tag is deprecated and support for it in future cannot
186     be guaranteed.}
187     \end{description}
188     \index{Changing the default source code directory}
189     \index{\texttt{SourceCode} tag}%
190    
191     \subsubsection{The RequirementsDoc Class}\label{sec:requirementsdocclass}
192     \index{\texttt{RequirementsDoc} class}
193    
194     To make external products available in a project area and be able to
195     link against external libraries, a requirements file is used. This
196     file starts with the statement\index{requirements file}
197     \begin{tagprint}
198     \lbkt\texttt{doc} type=\texttt{BuildSystem::Requirements}
199     version=\textit{2.0}\rbkt
200     \end{tagprint}
201     \ni and specifies the external tools and their corresponding versions
202     that should be configured. The requirements file provides information
203     for \scram\ to use when downloading the tool descriptions from the
204     toolbox \texttt{CVS} repository. If more than one version of a tool is defined,
205     the first one is taken as the default.
206     The following tags are available:
207    
208     \begin{description}
209     \item[\lbkt\texttt{require} name=\textit{name} version=\textit{version} url=\textit{url}\rbkt~\tagend{require}]\mbox{}\\
210     Specify the name and version of a required tool. The \texttt{URL} should
211     point to a \texttt{ToolDoc} that describes the tool. Base \texttt{URL} tags
212     (\lbkt\texttt{base}\rbkt\ldots) can be used to modify the \texttt{URL}.
213     \item[\lbkt\texttt{include} url=\textit{url}\rbkt]\mbox{}\\
214     This is for \texttt{URL} document preprocessing.\texttt{ActiveDocs} provide
215     an equivalent of the \texttt{C}-preprocessor
216     \texttt{\#include}
217     \index{\texttt{include} directive}
218     directive that is web-aware. In this way, it is possible to assemble
219     a document from many components that are maintained at different
220     locations. A common configuration file containing multiple tool
221     \lbkt\texttt{require}\rbkt statements can be included in this way.
222     \item[\lbkt\texttt{architecture} name=\textit{arch}\rbkt~\tagend{architecture}]\mbox{}\\
223     \index{architecture tags}
224     \index{SCRAM!architecture}
225     \index{\texttt{SCRAM\_ARCH}}
226     \ni The \textit{arch} is an architecture tag which limits certain
227     functionality only to a specific operating system. This
228     architecture is determined automatically by \scram. Unlike previous
229     versions, the mechanism to determine the architecture name is
230     defined in \texttt{Installation/SCRAM\_SITE.pm} and is fully
231     customisable. Internally, \scram\ sets a variable called \texttt{SCRAM\_ARCH} to
232     whatever is determined as the architecture string. This string can
233     then be used as \textit{arch} (either the full architecture name or an
234     abbreviation will match).
235    
236     \item[\lbkt\texttt{download} url=\textit{url}\rbkt]\mbox{}\\
237     Specify a link to download information for the tool.
238     \item[\lbkt\texttt{select} name=\textit{name}\rbkt]\mbox{}\\
239     Select a tool from a list of available tools.
240     \end{description}
241    
242     \subsubsection{The ToolDoc Class}\label{sec:tooldocclass}
243     \index{\texttt{ToolDoc}!class}
244     An external tool is described using a tool description file called a
245     \texttt{ToolDoc}. When a tool is required, a certain version of that
246     tool is configured by \scram\ in the project area. A tool description
247     begins with the statement\index{\texttt{ToolDoc}}
248     \begin{tagprint}
249     \lbkt\texttt{doc} type=\texttt{BuildSystem::ToolDoc} version=\textit{1.0}\rbkt
250     \end{tagprint}
251     \ni The \texttt{ToolDoc} describes such things as the default location
252     of the tool on the system, the names of libraries to be used when
253     linking against the tool and environment variables that must be set at
254     runtime. The external dependencies of the tool are also declared.
255    
256     \ni The following tags are available in \texttt{ToolDoc}s:
257     \index{\texttt{ToolDoc}!valid markup tags}
258     \begin{description}
259     \item[\lbkt\texttt{Tool} name=\textit{name} version=\textit{version}\rbkt\tagend{Tool}]\mbox{}\\
260     Specify the name and the version of the tool that is being
261     described. Everything between these tags relates to version
262     \textit{version} of the tool.
263     \item[\mbox{\lbkt\texttt{environment} name=\textit{variable}
264     {[}default=`\textit{def}' \textbf{or} value=`\textit{value}'{]}
265     type=\textit{type}\rbkt}]
266     \item[\tagend{environment}]\vspace{-4mm}\mbox{}\\
267     Set up a variable in the \scram\ environment for this tool.
268     Either `value' or `default' can be set
269     to provide the appropriate path for the variable but not both.
270     \item[\mbox{\lbkt\texttt{Runtime} name=\textit{variable}
271     {[}type=`\textit{path}'{]} {[}handler=`\textit{warn,error}'{]} \rbkt}]\mbox{}\\
272     Define a runtime variable which should be set in the users' shell
273     environment. The optional variable type \textit{type} can be set
274     to \texttt{path} for a path-like variable, \eg
275     \texttt{\$PATH} or \texttt{\$LD\_LIBRARY\_PATH}, at runtime.
276     If the handler option \textit{handler} is set to \texttt{warn},
277     \scram\ will not pause and prompt for a value for the runtime
278     variable if the value is incorrect (for example, if the path is
279     missing because the directory has not yet been created).
280     \item[\lbkt\texttt{use} name=\textit{tool name}\rbkt]\mbox{}\\
281     Specify that the tool has a dependency on another external tool.
282     \item[\lbkt\texttt{lib} name=\textit{libname}\rbkt]\mbox{}\\
283     Specify the name of a library belonging to the tool. Note that the
284     preceding `lib' or extension are not required.
285     \item[\tagstart{client}~\tagend{client}]\mbox{}\\
286     Any \inbrackets{environment} definition between these tags will be
287     checked as a directory location on the client machine.
288     The presence of all libraries defined by \lbkt\texttt{lib}\rbkt tags
289     will be checked for automatically. The \texttt{client} tags should
290     only contain \texttt{environment} tags: if an environment is
291     architecture-specific, the \texttt{client} block must be included in
292     the architecture block and not the other way around.
293     \item[\tagstart{makefile}~\tagend{makefile}]\mbox{}\\
294     These tags delimit \texttt{gmake} makefile content intended for
295     inclusion in the build system associated with the tool. It is preferable to use
296     text templates (or modify existing templates) if the content to be
297     added is more than a single line (\eg a variable definition).
298     \item[\lbkt\texttt{flags} \texttt{NAME}='definition'\rbkt]\mbox{}\\
299     Extra compiler flags can be specified which will be added to the
300     global compiler flags if the tool defining them is required
301     globally, or added to the compiler flags for a package if the tool
302     is required there.
303     \end{description}
304    
305     \ni Note that all environment variables can be referred to by others in
306     addition to internal \scram\ variables like \texttt{\$SCRAM\_ARCH}, the
307     tool name \texttt{\$SCRAMtoolname} and the version
308     \texttt{\$SCRAMtoolversion}.
309    
310 sashby 1.3 \subsection{The CVS Infrastructure}\label{sec:configuringCVSinf}
311 sashby 1.1 \index{CVS repositories}
312     \index{CVS repositories!setting up for a new project}
313     All code management within \scram\ uses \texttt{CVS}, a versioning system
314     derived from \texttt{RCS}.\footnote{However, \scram\ does
315     not fully depend on CVS: another tool could be used instead if
316     required at a later date.}
317     Every project consists of source code and \scram\ project
318     configuration files which are imported into a \texttt{CVS} repository which
319     has a directory structure mirroring the structure of the project itself.
320     \begin{figure}[ht]\index{CVS repositories!recommended structure}\index{CVSROOT}
321     \begin{center}
322     \leavevmode \epsfig{file=images/projectCVSstructure.eps, width=\linewidth}
323     \caption{Recommended CVS repository structure for a \scram\
324     project. The directory \texttt{CVSROOT} contains CVS information
325     and is created automatically when initialising the CVS repository.}
326     \label{fig:recprojstructCVS}
327     \end{center}
328     \end{figure}
329     The typical repository structure, based on the project structure
330 sashby 1.2 described earlier, is illustrated in Figure~\ref{fig:recprojstructCVS}.
331 sashby 1.1 %
332     \subsubsection{CVS Authentication}\label{sec:CVSauth}
333     \index{CVSROOT!authentication settings and}
334     \index{CVS authentication options}
335     To access the CVS repository, an authentication method must be chosen
336     and specified in the \texttt{CVSROOT} environment variable. There are
337     currently two supported methods for file checkout in \scram:
338     \texttt{pserver:}, standard anonymous checkout, and \texttt{local:},
339     using a CVS repository on a local filesystem on the current machine
340     rather than a dedicated server accessible only via a network
341     connection.
342    
343     \subsubsection{Importing the Code for New Projects}\label{sec:importingcode}
344     \index{CVS repositories!importing files to}
345     \ni Moving source code into a repository when creating a new project
346     is explained in detail in the CVS manual but a brief description is
347     given here. Once project source code exists in a suitable directory tree, the
348     whole project can be imported into a CVS repository using
349     the \texttt{cvs import} command. Initially, the \texttt{CVSROOT}
350     environment variable must be set and
351     the repository created using the command \texttt{cvs init}.
352     To make life easier when defining download paths in bootstrap
353     files, the \texttt{CVSROOT} for project \texttt{MyProject} on a local
354     filesystem would look like
355    
356     \begin{list}{}
357     \item\texttt{/local/path/cvs\_repository/MyProject}
358     \end{list}
359    
360     \ni and would be set before importing the code. Import the
361     configuration directory (and contents) first
362    
363     \begin{indentprint}\texttt{cd config}\end{indentprint}
364     \vspace{-3mm}
365     \begin{indentprint}
366     \texttt{cvs import -m "First import of my project config" config V1-0 V1-0}
367     \end{indentprint}
368    
369     \ni and then repeat this step for the project sources:
370    
371     \begin{indentprint}\texttt{cd MyProject}\end{indentprint}
372     \vspace{-3mm}
373     \begin{indentprint}
374     \texttt{cvs import -m "First import of my project src" MyProject V1-0 V1-0}
375     \end{indentprint}
376    
377     \ni Once this has been done and assuming that the import was
378     successful, the original sources can be removed and then restored from \texttt{CVS}
379     using \texttt{cvs co MyProject}.
380    
381     \subsection{The SCRAM Toolbox}\label{sec:toolboxrep}
382     \index{SCRAM!toolbox CVS repository}
383     \index{CVS repositories!for tool descriptions}
384     A separate \texttt{CVS} repository must exist which contains
385     documents describing external tools: these are components of a {\em toolbox}.
386     This is referred to as the \scram\ toolbox.
387     Each tool has a \texttt{ToolDoc} in which every
388     version of the tool that can be used in a project environment is
389     described. Any environment or makefile variable needed to use the
390     external software is declared in the file and interpreted by \scram\ as
391     a variable to be set up when creating the project area for the first
392     time, or installing a new version of the tool into an existing area.
393     A global configuration file (called
394     `the configuration') indicates which tools and the corresponding versions that can
395     be downloaded by \scram\ and used in project-space. The toolbox is
396     tagged with a \texttt{CVS} symbolic tag which is used to \textit{freeze} the
397     configuration: this tag is then specified in the project
398     \texttt{RequirementsDoc} as the version to download.
399     There is no requirement for a particular structure for the toolbox
400     but including at least the following is recommended:
401    
402     \begin{description}
403     \item[\textbf{Compiler Tools}]\mbox{}\\
404     Any number of programming languages can be supported (for example \texttt{C},
405     \texttt{C++}, \texttt{Java} or \texttt{Fortran}). The top-level
406     \texttt{BuildFile} for the project should select the compilers that should
407     be configured globally (compilers can also be selected for use only at
408     the package level where they are required).
409     \item[\textbf{External Software}]\mbox{}\\
410     Each external software package to be used by a project should have a
411     unique tool description file which defines the required version of
412     the tool.
413     \item[\textbf{Project Software Releases}]\mbox{}\\
414     Tool descriptions for all projects that provide libraries to be used
415     by other projects or tools should be created.
416     \item[\textbf{A Configuration File}]\mbox{}\\
417     The most important element in the toolbox. The
418     configuration describes the available tools and
419     versions of these tools that are to be used in a
420     project area.
421     \end{description}
422    
423     \section{Creating a Project Release Area}\label{sec:creatProjArea}
424     \index{Project areas!creating new}
425    
426     The starting point in a software development cycle is to create a project
427     release to estabish a baseline for further development.
428     A \scram\ project must have, at least, the following configuration
429     files in a configuration directory to properly define the project:
430     \begin{description}
431     \item[\texttt{BootStrapFile}]\mbox{}\\
432     For bootstrapping the project. This will relate a specific project
433     version with the relevant source code version and define a
434     requirements file to be read to select external products.
435     \item[\texttt{RequirementsDoc}]\mbox{}\\
436     The requirements file containing information to be passed to the
437     configuration manager for setting up external tools. A \texttt{CVS}
438     symbolic tag for a released configuration specifies which tools and
439     version should be downloaded from the toolbox repository.
440     \item[\texttt{BuildFile}]\mbox{}\\
441     The top-level \texttt{BuildFile}, containing project-wide default settings for
442     export of external tools, build product storage and global compiler settings.
443     \end{description}
444    
445     \ni These files are normally kept in a directory called
446     \index{\texttt{config} directory}
447     \index{project configuration directory}
448     \texttt{config} (the name of the directory can be changed using a
449     directive in the boot file). A \scram\ command exists
450     which can be used to grab basic template files for a new project.
451     Typing
452    
453     \begin{scramcmd}{project -template}\end{scramcmd}
454    
455     \ni will download some basic project configuration files to a
456     directory called \texttt{config} in the current directory. These
457     should be edited to suit and imported into the project CVS repository
458 sashby 1.3 (see Section~\ref{sec:configuringCVSinf}). Once these configuration
459 sashby 1.1 files exist, they must be tagged with a \texttt{CVS} symbolic tag that matches the name
460     and version of the project (for example \texttt{myProject\_1\_0}).
461     All project source code must have the same global \texttt{CVS} tag (this is
462     especially important if you want the bootstrap mechanism to also
463     download source code).
464    
465     \ni Creating the project area is very easy- just type the command
466    
467     \begin{scramcmd}{project -b config/boot}\end{scramcmd}
468    
469     \ni indicating the location of the bootstrap file after the \texttt{-b}
470     option, and that's it. \scram\ will set up the tools automatically
471     using the settings in the default lookup file \texttt{tools-X.conf}
472     found in \texttt{config/site}, or whichever lookup file is
473     specified on the command line.
474    
475     \ni Two subdirectories are created in the project area as part of the
476     initialisation: \texttt{config} and \texttt{.SCRAM}. All files used
477     for bootstrapping and the build system are contained in
478     \texttt{config}, downloaded directly from the \texttt{CVS} repository. The
479     important project information is contained in the \texttt{.SCRAM}
480     subdirectory
481     \label{sec:dotSCRAMcontents}
482     \index{\texttt{.SCRAM} directory} so this must not be renamed or
483     deleted. A closer look at the contents of the \texttt{.SCRAM}
484     directory reveals the following subdirectories and files:
485    
486     \small{
487     \begin{verbatim}
488     ObjectDB/
489     Environment
490     cache/
491     InstalledTools/
492     slc3_ia32_gcc323/
493     DirCache.db
494     \end{verbatim}
495     }\normalsize
496    
497     \ni The directories \texttt{ObjectDB}, \texttt{cache} and
498     \texttt{InstalledTools} store tool description files as they are downloaded
499     from the \texttt{CVS} repository prior to being parsed by the setup mechanism.
500     Once each tool has been configured for use in the current environment,
501     the tool information is stored in the tool cache in
502     a directory for the architecture (in this example,
503     the architecture is \texttt{slc3\_ia32\_gcc323}). The file
504     \texttt{Environment} contains information required about the project
505     by \scram. The file content for a typical project \texttt{TEST} version
506     \texttt{TEST\_1\_0} looks like this:
507    
508     \small{
509     \begin{verbatim}
510     SCRAM_PROJECTNAME=TESTING
511     SCRAM_PROJECTVERSION=1.0
512     SCRAM_TOOLBOXVERSION=CMS_112_3
513     SCRAM_PROJECT_TIMESTAMP=Fri-5-Feb-2005 14:10:22
514     LOCALTOP=/home/t/work/projects/TESTING_1.0
515     \end{verbatim}}\normalsize
516     %
517     \ni These entries are also defined as environment variables, visible in
518     the runtime and build environments. There will also be content like
519     \index{\texttt{RELEASETOP} settings}
520     \small{
521     \begin{verbatim}
522     RELEASETOP=/home/t/work/releases/TESTING_1.0
523     SCRAM_PROJECT_RELEASE_TIMESTAMP=Tues-1-Feb-2005 16:12:28
524     \end{verbatim}
525     }\normalsize
526    
527     \ni in a developer area, informing \scram\ that the central area containing libraries and
528     header files should be used first, before any of the contents of the
529     current area. The timestamp of the release is also shown.
530    
531     \ni The file \texttt{DirCache.db} is the timestamp cache file and
532     contains timestamp information for each file and directory in the
533     project source tree and configuration directory (\texttt{config}).
534     This will only exist when a build has run for the project.
535    
536     \subsection{The Project Boot Process}
537     The principle of both the bootstrapping and tool setup is the same as
538     with previous versions of \scram. However, in the current version there is a fundamental
539     difference in the way that the tool data, before and after being set
540     up, is stored in the project.
541     All tool data is now cached in a file called \texttt{ToolCache.db} which is
542     stored in an architecture-dependent location inside the
543     project (\ie under \texttt{.SCRAM/\$SCRAM\_ARCH}).
544    
545     \begin{description}
546     \item[Tool downloading:]\mbox{}\\
547     After tools have been downloaded to the local \scram\ cache (usually
548     \texttt{.SCRAM/cache}), those tools selected in the \texttt{RequirementsDoc} will be
549     set up. For each tool, a file \texttt{.SCRAM/InstalledTools/}\textit{toolname} will
550     be created. At the same time, the contents of this file will be
551     parsed and stored in the tool cache file. The order in which the
552     \lbkt\texttt{select}\rbkt statements appear in the \texttt{RequirementsDoc} will be the order
553     in which the tools are set up \textit{and} the order in which they appear in
554     any path-like runtime variables. This is completely independent of the
555     order in which tool files are downloaded (that is, the order in
556     which the \lbkt\texttt{require}\rbkt statements appear in the tool
557     configuration file, \ie \texttt{CMSconfiguration}).
558    
559     \item[Tool Storage:]\mbox{}\\
560     The cache file \texttt{ToolCache.db} replaces the numerous \texttt{*.dat} files that were previously
561     located in the architecture-dependent directories under \texttt{.SCRAM}.
562    
563     \item[Tool Parse:]\mbox{}\\ Once the tool is parsed and set up (using input from
564     \texttt{tools-CERN.conf}), a \texttt{ToolData} object holds the
565     data within the cache. The tool object provides the methods to access the
566     tool metadata.
567    
568     %% Skip this part for now, since it's not particularly reliable!
569     %%
570     % \item[Other Project Setup:]\mbox{}\\
571     % Setting up a project area which depends on another SCRAM-managed
572     % project is now quicker and less prone to error since the entire tool
573     % setup is copied to the new area. Only additional tools are set up in
574     % the traditional way. Note that the SCRAM projects used in the
575     % current project configuration must be installed in the scram database.
576     %%
577     \end{description}
578    
579     \subsection{Standalone Project Areas}
580    
581     Project areas can also be bootstrapped without having access to a
582     \texttt{CVS} repository or a version control system by using only local copies of the project
583     configuration files (and toolbox files, if required). This is ideal for fast prototyping.
584     There are two possible methods:
585    
586     \begin{description}
587     \item[Method 1:]\mbox{}\\
588     Use a standalone configuration directory which be copied directly to
589     the new project area, with \texttt{CVS} used only in the requirements
590     file to specify where the tool configuration and tools should be
591     downloaded from.
592     In this context, "standalone" means that the download \texttt{URL} is
593     of type \texttt{file:}, rather than \texttt{cvs:}.
594     The requirements file does specify \texttt{cvs:} with the path to the
595     toolbox repository.
596    
597     \item[Method 2:]\mbox{}\\
598     Use a standalone configuration directory and toolbox. Both the config
599     and the toolbox are normal directories on a local filesystem and only
600     the \texttt{file:} type of \texttt{URL} is used.
601     \end{description}
602    
603     \ni Examples of the content of boot files, requirements files and a
604     standalone toolbox are given in Chapter~\ref{ch:examples}.
605    
606     \section{Creating a Developer Area}\label{sec:SCRAMdevareas}
607     \index{using SCRAM developer areas}
608     \index{SCRAM developer area}
609    
610     \ni A developer area is an isolated area where a developer can work on a
611     given project without affecting other developers. This area is
612     associated with a particular version of a project available centrally
613     from which it can use resources (\eg \texttt{\#include} files, libraries or
614     environment files and settings). Software developers can check out source code
615     from \texttt{CVS} and \scram\ will build the products defined locally
616     and use these in place of those available in the
617     central release. All other products are transparently taken from the central project
618     release.
619    
620     \ni To develop on a given project a copy of the project must be installed
621     at the developer site. Available projects can be viewed using the
622     command \texttt{scram list}. To create the developer space, the command
623    
624     \begin{scramcmd}{project}
625     \inbrackets{project\_name}~\inbrackets{project\_version}
626     \end{scramcmd}
627    
628     \ni should be issued. The project name and version above are taken
629     from the list of \scram\ projects. The development area has the
630     structure and the same build environment as the base project.
631     Alternatively, a developer can bootstrap a project by first
632     checking out the \texttt{config} directory that matches the version of
633     the project that the developer are is to be based on and following the
634     steps described in Section~\ref{sec:creatProjArea}.
635     This can be implemented via a web interface such that a
636     source code distribution of the project can be obtained via a \scram\
637     download mechanism which can be enabled using any web browser. Follow
638     the instructions in Section~\ref{sec:webbootstrap} on page
639     p\pageref{sec:webbootstrap} to do this. Once
640     correctly configured, a project can be installed using a single-click
641     operation in a browser window.
642    
643     \subsection{Using the Developer Area}\label{sec:usingscramdevarea}
644     \index{SCRAM developer area!using a}
645    
646     Once the area has been created, the \texttt{src} directory can be
647     populated with the source code of interest. This step
648     involves \texttt{CVS} alone; usually, a module corresponds to a package and so
649     the whole module would be checked out from the \texttt{CVS} repository. This
650     would be achieved using the command
651    
652     \texttt{cd src;}~\texttt{cvs co}~\textit{module}
653    
654     \ni Note that the above command will check out the development
655     \texttt{HEAD}. To check out a fixed tagged version or the head of
656     another development branch, specify a \texttt{CVS} revision using the {\bf -r}
657     option:
658    
659     \texttt{cd src;}~\texttt{cvs co -r}~\textit{version}~\textit{module}
660    
661     \ni Once the sources are checked out, they can be edited as required
662     and committed to \texttt{CVS}.
663    
664    
665     \subsection{Obtaining Help}\label{sec:gettinghelp}
666     \index{getting help}
667     \index{\texttt{scram help}}
668     \index{\texttt{scram help} for specific commands}
669     Help can be obtained directly using the \scram\ global \texttt{help}
670     command, or by using the \texttt{help} option of a specific command.
671     For example,
672    
673     \begin{description}
674     \item[\texttt{scram help} or \texttt{scram -help}]\mbox{}\\
675     will list all available \scram\ commands
676     \item[\texttt{scram} \textit{command} \texttt{-help}]\mbox{}\\
677     will print the help for a specific command
678     \item[\texttt{scram build -help}]\mbox{}\\
679     will print the help available for the current build location.
680     Normally, this will show the available types of build that can be
681     performed in the current directory.
682     \end{description}
683    
684     \ni The short versions of the help command can also be used (\ie
685     \texttt{-h} instead of \texttt{--help}).
686    
687     \ni A summary of the \scram\ commands is available in Chapter~\ref{ch:quickhelpguide}.
688    
689    
690     \section{The SCRAM Runtime Environment}\label{sec:scramruntimeenv}
691     \index{SCRAM!runtime environment}
692     \index{runtime environment}
693     Each development area has an environment associated with it which is
694     related to the tools used at build-time (the \textit{configuration
695     environment}) or project-wide defaults used at runtime (the
696     \textit{application environment}). \scram\ establishes the build-time
697     environment through the parsing of the \texttt{ToolDocs} of the tools
698     in the configuration environment. The values of any variables that
699     describe paths to header files or required libraries are passed
700     automatically to the build system at build-time. Project-wide defaults
701     can be specified using a document called \texttt{Self}, which is
702     located in project configuration directory and contains default
703     settings for variables that should be available globally in the
704     project area.
705     \index{SCRAM!runtime environment!viewing and setting}
706     \ni The current environment can be viewed using the command
707    
708     \begin{scramcmd}{runtime}
709     \marg{-sh}~(\textit{or}~\marg{-csh} for \texttt{tcsh} users)
710     \end{scramcmd}
711    
712     \ni choosing the appropriate shell type flag according to the type of
713     shell in use. The runtime environment is not set automatically. To set
714     it, evaluate the command above using the shell \texttt{eval} function:
715    
716     \begin{tagprint}
717     \texttt{eval} `\texttt{scram runtime}~\texttt{-sh}` (\textit{or} \texttt{-csh})
718     \end{tagprint}
719    
720     \ni This must be set manually when running an executable since it
721     sets the \texttt{LD\_LIBRARY\_PATH} and other environment
722     variables, as defined in the configuration documents of the
723     project. All variables that are set also have an associated
724     \texttt{SCRAMRT\_xxxx} variable. This allows \scram\ to undo any
725     changes to the environment and facilitates the switching between
726     project areas without interference. The consistency checking is done
727     automatically.
728    
729     \subsection{Constructing Runtime Environment Documents}\label{sec:constructingruntimedocs}
730     \index{SCRAM!runtime environment!constructing}
731     \index{constructing a runtime environment document}
732     A runtime document can be created for any application with the purpose
733     of defining any environment variables that might be required to run
734     the application properly. These might be special switches that control
735     how an application runs or settings of internal debugging or verbosity
736     levels. A variable can be defined in a runtime document using the tag
737    
738     \begin{tagprint}
739     \lbkt\texttt{Runtime} name=\textit{variable} value=\textit{value}
740     {[}type=\textit{type}{]} {[}handler=\textit{warn,error}{]}\rbkt\mbox{}\\
741     \tagend{Runtime}
742     \end{tagprint}
743    
744     \ni A good practise is to include some usage information between the
745     \lbkt\texttt{Runtime}\rbkt tags in the definition of the variable.
746     All variables defined in a runtime document \texttt{filename} can be viewed using the command
747    
748     \begin{scramcmd}{runtime}
749     \marg{-sh}~(\textit{or}~\marg{-csh})~\marg{-f filename}
750     \end{scramcmd}
751    
752     \ni or for a specific variable only using
753    
754     \begin{scramcmd}{runtime}
755     \marg{-sh}~(\textit{or}~\marg{-csh})~\marg{-f filename}~\marg{-info varname}
756     \end{scramcmd}
757    
758     \ni The file \texttt{filename} is assumed to be located in the current directory.
759    
760     \section{Interacting with the Configuration Environment}\label{sec:configurationtools}
761     \index{configuration tools}
762     Although all required external tools are automatically set up by the
763     \scram\ configuration manager in every project area, a developer may
764     want to change settings to suit a local system like a laptop computer.
765     \scram\ provides several commands to allow developers to easily view
766     the configuration environment and also to change it. The list of
767     configured tools available can be obtained using the command
768    
769     \begin{scramcmd}{tool}
770     \texttt{list}
771     \end{scramcmd}
772    
773     \ni This will present a list like the one shown below: \footnotesize{
774     \begin{verbatim}
775     Tool list for location /home/t/work/projects/TESTING_1.0
776     ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
777    
778     cxxcompiler 3.2.3
779     f77compiler 3.2.3
780     ccompiler 3.2.3
781     clhep 1.9.1.2
782     aida 3.2.1
783    
784     \end{verbatim}
785     }\normalsize
786    
787     \ni The settings for a tool can be viewed using the command
788    
789     \begin{scramcmd}{tool}
790     \texttt{info} \texttt{tool\_name}
791     \end{scramcmd}
792    
793     \ni For example, the settings of the tool \texttt{zlib} would look like
794     this: \small{
795     \begin{verbatim}
796     Tool info as configured in location /home/t/work/projects/TESTING_1.0
797     +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
798    
799     Name : zlib
800     Version : 1.1.4
801     ++++++++++++++++++++
802     SCRAM_PROJECT=no
803     ZLIB_BASE=/opt/lcg/external/zlib/1.1.4/slc3_ia32_gcc323
804     LIB=z
805     LIBDIR=/opt/lcg/external/zlib/1.1.4/slc3_ia32_gcc323/lib
806     INCLUDE=/opt/lcg/external/zlib/1.1.4/slc3_ia32_gcc323/include
807     LD_LIBRARY_PATH=/opt/lcg/external/zlib/1.1.4/slc3_ia32_gcc323/lib
808     \end{verbatim}
809     }\normalsize
810    
811     \ni Another useful command can be used to extract the settings of
812     individual variables for a tool:
813    
814     \begin{scramcmd}{tool}
815     \texttt{tag} \texttt{tool\_name} \option{tag\_name}
816     \end{scramcmd}
817    
818     \ni where \textit{tag\_name} is the name of a variable relevant for
819     the tool \textit{tool\_name}. If no tag name is given then all
820     variable names will be printed. If this command is used in the
821     following way
822    
823     \begin{scramcmd}{tool}
824     \texttt{tag} \texttt{zlib} \marg{INCLUDE}
825     \end{scramcmd}
826    
827     \ni then \texttt{/opt/lcg/external/zlib/1.1.4/slc3\_ia32\_gcc323/include} will be printed. This
828     is especially useful within shell scripts and avoids the need for
829     parsing the command output with shell utilities like \texttt{sed} or
830     \texttt{awk}.
831    
832     \subsection{Changing Settings of Tools}\label{sec:changingtoolsettings}
833     \index{changing settings of tools}
834    
835     The default settings of the installation can be changed at any time.
836     There are two modes available for setting up the tools: automatic and
837     interactive. The automatic mode is the default and will be used to set
838     up tools after a \texttt{scram project} command using a bootstrap file
839     has been issued. In this automatic mode, the \scram\ configuration
840     manager attempts to determine the correct values of the tool variables
841     using default locations, environment variables or checking other
842     already installed projects. Failing this, the user will be prompted to
843     enter a value using interactive mode. Once a value has been chosen
844     for a path it will be checked to make sure that it exists. If it does
845     not, the user will be prompted to try again.
846    
847     \ni Many of the common external tools used at CERN are installed in
848     single locations. The automated setup mechanism can use a variable to
849     define a search path. This is the purpose of the tool lookup file (usually a file
850     called \texttt{tools-SITENAME.conf} where sitename is site-specific
851     and can be set when \scram\ is installed \footnote{Some examples of
852     site names area CERN, LAPTOP, STANDALONE etc.}).
853    
854     The variable called \texttt{SCRAM\_BASEPATH} can be set to
855     point to the base directory of an external installation area as in the example
856     below. Variable expansion occurs automatically so this variable can be
857     used anywhere in a tool lookup file.
858     A lookup file for a system with \texttt{SCRAM\_ARCH} set to
859 sashby 1.4 \texttt{slc3\_ia32\_gcc323} starts with the following entries:
860 sashby 1.1
861     \small{
862     \begin{verbatim}
863     ARCHITECTURE:slc3_ia32_gcc323
864     SCRAM_BASEPATH:/opt/cms/external
865     \end{verbatim}
866     }\normalsize
867    
868     An entry for a tool then looks like this:
869    
870     \small{
871     \begin{verbatim}
872     TOOL:cxxcompiler:
873     +CXX:/usr/bin/c++
874     +CC:/usr/bin/gcc
875     TOOL:clhep:
876 sashby 1.4 +CLHEP_BASE:$SCRAM_BASEPATH/clhep/1.9.2.2/slc3_ia32_gcc323
877 sashby 1.1 \end{verbatim}
878     }\normalsize
879    
880     \ni When \scram\ tries to set up a particular tool, it will search the
881     lookup file first for a variable name that matches the one that is
882     being set up: if there is a value set, it will be used. Using the
883     command
884    
885     \begin{scramcmd}{setup}
886 sashby 1.4 \flag{-i}~\option{tool\_name}~\optionwflag{-f}{tools.conf}
887 sashby 1.1 \end{scramcmd}
888    
889     \ni the setup of a specific tool that is already installed is rerun.
890     The \textbf{-f} flag causes setup to read the tool lookup file given.
891     This filename must end in `.conf' but can have any name. Supplying a
892     tool lookup file on the command-line like this overrides any other
893     \scram\ variables that point to lookup files. All automatic mechanisms
894     that \scram\ uses to install a tool can be overidden with the
895     \textbf{-i} option giving the user complete control.
896    
897     \subsection{Removing Tools from a Project Area}\label{sec:removingtools}
898     \index{removing tools from a project area}
899     A tool can be removed from a project area using the command
900    
901     \begin{scramcmd}{tool}
902     \texttt{remove} \texttt{tool\_name}
903     \end{scramcmd}
904    
905     \ni This completely removes all references to the tool. To re-install
906     the default version, the setup must be re-run. Before installing a new
907     version of a tool it is best to remove the old version.
908    
909     \subsection{Installing New Tools into a Project Area}\label{sec:cvsrootbreakdown}
910     \index{installing new tools in a project area}
911     A new tool is installed using the command
912    
913     \begin{scramcmd}{setup}
914 sashby 1.4 \flag{-i}~\marg{tool\_name}~\marg{tool\_version}~\marg{url}~\optionwflag{-f}{tools.conf}
915 sashby 1.1 \end{scramcmd}
916    
917     \ni where the \texttt{url} is either a tool description file or a
918     valid CVS location (that is, the URL types are \texttt{file:},
919     \texttt{http:} or \texttt{url:}). A tool description template can be created using the
920     command \texttt{scram tool template}: this will create a template in
921     your current directory. Edit this to suit, ensuring that it has a tool
922     name and version. Define any variables that need to be set, and
923     libraries that are required. Then just run
924    
925     \begin{scramcmd}{setup}
926 sashby 1.4 \flag{-i}~\marg{tool\_name}
927     ~\marg{tool\_version}~\marg{file:./tool\_template}~\optionwflag{-f}{tools.conf}
928 sashby 1.1 \end{scramcmd}
929    
930     \ni and supply the settings as required. Using \texttt{http:} and a
931     path to a tool document, transfer using the HTTP protocol can be used
932     to download the document to the local directory where it will be parsed.
933    
934     %% FIXME: This whole section needs updating!
935     \ni The third URL type refers to download locations on a CVS server. A
936     typical URL can be broken down into six parts that are combined as a
937     single string. These components, for a typical URL, are--
938    
939     \begin{description}
940     \item[\texttt{cvs://lcgapp.cern.ch/cvs/SPITOOLS}]\mbox{}\\
941     The path to to the \texttt{ToolBox} repository on a CVS server. This
942     example is for a regular CVS server allowing at least \texttt{pserver}
943     anonymous access. If the authentication type is \texttt{local} then
944     the path will point directly to a directory:\mbox{}\\
945     \begin{center}
946     \small{
947     \begin{verbatim}
948     cvs:/fs/local/cvs_repositories/ToolBox
949     \end{verbatim}}\normalsize
950     \vspace{-5mm}
951     \end{center}
952     \index{CVSROOT!elements}
953     \index{CVSROOT!setting for a new tool}
954     \item[\texttt{{?}auth=pserver}]\mbox{}\\
955     The authentication type. This can be \texttt{pserver} for anonymous
956     checkouts or \texttt{local} for a repository on a local filesystem
957     instead of a dedicated server.
958     \item[\texttt{\&module=SCRAMToolBox/Tools/TOOLNAME}]\mbox{}\\
959     The location of the module (the tool document for \texttt{TOOLNAME})
960     to be checked out.
961     \item[\texttt{passkey=Ah<Z}]\mbox{}\\
962     The passkey needed for anonymous checkout. This is the password entry
963     in the file \texttt{.cvspass} usually found in a user home directory
964     after a \texttt{cvs login} command has been run.
965     \item[\texttt{user=anonymous}]\mbox{}\\
966     The user name for anonymous checkout. This can sometimes be
967     \texttt{anon}. Check with local CVS administrators to see how your
968     site repository has been set up.
969     \item[\texttt{version=LCG\_06}]\mbox{}\\
970     The configuration version.
971     \end{description}
972    
973     % % \subsection{The SCRAM Graphical Interface}\label{sec:scramgui}
974     % % \textit{still work in progress!!!!}\mbox{}
975     % % A graphical interface to the tool metadata allows direct interaction
976     % % with tool settings. This is especially useful for modifying compiler
977     % % flags. The command
978    
979     % % \begin{scramcmd}{ui}
980     % % \optionwflag{-edit}{compiler}
981     % % \end{scramcmd}
982    
983     % % will show a window in which compiler information for each configured
984     % % compiler can be seen. Another option \texttt{tool} can be used to
985     % % modify tool settings.
986    
987    
988     %%% Local Variables:
989     %%% mode: latex
990     %%% TeX-master: "SCRAM-manual"
991     %%% End:
992    
993     %%____________________________________________________________________
994     %% End of CreatingProjects.tex
995     %%____________________________________________________________________
996     %%