At the moment we’re already in the last stage of testing before the next version 2.0 will be released as beta. We hoped to make this happen in November and it still might, but probably at the very end of this month as there are still about 30+ issues that need to be resolved before a beta release. Most of them are tiny things, but there are still some heavy one, that needs more work than others. As you are developers as well, you probably know what we’re talking about…
In the meantime, this post is meant to give you some ideas of what will be possible with the next version. The main topic is about the new build system. With this it is possible to inject custom code at several stage during compilation.
Build Stages
The different stages available are: Pre-Build, Pre-Link & Post Build. The first stage is executed before any compilation takes place. It can be used to build/copy/pre-process some code that is used by the compiler. This can be useful to update externally generated interfaces to external JS code automatically on each compilation.
The next step is pre-link and takes place after the JavaScript has been compiled, but before it is embedded or “linked” to an HTML file (or any other context). It can be useful to perform some manual linking of the JavaScript code into any custom format and opens Smart Mobile Studio for a wider use.
The final post-build stage is executed after the build process is (nearly) done. Within this stage the output can be post-processed or uploaded. It might be the most useful stage, as there might be plenty of things you’d like to do with your application. Typical use cases of the post-build would be to upload the entire application to a certain location, typically done via FTP.
You may also want to trigger a PhoneGap / Cordova build, resulting in an APK file suited directly for native testing on an Android device. This can then be transmitted to services such as Testdroid to test your app on real devices. Or maybe you only want to backup your code on each compilation…
Build Scripting
Since Smart Mobile Studio uses DelphiWebScript (DWS) for the JavaScript code generation, a powerful script engine to power the IDE comes already for free. The build system not only make use of DWS, but also extends it for the needs in the context of build scripts. Special care has been taken to make the available code compatible to what you know from other Pascal environments such as Delphi / Lazarus.
The least the build script offers is to call system functions. So in case you have already written some batch files, you can just trigger these from the build script. For these needs a close wrapping of the Win API function ShellExecute is available. Similar to Delphi, this is called asynchronously. Which means Smart Mobile Studio immediately returns, so that you can continue working on the code, while the batch file is executed in the background. However, in some cases a synchronous call is required, which at the same time blocks the IDE from continuation. For this case a special command is available called ‘Call’:
procedure Call(FileName: String; Parameters: String = ''; Path: String = '')
Furthermore several classes are available that directly wrap Indy code. At the moment clases for FTP and SMTP are available. These let you upload your project to an FTP server with all the options that Indy offers. Or you can use it to download the latest external JavaScript library from a certain location. Or just check if a newer version is available.
With SMTP you can email the project or only a notification to any address. Or only trigger an automatic notification, that the project has been built. All with the flexibility you are used to from Delphi. While you have high level access to the related classes you can also use custom-tailored functions for typical access such as:
procedure Upload(FileName: String; Host: String; UserName: String = 'anonymous'; Password: String = 'anonymous'; Path: String = '');
or
procedure SendEmail(Host: String; Recipient: String; Subject: String = ''; Body: String = ''; Attachment: String = '');
which, due to it’s default parameter can be shortened as well to even simpler function.
Beside basic internet access, you also have in depth access to some of the TurboPower Abbrevia classes used for zipping. Furthermore it is possible to query information from the project.
At the moment the options for this are limited, but more and more options will be added in the future.
Despite being under development as well, some basic access to Cordova is also available. Though it’s recommended to use batch files instead. With Cordova it’s possible to transform any HTML5 app into a native application. While this still uses HTML5 rendered through a browser view for the UI, it extends the possibilities to access the hardware natively.
Future plans
With the next minor updates we plan to refine the build system even further. For example it shall be possible to get basic access to the code to extract symbols, expressions and more. With this (and some yet unpublished code) it is also possible to build a documentation along with the project.
With the next major version we also plan to add support for our own cloud solution, to transfer the app directly to the Smart Mobile Studio ecosystem. But that’s content of another post, some day in the future…
So let’s focus on the upcoming release right now, as it is mandatory to give you all this nice stuff described above!