ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/doc/tex/manual/Examples.tex
Revision: 1.1
Committed: Wed Nov 2 16:24:18 2005 UTC (19 years, 6 months ago) by sashby
Content type: application/x-tex
Branch: MAIN
CVS Tags: V1_0_2_p1
Log Message:
Commit first version of updated manual.

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     %% Revision: $Id$
8     %%
9     %% Copyright: 2005 (C) Shaun ASHBY
10     %%
11     %%--------------------------------------------------------------------
12     \chapter{Examples}\label{ch:examples}
13    
14    
15     \section{Configuring New Projects}\label{sec:configuringprojectexample}
16    
17    
18     \subsection{Creating Standalone Projects}\label{sec:configuringstandaloneprojects}
19    
20    
21    
22     \section{BuildSystem and Configuration Tips And Tricks}
23    
24     Examples of useful tips? For configuration, could mention changes to \texttt{Self}.
25    
26     \paragraph{Using Project ClassPaths to Customise the Build System}
27    
28     Describe a proper ClassPath.
29    
30     \paragraph{Redefining An Existing Tool}
31    
32     Currently it is not possible to have multiple versions of the same
33     tool. Therefore, this recipe should be followed if an installed tool
34     should be modified, for example to redefine the libraries used or to
35     add an extra runtime variable definition.
36    
37     - Create a new template using \scram, or copy the installed version
38     from \texttt{.SCRAM/architecture/InstalledTools}. If you cannot see
39     the \texttt{InstalledTools} directory (which sometimes happens for
40     %% FIXME>> Should this be ``scram set'' or will ``scram setup <tool>'' work?
41     developer areas), type \texttt{scram setup} or copy the tool description file
42     from the release area for the version of the project you're using to
43     the project area.
44    
45     Next, edit this version of the tool file.
46    
47     Delete the installed version by running \texttt{scram tool remove <tool>}.
48    
49     Set up the new version of the tool, giving a \texttt{file:} URL to
50     point to your new tool description file.
51    
52     \paragraph{Creating an executable}
53    
54     How to create a binary executable.
55    
56     \paragraph{Creating a test executable}
57    
58     How to create a test binary executable. How is this different to a
59     normal binary? Different template defines custom behaviour, in this
60     case to move the product to a \texttt{test} storage location and
61     defining rules for executing the test.
62    
63     \paragraph{Changing the default name of a package library}
64    
65     The CMSSW example. Demonstrate how to change the name of the target,
66     taking the path information from the standard template for the library.
67    
68     \paragraph{Creating an extra shared library}
69    
70     How to use the \texttt{extra\_library.tmpl} template. Types of globs
71     to pick up source files from a stubs directory, for example.
72    
73    
74     \paragraph{How to create a debug version of something}
75    
76     Basically by adding $<$flags \texttt{CXXFLAGS}=\texttt{-g -O0}$>$ to
77     the \buildfile. Easy.
78    
79     \subsection{How To Avoid Rebuilding}
80    
81     Info here on creating a private ``release'' area from which to create
82     a developer area.
83    
84    
85     \example{Example} An example of the contents of a bootstrap file for
86     a project is shown below. \index{example bootstrap file}
87     %\footnotesize{\begin{verbatim}
88     %<doc type=Configuration::BootStrapProject version=1.0>
89     %<project name=P version=P_1_0>
90     %<base url="cvs://server.cern.ch?auth=pserver&user=anoncvs&passkey=Ah<Z&version=TAG">
91     %<download url="cvs:?module=SCRAMToolBox/configs" name=config/site>
92     %</base>
93     %
94     %*************************************************************
95     %
96     %<Config dir=config>
97     %<base url="cvs://server.cern.ch/cvs/SEAL?auth= \
98     %pserver&user=anoncvs&passkey=Ah<Z&version=SEAL_1_1_0">
99     %<download url="cvs:?module=scram" name="config">
100     %<RequirementsDoc name=config/RequirementsDoc>
101     %</base>
102     %</project>
103     %\end{verbatim}}\normalsize
104    
105     \ni This bootstrap file instructs \scram to create a project area
106     called \texttt{P\_1\_0}. Inside this area there is a
107     directory called \texttt{config} (the configuration directory)
108     where all project configuration files are stored. All source code
109     for the project is downloaded to a directory called
110     \texttt{src}. Once the configuration files have been downloaded,
111     \scram parses the requirements file \texttt{RequirementsDoc},
112     found in the \texttt{config} directory.
113    
114     \example{Example} Here is part of the requirements file for the
115     \texttt{COBRA} project example used above:\index{example requirements file}
116     %% \footnotesize{\begin{verbatim}
117     %% <doc type=BuildSystem::Requirements version=2.0>
118     %% <baseurl="cvs://cmscvs.cern.ch/cvs_server/repositories/ToolBox?auth=\
119     %% pserver&user=anonymous&passkey=AA_:yZZ3e&version=CMS_53_1">
120     %% <include url="cvs:?module=ToolBox/CMS/Configuration/CMSconfiguration">
121     %% <Architecture name=SunOS__5>
122     %% <select name=CC>
123     %% </Architecture>
124     %% <Architecture name=Linux__2>
125     %% <select name=gcc>
126     %% </Architecture>
127     %% <select name=clhep>
128     %% <select name=htl>
129     %% <select name=qt>
130     %% </base>
131     %% \end{verbatim}}\normalsize
132    
133     %% \ni The base URL is set to point to a CVS repository for the
134     %% toolbox. The version of the toolbox to be used has the CVS
135     %% symbolic tag \texttt{CMS\_53\_1} according to local
136     %% conventions.The configuration file \texttt{CMSconfiguration} is
137     %% included using an \lbkt\texttt{include}\rbkt statement. This file
138     %% contains entries like these\index{example using the \texttt{include} directive}
139    
140     %% \footnotesize{\begin{verbatim}
141     %% <Architecture name=SunOS__5>
142     %% <require name=CC version=5.2 url="cvs:?module=ToolBox/CompilerTools/CXX/SunCC">
143     %% </require>
144     %% </Architecture>
145     %% <Architecture name=Linux__2>
146     %% <require name=cxxcompiler version=2.95.2 url="cvs:?module=ToolBox/CompilerTools/CXX/gcc">
147     %% </require>
148     %% </Architecture>
149     %% <require name=Qt version=3.0.1 url="cvs:?module=ToolBox/LHCxx/Qt">
150     %% </require>
151     %% <require name=CLHEP version=1.7.5.0 url="cvs:?module=ToolBox/LHCxx/CLHEP">
152     %% </require>
153     %% <require name=HTL version=1.3.2.1 url="cvs:?module=ToolBox/LHCxx/HTL">
154     %% </require>
155     %% \end{verbatim}}\normalsize
156    
157     \ni which are parsed directly after the file is downloaded,
158     \ie the behaviour is exactly the same as if the
159     \lbkt\texttt{require}\rbkt statements are written in the
160     requirements file itself. The compiler tool document wraps the
161     architecture-specific information within the document itself so that
162     it is only necessary to have \lbkt\texttt{use} name=\texttt{cxxcompiler}\rbkt
163     declared in the project \texttt{BuildFile} to use the specified
164     compiler. If no compiler is declared like this, the native
165     \texttt{g++/gcc} will be used instead.
166     %Notice that the compilers are
167     %enclosed within architecture specific blocks-- more details
168     %concerning compiler support can be found in Section~\ref{sec:compilersupport}.
169    
170    
171     \example{Example} Here is an example of a \texttt{ToolDoc} for a tool
172     called \texttt{CLHEP}: \index{\texttt{ToolDoc}!example}
173     %% \footnotesize{\begin{verbatim}
174     %% <doc type=BuildSystem::ToolDoc version=1.0>
175     %% <Tool name=CLHEP version=1.7.5.0>
176     %% <info url=http://wwwinfo.cern.ch/asd/lhc++/clhep></info>
177     %% <LIB name=CLHEP>
178     %% <Client>
179     %% <Environment name=CLHEP_BASE>
180     %% The top of the standard CLHEP distribution.
181     %% </Environment>
182     %% <Environment name=LIBDIR default="$CLHEP_BASE/lib" type=lib>
183     %% The Library location for the CLHEP distribution
184     %% </Environment>
185     %% <Environment name=INCLUDE default="$CLHEP_BASE/include">
186     %% The header file location for the CLHEP distribution
187     %% </Environment>
188     %% </Client>
189     %% <Environment name=LD_LIBRARY_PATH value="$LIBDIR" type=Runtime_path>
190     %% </Environment>
191     %% </Tool>
192     %% \end{verbatim}}\normalsize
193     %% %$
194     \ni When this \texttt{ToolDoc} is parsed by \scram,
195     \texttt{CLHEP\_BASE} is set by the configuration manager
196     (either automatically or by prompting the user if necessary), both
197     \texttt{LIBDIR} and \texttt{INCLUDE} are set to the default
198     values if these paths are found to be valid and, at runtime, the
199     value of the path \texttt{\$LIBDIR} is appended to the user
200     shell variable \texttt{\$LD\_LIBRARY\_PATH} if it exists
201     (otherwise, it is defined automatically).
202    
203    
204     \ni Here area several examples illustrating how to use the \texttt{scram setup} command.
205    
206     \example{Example A} We want to add to our area an analysis tool called \texttt{ROOT}.
207     This tool is included in the tagged configuration available to all projects, so the
208     setup command to use in this case is--
209    
210     \small{\begin{verbatim}
211     scram setup [-i] root 3.05.03 \
212     'cvs://lcgapp.cern.ch/cvs/SPITOOLS? \
213     auth=pserver&module=SCRAMToolBox/General/ROOT \
214     &passkey=Ah<Z&user=anonymous&version=LCG_06'
215     \end{verbatim}}\normalsize
216    
217     \example{Example B} We want to add the tool \texttt{ruby}
218     to our project area. This is not a regularly used tool (that is, the tool is not contained in
219     the configuration), so we will add it using a local tool
220     description file. The command is
221    
222     \begin{scramcmd}{setup}
223     \flag{-i}~\marg{ruby}~\marg{1.6.7}~\marg{file:./ruby-1.6.7}
224     \end{scramcmd}
225    
226     \ni The tool description file looks like this:
227    
228     \footnotesize{
229     \begin{verbatim}
230     <doc type=BuildSystem::ToolDoc version=1.0>
231     <Tool name=RUBY version=1.6.7>
232     <Client>
233     <Environment name=RUBY_BASE>
234     The top of the Ruby distribution.
235     </Environment>
236     <Environment name=LIBDIR default=$RUBY_BASE/lib/ruby/1.6 type=lib>
237     </Environment>
238     </Client>
239     <Environment name=PATH value="$RUBY_BASE/bin" type=Runtime_path>
240     </Environment>
241     <Environment name=LD_LIBRARY_PATH value=$LIBDIR type=Runtime_path>
242     </Environment>
243     </Tool>
244     \end{verbatim}
245     }\normalsize
246     %$
247     \ni so the interactive setup mechanism will ask for a value for
248     \texttt{RUBY\_BASE} and the other values will be set automatically.
249    
250    
251     \example{ClassPath Example} Following the recommended project
252     structure conventions, here is an
253     example of \lbkt\texttt{ClassPath}\rbkt settings for a project:
254     \index{\texttt{ClassPath} tag!example}
255     %% \small{\begin{verbatim}
256     %% <ClassPath path=+Project/+SubSystem/+Package/src+library>
257     %% <ClassPath path=+Project/+SubSystem/+Package/test+UnitTest>
258     %% <ClassPath path=+Project/+SubSystem/+Package/application+binaryApp>
259     %% \end{verbatim}}\normalsize
260     \index{structure templates! and the \texttt{ClassPath}}
261     \ni These settings will associate the top-level \texttt{src}
262     directory with \texttt{Project\_template.tmpl} and any directory in the next
263     level with the template \texttt{SubSystem\_template.tmpl}.
264     The level below that will be associated with \texttt{Package\_template.tmpl}.
265     The last elements have a pattern-matching string before the \texttt{+}
266     sign: only directories matching the names \texttt{src},
267     \texttt{test} and \texttt{application} at the third level below
268     the top-level \texttt{src} directory will be mapped to the
269     templates \texttt{library\_template.tmpl},
270     \texttt{UnitTest\_template.tmpl} and
271     \texttt{binaryApp\_template.tmpl} respectively. Thus, any
272     source files in a directory \texttt{src} at package-level will
273     source the template \texttt{library\_template.tmpl} for build
274     rules to build a library. Likewise, binary applications will be
275     built from sources located in any directory called
276     \texttt{application} using a template
277     \texttt{binaryApp\_template.tmpl}.
278    
279     \example{ProductStore Example} To create separate \texttt{include},
280     \texttt{bin} and \texttt{lib} subdirectories, all of which are
281     architecture-dependent, the following tags would be added to the project \texttt{BuildFile}:
282     \index{\texttt{ProductStore} tag!example}
283     %% \small{\begin{verbatim}
284     %% <ProductStore name=include type=arch></ProductStore>
285     %% <ProductStore name=lib type=arch></ProductStore>
286     %% <ProductStore name=bin type=arch></ProductStore>
287     %% <ProductStore name=module type=arch swap=t></ProductStore>
288     %% \end{verbatim}}\normalsize
289    
290     \ni In the above example, the storage location for modules is architecture-dependent and is
291     created as \texttt{module/rh73\_gcc32} on a system with a \scram
292     architecture \texttt{rh73\_gcc32}. The other directories
293     (\texttt{bin}, \texttt{lib} and \texttt{include}) are created under a
294     directory \texttt{rh73\_gcc32} in the project area.
295    
296    
297     \ni Here are two examples of how the tag might be used.
298     \index{using external libraries!example}
299     \example{Example 1} Working in a local area, you want to link against
300     the X11 libraries. Firstly, X11 must be an external tool that is
301     available in your project configuration. You can check this by seeing
302     if X11 is listed when you run \texttt{scram tool list}. Then just add
303     the line
304    
305     \begin{tagprint}
306     \lbkt\texttt{external} ref=\texttt{X11}\rbkt
307     \end{tagprint}
308    
309     \ni to your \texttt{BuildFile} to use the X11 libraries.
310    
311    
312     \example{Example 2} You are developing code which is dependent on
313     another \textsc{scram}-managed project called \texttt{fooproject}.
314     Following the previous example would result in all of the project
315     libraries being used. However, if libraries belonging to one
316     particular subsystem are required, and only these libraries, the line
317    
318     \begin{tagprint}
319     \lbkt\texttt{external} ref=\texttt{fooproject} use=\texttt{barsub}\rbkt
320     \end{tagprint}
321    
322     \ni will select only the subsystem \texttt{barsub}.
323    
324     \example{Example Binary BuildFile} Here is an example of a
325     \texttt{BuildFile} to build two binary executables:
326    
327     \small{\begin{verbatim}
328     <environment>
329     <Group name=SimReader>
330     <Use name=CARF>
331     <bin file=testSimReader.cpp>SimReader test executable</bin>
332     <bin file=testObserver.cpp>Observer test executable</bin>
333     </environment>
334     \end{verbatim}}\normalsize
335    
336     \ni The object files for both binaries are linked against the
337     libraries provided by group \texttt{SimReader} which is defined in the
338     \texttt{CARF} subsystem \texttt{BuildFile} to produce the executables.
339    
340     \example{Example Module BuildFile} This example will build
341     two separate modules:
342    
343     \small{\begin{verbatim}
344     <environment>
345     <Group name=BaseUtilities>
346     <Use name=Utilities>
347     <module file=BaseUtilitiesModule.cpp>Base utilities plug-in</module>
348     </environment>
349    
350     <environment>
351     <Group name=Persistency>
352     <Use name=Utilities>
353     <module file=PersistencyModule.cpp>Persistency layer</module>
354     </environment>
355     \end{verbatim}}\normalsize
356    
357     \example{Adding a New Rule} Suppose that for a package called
358     \texttt{myPackage}, some additional library should be built in
359     addition to the default library \texttt{libmyPackage.so}.
360     The typical \tagstart{ClassPath} entry to build a library looks like
361     this
362     %% \small{\begin{verbatim}
363     %% <ClassPath path=+Project/myPackage+Package/src+library>
364     %% \end{verbatim}}\normalsize
365     %% \ni and this uses a makefile called \texttt{library\_makefile.tmpl}.
366     %% At the top of this makefile there exists a statement for the default
367     %% build, namely,
368     %% \small{\begin{verbatim}
369     %% # Package Context Defaults
370     %% library : lib
371     %% \end{verbatim}}\normalsize
372     %% \ni A new build rule called \texttt{customlib} can be defined in the
373     %% structure makefile: if it is added above, it will be run by default
374     %% when building \textit{any} library.
375     %% For this action to take place only for the package \texttt{myPackage},
376     %% it is best to create a new structure makefile with a different name,
377     %% say \texttt{myCustomlib\_makefile.tmpl}, in which the new rule is
378     %% defined. Now the statement in \texttt{myCustomlib\_makefile.tmpl}
379     %% for the default build looks like this
380    
381     %% \small{\begin{verbatim}
382     %% # Package Context Defaults
383     %% myCustomlib : lib customlib
384     %% \end{verbatim}}\normalsize
385    
386     %% \ni and the corresponding \tagstart{ClassPath}
387    
388     %% \small{\begin{verbatim}
389     %% <ClassPath path=+Project/myPackage+Package/src+myCustomlib>
390     %% \end{verbatim}}\normalsize
391    
392     \ni will ensure that the new rule is used when building in the
393     \texttt{src/myPackage} directory.
394    
395     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
396    
397     %%% Local Variables:
398     %%% mode: latex
399     %%% TeX-master: "SCRAM-manual"
400     %%% End:
401    
402     %%____________________________________________________________________
403     %% End of Examples.tex
404     %%____________________________________________________________________
405     %%