Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Erlang Build Tools

648 views

Published on

Different build tools available for Erlang and simple examples for each of them. The build tools discussed here are Emakefile, rebar/rebar3, Erlang.mk and Mix.

Published in: Technology
  • Be the first to comment

Erlang Build Tools

  1. 1. ERLANG BUILD TOOLS
  2. 2. HELLO! I am Akhil Agrawal Doing Erlang development for last five years Doing Ejabberd development for last eight months now Started BIZense in 2008 & Digikrit in 2015
  3. 3. Overview Different build tools available for Erlang and simple examples for each 1
  4. 4. BUILD TOOLS SUMMARY It is an include file for GNU Make, meaning including it in a Makefile allows building project, fetching/building dependencies and more Erlang.mk rebar is a self-contained Erlang script, easy to distribute or embed in a project, provides dependency management, rebar3 has lot of improvements over 2.x rebar & rebar3 Mix is a command-line utility that manages Elixir projects but can be used for managing erlang projects as well Mix A make utility for erlang providing set of functions similar to unix style make funtions. Packaged with erlang distribution, popular & default build tool Emakefile
  5. 5. Emakefile - Referenced from http://learnyousomeerlang.com/building-otp-applications 1. Creating a folder for your project $ mkdir emakefile_project $ cd emakefile_project 2. Creating erlang project structure $ mkdir src include priv test 3. Creating Emakefile $ vim Emakefile {"src/*", [debug_info, {i,"include/"}, {outdir, "ebin/"}]}. {"test/*", [debug_info, {i,"include/"}, {outdir, "ebin/"}]}. 4. Compiling erlang code $ erl -make $ erl -pa ebin/ 1> make:all([load]). 5. Reload code on known nodes $ erl -pa ebin/ 1> make:all([netload]). 6. Compiling specific modules $ erl -pa ebin/ 1> make:files([“src/module1”, “src/module2”]).
  6. 6. Rebar - Referenced from https://github.com/rebar/rebar 1. Installing from binary $ wget https://github.com/rebar/rebar/ wiki/rebar && chmod +x rebar 2. Installing from source $ git clone https://github.com/rebar/rebar. git $ cd rebar $ ./bootstrap 3. Create new app $ mkdir rebar_app $ cd rebar_app $ ./rebar create-app 4. Creating new lib $ mkdir rebar_lib $ cd rebar_lib $ ./rebar create-lib 5. Configuration $ vim rebar.config 6. Dependency Management $ vim rebar.config {deps,[ %% Source Dependencies {meck, "0.8.*", {git, "https://github.com/eproxus/meck.git"}}, %% rsync {mod_useful, "1.0.1", {rsync, "modules/mod_useful"}} ]}. $ rebar get-deps
  7. 7. Rebar3 - Referenced from http://www.rebar3.org/docs 1. Installing from binary $ wget https://s3.amazonaws.com/rebar3 /rebar3 && chmod +x rebar3 2. Installing from source $ git clone https://github.com/erlang/rebar 3.git $ cd rebar3 $ ./bootstrap 3. rebar3 local install & upgrade $ ./rebar3 local install $ ./rebar3 local upgrade 4. Creating new project $ rebar3 new release rebar3_project $ cd rebar3_project $ rebar3 compile 5. Configuration $ vim rebar.config 6. Dependency Management $ vim rebar.config {deps,[ %% Packages (hex.pm) cowboy {cowboy,"1.0.4"}, %% Source Dependencies {cowboy, {git, "git://github.com/ninenines/cowboy.git"}}, %% Legacy {cowboy, “1.*", {git,"git://github.com/ninenines/cowboy.git"}} ]}. $ rebar3 deps
  8. 8. Erlang.mk - Referenced from https://erlang.mk/guide/getting_started.html 1. Creating a folder for your project $ mkdir emk_project $ cd emk_project 2. Downloading Erlang.mk $ wget https://raw.githubusercontent.c om/ninenines/erlang.mk/master/e rlang.mk -- or -- $ curl https://raw.githubusercontent.c om/ninenines/erlang.mk/master/e rlang.mk > erlang.mk 3. Getting started with OTP applications $ make -f erlang.mk bootstrap $ make 4. Getting started with OTP libraries $ make –f erlang.mk bootstrap-lib $ make 5. Getting started from scratch $ mkdir emk_scratch $ cd emk_scratch $ wget https://raw.githubusercontent.com/nin enines/erlang.mk/master/erlang.mk $ echo "include erlang.mk" > Makefile $ make
  9. 9. Mix - Referenced from http://elixir-lang.org/getting-started/mix-otp/introduction-to-mix.html 1. Creating a folder for your project $ mkdir mix_project $ cd mix_project 2. Downloading Elixir & adding to path $ wget https://github.com/elixir- lang/elixir/releases/download/v 1.1.1/Precompiled.zip $ unzip Precompiled.zip –d elixir $ mv elixir /opt/ $ export PATH=$PATH:/opt/elixir/bin 3. Creating new project $ mix new kv --module KV $ cd kv $ mix compile $ mix test 4. Different environments $ MIX_ENV=dev mix compile $ MIX_ENV=prod mix compile 5. Configuration $ vim mix.exs defmodule KV.Mixfile do use Mix.Project … end
  10. 10. BUILD TOOL REQUIREMENTS Packaging the erlang runtime to create the release build which can run independently Packaging & Releases Creating/updating documentation, concept of environments, umbrella projects etc Documentation & More Compilation of source code files, running tests (unit & functional) & static analysis Compilation & Tests Manage source dependencies as well as handle build artifacts, paths & libraries Dependency Management Erlang Build Tools
  11. 11. SOME REFERENCES ◉ http://ninenines.eu/articles/erlang.mk-and-relx/ ◉ http://learnyousomeerlang.com/building-otp-applications ◉ http://rustyrazorblade.com/2010/09/smarter-erlang-programming-with- emakefile-options-and-user_default/ ◉ http://featurebranch.com/using-mix-to-compile-your-erlang-projects/ ◉ http://kelly-mclaughlin.com/blog/2014/12/12/building-an-erlang-project-with- mix/
  12. 12. THANKS! Any questions? You can find me at @digikrit / akhil@digikrit.com Special thanks to all the people who made and released these awesome resources for free:  Presentation template by SlidesCarnival  Presentation models by SlideModel  Erlang by Ericsson, Erlang/Elixir projects by ProcessOne, Basho, Apache, Pivotal, NineNines & others

×