Difference between revisions of "Compile"
(typo) |
m (s/LibertyEiffel/Liberty Eiffel/) |
||
(16 intermediate revisions by 5 users not shown) | |||
Line 1: | Line 1: | ||
− | [[Category: |
+ | [[Category:Tool]] |
+ | <TT>compile</TT> is the most important tool because it is '''the''' Liberty Eiffel compiler. |
||
− | *** Please wait for the French version to stabilize |
||
+ | In a normal installation, it is invoked by the command <b><TT>[[se]] c</TT></b>. |
||
− | *** Thanks! |
||
+ | |||
+ | There are two ways of invoking it: the ''traditional'' mode and the ''ACE'' mode. |
||
+ | * In the traditional mode, many options can be specified on the command line. |
||
+ | * In the [[ACE]] mode ''(Assembly of Classes in Eiffel)'', most of its options are not allowed on the |
||
+ | command line; they have their equivalents ''in'' the ACE file. |
||
+ | |||
+ | == Synopsis == |
||
+ | |||
+ | * <code>se c [common_options] [c2c_options] <root_class> [<root_procedure>]</code> |
||
+ | * <code>se c [common_options] <ace_file.ace></code> |
||
+ | |||
+ | The first syntax is the traditional mode, the second is the ACE mode. |
||
+ | |||
+ | In the ACE mode, the name of the [[ACE]] file provided must end with the suffix <TT>.ace</TT>. |
||
+ | |||
+ | The <TT>compile</TT> command runs through several stages: |
||
+ | # the <TT>[[compile_to_c]]</TT> command is called to produce the C files (<TT>*.h</TT> and <TT>*.c</TT>). |
||
+ | A script file is also created, whose name depends on the application. |
||
+ | # this script is executed line by line; normally, it call the C compiler for each <TT>.c</TT> file, then it finishes with the link phase. |
||
+ | # if the <TT>-clean</TT> option is used, the <TT>[[clean]]</TT> command is called. |
||
+ | |||
+ | Like <TT>[[compile_to_c]]</TT>, <TT>compile</TT> must have at least one argument which gives the program's |
||
+ | starting point, which is, in fact, the creation of a class. In the ACE mode, this information is given by |
||
+ | parameters in the ACE file. |
||
+ | In the traditional mode, you have to give at least the class name: by default the creation feature is called <TT>make</TT>, and this must exist; otherwise, it is necessary to specify the creation feature. |
||
+ | |||
+ | In all cases, the creation feature must be a feature ''with no arguments''. |
||
+ | |||
+ | === Common options === |
||
+ | |||
+ | {| cellspacing="4" cellpadding="0" width="100%" |
||
+ | |- |
||
+ | | width="20%" valign="top" | <code>-clean</code> |
||
+ | | By default, the generated C files are kept from one execution to the next. This allows incremental compilation, since only the files changed since the last invocation of <TT>compile</TT> are regenerated. |
||
+ | |||
+ | Since the Eiffel compilation is usually much faster than the C compilation, this usually saves a lot of time. |
||
+ | |||
+ | However, there are situations when one wants to remove all the old generation of files, so as to start from scratch. |
||
+ | |||
+ | The <TT>-clean</TT> option deletes the C files, the object files and several other generated files, by invoking the <TT>[[clean]]</TT> command at the end of the compilation. |
||
+ | |- |
||
+ | | valign="top" | <code>-help</code> |
||
+ | | Display a short summary of the command line syntax,as well as a complete list of the compiler's options. |
||
+ | |- |
||
+ | | valign="top" | <code>-verbose</code> |
||
+ | | Display (an enormous amount of) information during the compilation: a complete list of files loaded, the [[type inference]] scores, the generated files, and so on. |
||
+ | |- |
||
+ | | valign="top" | <code>-version</code> |
||
+ | | Display the Liberty Eiffel version number. |
||
+ | |} |
||
+ | |||
+ | === c2c options === |
||
+ | |||
+ | These options are passed directly to <TT>[[compile_to_c]]</TT>. See that command for details. |
||
+ | |||
+ | === Examples of using traditional mode === |
||
+ | |||
+ | ==== Example 1 ==== |
||
+ | |||
+ | When Liberty Eiffel is installed correctly, you can run the following command to test compile the notorious ''Hello world'' program: |
||
+ | |||
+ | se c hello_world |
||
+ | |||
+ | In this mode, by default, the compiler is very silent; to see more detail, enter |
||
+ | |||
+ | se c -verbose hello_world |
||
+ | |||
+ | and suddenly Liberty Eiffel becomes ''very'' chatty! It just has to tell you about every file used and every file written. |
||
+ | |||
+ | An executable program is generated (normally <TT>a.out</TT> under UNIX, <TT>a.exe</TT> under Windows) which can be run directly. |
||
+ | |||
+ | ==== Example 2 ==== |
||
+ | |||
+ | Enter the following command to create a finalised version of our ''Hello world'': |
||
+ | |||
+ | se c -boost -c_mode release hello_world |
||
+ | |||
+ | These options are passed to <TT>[[compile_to_c]]</TT>. This is usually the best way to finalise a program. Note that using [[Configuration_file#C_modes|C mode]] commonly implies the <TT>-no_split</TT> option, as well as passing the <TT>-O3</TT> option to the C compiler. |
||
+ | |||
+ | ==== Example 3 ==== |
||
+ | |||
+ | To compile a large project (e.g. the class <TT>PROJECT</TT>) with incremental compilation and checking preconditions: |
||
+ | |||
+ | se c -require_check project |
||
+ | |||
+ | The very first time, all the C files are produced and compiled. Subsequently, if you use the same command after changing some Eiffel files, only the changed C files will be recompiled. |
||
+ | |||
+ | Note that extensive modifications of the source can force the recompilation of the whole project. |
||
+ | |||
+ | Again, changing the compilation options also involves recompiling the whole set of generated C files. |
Latest revision as of 13:06, 8 June 2016
compile is the most important tool because it is the Liberty Eiffel compiler.
In a normal installation, it is invoked by the command se c.
There are two ways of invoking it: the traditional mode and the ACE mode.
- In the traditional mode, many options can be specified on the command line.
- In the ACE mode (Assembly of Classes in Eiffel), most of its options are not allowed on the
command line; they have their equivalents in the ACE file.
Synopsis
se c [common_options] [c2c_options] <root_class> [<root_procedure>]
se c [common_options] <ace_file.ace>
The first syntax is the traditional mode, the second is the ACE mode.
In the ACE mode, the name of the ACE file provided must end with the suffix .ace.
The compile command runs through several stages:
- the compile_to_c command is called to produce the C files (*.h and *.c).
A script file is also created, whose name depends on the application.
- this script is executed line by line; normally, it call the C compiler for each .c file, then it finishes with the link phase.
- if the -clean option is used, the clean command is called.
Like compile_to_c, compile must have at least one argument which gives the program's starting point, which is, in fact, the creation of a class. In the ACE mode, this information is given by parameters in the ACE file. In the traditional mode, you have to give at least the class name: by default the creation feature is called make, and this must exist; otherwise, it is necessary to specify the creation feature.
In all cases, the creation feature must be a feature with no arguments.
Common options
-clean
|
By default, the generated C files are kept from one execution to the next. This allows incremental compilation, since only the files changed since the last invocation of compile are regenerated.
Since the Eiffel compilation is usually much faster than the C compilation, this usually saves a lot of time. However, there are situations when one wants to remove all the old generation of files, so as to start from scratch. The -clean option deletes the C files, the object files and several other generated files, by invoking the clean command at the end of the compilation. |
-help
|
Display a short summary of the command line syntax,as well as a complete list of the compiler's options. |
-verbose
|
Display (an enormous amount of) information during the compilation: a complete list of files loaded, the type inference scores, the generated files, and so on. |
-version
|
Display the Liberty Eiffel version number. |
c2c options
These options are passed directly to compile_to_c. See that command for details.
Examples of using traditional mode
Example 1
When Liberty Eiffel is installed correctly, you can run the following command to test compile the notorious Hello world program:
se c hello_world
In this mode, by default, the compiler is very silent; to see more detail, enter
se c -verbose hello_world
and suddenly Liberty Eiffel becomes very chatty! It just has to tell you about every file used and every file written.
An executable program is generated (normally a.out under UNIX, a.exe under Windows) which can be run directly.
Example 2
Enter the following command to create a finalised version of our Hello world:
se c -boost -c_mode release hello_world
These options are passed to compile_to_c. This is usually the best way to finalise a program. Note that using C mode commonly implies the -no_split option, as well as passing the -O3 option to the C compiler.
Example 3
To compile a large project (e.g. the class PROJECT) with incremental compilation and checking preconditions:
se c -require_check project
The very first time, all the C files are produced and compiled. Subsequently, if you use the same command after changing some Eiffel files, only the changed C files will be recompiled.
Note that extensive modifications of the source can force the recompilation of the whole project.
Again, changing the compilation options also involves recompiling the whole set of generated C files.