elixir_make v0.6.2 mix compile.elixir_make View Source

Runs make in the current project.

This task runs make in the current project; any output coming from make is printed in real-time on stdout.

Configuration

This compiler can be configured through the return value of the project/0 function in mix.exs; for example:

def project() do
  [app: :myapp,
   make_executable: "make",
   make_makefile: "Othermakefile",
   compilers: [:elixir_make] ++ Mix.compilers,
   deps: deps()]
end

The following options are available:

  • :make_executable - (binary or :default) it's the executable to use as the make program. If not provided or if :default, it defaults to "nmake" on Windows, "gmake" on FreeBSD, OpenBSD and NetBSD, and "make" on everything else. You can, for example, customize which executable to use on a specific OS and use :default for every other OS. If the MAKE environment variable is present, that is used as the value of this option.

  • :make_makefile - (binary or :default) it's the Makefile to use. Defaults to "Makefile" for Unix systems and "Makefile.win" for Windows systems if not provided or if :default.

  • :make_targets - (list of binaries) it's the list of Make targets that should be run. Defaults to [], meaning make will run the first target.

  • :make_clean - (list of binaries) it's a list of Make targets to be run when mix clean is run. It's only run if a non-nil value for :make_clean is provided. Defaults to nil.

  • :make_cwd - (binary) it's the directory where make will be run, relative to the root of the project.

  • :make_env - (map of binary to binary) it's a map of extra environment variables to be passed to make. You can also pass a function in here in case make_env needs access to things that are not available during project setup; the function should return a map of binary to binary. Many default environment variables are set, see section below

  • :make_error_message - (binary or :default) it's a custom error message that can be used to give instructions as of how to fix the error (e.g., it can be used to suggest installing gcc if you're compiling a C dependency).

  • :make_args - (list of binaries) it's a list of extra arguments to be passed.

Default environment variables

There are also several default environment variables set:

These may also be overwritten with the make_env option.

Compilation artifacts and working with priv directories

Generally speaking, compilation artifacts are written to the priv directory, as that the only directory, besides ebin, which are available to Erlang/OTP applications.

However, note that Mix projects supports the :build_embedded configuration, which controls if assets in the _build directory are symlinked (when false, the default) or copied (true). In order to support both options for :build_embedded, it is important to follow the given guidelines:

  • The "priv" directory must not exist in the source code
  • The Makefile should copy any artifact to $MIX_APP_PATH/priv or, even better, to $MIX_APP_PATH/priv/$MIX_TARGET
  • If there are static assets, the Makefile should copy them over from a directory at the project root (not named "priv")

Link to this section Summary

Functions

A task needs to implement run which receives a list of command line args.

Link to this section Functions

A task needs to implement run which receives a list of command line args.

Callback implementation for Mix.Task.run/1.