Building and using application libraries with ocs

Any number of Opal structures may be grouped together in a so-called subsystem and referred to as a custom library. (By convention, a subsystem corresponds to a physical directory)

Creating a library

Consider a situation where you have written a number of related OPAL structures dealing with that special foo data type you use every day. Suppose these structures are called Foo1, Foo2 and Foo3. You might want to put these structures in a subsystem foo so you have them at hand for consistent refinement as well as easy access. You can do so by following these steps:
  1. Create a suitable subdirectory foo. This might be somewhere in your home directory - if your subsystem is private - or some other place, if you want to share your code with others.
  2. Assume (after copying) that the six files (Foo1.sign through Foo3.impl) reside in the (newly created) foo directory.
  3. Create a file SysDefs with the following contents (the example below uses cat, whose input is terminated by ^D):

    $ cd foo
    foo $ cat > SysDefs
    SYSKIND=sub
    NODENAME=foo
    STRUCTS=Foo1 Foo2 Foo3
    ^D
    foo $
    
    Note that it is important that the value assigned to NODENAME is equal to the base name of the current directory.
If you run ocs in the foo directory, a library will be created (provided the Opal sources are context-correct). This results in (a) new file(s) libfoo.* within the subdirectory foo/OCS.
Remark: by running "ocs -sub foo Foo1,Foo2,Foo3" a file SysDefs.foo will be created which can be renamed SysDefs.

Using application libraries

Let us assume that you intend to write a program (or a more complex subsystem) based on two libraries foo and bar (which have been created as above). Simply add the line(s)
GENSUBSYS= \
  -s path-to-foo/foo \
  -s path-to-bar/bar \
  $(GENSTDSYS)
to the corresponding SysDefs file.

If you have a whole hierarchy of libraries, these must be listed in a top-down manner. Finally, the standard libraries must be supplied by $(GENSTDSYS).

Remark: inclusion of libraries can also be done via ocs command-line options, e.g. "ocs -top HelloWorld hello -s path-to-foo/foo -s path-to-bar/bar".


The Opal Group
Last modified: Tue Nov 25 16:21:35 1997