Mix.Tasks.Compile.Erlang
Compile Erlang source files.
When this task runs, it will first check the modification times of all files to be compiled and if they haven't been changed since the last compilation, it will not compile them. If any of them have changed, it compiles everything.
For this reason, the task touches your :compile_path
directory and sets the modification time to the current
time and date at the end of each compilation. You can
force compilation regardless of modification times by passing
the --force option.
Command line options
--force- forces compilation regardless of modification times
Configuration
ERL_COMPILER_OPTIONS- can be used to give default compile options. The value must be a valid Erlang term. If the value is a list, it will be used as is. If it is not a list, it will be put into a list.:erlc_paths- directories to find source files. Defaults to["src"], can be configured as:[erlc_paths: ["src", "other"]]:erlc_include_path- directory for adding include files. Defaults to"include", can be configured as:[erlc_include_path: "other"]:erlc_options- compilation options that apply to Erlang's compiler.:debug_infois enabled by default.There are many available options here: http://www.erlang.org/doc/man/compile.html#file-2
Summary
| compile_mappings(manifest, mappings, src_ext, dest_ext, force, callback) | Extracts the extensions from the mappings, automatically
invoking the callback for each stale input and output pair
(or for all if |
| manifests() | Returns Erlang manifests |
| run(args) | Runs this task |
| to_erl_file(file) | Converts the given file to a format accepted by the Erlang compilation tools |
Functions
Extracts the extensions from the mappings, automatically
invoking the callback for each stale input and output pair
(or for all if force is true) and removing files that no
longer have a source, while keeping the manifest up
to date.
Examples
For example, a simple compiler for Lisp Flavored Erlang would be implemented like:
compile_mappings ".compile.lfe",
[{ "src", "ebin" }],
:lfe, :beam, opts[:force], fn
input, output ->
:lfe_comp.file(to_erl_file(input),
[output_dir: Path.dirname(output)])
end
The command above will:
- Look for files ending with the
lfeextension insrcand theirbeamcounterpart inebin; - For each stale file (or for all if
forceis true), invoke the callback passing the calculated input and output; - Update the manifest with the newly compiled outputs;
- Remove any output in the manifest that that does not have an equivalent source;
The callback must return { :ok, mod } or :error in case
of error. An error is raised at the end if any of the
files failed to compile.