Compiling - mszczodrak/swift-fox GitHub Wiki
Before compiling a Swift Fox program, make sure you have the following:
- Installed Swift Fox compiler
- Wrote a Swift Fox program
- Have implemented all Fennec Fox modules used in the Swift Fox program
To check if the compiler is installed, run the Swift Fox Compiler (sfc) command from the shell. If you see the following in your shell, you are to procede:
user@linux $ sfc
sfc: no input files
If your source program is located in sample.sfp and sample.sfl, then run:
$ sfc sample
user@linux $
At this moment you should have written a Swift Fox program. Let's say that you have a Swift Fox program, like the one below, saved in file named simple_blinking.sfp, where sfp is the Swift Fox source code program file extension.
process hello { blink(1, 500) # Application layer module
nullNet() # Network layer module
nullAM() # MAC and Radio layer module
}
start hello
If all the modules used in the configuration hello are defined, then we can compile the Swift Fox source code from the simple_blinking.sfp file, as follows:
user@linux $ sfc simple_blinking.sfp
user@linux $
If everything is fine, there are no messages returned during the compilation; in the same way as gcc does.
Since Swift Fox compiler knows that the source code extension is sfp, the extension can be skipped during the compilation, therefore, the following is also valid:
user@linux $ sfc simple_blinking
user@linux $
After compilation, the Swift Fox Compiler will create nesC code stored in the Fennec Fox source code library. It will create a folder under the path
$(FENNEC_FOX_LIB)/src/Fennec/sfc
and store all compiled code in the sfc directory. The $(FENNEC_FOX_LIB) is the linux system environmental variable, that is saved in the user's ~/.profile file during the Fennec Fox installation.
Sometimes, however, the Swift Fox compilation will fail. One possible error can look as follows:
user@linux $ sfc simple_blinking
sfc in program simple_blinking.sfp
no such module at line 4, position 17:
nullAM2() }
^
user@linux $
which means that module nullRadio2 is not defined. This error would happen if in the simple_blinking.sfp we would use nullAM2() module on line 4, instead of the correct one nullAM().
To make sure that Swift Fox program knows about all the modules that are used in the code, we must tell the compiler what modules are available and where they are located. The compiler will look into two files to create a list of all Fennec Fox modules. First, it looks into the Fennec Fox standard library file, located in
$(FENNEC_FOX_LIB)/src/support/sfc/fennec.sfl
where sfl is a file extension used by Swift Fox to denote Swift Fox Library files with definitions of modules and their locations on the PC. The up-to-date list of Fennec Fox modules available in the Fennec Fox standard library can be found here.