Project generation - mrtrizer/FlappyTools GitHub Wiki
FlappyEngine uses a paradigm of templates to generate project for target platforms. A simple project template consists of one, or few files, with injections of Python code and setting names. In fact, the project templates look like some kind of PHP files. This approach provides easy way of adding support for new platforms and modification of existing project templates.
All user-defined templates should be placed to /templates/
dir at the root of the project. You can look at the predefined templates from template folder at engine root as examples.
Very often, it's need to extend a simple project generation from template. You can do that by adding build extensions, written on Python. Extensions can be called from injections in template files to provide complicated ways of project generation, file manipulation and other stuff. You can add Extensions for each generation step: project generation, resource building and resource copying, to control your build flow. Engine already contains a suite of some useful functions to simplify template building.
Generator performs substitution of special-formatted setting names with values from configuration files. Setting names should be enclosed to brace block {![<platform>].<setting>!}
to be substituted. File names also can contain substitution blocks. For example, Qt project file can be represented as {!qt.project_name!}.pro
.
Moreover, generator evaluates single-line python code, enclosed in braces with question marks {?callSomeMethod()?}
. What can you do in one-line python code? You can invoke a method from extension, for example, concatenate strings and other. So, python injections are not intended for complicated logic, they are rather suites for communication with extension scripts.
A piece of qt project template for example:
...
TARGET = {!name!}
...
{?printList(fileList(projectDir + "/src/",".cpp"),"SOURCES += ../../src/*\n",exclude)?}
...
There are also condition blocks and other useful things. See an article about templates for details.
FlappyEngine already provides templates for some general platforms by default:
- qt - Project for Qt5.5
- cmake - Project for CMake2.8
- android - Gradle project for Android Studio
- ios - XCode 7 project for iOS 7 and higher
You can fork and modify any of the standard templates for your needs.
See detailed description of available template injections: Template format
The project generation system can generate project for several platforms, using project templates. To configure generation process and final projects itself, you can put particular settings to configuration files. There are can be multiple files with settings, which can describe different build configuration, Debug and Release in simplest case. Configuration files use json format for setting representation. All common settings of project are placed at the root of json document. And platform-specific settings are distinguished to separate json blocks. Global settings affect common settings, such as a project name, an engine path, a source path, etc. Platform-specific settings help to configure building for different targets, iOS or Android for example.
One of the general ideas of configuration is overriding. You can create multiple configuration files and define order of they processing. Last configuration files will override settings of previous. So, you able create separate configuration files for QA, Developers, Presentations and other need. Each configuration will modify only particular fields of your configuration. It's also works the same way for sub projects. See an illustration below.
The standard configuration works the same way. There are one predefined configuration for all projects, which overridden by project configuration of your project.