Single file compilation

by Julian Tschannen (modified: 2007 Mar 12)

What I always liked about other compilers was the ease to compile simple examples. Just write a C file and call gcc hello_world.c and the compiler does the rest. Of course when you get to more complex systems you need wp:makefiles and the like, but for a quick test it is very convenient to be able to compile single files.

This mechanism is also available in the new version of EiffelStudio. So when you want to do a quick test, just write your root class and call ec hello_world.e The compiler then generates a standard ECF file which you can use to open your class in EiffelStudio. This is very useful if the quick test becomes more complex and you want the power of EiffelStudio for further development.

It is even possible to use some libraries in your example. If you need Vision2 for example, just add a library argument to the commandline: ec hello_gui_world.e -library vision2 Or if you need multiple libraries: ec hello_gui_world.e -library vision2 -library gobo These libraries will be added in addition to the base library. Libraries which are shipped with EiffelStudio can be added by using only the name, for other libraries the full path to the ECF file is needed.

When you do a single file compilation the Eiffel compiler does the following:

  • The filename is taken to look for an ecf file with the same name as the class file.
  • If it does not yet exist, a new ecf file is generated. It consists of:
    • A target with the same name as the class file
    • The class name as root class and make as root feature
    • The directory of the class file as root cluster
    • The setting console application set as true unless Vision2 or WEL is used as a library.
    • EiffelBase and libraries set via the commandline option added.
  • A workbench compilation is done using the ECF file.
  • The generated executable is copied into the current working directory.

I believe this mechanism makes it a lot easier to write simple examples in Eiffel by removing the work of writing a configuration file by hand or the need of using EiffelStudio for this.

Comments
  • Till Bay (17 years ago 12/3/2007)

    I'm sure this is going to be appreciated by the students. I will make sure that they come and use eiffelroom and see your blog posts. This will help lower the entry barrier for Eiffel newcomers. Thanks for the hard work.