Permalink
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
71 lines (69 sloc) 4.86 KB
---
title: Creating an Asteroid app
layout: documentation
---
<p>The app creation process of AsteroidOS needs a Software Development Kit generated by OpenEmbedded. You can either grab a prebuilt SDK for the nightlies <a href="https://release.asteroidos.org/nightlies/sdk/oecore-x86_64-armv7vehf-neon-toolchain-nodistro.0.sh">here</a> or for the latests stable release <a href="https://release.asteroidos.org/1.0/sdk/oecore-x86_64-armv7vehf-neon-toolchain-nodistro.0.sh">here</a> and install it on your system or you can build it yourself as follow.</p>
<div class="page-header">
<h1 id="crosscompiletoolchain">Building the Cross Compilation Toolchain</h1>
</div>
<p>If you’ve already got an OpenEmbedded build directory via the ‘Building AsteroidOS’ page, cd to that directory. Else, create one with:</p>
<pre><code>git clone https://github.com/AsteroidOS/asteroid
cd asteroid/
</code></pre>
<p>Then, build the cross compilation toolchain with:</p>
<pre><code>. ./prepare-build.sh dory
bitbake meta-toolchain-qt5
</code></pre>
<div class="page-header">
<h1 id="installsdk">Install the SDK</h1>
</div>
<p>If you downloaded a prebuilt SDK, run the downloaded script. If you followed the previous steps, this will have generated the same installation script in <em>tmp-glibc/deploy/sdk/</em>, you can run it as follow:</p>
<pre><code>./tmp-glibc/deploy/sdk/oecore-x86_64-armv7vehf-neon-toolchain-nodistro.0.sh
</code></pre>
<p>This script will install the cross compiler and ARM libraries in <em>/usr/local/oecore-x86_64</em> by default, along with a script that needs to be sourced before every build. If you want to build a simple project via the terminal, this can be done like that:</p>
<pre><code>source /usr/local/oecore-x86_64/environment-setup-armv7vehf-neon-oe-linux-gnueabi
qmake
make
</code></pre>
<div class="page-header">
<h1 id="configqtcreator">Configure QtCreator for cross compilation</h1>
</div>
<p>Before running QtCreator you must run the previously mentioned script:</p>
<pre><code>source /usr/local/oecore-x86_64/environment-setup-armv7vehf-neon-oe-linux-gnueabi
qtcreator
</code></pre>
<p>This can be done automatically by prepending “source /usr/local/oecore-x86_64/environment-setup-armv7vehf-neon-oe-linux-gnueabi” before #!/bin/sh in <em>/usr/bin/qtcreator.sh</em></p>
<p>Now that you are in QtCreator go to ‘<em>Tools-&gt;Options-&gt;Devices</em>‘</p>
<ul>
<li>Add a new Generic Linux Device.</li>
<li>Name it "AsteroidOS Watch".</li>
<li>Choose 192.168.2.15 as IP address.</li>
<li>Use root as user.</li>
<li>Choose Password authentication and leave the password field empty.</li>
</ul>
<p>Under the '<em>Build &amp; Run</em>'</p>
<ul>
<li>In the Compilers tab add the following GCC (C++): <em>/usr/local/oecore-x86_64/sysroots/x86_64-oesdk-linux/usr/bin/arm-oe-linux-gnueabi/arm-oe-linux-gnueabi-g++</em> and GCC (C): <em>/usr/local/oecore-x86_64/sysroots/x86_64-oesdk-linux/usr/bin/arm-oe-linux-gnueabi/arm-oe-linux-gnueabi-gcc</em></li>
<li>In the Qt Versions tab add the following qmake: <em>/usr/local/oecore-x86_64/sysroots/x86_64-oesdk-linux/usr/bin/qt5/qmake</em></li>
<li>In the Kits tab add a kit with the previously defined device, Qt5 version and compilers, set the sysroot to <em>/usr/local/oecore-x86_64/sysroots/armv7a-vfp-neon-oe-linux-gnueabi/</em> and let the other variables empty.</li>
</ul>
<div class="page-header">
<h1 id="firstapp">First app</h1>
</div>
<p>Asteroid-Stopwatch can act as a cool QML demo app to make your first steps into AsteroidOS development easier. You can clone it, build it, install it and then modify it to follow your needs:</p>
<pre><code>git clone https://github.com/AsteroidOS/asteroid-stopwatch
cd asteroid-stopwatch/
./i18n/generate-desktop.sh . asteroid-stopwatch.desktop
source /usr/local/oecore-x86_64/environment-setup-armv7vehf-neon-oe-linux-gnueabi
qtcreator asteroid-stopwatch.pro
</code></pre>
<p>Try to build and deploy the app. If it wasn’t already installed, a new icon should have already appeared on asteroid-launcher.</p>
<p>You can start by modifying occurrences of “asteroid-stopwatch” to your app’s name. Then you can change the *.desktop file which describes the icon on the apps launcher. Then modify main.qml to describe your UI. To get started with QML development you can read the <a href="http://doc.qt.io/qt-5/qml-tutorial.html">official tutorial</a>.</p>
<div class="page-header">
<h1 id="tipsandtricks">Tips and tricks</h1>
</div>
<p>If you want to start your app from the command line, open a shell with <a href="{{rel 'wiki/ssh'}}">SSH</a>, connect to ceres and use invoker:</p>
<pre><code>invoker --type=qtcomponents-qt5 /usr/bin/asteroid-stopwatch</code></pre>
<p><b>TODO:</b> Document the integration of this invoker command as a run step in the Qt Creator configuration.</p>
<p>If you want to disable screen locking for easier development you can enable the demo mode of mce as root with:</p>
<pre><code>mcetool -D on</code></pre>