What is Cppia?
Cppia (pronounced "sepia") is a new beta feature that allows
desktop games to be compiled faster. Using my favorite test case, Ghost Song, compile time went from ~40 minutes to ~40 seconds with Cppia and other recent Haxe generation improvements.
How does it work?
There are many steps to the compilation process of a Stencyl game.
- Design mode behaviors are stored as xml. They are read and transformed into Haxe code. (very quick)
- Generated Haxe code and assets are copied to the games-generated folder. (fairly quick)
- From here, the steps are a little different depending on what you're targeting. We're focusing on desktop games here.
- The haxe code, including the source for Stencyl, the haxe standard library, openfl, lime, and additional libraries we use, and your own behavior code on top of all that, is translated into C++ code. (very quick)
- The C++ code is compiled into an executable that you can run on your OS. (
THIS TAKES A LONG TIME!!!)
Cppia is a way of speeding up the process. How does it work? Cppia divides the program into two parts: A
host application and a
script.
The
host application is compiled C++ code, so it can be run on your OS, and has high performance. The host is made up of all of the parts of an application that don't change very often, and parts that are critical to performance, such as physics engines. In stencyl-cppia, the host is made up of almost everything except for the code you generate with design mode behaviors.
The
script is not compiled C++ code. Instead, it's a plain text format that the host application can interpret. This means that, at the cost of losing highly efficient compiled code, we can have much quicker "compile" times for our games.
Since a huge amount of code is now compiled only once, in the host application, there's no need to worry about compiling all that framework code again when you test a new game. The only thing that will be "compiled" is the code from your behaviors, and it'll only be translated into a text format that the host understands, which is much faster than traditional compiling. The big drawback is performance, but since we place most of our performance-critical code into the host application, you only have to worry about performance drawbacks in your own behaviors, not in the engine.
How do I use Cppia?
(This step no longer required with the latest builds)
- Download the latest build (b8627, September 1) and set the cppia.enabled flag in [workspace]/prefs/boot.txt.
cppia.enabled=true
- Test a game in Stencyl with the "Cppia" target.
===== Feedback =====
This feature is still in beta, and there may be differences between a full native game and one run with the Cppia target. Please report any such differences or anything that causes a crash in cppia but not on desktop.
For now, this is a desktop-only feature, but in the future, we plan to also allow mobile games to be exported with Cppia.