From 9385af2a2294383e75378333fefd24e360f00233 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonatan=20K=C5=82osko?= Date: Tue, 28 Jan 2025 13:52:36 +0700 Subject: [PATCH 1/3] Add more details on priv artifacts --- lib/mix/tasks/compile.elixir_make.ex | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/mix/tasks/compile.elixir_make.ex b/lib/mix/tasks/compile.elixir_make.ex index 97fdeca..d2d4c1c 100644 --- a/lib/mix/tasks/compile.elixir_make.ex +++ b/lib/mix/tasks/compile.elixir_make.ex @@ -109,8 +109,21 @@ defmodule Mix.Tasks.Compile.ElixirMake do Generally speaking, compilation artifacts are written to the `priv` directory, as that the only directory, besides `ebin`, which are available to Erlang/OTP applications. Therefore, we recommend the - Makefile top copy any artifact to `$MIX_APP_PATH/priv` or, even - better, to `$MIX_APP_PATH/priv/$MIX_TARGET`. + Makefile top copy any artifact to `$MIX_APP_PATH/priv` and to have + no top-level `priv` directory. + + In case you create a top-level `priv` directory, it gets symlinked + to all build directories, in which case you should rather copy the + artifacts to `$MIX_APP_PATH/priv/$MIX_TARGET`. This is relevant for + projects like Nerves that build for several targets and may involve + cross-compilation, so the user ends up with one _build subdirectory + per target and we don't want artifacts in the symlinked `priv` to + override each other. The downside of shared `priv` is that creating + a release would copy all its contents, even with the artifacts not + related to the given target. So, if your compilation is expensive + it may be better to never create top-level `priv` and manage your + own `cache` directory with per-target artifacts and copy them to + `$MIX_APP_PATH/priv`. """ use Mix.Task From 9eecf287d1cddadd03c9ae9891980c9ad5804aed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonatan=20K=C5=82osko?= Date: Tue, 28 Jan 2025 14:14:27 +0700 Subject: [PATCH 2/3] Up --- PRECOMPILATION_GUIDE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PRECOMPILATION_GUIDE.md b/PRECOMPILATION_GUIDE.md index 4f97e7b..6fd795b 100644 --- a/PRECOMPILATION_GUIDE.md +++ b/PRECOMPILATION_GUIDE.md @@ -1,6 +1,6 @@ # Precompilation guide -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. +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. - [Library Developer](#library-developer) - [Precompiler Module Developer](#precompiler-module-developer) From 7152f36107d734e3f01f2102ae2222366b508547 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Tue, 28 Jan 2025 10:31:07 +0100 Subject: [PATCH 3/3] Update lib/mix/tasks/compile.elixir_make.ex --- lib/mix/tasks/compile.elixir_make.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/mix/tasks/compile.elixir_make.ex b/lib/mix/tasks/compile.elixir_make.ex index d2d4c1c..8c8e969 100644 --- a/lib/mix/tasks/compile.elixir_make.ex +++ b/lib/mix/tasks/compile.elixir_make.ex @@ -109,7 +109,7 @@ defmodule Mix.Tasks.Compile.ElixirMake do Generally speaking, compilation artifacts are written to the `priv` directory, as that the only directory, besides `ebin`, which are available to Erlang/OTP applications. Therefore, we recommend the - Makefile top copy any artifact to `$MIX_APP_PATH/priv` and to have + Makefile to copy any artifact to `$MIX_APP_PATH/priv` and to have no top-level `priv` directory. In case you create a top-level `priv` directory, it gets symlinked