View Source mix compile.elixir_make (elixir_make v0.7.6)
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
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()]
endThe following options are available:
:make_executable- (binary or:default) it's the executable to use as themakeprogram. 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:defaultfor every other OS. If theMAKEenvironment 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[], meaningmakewill run the first target.:make_clean- (list of binaries) it's a list of Make targets to be run whenmix cleanis run. It's only run if a non-nilvalue for:make_cleanis provided. Defaults tonil.:make_cwd- (binary) it's the directory wheremakewill 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 tomake. You can also pass a function in here in casemake_envneeds 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 installinggccif you're compiling a C dependency).:make_args- (list of binaries) it's a list of extra arguments to be passed.
The following options configure precompilation:
:make_precompiler- a two-element tuple with the precompiled type and module to use. The precompile type is either:nifor:portand then the precompilation module. If the type is a:nif, it looks for a DDL or a shared object as precompilation target given by:make_precompiler_filenameand the current NIF version is part of the precompiled archive. If:port, it looks for an executable with:make_precompiler_filename.:make_precompiler_url- the download URL template. Defaults to none. Required whenmake_precompileris set.:make_precompiler_filename- the filename of the compiled artefact without its extension. Defaults to the app name.:make_force_build- if build should be forced even if precompiled artefacts are available. Defaults to true if the app has a-devversion flag.
See the Precompilation guide for more information.
default-environment-variables
Default environment variables
There are also several default environment variables set:
MIX_TARGETMIX_ENVMIX_BUILD_PATH- same asMix.Project.build_path/0MIX_APP_PATH- same asMix.Project.app_path/0MIX_COMPILE_PATH- same asMix.Project.compile_path/0MIX_CONSOLIDATION_PATH- same asMix.Project.consolidation_path/0MIX_DEPS_PATH- same asMix.Project.deps_path/0MIX_MANIFEST_PATH- same asMix.Project.manifest_path/0ERL_EI_LIBDIRERL_EI_INCLUDE_DIRERTS_INCLUDE_DIRERL_INTERFACE_LIB_DIRERL_INTERFACE_INCLUDE_DIR
These may also be overwritten with the make_env option.
compilation-artifacts-and-working-with-priv-directories
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/privor, 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")