Sample cURL application built using CLI tools
This article shows how to build sample application based on url2file cURL demo using command-line tools.
Related Info
Prerequisites
- It is assumed that you have already installed Samsung Customized Emscripten SDK as described in WebAssembly/Getting Started
- You have installed either
Tizen Studio
orTizen Studio with CLI(command line interface)
. See Quick-Start Gudie
Step-by-step guide
- Download url2file.c.Note :
You can also clone whole repository from github.com.
-
Download CA certificates extracted from Mozilla:
curl -O https://curl.haxx.se/ca/cacert.pem
-
Compile url2file.c demo
emcc -o url2file.html -Os -s ENVIRONMENT_MAY_BE_TIZEN -s USE_CURL=1 --proxy-to-worker --preload-file cacert.pem url2file.c
Option Description -Os
Reduce size of generated WebAssembly module. This will reduce memory consumption of WebAssembly module compilation on Samsung Smart TV. -o url2file.html
Name of the output, this will make that Emscripten will generate url2file.wasm, url2file.js and url2file.html -s ENVIRONMENT_MAY_BE_TIZEN
Flag indicating that we want to use Samsung Tizen Emscripten extensions available on Samsung Smart TV. This flag is necessary to use POSIX sockets APIs in your application. -s USE_CURL=1
Flage indicating that we want to build and use cURL library provided with Samsung Customized Emscripten. Note that during 1st build full library is being built, so compilation may take a while. However after 1st build cURL library is cached. See more on details on Emscripten Ports --proxy-to-worker
This flag is needed to run main()
function of your application in a Web Worker, because Samsung Tizen Sockets Extensions can only be used in a Web Worker.--preload-file cacert.pem
This option allows your application to read cacert.pem file using standard C APIs fopen(./cacert.pem)
Implicitly enabled options:
Option Description -s USE_SSL=1
Flag enabling SSL library (libssl) from OpenSSL libraries. This flags is implicitly turned on by -s USE_CURL=1
-s USE_CRYPTO=1
Flag enabling use crypto library (libcrypto) from OpenSSL libraries. This flags is implicitly turned on by -s USE_SSL=1
-s USE_ZLIB=1
Flag enabling use of zlib compression library. This flag is implicitly turned on by -s USE_CURL=1
Further information regarding Emscripten build options can be found on Emscripten Compiler Frontend (emcc)
-
Download config.xml to the same directory where the demo was built.
Note:- this application needs
http://tizen.org/privilege/internet
privilege - content src attribute points to "url2file.html" instead of standard
index.html
, as this is what was generated by emcc.
More information regarding the config.xml file format can be found on Tizen Developers
- this application needs
-
Sign and pack widget using Tizen CLI interface:
tizen package -t wgt -s <YOUR_CERTIFICATE_PROFILE_NAME> -- .
Guide showing how to create certificate profile can be found at Creating Certificates
More information regarding Tizen CLI interface can be found at Command Line Interface Commands
-
Set your TV into developer mode as described in TV Device
-
Connect to the TV using sdb:
sdb connect <TV_IP>
SDB command and its options are described on Connecting Devices over Smart Development Bridge
-
List connected devices:
sdb devices
Sample output:
List of devices attached 192.168.13.2:26101 device 0
-
Install widget on the TV:
tizen install -n url2file.wgt -t 0
Note:
In option-t 0
value0
is taken from last column ofsdb devices
command output. -
Run widget on the TV:
tizen run -p url2file00.curl -t 0