Build and Test

Version added 07-Mar-2018| Modified 12-Jun-2019

After developing the service, you must build the service and verify its functionality.

Add Recipe File

webOS OSE uses OpenEmbedded of Yocto project to build its components. You must write a recipe that configures the build environment. For more details about the recipe, see Yocto project reference manual.

  • Create and update the file : <native-service-name>.bb

  • Directory : build-webos/meta-webosose/meta-webos/recipes-webos/<native-service-name>

where <native-service-name> is the name of the native service. For the sample native service, <native-service-name> must be replaced by 'com.example.service.native'.

SUMMARY = "Native service sample"
AUTHOR = "Author's name <Author's e-mail>"
LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"
DEPENDS= "glib-2.0 luna-service2 pmloglib libpbnjson"
PR = "r0"
inherit webos_component
inherit webos_submissions
inherit webos_cmake
inherit webos_system_bus

A brief explanation of the above file:

  • Lines(1~4) : Basic descriptions of the component.

  • Line(6) : Add GLib, LS2, PmLog, and pbnjson as dependencies.

  • Line(8) : Version of the component. For the webOS OSE component, this field is mandatory.

  • Line(9) : Revision version of the recipe. Each recipe requires a counter to track its modification history. Make sure that you increment the version when you edit the recipe, unless you only change the value of the WEBOS_VERSION field or comments.

  • Line(11) : Inherit common functions of webOS OSE. For all components of webOS OSE, this entry is required.

  • Line(12) : Instruct OpenEmbedded to use the WEBOS_VERSION value as the component version number. If you develop your component on a local repository, this entry is required.

  • Line(13) : Instruct OpenEmbedded that the component uses CMake for configuration, which is the preferred choice for webOS components.

  • Line(14) : To register component as a service and install LS2 configuration files, inherit webos_system_bus.

Configure Local Source Directory

To build a component that is located on the local system, you must specify the directory information.

  • Create and update the file : webos-local.conf

  • Directory : build-webos

For the sample native service (com.example.service.native), you must provide the local path where the source exists.

INHERIT += "externalsrc"
EXTERNALSRC_pn-com.example.service.native = "/home/username/project/com.example.service.native/"
EXTERNALSRC_BUILD_pn-com.example.service.native = "/home/username/project/com.example.service.native/build/"
PR_append_pn-com.example.service.native =".local0"

A brief explanation of the above file:

  • Line(1) : Inherit "externalsrc" bbclass file.

  • Line(2) : The local source directory. The syntax of the property is EXTERNALSRC_pn-<component>. 

  • Line(3) : The local build directory. The syntax of the property is EXTERNALSRC_BUILD_pn-<component>. 

  • Line(4) : The appended revision version (PR) for building local source files. The syntax of the property is PR_append_pn-<component>. This property is optional.

We recommend that you add a trailing slash (/) at the end of all local directory paths, as in Line(2) and Line(3).

Build, Run, and Verify

  1. Build the service.

    To build the component on the OpenEmbedded environment, enter the following commands on the shell.

    build-webos$ source oe-init-build-env
    build-webos$ bitbake com.example.service.native

    For more information, see Building webOS OSE.

  2. Copy the IPK to the target.

    When the build is successful, oe-related directories are created under the project root directory. These directories are linked to the directory where the build output is generated from the actual build-webos sub-directory.

    ├── CMakeLists.txt
    ├── files
    │   ├── sysbus
    │   │   ├──
    │   │   ├──
    │   │   ├──
    │   │   └──
    │   └── systemd
    │       └──
    ├── main.cpp
    ├── oe-logs -> /home/username/build/build-webos/BUILD/work/raspberrypi3-webos-linux/com.example.service.native/0.0.1-r0.local0/temp
    ├── oe-workdir -> /home/username/build/build-webos/BUILD/work/raspberrypi3-webos-linux/com.example.service.native/0.0.1-r0.local0

    If you go to oe-workdir/deploy-ipks/raspberrypi3, you can see com.example.service.native_0.0.1-r0.local0_raspberrypi3.ipk file.

    └── com.example.service.native_0.0.1-r0.local0_raspberrypi3.ipk

    Copy the IPK file to the target device using the scp command.

    com.example.service.native/oe-workdir/deploy-ipks/raspberrypi3$ scp com.example.service.native_0.0.1-r0.local0_raspberrypi3.ipk root@


  3. Install the service on the target.

    Connect to the target using the ssh command and install com.example.service.native_0.0.1-r0.local0_raspberrypi3.ipk.

    $ ssh root@
    root@raspberrypi3:~# cd /media/internal/downloads/
    root@raspberrypi3:/media/internal/downloads# opkg install com.example.service.native_0.0.1-r0.local0_raspberrypi3.ipk
    Installing com.example.service.native (0.0.1) on root.
    Configuring com.example.service.native.


  4. Discover the LS2 configuration files.

    To make LS2 daemon scan the LS2 configuration files of the service, use the ls-control command as follows.

    root@raspberrypi3:/media/internal/downloads# ls-control scan-services
    telling hub to reload setting and rescan all directories


  5. Run the service.

    You can run the com.example.service.native using the systemctl command.

    root@raspberrypi3:~# systemctl start com.example.service.native


  6. Verify the execution of the service.

    • Using systemctl

      You can check the PID and attribute of the executed process using the command 'systemctl status'.

      [[0;1;32m●[[0m com.example.service.native.service - webos - "com.example.service.native.service"
         Loaded: loaded (/etc/systemd/system/com.example.service.native.service; static; vendor preset: enabled)
         Active: [[0;1;32mactive (running)[[0m since Sun 2019-05-26 19:19:38 PDT; 2min 35s ago
       Main PID: 3264 (com.example.ser)
         CGroup: /system.slice/com.example.service.native.service
                 └─3264 /usr/sbin/com.example.service.native
    • Using ls-monitor

      You can use 'ls-monitor' to check whether the service is successfully registered. It also shows the methods available in the service. For more detail about ls-monitor, see ls-monitor.

      root@raspberrypi3:/#ls-monitor -i com.example.service.native
            "hello": {"provides":["all",""]}
    • Using log com.example.service.native [] NativeService SERVICE_MAIN {} start com.example.service.native com.example.service.native [] NativeService GETTIME_CALLBACK {"payload":{"source":"system","offset":{"source":"system","value":0},"timestamp":{"source":"monotonic","sec":328334,"nsec":126779594},"utc":1558923578,"returnValue":true,"systemTimeSource":"ntp"}} com.example.service.native [] NativeService GETTIME_CALLBACK {"UTC : ":1558923578}

Verify the Output

Verify the output of the "hello" Method. You can call a method by using the luna-send command: 

root@raspberrypi3:/# luna-send -n 1 -f luna://com.example.service.native/hello '{}'
    "answer": "Hello, Native Service!!",
    "returnValue": true

For more details, see LS2 API development.

*Note: If com.example.service.native is not registered successfully, you will see a return message as below.

root@raspberrypi3:~# luna-send -n 1 -f luna://com.example.service.native/hello '{}'
    "errorCode": -1,
    "returnValue": false,
    "errorText": "Service does not exist: com.example.service.native."

Specify the Order of Execution on Target

To verify that the service can run automatically after rebooting, add the service to the systemd's start execution list. This ensures that the service runs automatically without the 'systemctl start' command.

  • Update the file :

  • Directory : /etc/systemd/system (on the target device)

Wants=nyx-utils.service \
      second-screen-gateway.service \
Except as noted, this content is licensed under Creative Commons Attribution 4.0 and sample code is licensed under Apache License 2.0.