Skip to content

Commit a9ad7eb

Browse files
Add more details on priv artifacts (#90)
1 parent 5259a94 commit a9ad7eb

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

PRECOMPILATION_GUIDE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Precompilation guide
22

3-
This guide has two sections, the first one is intended for precompiler module developers. It covers a minimal example of creating a precompiler module. The second section is intended for library developers who want their library to be able to use precompiled artefacts in a simple way.
3+
This guide has two sections, the first one is intended for library developers who want their library to be able to use precompiled artefacts in a simple way. The second section one is intended for precompiler module developers and it covers a minimal example of creating a precompiler module.
44

55
- [Library Developer](#library-developer)
66
- [Precompiler Module Developer](#precompiler-module-developer)

lib/mix/tasks/compile.elixir_make.ex

+15-2
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,21 @@ defmodule Mix.Tasks.Compile.ElixirMake do
109109
Generally speaking, compilation artifacts are written to the `priv`
110110
directory, as that the only directory, besides `ebin`, which are
111111
available to Erlang/OTP applications. Therefore, we recommend the
112-
Makefile top copy any artifact to `$MIX_APP_PATH/priv` or, even
113-
better, to `$MIX_APP_PATH/priv/$MIX_TARGET`.
112+
Makefile to copy any artifact to `$MIX_APP_PATH/priv` and to have
113+
no top-level `priv` directory.
114+
115+
In case you create a top-level `priv` directory, it gets symlinked
116+
to all build directories, in which case you should rather copy the
117+
artifacts to `$MIX_APP_PATH/priv/$MIX_TARGET`. This is relevant for
118+
projects like Nerves that build for several targets and may involve
119+
cross-compilation, so the user ends up with one _build subdirectory
120+
per target and we don't want artifacts in the symlinked `priv` to
121+
override each other. The downside of shared `priv` is that creating
122+
a release would copy all its contents, even with the artifacts not
123+
related to the given target. So, if your compilation is expensive
124+
it may be better to never create top-level `priv` and manage your
125+
own `cache` directory with per-target artifacts and copy them to
126+
`$MIX_APP_PATH/priv`.
114127
"""
115128

116129
use Mix.Task

0 commit comments

Comments
 (0)