Build and Test

Version added 2018-03-07 20:32:00| Modified 12-Apr-2018

After developing the web app, you must build 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 : <web-app-name>.bb

  • Directory : build-webos/meta-webosose/meta-webos/recipes-webos/<web-app-name>

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

SECTION = "webos/apps"
LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"
 
WEBOS_VERSION = "1.0.0"
PR = "r0"
 
inherit webos_component
inherit webos_submissions
inherit webos_cmake
inherit webos_app
inherit webos_arch_indep
 
FILES_${PN} += "${webos_applicationsdir}"

A brief explanation of the above file:

  • Line(1~3) : Basic descriptions of the component.

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

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

  • Line(9) : Inherit the WEBOS_VERSION value. If you develop your component on a local repository, this entry is required.

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

  • Line(11) : Added since the component is an app.

  • Line(12) : The web app is CPU architecture independent, add inherit webos_arch_indep. If you inherit from webos_arch_indep, ensure that your project command in the CMake script specifies NONE as the language (i.e. project(component NONE). Otherwise, CMake will attempt to find the C and C++ compilers. Your component may well be built before the tool chain, and this will result in a failure to build.

  • Line(14) : ${webos_applicationsdir} indicates /usr/palm/applications, ${PN} is package name. webos.example.app.web set to ${PN}.

 

 

Configure Local Source Directory

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

  • Update the file : webos-local.conf

  • Directory : build-webos

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

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

A brief explanation of the above file:

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

  • Line(2) : The local source directory. It is recommended that all path to webos-local directory end with a /.

  • Line(3) : The local build directory.

  • Line(4) : [Optional] Set appended PR version for local source build.

 

Build, Run, and Verify

 

  1. Build the web app.

    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.app.web
    

    For more information, see Building webOS OSE.

     

  2. Copy the IPK to target.

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

    com.example.app.web
    ├── CMakeLists.txt
    ├── README.md
    ├── appinfo.json
    ├── build
    ├── icon.png
    ├── index.html
    ├── oe-logs -> /home/username/build/build-webos/BUILD/work/all-webos-linux/com.example.app.web/1.0.0-r0.local0/temp
    ├── oe-workdir -> /home/username/build/build-webos/BUILD/work/all-webos-linux/com.example.app.web/1.0.0-r0.local0
    └── webOSjs-0.1.0
        ├── LICENSE-2.0.txt
        └── webOS.js

    If you go to oe-workdir/deploy-ipks/all, you can see that com.example.app.web_1.0.0-r0.local0_all.ipk file.

    com.example.app.web/oe-workdir/deploy-ipks/all
    └── com.example.app.web_1.0.0-r0.local0_all.ipk

    Copy the IPK file to target and install it.

    com.example.app.web/oe-workdir/deploy-ipks/all$ scp com.example.app.web_1.0.0-r0.local0_all.ipk root@192.168.0.12:/media/internal/downloads/

     

  3. Install the app on the target.

    Connect to target with ssh and install com.example.app.web_1.0.0-r0.local0_all.ipk.

    $ ssh root@192.168.0.12
    root@raspberrypi3:~# cd /media/internal/downloads/
    root@raspberrypi3:/media/internal/downloads# opkg install com.example.app.web_1.0.0-r0.local0_all.ipk
    
    Installing com.example.app.web (1.0.0) on root.
    Configuring com.example.app.web.
    No image conversions needed for com.example.app.web
    

     

  4. Discovery of LS2 configuration files

    In order to make LS2 daemon scan the LS2 configuration files of com.example.app.web, enter 'ls-control' command or reboot target.

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

     

  5. Restart SAM or reboot target.

    This step is required so that app is scanned by SAM.

    root@raspberrypi3:/# systemctl restart sam
    

     

  6. Run the web app.

    Use the "windows" key or "F1" key on keyboard to show the Launcher. Click the app icon to see the window titled "Web app sample" with the following page:

    webApp1-new.png.

     

  7. Verify the execution of the web app.

    • Using SAM

      You can check whether the app is running by using SAM. For more SAM methods, see com.webos.service.applicationmanager.

      root@raspberrypi3:/# luna-send -i -f luna://com.webos.service.applicationmanager/running '{"subscribe":true}'
      {
          "subscribed": true,
          "running": [
              {
                  "id": "com.example.app.web",
                  "webprocessid": "1827",
                  "defaultWindowType": "card",
                  "appType": "web",
                  "processid": "1827"
              }
          ],
          "returnValue": true
      }
    • Using Logs

      You can check the app's log in /var/log/messages on target. Open the file and fine "UTC" keyword.

      2018-02-27T08:46:34.060614Z [92622.667553627] user.info WebAppMgr [] WAM WEBAPP_STAGE_ACITVATED {"APP_ID":"com.example.app.web","PID":1827}
      Feb 27 00:46:34 raspberrypi3 daemon.info webapp-mgr.sh[732]: [0227/004634:INFO:CONSOLE(33)] "UTC:1519721194", source: file:///usr/palm/applications/com.example.app.web/index.html (33)
Except as noted, this content is licensed under Creative Commons Attribution 4.0 and sample code is licensed under Apache License 2.0.