Login | Register
My pages Projects Community openCollabNet


In version 0.8.7, lightblue introduced  a new build system which is based on GNU MAKE. The build process has been  simplified again.  By using this new system, you can
  • Build simulator code without visual studio IDE.
  • Fast switch which compiler and SDK to use.
  • Easily add or remove source codes.

Table of contents

Setup the environment
Use the build system
Build examples step by step
Build examples in VS.NET IDE

Setup the environment

Before compiling lightblue, we  need  to  install  required compiler, SDK and tools.  Below  is  a  list  of  softwares that  are  needed:

  • Visual Studio. NET   (Only if you want to build and debug the simulator code)
  • Realview ARM Compiler 2.x from ARM or GNU ARM Compiler  from gnude.   (You can choose one of these compiler to install)
  • For GNU ARM compiler, BREWelf2mod.exe is also needed which is included in BREW ADDINS 3.0 for Mocrosoft Visual Studio.
  • Brew SDK 2.1.3 or 3.1.4  (Only these two versions are currently supported)
  • GNU MAKE 3.8.0 or later.  (A native win32 build of GNU MAKE 3.8.0 is included in the lightblue package)

Use the build system

 The new build system is designed for simplicity, so everything you need is:

Configiure the tool path
Generate the makefile
Build the project
Re generate the makefile

Configure the tool path

In the root directory of the lightblue project directory, there is a file called lb_env.cmd which contains all  tool settings  used by the build system. Currently the only variable that you should change is %make% which is set to the absolute path to the GNU make executable "make.exe". By default, this variable is set to %lb_root%\utils\make.exe which is a native win32 build of GNU MAKE 3.8.0 included in the package.  You can change the %make% variable to the path you want the build system to use, for example, the one from the cygwin package. Also, the %lb_root% is automatically set to "%~dp0" which is expended to absolute path of the directory where lb_env.cmd resides. 

After the lb_env.cmd is updated correctly, there are compiler specific settings in following files:

configure\cfg\rvct.cfg   (for the real view 2.2 compiler)
configure\cfg\gnuarm.cfg (for the GNU ARM compiler)
confgure\cfg\gnuvc.cfg  (for the Visual C++)

Only update the compiler settings that are used.

Usually, these files contain settings of the path to the compiler, linker and which BREW SDK is used. Check the comments in the file before changing them. One thing you have to awared is that  these files are actually makefiles, so never put an '\' at the end of a line when you are writing an directory. Otherwise, weird errors will occur.

Generate the makefile

Before generate the makefiles , please make sure that all tool settings are set correctly by previous step.

In the "build"  directory,  call  makegen.bat will  generate all  makefiles. After a sucessful generation which might take for a while, several batch files and directories are generated in the "build" directory, for example:

 Please check the next section for the usage of these batch files.

Build the project

Each generated batch files is a shortcut of  launching the actually makefile which resides in the sub directory. For example, make_rvct_runtime.bat will call makefile in rvct_runtime directory.  All parameters are passed through to the makefile so you can  indicate target to build in the command line, for example:

"make_rvct_runtime.bat all" will build the "all" target in the makefile.

Currently, two targets are implemented for each makefile:

all                -- to build the component
clean            -- clean the output and intermedia files.

Every batch file has the name pattern of: build_<toolset>_<component>.bat. The <toolset> part indicates the toolset (the compiler and SDK combination) used, they could be:

rvct          -- the real view ARM compiler (ARM only)
gnuarm     -- the GNU ARM compiler (ARM only)
vc             -- Visual C++ (simulator only)

 Each tool set has its own configuration file in the "configure\cfg"  with the same file name as the tool set  and the extension of  "cfg".

The <component>  part  indicates which component to build:

runtime          -- the runtime  (Must be built before other component could be built)
examples       -- the examples (Contains 5+ examples)

You can easily determine which  batch file to call  by  its name. For instance, if you are using the Realview ARM compiler and want to build the runtime component, you should call "make_rvct_runtime.bat" .

The "runtime" component is always the first component to build which is depend by almost all other components.  It is also a good idea to build the "examples" component right after the "runtime" component , so that you can determine the "runtime" is built correctly.

Re generate the makefile

Each time you move the lightblue project to a different directory or  change the lb_env.cmd or cfg files in the configure\cfg directory, you need to re generated all the makefiles to reflect the changes. However, no  regeneration is needed if you just added or removed some source files in the component.

Build examples step by step

Below is a step by step instruction of how to build the lightblue runtime and examples using the new build system. Both ARM and X86 emulator code could be generated.
  1.  Extract the lightblue distribution package to a local directory.
  2.  Setup the environment
  3. Edit lb_env.cmd in the root directory of lightblue, the %make% variable is set to the right path.
  4. Depending on which compiler or compilers you will use, edit  these compiler specific configurations in the configure\cfg directory:
    "rvct.cfg", "gnuarm.cfg" and "vc.cfg"
  5. Open  a  cmd shell
  6. cd <the dir that lightblue is extract to>\build
  7. call makegen.bat       
  8. Several files and directories are created.         --Notes: Several batch files and sub directories will be created in the current directory.
  9. call make_<tool_set>_runtime.bat all              --Notes: <tool_set> could be rvct, gnuarm or vc,  You can you a toolset only when it is installed and  properly configured. in step 4.
  10. call make_<tool_set>_examples.bat all           --Notes: Call this only when make_<tool_set>_runtime is finished.

After a successful build, following files and directories are created:
build\out\g++\*        -- The example programs compiled by the GNU ARM compiler.
build\out\vc\*            -- The example programs compiled by the Real View ARM Compiler.
build\out\gnuarm\*     -- The example programs compiled by the Visual C++ Compiler.

Now you can test the example programs in the simulator or the handset:

 For the simulator, you just change the applet dir of the simulator to "build\out\vc".

For the handset, beside the mifs and the mod  files, you also need a signature files for each example programs. Install them to the handset like any other brew applications.

If you prefer to compile using Visual studio IDE, please continue in the next section

Build examples in VS.NET IDE

Below is a step by step instruction of how to build and run lightblue examples in the BREW emulator:

  1.  Make sure the bin\vc\entryptr.o is there . If not, please check the previous section for instructions how to build it.
  2. Open vs_projects\examples\examples.sln
  3. If you are using BREW SDK 2.1.3, please set the active configuration of the solution to "Use_BREW213" otherwise, please select "Use_BREW314".
  4. (Note: Only BREW SDK 2.1.3 and 3.1.4 are currently supported.)
  5. For each project,update project properties -> c/c++ -> "Additional Include Directories" to the absolute BREW SDK  directory.
  6. Build solution.
  7. Run the BREW emulator and change applet dir to "examples"
  8. Choose and execute one of the four examples.

Notes: The supplied sln is in Visual Studio.net 2003 format, previous version of VS.net might not be able to open it.

To run and debug the example programs on the simulator, you have to do following steps:
  1. Manually copy examples\mifs\*.mif to examples\
  2. Open the simulator and change the applet dir to the examples directory
  3. Run the applet

After the runtime and the examples are compiled and tested on your system, it is time to build your own  programs using the lightblue library.