wiki:Developing your own applications

Version 33 (modified by Ben, 4 years ago) (diff)

--

Developing your own applications

disclaimer: this article is work in progress and I am learning as I write

Here I will write how to begin developing your own applications for SHR, using the familiar Hello World program as an example. I will use Vala as the programming language which should be familiar and easy to understand for people with Java experience.

This guide assumes that the reader has already succussfully built SHR using the instructions at Building SHR.

1. Creating a source folder

$ cd /path/to/shr/build
$ mkdir my_first_app

2. Writing Hello World in Vala

Create a file called my_first_app.vala and insert the following text:

class Demo.HelloWorld : GLib.Object
{
    public static int main(string[] args)
    {
        stdout.printf("Hello, World\n");
        return 0;
    }
}

3. Set up autotools

Create a file called configure.in and insert the following text:

AC_INIT(emtooth2, 0.1, pespin.shar@gmail.com)
AC_PREREQ(2.52)
AC_CONFIG_SRCDIR(configure.in)

AM_INIT_AUTOMAKE(1.11 dist-bzip2)
AM_CONFIG_HEADER(config.h)

AC_C_BIGENDIAN
AC_ISC_POSIX
AC_PROG_CC
AM_PROG_CC_STDC
AC_HEADER_STDC
AC_C_CONST

AM_PROG_VALAC ([0.11.3])

EMTOOTH2_PACKAGES="--pkg gio-2.0 --pkg eina --pkg evas --pkg ecore --pkg elm"

PKG_CHECK_MODULES(EMTOOTH2, glib-2.0 >= 2.26.1
gobject-2.0
gio-2.0
dbus-glib-1
elementary
eina
dbus-1)

AC_SUBST(EMTOOTH2_LIBS)
AC_SUBST(EMTOOTH2_CFLAGS)
AC_SUBST(EMTOOTH2_PACKAGES)


EMTOOTH2_VALAFLAGS=""



AC_ARG_ENABLE([fso],
[AC_HELP_STRING([--enable-fso], [enable FSO support])],
[
if test "x${enableval}" = "xyes" ; then
enable_fso="yes"
else
enable_fso="no"
fi
],
[enable_fso="no"])


EMTOOTH2_VALAFLAGS=""
if test "x$enable_fso" = "xyes" ; then
echo "ADDING FSO SUPPORT FOR THIS BUILD..."
EMTOOTH2_VALAFLAGS="--define=_FSO_"
fi
AC_SUBST(EMTOOTH2_VALAFLAGS)

AC_OUTPUT(Makefile)


Create a file called Makefile.am and insert the following text:

AUTOMAKE_OPTIONS     = 1.4 foreign
MAINTAINERCLEANFILES = Makefile.in

INCLUDES = -I$(top_srcdir) @EMTOOTH2_CFLAGS@

bin_PROGRAMS      = emtooth2

emtooth2_SOURCES = \
	src/main.vala \
	src/shared.vala \
	src/fso.vala \
	src/bluez_adapter.vala \
	src/bluez_rdevice.vala \
	src/bluez_agent.vala \
	src/gui_main.vala \
	src/gui_settings.vala \
	src/gui_rdevice.vala \
	src/org-bluez.vala
	
emtooth2_LDADD = @EMTOOTH2_LIBS@
emtooth2_CFLAGS =
VALAFLAGS = @EMTOOTH2_PACKAGES@ @EMTOOTH2_VALAFLAGS@

desktopdir = $(datadir)/applications
desktop_DATA = data/emtooth2.desktop

pixmapsdir = $(datadir)/pixmaps
pixmaps_DATA =  data/emtooth2.png

4. Add a bitbake recipe

Create a file called my_first_app.bb and insert the following text:

DESCRIPTION = "A hello world program written in Vala"
SRCREV = "?"
PV = "0.1+svnr${SRCPV}"
PR = "r0"

SRC_URI = "file:///path/to/shr/build/my_first_app"

inherit autotools vala

5. Build a package

todo