Welcome to the Ameba project. Port your MIDlets to others platforms (Nokia, Siemens, Motorola, Samsung etc.) fast and easily. Debug, build, deploy and backup with one command. Save your time!
Ameba was created to help port MIDlets from one platform to another. Because the differences between
phones are getting bigger and bigger, I've ended up with many versions (18+) of the same MIDlet for
various phones. The idea is to write the source code only once and change only the code that is
specific to some phone. The easiest way was to add the #define statement, just like in C. In general
AmebaEngine is simply preprocessor similar to the one from C/C++. However it has some more features
and sometimes the syntax is shorter. In addition to AmebaEngine there is a complete script environment,
that helps to manage the code, versions etc.
Project management is done via Ameba scripts. First step is to create a new project. The developer works with only one source code (reference version). This source is not a valid Java code (it will not compile) and consists of code for all the platforms. This is achieved via special keywords like #define, #if, #include etc. Later to produce valid source code for a given platform appropriate script has to be invoked. All scripts (make, build, run, deploy, backup) to handle the project are in the "scripts" directory. They are all in perl, thus work on Win32 and Linux.
To show all the most important features and basic usage, we shall create new project using simple template, add new platform and compile it. For this example we will assume that Ameba is properly installed in C:\ameba. Suggested place for all the projects is in "/projects" directory in ameba's main directory.
1. Create a new project
This command will produce in the current directory a new directory called "MyGame". Inside there is a whole structure of subdirectories. Each has its purpose as listed below:
Directory structure inside a target's directory:
At this moment a whole set of directories, scripts and files is created. Below is the list of major files:
2. Create new targets
Default template which was used has 4 targets: nokia s40 en, nokia s40 pl, nokia s30 en, nokia s30 pl. Of cource that is not enough and we want another target: nokia s60 in english and polish. So we need to create 2 more targets.
NOTE: this command should be invoked in the project's main directory (containing file: ameba.project).
This adds english version for nokia s60, and we add another one for polish version:
At this point 2 new directories appear: nokia_s60_en and nokia_s60_pl. Both have the same subdirectory structure as for other targets. At this point we can have a look at the source code.
3. The source code
When AmebaEngine starts
transforming files it first reads the config.jh file to look for the 3 pragmas: "platform",
"type" and "lang". Any extra defines are evaluated. Below the target pragmas there is conditional
including of file "l_en.jh" or "l_pl.jh". These files contain text for MIDlet in english and
polish. Because these 3 pragmas also add new defines they can be already used. As showed in the
comment at the begining of the config.jh file, new defines have special format. __yyy__ where
yyy is the value of pragma so here we can have __EN__ or __PL__ and this is used to include
appropriate file. Below are those two files.
These 4 files is the complete reference source code for the MyGame MIDlet. In the MyGame() constructor there are those defines from langugage files: L_EXIT and L_HELLO_WORLD. Now how to change the reference version into valid source code?
3. Make valid Java source code
The "scripts" directory in the project main directory contains several files used to make your source code.
As you can see all scripts are in perl so should work the same on win32 and linux platforms. Lets have a look at one of the scripts for example "makedef.pl".
NOTE: This file was reformated to fit the page.
NOTE: Ameba is under constant development, so this file in the current version of Ameba may differ.
The main purpose of this scripts is to run AmebaEngine. This can also be done by the developer, however as you can see the parameters list is quite long and running it not from a any script would be very inconvienient. We will not discuss the parameters now. I just want you to take notice of two things:
1. All paths are absolute - this means you can run this script from anywhere you want.
2. Slashes "/" are used in the paths even on win32 platform.
After executing AmebaEngine script add one line to project's history file.
Other make scripts are very similar and differ in parameters passed to AmebaEngine and line added to history file.
There are many benefits if Ameba is used. The most important is faster development, much easier debug. Read sections below to learn more about the major benefits.
Ameba needs Perl to work! For win32 platforms I suggest ActiveState ActivePerl
http://www.activestate.com. I use version 5.8.
2. Adding bin directory to PATH
Later you can check if everything is OK by running check script.
AmebaEngine is the core of Ameba. This is the program that transforms reference version of source code and produces valid java source code. AmebaEngine can be used as a stand alone program. However it is intended to be used with Ameba, which is generating scripts to run AmebaEngine (they can be quite complex).
Ameba *is* platform independant - Java + perl is a good solution. However to have everything working the way I want some scripts are platform dependant. These are in to versions: with extension (bat) for win32 platform and without for linux (ex. 'ameba.bat' for win32 and 'ameba' for linux).
Reference version of source code - This is the source code the developer writes with all the AmebaEngine's
directives like "#define" etc. and is used by AmebaEngine to produce valid Java source code.
This project is under constant development. When ever I feel I need some feature and I have time
I try to implement it. The most recent version is available in CVS, and from time to time whole
package will be prepared.
|copyright: Maciej Kocemba (hmml)|