-
Notifications
You must be signed in to change notification settings - Fork 43
Examples
Elle comes with a few examples, demonstrating key features of Elle. Most of the examples, if not all, have no real usage but showing Elle in action (and be used as reference if you want to bootstrap something).
The examples shipped with Elle are:
- samples/get_wikipedia: Get the Wikipedia article about JSON.
- samples/http_get_signed_json: Get a JSON containing an hidden message.
- samples/elle/printable: Demonstrate elle::Printable.
- samples/elle/das/das: Demonstrate Das, the symbol-based meta-programming framework.
- samples/elle/serialization: Demonstrate the serialization module.
- samples/elle/cryptography/sample: Show some of the basic of our serialization module.
- samples/elle/buffer: Demonstrate elle::*Buffer.
- samples/elle/log: Demonstrate our logging system.
- samples/elle/attributes: Demonstrate our ELLE_ATTRIBUTE_*.
- demo/elle/cryptography/crypt: Encrypt and decrypt an message (using a passphrare).
- demo/elle/reactor/echo_server: Echo messages passed in TCP.
- demo/google_maps: Query google maps API.
You can use our Docker image, download our tarball for Ubuntu LTS and later or build Elle manually.
Examples comes with build scripts for Drake, CMake and make.
If you want to give Elle a try and play with our examples, you can use our Docker image that contains Elle, built and installed, gcc, python3 and Drake so you don't have to worry about anything.
N.B.: Examples are located at /home/root/examples. You can overwrite that folder by mounting a volume at the exact same location, so you can edit them (see Tweak the examples).
Run bash in the container.
$> docker run --rm -i -v /tmp/out:/home/root/build -t infinit/elle /bin/bash
N.B.: -v /tmp/out:/home/root/build serves as build folder, otherwise, you'll have to rebuild from scratch after killing the container.
You can edit examples in-place, by installing and running a text editor directly in the container, or you can host the examples locally and share their folder to the container.
Considering you've extracted the examples to /tmp/examples, on your host.
$> docker run --rm -i -v /tmp/examples:/home/root/examples:ro -v /tmp/out:/home/root/build -t infinit/elle bin/bash
<docker>::/home/root/build# drake ../examples -j 3
or, in a non-interactive manner.
# Invoke Drake (without using a intermediate shell).
$> docker run --rm -i -v /tmp/examples:/home/root/examples:ro -v /tmp/out:/home/root/build -t infinit/elle drake ../examples -j 3
$> docker run --rm -i -v /tmp/out:/home/root/build -t infinit/elle ./bin/samples/get_wikipedia
N.B.: In this case, because the examples are stored on the host, you can use your favorite editor to edit them.
We provide a tarball of Elle, built for Ubuntu LTS and later, available here. Extract it anywhere you like.
$> tar xvf elle.tbz -C <path>
For this section, consult the build section of this wiki. In this case, you can use or the examples located on the git repository, or the tarball containing examples.
Once you have Elle installed, you can build and run our examples. Depending on how you retrieved Elle, the procedure may vary.
From the container, you can directly run Drake, CMake or make.
<docker>:/home/root/build# drake ../examples -j 4
/opt/drake/src/bin/drake: Entering directory `/home/root/build'
[...]
/opt/drake/src/bin/drake: Leaving directory `/home/root/build'
<docker>:/home/root/build# cmake ../examples
<docker>:/home/root/build# make -j 4
<docker>:/home/root/build# make -f ../examples/Makefile -j 4
Built examples will be located in /home/root/build/bin.
If you chose not to use the Docker image, you will probably need to set a few paths for Elle's examples to build.
$ drake //examples -j 4
$ drake <path_to_examples> -j 4 --elle <path_to_elle>
Edit the CMakelists.txt and change both include_directories and link_directories. Default is /usr/elle.
$ cmake <path_to_examples>
$ make -j 4
Edit the Makefile and change SOURCE_DIR and ELLE constants.
$ make -f <path_to_examples>/Makefile -j 4
Now that you are ready to go, you can run examples, tweak them. If you have any trouble, contact us:
- by email: open+elle@infinit.sh
- on Slack: channel #Elle
- on GitHub: https://github.com/infinit/elle