[View]  [Edit]  [Lock]  [References]  [Attachments]  [History]  [Home]  [Changes]  [Search]  [Help] 

[jx8-android] Building the application image

In jx8-android platform an Android application has an s8 image -a .js file- considered as an asset in for the Android app.

S8 image building process consist on executing batch files that fileIn (.st files ) or emmit (fileIn .st files and generate corresponding .js files) or load -js file pieces of s8 images, and gathering those pieces togheter to generate the s8 -javascript file- image.

This process provides a modular building and also the ability to dynamically change the deployed s8 image.

To build this s8 image we use s8 console platform and script files in s8 folder.

Files and structure

At Android Studio project level we have s8 folder containing our elements and scripts to build our s8 image -finally an asset for an app within that Android project.
For instance:
cd \Android\JX8\s8\library\s8
call _updateLibs
cd \Android\JX8\s8\library\NodeJS
call _updateLibs
cd \Android\JX8\s8\browse
call _updateLibs

cd \Android\JX8\s8
\C\v8\s8\release\s8vm.exe --expose-gc --shell app.js build.js
\C\v8\s8\release\s8vm.exe --expose-gc --shell appU8.js build.js
In this case we have two Android apps in the project: app and appU8. And app.js and appU8.js define paths for s8 image building process for both apps respectively.

For example, in appU8.js we have:
// Settings to build application image
applicationSources = "sources/app/build.st";
assetsPathName = "../app/src/main/assets/";
snapshotPathName = assetsPathName+"default.snapshot.js";
That depict:

In the same s8 folder, build.js defines the main body of the s8 image building process:
(function() {
    try {

	if (applicationSources) fileIn(applicationSources);

	if (snapshotPathName) {
		("	 ('function print(text) { return console.log(text); }' "
		+"	,Snapshot contents) outputToFile: #{snapshotPathName} "

    } catch (err) {
	print('// Bootstrap Error: '+err);
this script defines a loading order and the generation of a new s8 image (... outputToFile: ... part).

Let's describe each loading part:
	" Private - Launch the receiver.
	This method will be activated when loading image and is used to finish application setup from S8 side."

How to start

A starting point would be placing your s8 code in \s8\sources\ and then executing __rebuild.bat in that same folder. Then s8 image will be built and included as an asset of your Android application.
The final step: generate your application apk -that will include your s8 generated image- and deploy it to the Android device.