This topic describes how to build a sample application with Tizen Studio. The sample application uses Tizen Sockets Extension APIs and is based on the url2file cURL demo.
WebAssembly Getting Started
Using Tizen Studio for WebAssembly
url2file cURL demo
Before you can build the sample application:
Install the Samsung Emscripten SDK as described in WebAssembly Overview.
Install Tizen Studio as described in Quick-start Guide.
Set up Tizen Studio and the Samsung Emscripten SDK toolchain as described in Creating WebAssembly Applications .
To build a sample application based on url2file cURL demo with Tizen Studio:
Launch Tizen Studio.
Create a project in Tizen Studio:
Add the http://tizen.org/privilege/internet privilege to your application. For more information, see Configuring Web Applications.
http://tizen.org/privilege/internet
Add a new WebAssembly module to your project:
stdout
Either replace the contents of src/empty.cpp file in the created WebAssembly module with the contents of url2file_side_thread.cpp or just copy the "url2file_side_thread.cpp" file to the src/ directory and delete the src/empty.cpp file.
src/empty.cpp
src/
Download CA certificates extracted from Mozilla and save them in the main directory of the WebAssembly module project.
Add necessary compiler flag to your WebAssembly module:
-s USE_CURL=1
The-s USE_CURL=1 flag is required here and in the linker flags below. As a compiler flag it is required to make cURL include directories populated and provided to compilation stage (using the -I switch). Also, putting this flag here allows the indexer to see cURL-included directories and properly resolve cURL includes.
-I
Add necessary linker flags to your WebAssembly module:
-s ENVIRONMENT_MAY_BE_TIZEN -s USE_CURL=1 --preload-file ../cacert.pem@/cacert.pem -pthread -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=2
-s ENVIRONMENT_MAY_BE_TIZEN
--preload-file ../cacert.pem@/cacert.pem
fopen(./cacert.pem)
CurrentBin
cacert.pem
/cacert.pem
@/cacert.pem
-pthread -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=2
Build your WebAssembly module project.
Apply the following workarounds:
Unlink the WebAssembly module from main application. Right-click on the main application, go to "Others > Project References", and unselect the referenced WebAssembly module project.
While in the project properties, add the "*.data" file to the WGT package. In "Tizen Studio > Package", expand the tree to the 'CurrentBin' directory of the WebAssembly module project and check the file with the data extension. Click "Apply and Close". Note this particular step must be performed after each build of the WebAssembly module project.
data
Add the following snippet to wasm_modules/scripts/wasm_tools.js after the body print() method:
wasm_modules/scripts/wasm_tools.js
print()
locateFile: ( () => { return (path, prefix) => { if (prefix == '') { prefix = this.path.substring(0, this.path.lastIndexOf('/')) || ''; prefix = prefix + '/'; } return prefix + path; }; })(),
Build a signed package.
Now you are done and can run your application on the device.