This document explains the individual geant examples and how to use them. It serves as a first draft version for the geant documentation. All examples should be invoked from the commandline. geant syntax: geant [-V][-v|--verbose][-b|--buildfile ] [-D=]* [target] Getting started: ================ cd to the examples/hello directory and type 'geant'. You should see the following output: ___________________________________________________________ Hello world ___________________________________________________________ Let's have a look at the project file which produces this output. ___________________________________________________________ ___________________________________________________________ Since we do not provide a buildfile on the commandline the default name (build.eant) is used. With the option '-b' respectively '--buildfile' it is possible to use a different file. There is no target specified on the commandline either. In this case geant tries to find a 'default' attribute in the element by which the start target for the build process can be specified. When there is no default attribute geant gives up and terminates with the message 'Cannot determine start target.'. With the option '-v' respectively '--verbose' geant's output is more verbose: ___________________________________________________________ Loading Project's configuration from build.eant Building Project hello.hi: [echo] Hello world ___________________________________________________________ A target can have an optional 'description' subelement which should describe briefly what the target does. It must be the first subelement. In a future version there will be a '--projecthelp' commandline option which will just list all the targetnames with its description without starting the build process. A element may contain zero or more task elements as direct children. Each task element is executed in sequential order. The specific action which is performed is dependent on the individual tasks. The only task wich our 'hi' target contains is . has a single attribute called 'message' and this message is printed to stdout. This is the reason why you see 'Hello world' on your screen. In the following sections all other examples are explained. We usually do not use 'build.eant' as filename for the examples since we have mostly more than one build file in a directory. Variables: =========== variable1: Setting and querying a variable cd to examples/variables buildfile variable1.eant: ___________________________________________________________ set and query a variable ___________________________________________________________ 'geant -v -b variables1.eant' produces: ___________________________________________________________ Loading Project's configuration from variables1.eant Building Project variables1.var: [set] who=world [echo] Hello world ___________________________________________________________ With the task a variable can be defined. The 'name' attribute specifies the name of the variable and the 'value' attribute it's value. The values of variables can be retrieved using the ${} syntax. Thus ${who} in the examples returns 'world'. The value of a variable can be overridden by a -D option on the commandline 'geant -v -b variables1.eant -Dwho=Eiffel' produces: ___________________________________________________________ Loading Project's configuration from variables1.eant Building Project variables1.var: [set] who=world [echo] Hello Eiffel ___________________________________________________________ variable2: ========== Cascading Variables: cd to examples/variables buildfile variables2.eant: ___________________________________________________________ set and query a variable ___________________________________________________________ 'geant -v -b variable2.eant' produces: ___________________________________________________________ Loading Project's configuration from variables2.eant Building Project variables2.var: [set] firstname=Bart [set] fullname=Bart Simpson [echo] Hello Bart Simpson ___________________________________________________________ This examples demonstrates how variables can be constructed from other variables. exec: ===== Demonstrates the task. cd to examples/exec buildfile dir.eant (for windows): ___________________________________________________________ executes a dir command under dos/windows ___________________________________________________________ 'geant -v -b dir.eant' produces: ___________________________________________________________ Loading Project's configuration from dir.eant Building Project dir.dir: [set] directory=. [exec] dir . Volume in drive D is D Volume Serial Number is 5C52-67D3 Directory of D:\svnstuff\gobo-eiffel\gobo\example\geant\exec 09/08/2002 07:32a . 09/08/2002 07:32a .. 05/04/2002 01:45p 2,429 build.eant 11/26/2002 08:41p .svn 09/01/2001 01:30p 261 dir.eant 09/01/2001 01:30p 519 dir2.eant 09/08/2002 07:32a 875 exec1.eant 09/01/2001 01:30p 251 ls.eant 5 File(s) 4,335 bytes 3 Dir(s) 7,162,626,048 bytes free ___________________________________________________________ The exec task can be used as a general means to execute a command as one would do on the commandline. This can always be used when there is no appropriate task available. The attribute 'executable' takes the exact string one would specify on the commandline after replacing possibly existing variables. call (unix): geant -b ls.eant output: the same output as a 'ls -l' command on the commandline would show. geant: Demonstrates the task. cd to examples/geant buildfile geant1.eant: ___________________________________________________________ calls other ant files ___________________________________________________________ 'geant -v -b geant1.eant' produces: ___________________________________________________________ Loading Project's configuration from geant1.eant Building Project geant.one: [set] who=Bart [set] buildfile=../variables/variables5.eant [echo] ------------------------ [echo] before call of ../variables/variables5.eant Loading Project's configuration from ..\variables\variables5.eant Building Project variables5.var: [echo] Hello ${who} [echo] after call of ../variables/variables5.eant [echo] ------- [echo] before call of ../variables/variables5.eant Loading Project's configuration from ..\variables\variables5.eant Building Project variables5.var: [echo] Hello Bart [echo] after call of ../variables/variables5.eant ___________________________________________________________ With the geant task other geant files can be invoked. This can be done in the within the same project scope (default behaviour) or in a new project scope when the 'file' attribute is set to 'true'. At the moment the big difference is that for an invocation in the same scope all defined variables are still available in the called build file. The example makes this visible by displaying 'Hello ${who}' instead of 'Hello Bart' for the first invokation. The second invocation passes all variables and thats why you see 'Hello Bart'. In the future will be able to take arguments which can be passed to the called build project exactly like you can do it on the commandline already. depends: ======== Demonstrates the depend attribute of targets. cd to examples/depends depends1.eant: ___________________________________________________________ ___________________________________________________________ 'geant -v -b depends1.eant' produces: ___________________________________________________________ Loading Project's configuration from depends1.eant Building Project depend_demo.A: [echo] A depend_demo.B: [echo] B depend_demo.C: [echo] C ___________________________________________________________ With the XML attribute 'depend' targets can be made dependent on another. In the example target 'C' is dependent on target 'B'. This means that target 'B' will be executed before target 'C' is executed. It is possible to specify more than one target dependency using comma separated target names in the 'depend' attribute: This means that target 'B' is executed first, then target 'A' and then target 'C'. gexace: ======= Demonstrates how to generate a compiler specific ace/esd file from a compiler independent xace file. It builds on the 'gexace' tool which is able to produce specific ace/esd files from xace files. cd to examples/gexace. buildfile build.eant: ___________________________________________________________ compiles HELLO executes example deletes generated files ___________________________________________________________ invoke 'geant' calls the gexace tool which generates a SmartEiffel ace file. then will compile our system using SmartEiffel Now we could simply invoke the hello program from the commandline but since this would be too easy simply invoke 'geant -v run' which produces the following output: ___________________________________________________________ Loading Project's configuration from build.eant Building Project geant.init: [set] system=hello geant.run: [exec] hello Hello World ___________________________________________________________ condidional/if,unless: ====================== Demonstrates the optional 'if' and 'unless' XML attributes of targets. cd to examples/conditional. buildfile if1.eant: ___________________________________________________________ ___________________________________________________________ 'geant -v -b if1.eant' produces: ___________________________________________________________ Loading Project's configuration from if1.eant Building Project if_demo1.C: [echo] C ___________________________________________________________ As values of the 'if' and 'unless' XML attributes of target elements you can use variable values and environmentvariables. This means the 'if' attribute returns true if the variable is defined otherwise true. The value of the variable does not matter. The same is true for 'unless' except that it returns true if it is not defined. Since the variables 'runa' and 'runb' are not defined target 'A' and target 'B' do not produce any output. 'geant -v -b if1.eant -Druna=any_value_you_like' produces: ___________________________________________________________ Loading Project's configuration from if1.eant Building Project if_demo1.A: [echo] A if_demo1.C: [echo] C ___________________________________________________________ geant -v -b if1.eant -Druna=any_value_you_like -Drunb=another_value_you_like ___________________________________________________________ Loading Project's configuration from if1.eant Building Project if_demo1.A: [echo] A if_demo1.B: [echo] B if_demo1.C: [echo] C ___________________________________________________________ As you can see the if's return true and targets 'A' respectively 'B' get executed. The file unless1.eant contains the same examples but the if's have been replaced with unless's. condidional/if2: Demonstrates how we can use 'if' and 'unless' to create a os independent buildfile. cd to examples/conditional. if2.eant: ___________________________________________________________ ___________________________________________________________ 'geant -v -b if2.eant' produces (for windows): ___________________________________________________________ Loading Project's configuration from if2.eant Building Project if_demo2.list_for_windows: [exec] dir Volume in drive D is D Volume Serial Number is 5C52-67D3 Directory of D:\svnstuff\gobo-eiffel\gobo\example\geant\conditional 09/03/2002 08:15p . 09/03/2002 08:15p .. 11/26/2002 08:41p .svn 11/11/2001 10:58p 261 if1.eant 11/11/2001 10:58p 316 if2.eant 11/11/2001 10:58p 593 if3.eant 11/11/2001 10:58p 925 if4.eant 05/12/2002 05:30p 724 if5.eant 09/03/2001 05:58p 271 unless1.eant 6 File(s) 3,090 bytes 3 Dir(s) 7,162,556,416 bytes free if_demo2.list: ___________________________________________________________ Note: for simplicity we assume here that if a environment variable 'windir' exists that we are in a windows environment. Otherwise we are on unix. This should be ok for most situations. File if3.eant basically has the same behaviour but introduces an additional abstraction layer by introducing some variables defining the operating system: ___________________________________________________________ ___________________________________________________________