ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/doc/tex/manual/Examples.tex
Revision: 1.3
Committed: Mon Nov 7 14:30:19 2005 UTC (19 years, 6 months ago) by sashby
Content type: application/x-tex
Branch: MAIN
CVS Tags: V1_0_2
Branch point for: v103_branch
Changes since 1.2: +122 -319 lines
Log Message:
Update to docs.

File Contents

# User Rev Content
1 sashby 1.1 %%____________________________________________________________________
2     %% File: Examples.tex
3     %%____________________________________________________________________
4     %%
5     %% Author: Shaun ASHBY <Shaun.Ashby@cern.ch>
6     %% Update: 2005-11-02 17:08:52+0100
7 sashby 1.3 %% Revision: $Id: Examples.tex,v 1.2 2005/11/04 16:32:44 sashby Exp $
8 sashby 1.1 %%
9     %% Copyright: 2005 (C) Shaun ASHBY
10     %%
11     %%--------------------------------------------------------------------
12     \chapter{Examples}\label{ch:examples}
13    
14 sashby 1.3 This chapter contains some useful examples of how to work with
15 sashby 1.2 \scram.
16 sashby 1.1
17     \section{Configuring New Projects}\label{sec:configuringprojectexample}
18    
19 sashby 1.2 This section covers how to create a new project using the boot
20     mechanism. Normally, a boot file will instruct \scram\ to download
21     configuration documents from a \texttt{CVS} repository. However,
22     sometimes this may not be possible because the appropriately
23     configured files may not yet be available in a repository or it is
24     more desirable to make a prototype locally before committing anything.
25 sashby 1.1
26     \subsection{Creating Standalone Projects}\label{sec:configuringstandaloneprojects}
27    
28 sashby 1.2 First we will describe how to boot a project from copies of
29     configuration files based on the templates provided by
30     \scram. These templates can be obtained using \texttt{scram project -t}.
31     The \texttt{config} directory created locally contains build
32     templates and a global \buildfile, plus the boot and requirements
33     files. The boot file looks like this:
34     \small{
35     \begin{verbatim}
36     <doc type=Configuration::BootStrapProject version=1.0>
37 sashby 1.3 <project name=TEST version=1_0>
38     <base url="file:SCRAMToolBox">
39     <download url="file:/CMSconfigs" name=config/site>
40 sashby 1.2 </base>
41    
42     <Config dir=config>
43     <base url="file:config">
44     <download url="file:/" name="config">
45     <RequirementsDoc name=config/requirements>
46     </base>
47     </project>
48     \end{verbatim}}\normalsize
49    
50     \ni and the requirements document looks like this:
51     \small{
52     \begin{verbatim}
53 sashby 1.3 <doc type=BuildSystem::Requirements version=2.0>
54     <base url="file:SCRAMToolBox">
55     <include url="file:/CMS/Configuration/CMSconfiguration">
56     <select name=cxxcompiler>
57     </base>
58 sashby 1.2 \end{verbatim}}\normalsize
59    
60 sashby 1.3 \ni These must now be edited to suit. Here is a recipe:
61 sashby 1.2
62     \begin{description}
63     \item[Decide on a project name and version:]\mbox{}\\
64     Edit the boot file, changing the name and version of the project as
65 sashby 1.3 desired. In the example, the project name is \texttt{TEST} and the
66     version is $1.0$.
67 sashby 1.2 \item[Configure a toolbox with required tools:]\mbox{}\\
68     In this example, we configure a completely standalone toolbox as a
69     directory structure containing the tool descriptions needed for the
70     project dependencies. There are no references to \texttt{cvs:\\} type
71     URLS and therefore no interaction with a CVS repository.
72     This allows for a very fast setup process since files are
73     "downloaded" from a local disk.
74 sashby 1.3 \end{description}
75 sashby 1.2
76     \ni Now we follow a second example in which a toolbox configuration
77     already exists, as prepared by the software librarian, with a
78 sashby 1.3 published CVS tag. The boot file looks like this:
79     \small{
80     \begin{verbatim}
81     <doc type=Configuration::BootStrapProject version=1.0>
82     <project name=TEST version=1_0>
83     <base url="cvs://cmscvs.cern.ch/cvs_server/repositories/SCRAMToolBox
84     ?auth=pserver&user=anonymous&passkey=AA_:yZZ3e&version=CMS_127_2">
85     <download url="cvs:?module=SCRAMToolBox/CMSconfigs" name=config/site>
86     </base>
87    
88     <Config dir=config>
89     <base url="file:config">
90     <download url="file:/" name="config">
91     <RequirementsDoc name=config/requirements>
92     </base>
93     </project>
94     \end{verbatim}}\normalsize
95    
96     \ni and the requirements document looks like this:
97     \small{
98     \begin{verbatim}
99     <doc type=BuildSystem::Requirements version=2.0>
100     <base url="cvs://cmscvs.cern.ch/cvs_server/repositories/SCRAMToolBox
101     ?auth=pserver&user=anonymous&passkey=AA_:yZZ3e&version=CMS_127_2">
102     <include url="cvs:?module=SCRAMToolBox/CMS/Configuration/CMSconfiguration">
103     <select name=cxxcompiler>
104     </base>
105     \end{verbatim}}\normalsize
106    
107     \ni The toolbox has the CVS tag \texttt{CMS\_127\_2} which is
108     formatted according to local conventions but can be any valid
109     (existing) tag. When the project is booted, the toolbox will be
110     checked out from CVS but the project configuration will be taken from
111     a local \texttt{config} directory and copied to the final project area.
112 sashby 1.1
113    
114     \section{BuildSystem and Configuration Tips And Tricks}
115    
116     Examples of useful tips? For configuration, could mention changes to \texttt{Self}.
117    
118     \paragraph{Using Project ClassPaths to Customise the Build System}
119    
120     Describe a proper ClassPath.
121    
122     \paragraph{Redefining An Existing Tool}
123    
124     Currently it is not possible to have multiple versions of the same
125     tool. Therefore, this recipe should be followed if an installed tool
126     should be modified, for example to redefine the libraries used or to
127     add an extra runtime variable definition.
128    
129 sashby 1.3 \begin{itemize}
130     \item Create a new template using \scram, or copy the installed version
131     from \texttt{.SCRAM/architecture/InstalledTools}. If you cannot see
132 sashby 1.1 the \texttt{InstalledTools} directory (which sometimes happens for
133     %% FIXME>> Should this be ``scram set'' or will ``scram setup <tool>'' work?
134     developer areas), type \texttt{scram setup} or copy the tool description file
135     from the release area for the version of the project you're using to
136     the project area.
137    
138 sashby 1.3 \item Edit this version of the tool file.
139 sashby 1.1
140 sashby 1.3 \item Delete the installed version by running \texttt{scram tool remove <tool>}.
141 sashby 1.1
142 sashby 1.3 \item Set up the new version of the tool, giving a \texttt{file:} URL to
143     point to your new tool description file.
144     \end{itemize}
145 sashby 1.1
146     \paragraph{Creating an executable}
147    
148 sashby 1.3 How to create a binary executable. Define real binaries in a
149     \texttt{bin} directory in the package.
150 sashby 1.1
151     \paragraph{Creating a test executable}
152    
153 sashby 1.3 How to create a test binary executable? Binaries defined in
154     \texttt{test} subdirectories are automatically treated as test executables
155     A different template for tests (relative to normal binaries) defines custom behaviour, in this
156 sashby 1.1 case to move the product to a \texttt{test} storage location and
157 sashby 1.3 defining rules for executing the test.
158 sashby 1.1
159     \paragraph{Changing the default name of a package library}
160    
161     The CMSSW example. Demonstrate how to change the name of the target,
162     taking the path information from the standard template for the library.
163    
164     \paragraph{Creating an extra shared library}
165    
166 sashby 1.3 How to use the \texttt{extra\_library\_template.tmpl} template. Types of globs
167 sashby 1.1 to pick up source files from a stubs directory, for example.
168    
169     \paragraph{How to create a debug version of something}
170    
171 sashby 1.3 Adding $<$Flags \texttt{CXXFLAGS}=\texttt{-g -O0}$>$ to the
172     \buildfile\ will add the debug flags to the global compiler flags.
173 sashby 1.1
174     \subsection{How To Avoid Rebuilding}
175    
176 sashby 1.3 Create a private ``release'' area from which to create
177     a developer area. Use your own project database by setting
178     \texttt{SCRAM\_USERLOOKUPDB} to a local directory in which a
179     \texttt{project.lookup} is added.
180     To install the project on which a release will be based, change to the
181     project area and type \texttt{scram install}. The project should now
182     appear in the list of projects returned by \texttt{scram list}.
183    
184     \ni A developer area can be created using \texttt{scram project NAME
185     VERSION}, where the \texttt{NAME} and \texttt{VERSION} match those
186     in the list of projects.
187 sashby 1.1
188    
189 sashby 1.3 \example{Defining a New ClassPath}
190     Following the recommended project structure conventions, here is an
191     example of \lbkt\texttt{ClassPath}\rbkt settings for a project:
192     \index{\texttt{ClassPath} tag!example}
193    
194     \small{
195     \begin{verbatim}
196     <ClassPath path=+Project/+SubSystem/+Package/src+library>
197     <ClassPath path=+Project/+SubSystem/+Package/test+test>
198     <ClassPath path=+Project/+SubSystem/+Package/bin+binary>
199 sashby 1.1 \end{verbatim}}\normalsize
200    
201     \index{structure templates! and the \texttt{ClassPath}}
202     \ni These settings will associate the top-level \texttt{src}
203     directory with \texttt{Project\_template.tmpl} and any directory in the next
204     level with the template \texttt{SubSystem\_template.tmpl}.
205     The level below that will be associated with \texttt{Package\_template.tmpl}.
206     The last elements have a pattern-matching string before the \texttt{+}
207     sign: only directories matching the names \texttt{src},
208 sashby 1.3 \texttt{test} and \texttt{bin} at the third level below
209 sashby 1.1 the top-level \texttt{src} directory will be mapped to the
210     templates \texttt{library\_template.tmpl},
211 sashby 1.3 \texttt{test\_template.tmpl} and
212     \texttt{binary\_template.tmpl} respectively. Thus, any
213 sashby 1.1 source files in a directory \texttt{src} at package-level will
214     source the template \texttt{library\_template.tmpl} for build
215 sashby 1.3 rules to build a library. Likewise, binary executables will be
216 sashby 1.1 built from sources located in any directory called
217 sashby 1.3 \texttt{bin} using a template \texttt{binary\_template.tmpl}.
218 sashby 1.1
219 sashby 1.3 \example{An Example ProductStore}
220     To create separate \texttt{include},\texttt{bin} and \texttt{lib} subdirectories, all of which are
221 sashby 1.1 architecture-dependent, the following tags would be added to the project \texttt{BuildFile}:
222     \index{\texttt{ProductStore} tag!example}
223 sashby 1.3
224     \small{
225     \begin{verbatim}
226     <ProductStore name=include type=arch>
227     <ProductStore name=lib type=arch>
228     <ProductStore name=bin type=arch>
229     <ProductStore name=module type=arch swap=t>
230     \end{verbatim}}\normalsize
231 sashby 1.1
232     \ni In the above example, the storage location for modules is architecture-dependent and is
233 sashby 1.3 created as \texttt{module/slc3\_ia32\_gcc323} on a system with a \scram\
234     architecture \texttt{slc3\_ia32\_gcc323}. The other directories
235 sashby 1.1 (\texttt{bin}, \texttt{lib} and \texttt{include}) are created under a
236 sashby 1.3 directory \texttt{slc3\_ia32\_gcc323} in the project area.
237 sashby 1.1
238 sashby 1.3 \example{Example Binary BuildFile}
239     Here is an example of a \buildfile\ to build two binary executables:
240 sashby 1.1
241 sashby 1.3 \small{
242     \begin{verbatim}
243     <Group name=SimReader>
244     <bin file=testSimReader.cpp>
245     </bin>
246     <bin file=testObserver.cpp>
247     </bin>
248 sashby 1.1 \end{verbatim}}\normalsize
249    
250     \ni The object files for both binaries are linked against the
251 sashby 1.3 libraries provided by group \texttt{SimReader} to produce the executables.
252 sashby 1.1
253 sashby 1.3 \example{Example Plugin BuildFile} This example will build
254     a shared library which is to be used as a managed plugin:
255 sashby 1.1
256 sashby 1.3 \small{
257     \begin{verbatim}
258     <library file=BaseUtilitiesModule.cpp name=BaseUtilPlugin>
259     <Group name=BaseUtilities>
260     <Flags SEAL_PLUGIN_NAME='BaseUtilPlugin'>
261     </library>
262 sashby 1.1 \end{verbatim}}\normalsize
263    
264    
265     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
266    
267     %%% Local Variables:
268     %%% mode: latex
269     %%% TeX-master: "SCRAM-manual"
270     %%% End:
271    
272     %%____________________________________________________________________
273     %% End of Examples.tex
274     %%____________________________________________________________________
275     %%