Building cURL Applications Using CLI Tools
This article shows how to build a sample application using command line tools. The sample application uses Tizen Sockets Extension APIs and is based on the url2file cURL demo.
Before you can build the sample application:
- Install the Samsung Emscripten SDK as described in the WebAssembly overview.
- Install either Tizen Studio or Tizen Studio with CLI (command line interface). See the Quick-start Guide for more information.
Building the Application
To build the sample application:
Download url2file.c.NoteYou can also clone the whole repository from github.com.
Download CA certificates extracted from Mozilla:
curl -O https://curl.haxx.se/ca/cacert.pem
Compile the 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
Flag used to reduce size of the generated WebAssembly module. It reduces the memory consumption of the WebAssembly module compilation on a device.
Flag indicating the name of the output file. The provided value makes the Samsung Emscripten SDK generate "url2file.wasm", "url2file.js", and "url2file.html" files.
Flag indicating that you want to use the Tizen extensions to the Samsung Emscripten SDK available on a device. This flag is necessary to use POSIX sockets APIs
Flag indicating that you want to build and use the cURL library provided with the Samsung Emscripten SDK. Note that the full library is being built and cached during the first build, so compilation can take a while. For more details, see Emscripten Ports.
Flag needed to run the
main()method of your application in a Web Worker. This is needed because because the Tizen Sockets Extension can only be used in a Web Worker.
Flag allowing your application to read the cacert.pem file using standard C APIs
Table 1: Compilation flags
Enables the SSL library (libssl) from OpenSSL libraries. This flag is implicitly turned on by
Enables the crypto library (libcrypto) from OpenSSL libraries. This flag is implicitly turned on by
Enables the zlib compression library. This flag is implicitly turned on by
Table 2: Implicitly enabled compilation flags
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 compiled.Note
- This application needs the `http://tizen.org/privilege/internet` privilege.
- The content src attribute points to "url2file.html" instead of standard `index.html`, as this is what was generated by emcc.
For more information regarding the config.xml file format, see Tizen Developers
Sign and pack the application using the Tizen CLI interface:
tizen package -t wgt -s <YOUR_CERTIFICATE_PROFILE_NAME> -- .
Set your device into developer mode as described in Target Device.
Connect to the device using SDB:
sdb connect <TV_IP>
For the SDB command and its options, see Connecting Devices over Smart Development Bridge.
List the connected devices to determine the device number:
Sample output (the device number is 0):
List of devices attached 192.168.13.2:26101 device 0
Install the application on the device:
tizen install -n url2file.wgt -t 0NoteIn the parameter
-t 0, the value
0is the device number from the
sdb devicescommand output.
Run the application on the device:
tizen run -p url2file00.curl -t 0