Build and Test

Version added 07-Mar-2018| Modified 20-May-2019

After developing the JS 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 : <js-service-name>.bb

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

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

SUMMARY = "JS 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"
PR = "r0"
inherit webos_component
inherit webos_submissions
inherit webos_cmake
inherit webos_system_bus
FILES_${PN} += "${webos_servicesdir}/${PN}/*"

A brief explanation of the above file:

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

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

  • Line(7) : 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(9) : Inherit common functions of webOS OSE. For all components of webOS OSE, this entry is required.

  • Line(10) : 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(11) : Instruct OpenEmbedded that the component uses CMake for configuration, which is the preferred choice for webOS components.

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

  • Line(14) : Append the list of files and directories that are placed in a package. Add the files under /usr/palm/service/com.example.service.js directory for packaging.

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 JS service (com.example.service.js), you must provide the local path where the source exists.

INHERIT += "externalsrc"
EXTERNALSRC_pn-com.example.service.js = "/home/username/project/com.example.service.js/"
EXTERNALSRC_BUILD_pn-com.example.service.js = "/home/username/project/com.example.service.js/build/"
PR_append_pn-com.example.service.js =".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 JS 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.js

    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
    │       ├── com.example.service.js.api.json
    │       ├── com.example.service.js.perm.json
    │       ├──
    │       └──
    ├── com_example_service_js.js
    ├── package.json
    ├── oe-logs -> /home/username/build/build-webos/BUILD/work/raspberrypi3-webos-linux/com.example.service.js/0.0.1-r0.local0/temp
    ├── oe-workdir -> /home/username/build/build-webos/BUILD/work/raspberrypi3-webos-linux/com.example.service.js/0.0.1-r0.local0

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

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

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

    com.example.service.js/oe-workdir/deploy-ipks/raspberrypi3$ scp com.example.service.js_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.js_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.js_0.0.1-r0.local0_raspberrypi3.ipk
    Installing com.example.service.js (0.0.1) on root.
    Configuring com.example.service.js.	 


  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
    Rebooting the target after step 3 will have the same effect as running step 4. However, using the command in step 4 allows you to continue testing without rebooting.


  5. Run the service.

    Since the service is a dynamic service, it is executed when its method is called.

    Calling the hello method:

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

    Calling the locale method:

    root@raspberrypi3:/# luna-send -n 1 -f luna://com.example.service.js/locale '{}'
        "message": "You appear to have your locale set to: en-US",
        "returnValue": true


  6. Verify the execution of the service.

    If you check the result of ls-monitor immediately after calling the com.example.service.js/hello method, you can see that the service is executed dynamically.

    root@raspberrypi3:/# ls-monitor -l | grep example
    868           com.example.service.js            /usr/bin/node                          dynamic                 K4Nuvsrx

    If the service is not used for 5 seconds, it is terminated. Run the ls-monitor command again after about 5 seconds, and you will see that the service has been terminated.

    root@raspberrypi3:/# ls-monitor -l | grep example
Except as noted, this content is licensed under Creative Commons Attribution 4.0 and sample code is licensed under Apache License 2.0.