<p>ROMFS is integrated with <ahref="building.html">the build system</a> for maximum flexibility on various platforms. As a result, you can select the ROMFS contents for each board on which
<b>eLua</b> runs. Moreover, you can specify what <b>applications</b> (instead of individual files) go to the file system, as a real application might need more than a single Lua program
to run (for example a HTTP page with all its dependencies).</p>
<p>To use ROMFS, you have to copy the required files to the <i>romfs/</i> directory, before building eLua.
Keep in mind that the maximum file name of a ROMFS file is 14 characters, including the dot between the file
name and its extension. Make sure that the file names from <i>romfs/</i> follow this rule. Then edit the main build script (<b>SConstruct</b>) to add a new application
All the applications that can be included in ROMFS are defined in the <b>romfs</b> array in <b>SConstruct</b>. Each application in the <b>romfs</b> array lists its files, as shown below
(note that <b>ltthpd</b>, <b>tvbgone</b> and <b>pong</b> applications require more than one file in order to run):</p>
<p>After this, you need to decide the application-to-board mapping. This is defined in another array in <b>SConsctruct</b>, named <b>file_list</b>. The definition of this array is shown below,
<p>What's left to do is <ahref="building.html">build eLua</a>. As part of the build process, <b>mkfs.py</b> will be called, which will read the contents of the <i>romfs/</i> directory and
output a C header file that contains a binary description of the file system. To use ROMFS from C code, whevener you want to access a file, prefix its name with <b>/rom/</b>. For example,
if you want to open the <b>a.txt</b> file in ROMFS, you should call fopen like this:</p>
<p>Starting with version 0.7, the ROMFS can be added to the <b>eLua</b> binary image in 3 different ways:</p>
<ul>
<li><b>verbatim</b>: this is the default option. All the files are copied to the ROMFS directly, without any processing.</li>
<li><b>compress</b>: compress the Lua source code by using <ahref="http://luaforge.net/projects/luasrcdiet/">LuaSrcDiet</a> (included in <b>eLua</b>), a program
that can decrease the size of a Lua source file by applying different transformations. Every
Lua source file (extension <b>.lua</b>) from ROMFS is fed through LuaSrcDiet and the result is written in the <b>eLua</b> binary image. This option can yield
pretty good compression, the only downside being that the compressed Lua source files aren't generally easily readable. However, this isn't really a problem in
most practical cases.</li>
<li><b>compile</b>: precompile the Lua source code to bytecode. Every Lua source file (extension <b>.lua</b>) from ROMFS is fed through the Lua cross compiler
(see <ahref="using.html#cross">here</a> for details on cross compilation and its benefits) and the result is written in the <b>eLua</b> binary image. This option
might decrease or increase the physical size of the ROMFS image, but its real benefits are increased speed (because <b>eLua</b> doesn't need to compile the Lua
code to bytecode first) and decreased RAM consumption (the Lua parser might get quite memory-hungry at times, which in turn might lead to stack overflows and very
hard to find bugs). </li>
</ul>
<p>See <ahref="building.html#buildoptions">here</a> for instructions on how to specify the ROMFS compilation mode.</p>