-
Notifications
You must be signed in to change notification settings - Fork 269
The OIL Compiler
The following platform are supported: Mac OS X, Linux 32 and 64 bits, Windows.
Go in the goil/makefile-macosx
. Type ./build.py
. The command builds 2 versions: goil and goil-debug. The first one should be used. The second one performs more internal checking and is used for debugging purpose.
Updated for goil 2.1.24
Print a summary of the available options.
Print the version of goil.
Generate a goil.log file containing the a log of the compilation. The contents of the log file depends on the code generation templates.
Emit a warning if an object not defined for the first time in the implementation does not have the same multiple attribute as in the first definition.
Set the target platform. A target platform is a subpath of the machines and
the templates/code directory. For example cortex/armv7/stm32f407/stm32f4discovery
is a target platforms. Here the first component is the instruction set family for the platform.
In our exemple, the cortex instruction set family. The second component is the instruction set, here armv7. The third component is the microcontroller, here the ST Microelectronics STM32F407. The last one is the board, here the Discovery board from ST Microelectronics. goil uses the
appropriate templates along the same path in the subdirectories of the templates
directory and uses the code specific to the target in the machines
directory.
Set the path to the templates directory. Alternatively, the GOIL_TEMPLATES
environment variable can be set. If the --templates
option is set, goil looks for templates at this path.
If not, it looks for templates at the path contained in the
GOIL_TEMPLATES
environment variable if it is set. If no templates
directory path is set, goil emits an error.
Specifies the OIL config file used by goil. By default goil loads the config.oil
files and the config<version>.oil
files found along the target path.
Specifies the project directory where the generated files are put. By default, the project directory is the name of the oil file, without the .oil extension.
By default, after having parsed an oil file, goil
executes the root.goilTemplate
template which is located in the templates directory. It is possible to specify another template file by using the --root option. The template file has to be located in the templates directory. This allows to perform custom computations on the abstract syntax tree of the oil file. With goil 2.1.24, the templates root file must begin with the version of goil in the text part of the template.
Suppose for instance you want to count the number of tasks declared in an oil file. On the templates side, this information is the number of objects in the TASK list. So we could add a taskcount.goilTemplate
file with the following content:
2.1.24% # goil version needed
println [TASK length]
In this case, goil
would be invoked with the --root=taskcount
or -r=taskcount
option.
This option can be use to pass a set of options to the templates. Passed options are a list of key=value separated by a ,
. For instance let's suppose we want to pass options A and B with values 1 and 2. We would write -o='A=1,B=2'
. key is any identifier matching the C naming rules. value may be
- an identifier;
- a string delimited by a pair of
"
; - a signed or unsigned integer number;
- a floating point number;
- a list of any of the above. A list starts with a
(
and ends with a)
. It contains values separated by,
.
The following -o='ID=identifier, STR="a string", INT=1, SINT=-5, FLOAT=3.14159, SFLOAT=-10.5, LIST=(1,-1,2.7,-10,"hello world",maybe)'
passes options ID
with value "identifier"
, STR
with value "a string"
, INT
with value 1
, SINT
with value -5
, FLOAT
with value 3.14159
, SFLOAT
with value -10.5
and LIST
with value (1,-1,2.7,-10,"hello world",maybe)
.
On the templates side, a PASSEDOPTIONS variable is available. This variable is a map/struct where the keys are the options. For instance, with the previous example, the PASSEDOPTIONS variable has the following content (printed with the display
insruction) :
PASSEDOPTIONS (...) : struct
FLOAT:
3.14159
ID:
"identifier"
INT:
1
LIST:
item at 0:
VALUE:
1
item at 1:
VALUE:
-1
item at 2:
VALUE:
2.7
item at 3:
VALUE:
-10
item at 4:
VALUE:
"hello world"
item at 5:
VALUE:
"maybe"
SFLOAT:
-10.5
SINT:
-5
STR:
"a string"