Skip to content

A lightweight Snowpack application for rapid testing of the Cheerp C/C++ to WebAssembly compiler.

License

Notifications You must be signed in to change notification settings

congineer/cheerp-testlab

Repository files navigation

Cheerp Testlab

YouTube channel: congineer   Code license: MIT   Assets license: CC-BY

Prerequisite mandatory: Node.js   Prerequisite optional: Cheerp compiler

Git branch stability: master   Git branch stability: jsonparse

Git branch stability: runxgems  


CHEERP WEBASSEMBLY TESTING APP

This is a lightweight Snowpack application for rapid testing (with auto-reload on code change) of the Cheerp C/C++ to WebAssembly compiler with C++ code examples.

Why C++ compiling to WebAssembly (WASM) is needed?

  • There are many C++ applications that analyze or process data. Porting such applications to WebAssembly allows running them on web browser clients and thus eventually reach the goals of massively scalable architecture and low-cost computing.

Licensing

  • Code (scripts and compiled code) under MIT license.
  • Cheerp brand assets (icons, logos) under CC BY 4.0 license. Copyright by Leaning Technologies Ltd.
  • Brand assets (icons, logos) under CC BY 4.0 license. Copyright by CONGINEER Ltd.
  • Media assets (video, audio, graphics, animations) under CC BY 4.0 license. Copyright by CONGINEER Ltd.

How to download and run the test app

Clone the git repository (suppose in git/testlab) into your home directory:

mkdir -p ~/git/testlab/cheerp
git clone https://github.com/congineer/cheerp-testlab.git ~/git/testlab/cheerp

Install Node.js, as described:

OPTIONAL: Install Cheerp compiler, as described:

NOTE: you may have to open build.sh script once to adjust the compiler binary path according to your Cheerp installation.

# IMPORTANT: adjust Cheerp bin path
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
compiler_bin=/opt/cheerp/bin/clang++
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

To run the test app

Open the 1st terminal window, navigate to the test app folder

cd ~/git/testlab/cheerp

and start the app:

npm start

The test app will be loaded and then will open the app page in your default web browser. We recommend to open the browser console in order to watch the test results.

NOTE: Upon any saved change in JavaScript code, the running web app will update automatically and will reload the browser page to reflect the changes.


To re-compile the C++ test file with Cheerp, open the 2nd terminal window, navigate to the test app folder

cd ~/git/testlab/cheerp

and build the C++ target, e.g. here an example for buttons.cpp:

./build.sh cpp/buttons/buttons.cpp

NOTE: Upon re-building the C++ target, the running web app will update automatically and will reload the browser page to reflect the changes.

What is tested and how to test

Git branch "master" is a basic Cheerp test application

The app part consists of two versions of a basic "buttons" test. Cheerp version to showcase both WebAssembly and JavaScript compiled methods. Pure JavaScript version to allow direct performance profiling against the Cheerp one.

To run the pure Javescript version uncomment it in app/js/index.js whilst commenting out the Cheerp one.

A how-to-test screencast will be available on YouTube: (link)

How to test

  • Open the browser console to see test results logged there.
  • Run a test by clicking on its test buttons.
  • Watch the test output and examine error messages (if any).

Description of test cases

TBD