This text gives a hint how a simple application can be written/organised and imported to our target device WP7607:
HelloWorld
Legato definition files (.sdef, .adef, .cdef and .mdef) are used as instructions to the Build Tools (mk tools) and tell the mk tools how to bind the components, apps and systems together to create the Legato Runtime Environment which then gets installed on a target.
To build a system or an app we start with building a component, a collection of code and other files that are functionally related. Here is the hierarchy folder/files for our example:
The C file starts with a #include "legato.h" instead of #include <stdio.h> a,d main() is replaced with COMPONENT_INIT. legato.h is the main legato library, and includes stdio.h along with other system headers and Legato Framework headers. Also include interfaces.h. interfaces.h is a C header file that automatically includes all client and server interface definition that your client imports and exports. It is not used in helloWorld now, but it is a Legato best practice to include it in all of your Legato Component C or C++ code. Your helloWorld.c should look like this:
Each component must have a corresponding Component.cdef, which must be included in the same folder as the rest of the component code. Add the following to your Component.cdef file and then save and exit.
sources:
{
helloWorld.c
}
Next let's turn your helloWorld component into an App. Apps are the execution environment for your code, they contain one ore more executables that run together in a "Sandbox". The Application Definition .adef builds the instructions to tell the mktools how to build your app.
First we are going to define an executable named helloWorld for the helloComponent Component. This turns your source code into an executable binary. Next we need to tell the app to start the helloWorld executable within a process.
Now that all your files are created and you have provided a .cdef and an .adef for your app you are ready to use the Build Tools mktools to build your app into a binary and deploy it on your target. mkapp is the tool that is used to build the app into a binary package that can then be installed on your target. It is important to specify the target that you are building for as mkapp will include all the libraries and dependencies that are needed for your specific target. The command line is as follows:
$ mkapp -t <target> helloWorld.adef
Make sure you completed the installation of Leaf and the this configuration; after legato installation you should the following modifications in your bash configuration file
alias cfglegato=\
"pushd . && cd ~/legato_framework/legato && source ./bin/configlegatoenv ; popd"
and do a cfglegato in your command line. If you didn't install your development environment with Leaf, before you run mkapp make sure that you have configured the Framework for a specific target and have run bin/legs or sourced bin/configlegatoenv.
We did $ mkapp -t wp750x helloWorld.adef and the new structure appeared:
The _build directory is the intermediate directory where the compiler will place all staging files created during the build process. helloWorld.wp85.update is the package that is needed to install helloWorld onto your target. To do so we have to run
This text gives a hint how a simple application can be written/organised and imported to our target device WP7607:
HelloWorld
Legato definition files (.sdef, .adef, .cdef and .mdef) are used as instructions to the Build Tools (mk tools) and tell the mk tools how to bind the components, apps and systems together to create the Legato Runtime Environment which then gets installed on a target.
To build a system or an app we start with building a component, a collection of code and other files that are functionally related. Here is the hierarchy folder/files for our example:
The
C
file starts with a#include "legato.h"
instead of#include <stdio.h>
a,dmain()
is replaced withCOMPONENT_INIT
.legato.h
is the main legato library, and includes stdio.h along with other system headers and Legato Framework headers. Also includeinterfaces.h
.interfaces.h
is a C header file that automatically includes all client and server interface definition that your client imports and exports. It is not used in helloWorld now, but it is a Legato best practice to include it in all of your Legato Component C or C++ code. YourhelloWorld.c
should look like this:Each component must have a corresponding Component.cdef, which must be included in the same folder as the rest of the component code. Add the following to your
Component.cdef
file and then save and exit.Next let's turn your helloWorld component into an App. Apps are the execution environment for your code, they contain one ore more executables that run together in a "Sandbox". The Application Definition .adef builds the instructions to tell the mktools how to build your app.
First we are going to define an executable named helloWorld for the helloComponent Component. This turns your source code into an executable binary. Next we need to tell the app to start the helloWorld executable within a process.
Now that all your files are created and you have provided a
.cdef
and an.adef
for your app you are ready to use the Build Toolsmktools
to build your app into a binary and deploy it on your target.mkapp
is the tool that is used to build the app into a binary package that can then be installed on your target. It is important to specify the target that you are building for asmkapp
will include all the libraries and dependencies that are needed for your specific target. The command line is as follows:Make sure you completed the installation of Leaf and the this configuration; after legato installation you should the following modifications in your bash configuration file
and do a
cfglegato
in your command line. If you didn't install your development environment with Leaf, before you run mkapp make sure that you have configured the Framework for a specific target and have run bin/legs or sourced bin/configlegatoenv.We did
$ mkapp -t wp750x helloWorld.adef
and the new structure appeared:The
_build
directory is the intermediate directory where the compiler will place all staging files created during the build process. helloWorld.wp85.update is the package that is needed to install helloWorld onto your target. To do so we have to runwhere we remind that the last input is the IP address of the target. You might make your life easier