How to compile and run services

Setting up your environment

There are four sample WIG compilers available, pwig, wig4, wig10 and wig18. The wig4 and wig18 compilers were written in C by groups at the University of Aarhus in fall 1998. The pwig compiler was written at McGill, in C in 2001. The wig10 compiler was written at McGill, in Java using SableCC during fall 1999, and it should also be very stable.

To use four compilers you should:

  • Set the environment variable WIGDIR by:
    setenv WIGDIR ~hendren/WIG
  • Add $WIGDIR/Bin to your PATH or, add aliases of the form of one of the following:
    alias wig10 $WIGDIR/Bin/wig10             (any system with JDK 1.2 or later)
    alias pwig  $WIGDIR/Bin/perfectwig        (SUN server)
    alias wig4 $WIGDIR/Bin/wig4               (SUN server)
    alias wig18 $WIGDIR/Bin/wig18             (SUN server)
    You will probably find that wig10 , pwig and wig18 are more stable. The wig18 compiler is interesting because it illustrates generation of a stack code.
  • Create a subdirectory under the public_html directory.
    • cgi-bin/ (set permission of this directory to 711)

Compiling your WIG service

  • Create a file with a .wig extension, let us say foo.wig .
  • Compile foo.wig with the wig compiler using one of the following commands:
            pwig foo.wig
            wig10 foo.wig
            wig4 foo.wig 
            wig18 foo.wig

    The compilation will produce two files:
    • foo.c
    • foo.install
    Check that foo.install has execute permission, and if not do chmod +x foo.install .
  • On a FreeBSD machine execute the file foo.install . This must be on a FreeBSD machine because the web server is running FreeBSD operating system. You can execute the install script by logging on to a FreeBSD machine using slogin, or even easier you can just execute a command using ssh that first changes to the directory containing the files, and then executes the install script. For example, if the files are in the directory WIG/10/Examples and you wanted to logon to FreeBSD machine lab4-x , where x is some number, you would use:
    ssh lab4-2 "cd WIG/10/Examples; foo.install"
    The install script performs the following actions:
    • produces a binary foo.cgi (when using pwig), foo4.cgi (when using wig4), or foo10.cgi (when using wig10), or foo18.cgi (when using wig18). This binary is made by compiling foo.c and linking with the appropriate runwig.c ( ~hendren/WIG/PerfectWig/perfectwig_run.h or ~hendren/WIG/04/runwig.c or ~hendren/WIG/18/runwig.c ).
    • moves binary foo.cgi , foo4.cgi , foo10.cgi , or foo18.cgi to ~/public_html/cgi_bin

Running your WIG service.

You may now run your service by using one of the following URLs:

where YourName should be your user name, SessionName should be name of one of the sessions defined in foo.wig .

For example, consider the following service that could be in foo.wig .

service {
  const html ...
  const html ...
  session Init() { ... }
  session Doit() { ... }
  session Report() { ... }
In this case, if you compiled with wig10, there are three different sessions that could be run using: