How code is generated
When you build an application from a Business Application diagram, the files are input into the Code Generation Engine and application code files are output as 4gl.
BAM consolidates and generates
- Data Consolidation
- The input from the BA diagram and related entities is gathered into a single XML file.
- Code Generation
- The XML file and a code template are used to generate the application code. The default Tcl template produces Genero 4gl files, but another tool could be used to generate the code (XSL translator for example).
- Custom code
- Custom code is added to the generated code. The recommended method is using code events, except for some code that can only be provided using the POINT or BLOCK method. The custom code is preserved when the code is regenerated.
Configuring the code generation
If you use code events for custom code, the code is written to files based on the entity name (for example, entity_name.4fdm). These files are compiled like any other .4gl files in your project.
- Save custom code added by the user to the generated source files.
- Generate the new source files without user code.
- Restore the user code in the generated files.
- Compile the written and generated source files.
- Link the compiled files.
To view default build rules, select Language, for example, Genero (no link). Figure 2 shows the build rules used to generate the code for a Program entity in the Business Application Diagram, while Figure 3 shows the default link rules.
and then select theBuild rule command | Description |
---|---|
$(generate) | The $(generate) command creates an intermediary XML file from modeled entities. |
$(blockpoint) -code | BLOCK/POINT is extracted from previously generated and modified code. |
tclsh | The tclsh executable generates the final file by using both a Tcl template file and the intermediary XML file created by the $(generate) command. |
Build rule command | Description |
---|---|
$(echo) | The $(echo) command prints a string to the Output window. |
$(fglcomp) | The fglcomp tool compiles BDL program sources files into a p-code version. |
tclsh | The tclsh executable generates the final file by using both a Tcl template file and the intermediary XML file created by the $(generate) command. |
$(gslint) | The $(gslint) command runs the gslint file from the source file path. |
$(delete) | The $(delete) command removes the given files or directories in a platform independent way. When deleting a directory, the delete is recursive; all subdirectories and files contained within the directory are deleted. |
For a full list, see Command line options for build, link, execution rules.
To better understand what is happening during the build of the program, turn on verbose mode using , then (or, if you are on a Mac, ) . Compile a diagram file, program, or application and view the results in the output.