diff options
Diffstat (limited to 'guide/building.html')
-rw-r--r-- | guide/building.html | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/guide/building.html b/guide/building.html index a3b19af..dcff3d0 100644 --- a/guide/building.html +++ b/guide/building.html @@ -36,8 +36,7 @@ div.navfooter{margin-bottom:1em} <div class="navheader"><table width="100%" summary="Navigation header"><tr><td width="20%" align="left"><a accesskey="p" href="code.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="deps.html">Next</a></td></tr></table><hr /></div><div class="chapter"><div class="titlepage"><div><div><h2 class="title"><a id="building"></a>Chapter 6. Building</h2></div></div></div><p>Erlang.mk can do a lot of things, but it is, first and foremost, a build tool. In this chapter we will cover the basics of building a project with Erlang.mk.</p><p>For most of this chapter, we will assume that you are -using a project <a class="link" href="getting_started.html" title="Chapter 2. Getting started">generated by Erlang.mk</a> -<a class="xref" href="getting_started.html" title="Chapter 2. Getting started">Chapter 2, <em>Getting started</em></a>.</p><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_how_to_build"></a>6.1. How to build</h2></div></div></div><p>To build a project, all you have to do is type <code class="literal">make</code>:</p><pre class="programlisting">$ make</pre><p>It will work regardless of your project: OTP applications, +using a project <a class="link" href="getting_started.html" title="Chapter 2. Getting started">generated by Erlang.mk</a>.</p><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_how_to_build"></a>6.1. How to build</h2></div></div></div><p>To build a project, all you have to do is type <code class="literal">make</code>:</p><pre class="programlisting">$ make</pre><p>It will work regardless of your project: OTP applications, library applications, NIFs, port drivers or even releases. Erlang.mk also automatically downloads and compiles the dependencies for your project.</p><p>All this is possible thanks to a combination of configuration @@ -60,15 +59,13 @@ and develop on a machine with slow file access, like the Raspberry Pi and many other embedded devices.</p><p>Note that this command may fail if a required dependency is missing.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="_dependencies"></a>6.2.2. Dependencies</h3></div></div></div><p>You can build all dependencies, and nothing else, by running the following command:</p><pre class="programlisting">$ make deps</pre><p>This will fetch and compile all dependencies and their -dependencies, recursively.</p><p><a class="link" href="deps.html" title="Chapter 7. Packages and dependencies">Packages and dependencies</a> -<a class="xref" href="deps.html" title="Chapter 7. Packages and dependencies">Chapter 7, <em>Packages and dependencies</em></a> are covered +dependencies, recursively.</p><p><a class="link" href="deps.html" title="Chapter 7. Packages and dependencies">Packages and dependencies</a> are covered in the next chapter.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="_release"></a>6.2.3. Release</h3></div></div></div><p>It is not possible to build the release without at least building the application itself, unless of course if there’s no application to begin with.</p><p>To generate the release, <code class="literal">make</code> will generally suffice with a normal Erlang.mk. A separate target is however available, and will take care of building the release, after building -the application and all dependencies:</p><pre class="programlisting">$ make rel</pre><p>Consult the <a class="link" href="relx.html" title="Chapter 9. Releases">Releases</a> -<a class="xref" href="relx.html" title="Chapter 9. Releases">Chapter 9, <em>Releases</em></a> chapter for more +the application and all dependencies:</p><pre class="programlisting">$ make rel</pre><p>Consult the <a class="link" href="relx.html" title="Chapter 9. Releases">Releases</a> chapter for more information about what releases are and how they are generated.</p></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_application_resource_file"></a>6.3. Application resource file</h2></div></div></div><p>When building your application, Erlang.mk will generate the <a class="ulink" href="http://www.erlang.org/doc/man/app.html" target="_top">application resource file</a>. This file is mandatory for all Erlang applications and is @@ -129,9 +126,21 @@ PROJECT_VERSION = 2.0.0-pre.2 PROJECT_REGISTERED = cowboy_clock LOCAL_DEPS = crypto -DEPS = cowlib ranch</pre><p>Any space before and after the value is dropped.</p><p><a class="link" href="deps.html" title="Chapter 7. Packages and dependencies">Dependencies</a> -<a class="xref" href="deps.html" title="Chapter 7. Packages and dependencies">Chapter 7, <em>Packages and dependencies</em></a> are covered in details in -the next chapter.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="_legacy_method"></a>6.3.2. Legacy method</h3></div></div></div><p>The <span class="emphasis"><em>src/$(PROJECT).app.src</em></span> file is a legacy method of +DEPS = cowlib ranch</pre><p>Any space before and after the value is dropped.</p><p><a class="link" href="deps.html" title="Chapter 7. Packages and dependencies">Dependencies</a> are covered in details in +the next chapter.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="_application_environment"></a>6.3.2. Application environment</h3></div></div></div><p>The <code class="literal">PROJECT_ENV</code> variable is used to set the application +environment:</p><pre class="programlisting">define PROJECT_ENV +[ + {chips, [currysauce,{mushypeas,false}]}, + {pizza, [{size,large},{toppings,[anchovies]}]} +] +endef</pre><p>If you have a large set of environment variables, you may find it +easier to use a separate file. Do this by including the following +in your Makefile:</p><pre class="programlisting">PROJECT_ENV_FILE = src/env.src +PROJECT_ENV = $(subst \n,$(newline),$(shell cat $(PROJECT_ENV_FILE) | sed -e 's/$$/\\n/;')) +ebin/$(PROJECT).app:: $(PROJECT_ENV_FILE)</pre><p>The file has the same contents as the <code class="literal">PROJECT_ENV</code> variable:</p><pre class="programlisting">[ + {chips, [currysauce,{mushypeas,false}]}, + {pizza, [{size,large},{toppings,[anchovies]}]} +]</pre></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="_legacy_method"></a>6.3.3. Legacy method</h3></div></div></div><p>The <span class="emphasis"><em>src/$(PROJECT).app.src</em></span> file is a legacy method of building Erlang applications. It was introduced by the original <code class="literal">rebar</code> build tool, of which Erlang.mk owes a great deal as it is its main inspiration.</p><p>The <span class="emphasis"><em>.app.src</em></span> file serves as a template to generate the <span class="emphasis"><em>.app</em></span> @@ -160,7 +169,6 @@ files are run before, and the resulting Erlang source files are then built normally.</p><p>In addition, Erlang.mk keeps track of header files (<code class="literal">.hrl</code>) as described at the end of this chapter. It can also compile C code, as described in the <a class="link" href="ports.html" title="Chapter 8. NIFs and port drivers">NIFs and port drivers</a> -<a class="xref" href="ports.html" title="Chapter 8. NIFs and port drivers">Chapter 8, <em>NIFs and port drivers</em></a> chapter.</p><p>Erlang.mk also comes with plugins for the following formats:</p><div class="informaltable"><table class="informaltable" cellpadding="4px" style="border-collapse: collapse;border-top: 3px solid #527bbd; border-bottom: 3px solid #527bbd; border-left: 3px solid #527bbd; border-right: 3px solid #527bbd; "><colgroup><col class="col_1" /><col class="col_2" /><col class="col_3" /><col class="col_4" /></colgroup><thead><tr><th style="border-right: 1px solid #527bbd; border-bottom: 1px solid #527bbd; " align="left" valign="top"> Extension </th><th style="border-right: 1px solid #527bbd; border-bottom: 1px solid #527bbd; " align="center" valign="top"> Location </th><th style="border-right: 1px solid #527bbd; border-bottom: 1px solid #527bbd; " align="center" valign="top"> Description </th><th style="border-bottom: 1px solid #527bbd; " align="center" valign="top"> Output</th></tr></thead><tbody><tr><td style="border-right: 1px solid #527bbd; border-bottom: 1px solid #527bbd; " align="left" valign="top"><p>.dtl</p></td><td style="border-right: 1px solid #527bbd; border-bottom: 1px solid #527bbd; " align="center" valign="top"><p>templates/</p></td><td style="border-right: 1px solid #527bbd; border-bottom: 1px solid #527bbd; " align="center" valign="top"><p>Django templates</p></td><td style="border-bottom: 1px solid #527bbd; " align="center" valign="top"><p>ebin/*.beam</p></td></tr><tr><td style="border-right: 1px solid #527bbd; " align="left" valign="top"><p>.proto</p></td><td style="border-right: 1px solid #527bbd; " align="center" valign="top"><p>src/</p></td><td style="border-right: 1px solid #527bbd; " align="center" valign="top"><p>Protocol buffers</p></td><td style="" align="center" valign="top"><p>ebin/*.beam</p></td></tr></tbody></table></div></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_compilation_options"></a>6.6. Compilation options</h2></div></div></div><p>Erlang.mk provides a few variables that you can use to customize the build process and the resulting files.</p><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="_erlc_opts"></a>6.6.1. ERLC_OPTS</h3></div></div></div><p><code class="literal">ERLC_OPTS</code> can be used to pass some options to <code class="literal">erlc</code>, the Erlang compiler. Erlang.mk does not restrict any option. Please refer to |