Working with Embedded Wizard: Generating code
When you are done with the development of the GUI application and your implementation works already as expected in the prototyping environment, then you are ready to generate code for your particular target platform.
In the first phase of the code generation Embedded Wizard evaluates your project and verifies all project members regarding their correctness. In the second phase Embedded Wizard analyzes the dependencies between project members and optimizes your project. This includes elimination of all unused members, pre-evaluation of expressions and wherever possible the replacement of complex members with more simple entities.
Finally, in the last phase, the remaining and optimized members are converted in statements and expressions valid for the particular target platform, e.g. ANSI C syntax. The last phase includes also the conversion of all bitmap and font resources to the color format expected in the target. If necessary, color reduction and dithering are applied on the resources. This last phase is very individual to the Platform Package you use for the code generation.
The dependency evaluation starts always with the application class you have specified in the ApplicationClass attribute of the profile selected for the code generation and propagates recursively along all available references to other project members. This ensures that no needed members are excluded when your project is generated.
In particular circumstances, however, it may be necessary that you need to prevent the automatic elimination of project members. For example, if your project contains a method you intent to call directly from the native code you should ensure that it is generated even if the method is not referred by other members inside the application itself.
This aspect is controlled by the attribute Generator you can specify selectively for almost every project member. If this attribute is set true, the affected member cannot be ignored by the code generation. If the attribute is set false, the corresponding member is ignored unless the member is required due to dependencies from other members.
Start the code generation
If your project contains several profiles you can use the menu command . Activating this command causes the Build in batch mode dialog to appear where you can individually select all desired profiles for the code generation. In this case you can generate conveniently code for different target platforms or product variants at once.
Depending on the complexity of your project and the performance of your workstation, the code generation will take between few seconds and, if your project is especially large, few minutes. During the code generation appears following dialog permitting you to abort the operation if desired:
With the Pro edition (except Small Business license) of Embedded Wizard you can use the CHORAC.EXE command line compiler to start the code generation directly from a Windows batch file.
Check the Code Generation Report
If the code generation was successful, Embedded Wizard creates a Code Generation Report file. You see this in the Log window. For example:
This build report is stored in HTML format and as such it can be viewed simply by using a Web browser. When you open the file, you see an overview with estimated memory (flash) usage needed by your application (also known as code metrics). The estimation is subdivided in several categories including all the members used in your project. For example:
By clicking on the buttonsyou can navigate to the corresponding list containing all the involved members. The lists can be sorted when you click on the respective header caption. This helps to find which members occupy the most memory:
Find the generated code
Per default, Embedded Wizard stores the generated files within a folder named after the profile used for the code generation and located directly below the folder of your project. With the attribute OutputDirectory you can determine another location where to store the files.
Since the generated files contain source code you can open and evaluate them with a simple text editor. But in the usual case, it is not necessary. You can consider the files as an intermediate product similar to e.g. object files generated by an ANSI C compiler. Finally, the content of the files reflects 1:1 your project implementation.
In any case you should modify the generated files. Next time you start the code generation, your modification is overwritten.
If the Platform Package you are using supports it, you can specify individual directories for the include (e.g. *.h), source (e.g. *.c) and resource (e.g. *.png) files. See the attributes OutputIncDirectory, OutputSrcDirectory and OutputResDirectory. Also, with the attribute OutputFileNameExtension you are flexible to configure Embedded Wizard to generate source files with other extension as expected by your compiler. For example, you can create C++ files.
Use the generated ANSI C code
If you are using a Platform Package generating ANSI C code, you have to integrate the *.C and *.H files into your particular development system to build the final executable for the target device.
In the simplest case you will do this by adding new rules to your makefile, one for every generated *.C file. Please note, Embedded Wizard generates additionally two files ewfiles.inc and ewfiles.lst, which contain all the names of affected *.C files in syntax acceptable by various makefile systems. If you are working with an integrated development environment like Keil MDK, Microsoft Visual Studio, Apple XCode, etc. you will need to add the generated *.C and eventually *.H files to your actual project.
Additionally to the generated files your makefile or project should include the Runtime Environment and the Graphics Engine, which are fixed components of the particular Platform Package. These components are provided, depending on your license, in source code or as compiled static libraries. Please refer to the instructions provided with your Platform Package. Also see Build Environments.
When you generate your WebGL application you should make sure that the attribute Obfuscation is set true. Additionally, please delete the file _debug_only_dont_deploy.txt from the output directory when you deploy the generated application or transfer the code to your web server. Otherwise the generated code, and thus your project know-how can be evaluated easily.
Due to the security policy for local web pages, your web browser will probably fail to start the application if the files are accessed directly without a web server. Thus you should either use a web server or configure your web browser to allow web pages to access the locally stored files.
Use the CHORAC command line compiler
With the Pro edition of Embedded Wizard (except Small Business license) you can start the code generation directly from the Windows command line. This approach is ideal if you have to trigger the code generation in an automatic batch job or from your test environment. Opening your project in Embedded Wizard Studio is not necessary in such case.
To start the code generation from the Windows command line, please use the tool CHORAC.EXE found in the installation directory of Embedded Wizard. The tool automatically loads your project, compiles the Chora code and generates the resulting code for your target system - exact as if you had started the code generation in Embedded Wizard Studio. The tool CHORAC.EXE expects two parameter: the name of the affected project file (the EWP file) and the name of the profile to be selected during the code generation:
The following example demonstrates the usage of the tool to generate code from one of our example projects. Please note the cd command to change the working directory. You can of course use absolute paths to address the project file:
cd "C:\Users\Paul\Documents\Embedded Wizard 9.10\Examples\CoffeeMachine"
"C:\Program Files (x86)\Embedded Wizard 9.10\chorac" CoffeeMachine.ewp Win32
During its runtime the CHORAC.EXE tool reports information messages, or if there is a problem in your project, warnings and errors: