Gobo Eiffel on OpenBSD

Gobo Eiffel on OpenBSD

eiffel

The Eiffel language is one of the best object-oriented programming languages, most of the concepts of which have been taken up by languages such as Java, C# and others.
Unfortunately, Eiffel now has a very low popularity, which hardly encourages developers to learn it or use it.

Historically, the Eiffel language was conceived by Bertrand Meyer in 1985. There are several compilers for this language:

  • Eiffel from B. Meyer
  • Gobo Eiffel
  • LibertyEiffel

These languages are all distributed in open source, but Gobo Eiffel has the advantage of having a very permissive license and of being easily installed on OpenBSD.

Installation on OpenBSD

Let’s start by downloading the Eiffel Gobo software package on GitHub: gobo-master.zip

Let’s unzip this file in our user directory.

We can also use the git command with the link
gobo-eiffel

In the .profile file of our user session, let’s insert the lines:

ISE_PLATFORM=openbsd
export ISE_PLATFORM
GOBO=/home/<user>/<path-to>/gobo-master
export GOBO

Note that it is important that the word "bsd" be included in the name assigned to ISE_PLATFORM.

Let’s install the libiconv package in "root" mode, which is essential for the compilation of Gobo Eiffel.

pkg_add libiconv

Let’s check that the installed files are present:

ls -l /usr/local/include/iconv.h
ls -l /usr/local/lib/libiconv.*

Now let’s install Gobo Eiffel, for this we need to run the shell install.sh command file located in the $GOBO/bin directory which will start compiling the bootstrap C version of the compiler and then all the Eiffel language files. The executable files will be installed in the $GOBO/bin directory. We need to check that a C compiler is available and we will use clang which is normally pre-installed on OpenBSD.

Let’s go to the /home/<user>/<path-to>/gobo-master/bin directory and run the command:

sh install.sh -v clang

Everything compiles and installs normally without errors.

To test the installation let’s execute in the directory /home/<user>/<path-to>/gobo-master, the command

geant test_ge

At the end of this installation test suite, you should only see warnings and possibly empty error messages.

First program

Example

Let’s try a simple example anyway. To do this, let’s create the following files in the same directory:

hello.e

class HELLO

create
    make

feature
i: INTEGER
    make
        do
            print ("Hello, World%N")
            from
            i := 0
            until
                i >= 10
            loop
                print (i)
                i := i + 1
            end
            print ("%N")
        end

end

hello.ecf

<?xml  version="1.0"  encoding="ISO-8859-1"?>
<system
    xmlns="http://www.eiffel.com/developers/xml/configuration-1-22-0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-22-0  http://www.eiffel.com/developers/xml/configuration-1-22-0.xsd"
    name="hello"
    uuid="8C35A383-9927-4EF8-8784-D6F287B296E7"
>
    <target  name="hello">
        <root  class="HELLO"  feature="make"/>
        <file_rule>
            <exclude>.git</exclude>
        </file_rule>

        <option  warning="true">
            <assertions  precondition="true"  postcondition="true"  check="true"  invariant="true"  loop="true"  supplier_precondition="true"/>
        </option>

        <!--  Assumes  you  set  the  GOBO  environment  variable  to  the  path  to  your  gobo  repo  folder,  as  per  gobo's  install  instructions.  -->
        <library  name="free_elks"  location="${GOBO}/library/free_elks/library_ge.ecf"  readonly="true"/>

        <cluster  name="root_cluster"  location="./"  recursive="false">
            <file_rule>
                <exclude>.git</exclude>
            </file_rule>
        </cluster>
    </target>
</system>

Then let’s compile the program by running the command:

gec hello.ecf
Degree 6: 0/0/0 0:0:0.058
Degree 5: 0/0/0 0:0:0.522
Degree 4: 0/0/0 0:0:0.182
Degree 3: 0/0/0 0:0:0.244
Degree -2: 0/0/0 0:0:0.221
Degree -3: 0/0/0 0:0:0.210
hello1.c(hello1.o:(eif_file_creatable)): warning: strcpy() is almost always misused, please use strlcpy()
hello1.c(hello1.o:(eif_file_owner)): warning: sprintf() is often misused, please use snprintf()
Degree -4: 0/0/0 0:0:7.088
Total Time: 0/0/0 0:0:8.704

Apart from a few warning messages, it works.

At runtime, it displays:

Hello, World
0123456789