| How to compile and run There are five sample WIG compilers available: services      
       
       wig4andwig18, written in C by
      groups at the University of Aarhus in fall 1998; wig10, written in Java using SableCC at McGill
      in fall 1999; pwig(perfectwig), written in C at McGill in
      fall 2001; and lkwig(Louis & Kacper's WIG), written in C at
      McGill in fall 2004. 
      You will probably find that wig10,wig18, andpwigare most stable, butlkwigalso looks fairly promising.wig18is interesting because it generates stack
      code, andlkwigis interesting because it generates
      Perl. 
      Currently there are binary versions for FreeBSD, Linux, and
      Solaris available, with wrapper scripts that attempt to select
      the right one automatically for you.  We have the source code
      and can possibly compile a version for a different system if it
      would help you.  The wig10compiler, being written
      in Java, will run anywhere that Java runs. 
      In order to actually compile CGI scripts from the generated
      C-based WIG services, required for all compilers except
      lkwig, you will need to log in tofreebsd.cs.mcgill.ca, the webserver that hostswww.cs.mcgill.ca.  Compiled C binaries must target
      that machine, and while you may have some luck on other FreeBSD
      lab machines, there have been reports of incompatibilities. 1. Making sure prerequisites are installedBefore you can use these instructions, you should first follow
      the instructions on using Subversion in
      this class and setting up your
      environment for JOOS programs.  This will ensure that Java
      1.5 is on your PATH and that you have a local copy of the
      example WIG binaries.
       2. Setting up your environmentAs usual, we need to set up some additional environment variables:
       WIGDIRAssuming you have checked out the public_html directory from the
      class SVN repository to$HOME/cs520/public_html,
      add the following:
       
      setenv WIGDIR $HOME/cs520/public_html/wig
      
      or
       
       
      export WIGDIR=$HOME/cs520/public_html/wig  
      
      to your .cshrcor.bash_profilefortcshorbashrespectively. PATHWe want to be able to execute the WIG compiler binaries from
      anywhere.  Add the following:
       
      setenv PATH $WIGDIR/bin:$PATH
      
      or
             
       
      export PATH=$WIGDIR/bin:$PATH
      
      to your .cshrcor.bash_profileif you
      are usingtcshorbashrespectively. 
      Note that we can possibly make binaries for other platforms
      available, just send your request to your instructor or TA.
       cgi-bin directoryFinally, in order for WIG services to execute within a browser
      they need to be placed in a sub-directory of$HOME/public_html/on the SOCS machines.  The WIG
      installation scripts assume that this directory has the
      conventional namecgi-bin.
      $ cd $HOME
      $ mkdir -p public_html/cgi-bin
      $ chmod 711 public_html/
      $ chmod 711 public_html/cgi-bin
      You can access this directory by pointing your web browser at the URLhttp://www.cs.mcgill.ca/~`whoami`/cgi-bin/.3. Compiling your WIG service 
       Create or find a WIG service, making sure it has a
      .wigextension.  Assume your service is calledfoo.wig.
      Compile foo.wigwith some WIG compiler using
      one of the following commands:
       
      $ wig4 foo.wig
      $ wig10 foo.wig 
      $ wig18 foo.wig
      $ pwig foo.wig
      $ lkwig foo.wig
      For the first four compilers, the compilation will produce two
      files,foo.candfoo.install.  For thelkwigcompiler it will producefoo.pl.
      Check that foo.installhas its execute permission
      bit set usingls -l foo.install, and if not change
      it usingchmod +x foo.install.  The same applies
      forfoo.pl.
      For the compilers that target C, execute the file
      foo.installonfreebsd.cs.mcgill.ca;
      other FreeBSD machines may or not work.  Forlkwigsimply copy foo.pl to~/public_html/cgi-bin, or
      compile with-o ~/public_html/cgi-bin/foo.pl.
      The install scripts perform the following 3 actions:
       
       
      Remember that if you are ever unsure of the type of a file, you
      can use theCall gccto produce a binary:
        
      foo4.cgi, when using wig4;foo10.cgi, when using wig10;foo18.cgi, when using wig18; orfoo.cgi, when using pwig. 
      
      This binary is made by compiling foo.cand including the appropriate
      runtime support files in$WIGDIR/lib: 
       
      runwig4.candrunwig4.h, when using wig4;runwig10.c, when using wig10;runwig18.candrunwig18.h, when using wig18; orperfectwig_run.h, when using pwig. 
      Set the executable permission bit of the binary foo(4|10|18|).cgi.
      Move target binary foo(4|10|18|).cgito~/public_html/cgi_bin.
       filecommand:
      $ file foo.install 
      foo.install: Bourne shell script text executable
      and that this is often enough knowledge to know whether you can
      meaningfully use thecatcommand to examine it:
      $ cat foo.install 
      #!/bin/sh
      gcc -I$WIGDIR/lib foo.c -o foo10.cgi
      chmod a+rx foo10.cgi
      mv -f foo10.cgi ~/public_html/cgi-bin
      (You should now understand everything that the script does.) 4. Running your WIG serviceYou can now run your service by using one of the following URLs:
      http://www.cs.mcgill.ca/~`whoami`/cgi-bin/foo4.cgi?SessionName
      http://www.cs.mcgill.ca/~`whoami`/cgi-bin/foo10.cgi?SessionName
      http://www.cs.mcgill.ca/~`whoami`/cgi-bin/foo18.cgi?SessionName
      http://www.cs.mcgill.ca/~`whoami`/cgi-bin/foo.cgi?SessionName
      http://www.cs.mcgill.ca/~`whoami`/cgi-bin/foo.pl?SessionName
      where`whoami`expands to your CS user ID, andSessionNameis one of the sessions defined infoo.wig.
      For example, consider the following service
      that might be in foo.wig: 
      service {
        const html ...
        const html ...
        ...
        session Init() { ... }
        session Doit() { ... }
        session Report() { ... }
      }
      Here there are three different sessions,Init,Doit, andReportthat can substitute
      forSessionNamein the above links.  Note that the
      better WIG compilers provide links to all available sessions.
      (It may be an interesting language extension to have public and
      private sessions.)5. Batch compilation and installation of WIG examples WIG compilers come with their examples. You may want to compile and run them to check how they manage to parse files and generate codes. The examples have been already listed in benchmark lists: 
             classic_benchmark_listperfectewig_benchmark_listwig04_benchmark_listwig10_benchmark_listwig18_benchmark_list 5.1 CompilingIn the $WIGDIR, just run: ./compile <a_benchmark_list>  This will try to compile all examples listed in the benchmark list file using all possible compilers.
        Note that some of the examples may fail because these compilers are not completely compatible.  5.2 InstallingAfter compiling, run: ./install <a_benchmark_list> This will try to install all compiled codes listed in the benchmark list file into your public_html/cgi-bin and generate an index.html in that folder. If you've already put your own index.html in cgi-bin, please backup first.
        5.3 Running After installing,  just go to this URL: http://cs.mcgill.ca/~`whoami`/cgi-bin/index.html
 If you've got some error message saying "permission denied", please try to change the permission of the index.html generated in setp 2: chmod a+r $HOME/public_html/cgi-bin/index.html  5.4 Benchmark list file formatYou may want to write your own benchmark list file so that it will save a lot of your time when debugging your wig compiler. Actually it is quite easy, the format of benchimark_list is just a plain text file in which one line defines a wig program:  wig_program_id <tab> path <tab> wig_file_name<line break>  the wig_program id is used in script only; path should tell the script where your .wig located wig_file_name is the wig file you want to compile, DO NOT annex the file extension(.wig). For example, you want to compile wig programs in $HOME/yourwig/foo.wig and bar.wig, you should write a "my_benchmark_list" like this: foo $HOME/yourwig foo bar $HOME/yourwig bar
 and then you can compile and install codes using: ./compile my_benchmark_list./install my_benchmark_list
 
 |