From fa08d097f3c43fb1a22fc0850d07e6eda9636509 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonatan=20K=C5=82osko?= Date: Mon, 21 Oct 2024 15:19:24 +0800 Subject: [PATCH 1/2] Make Mix.Project.with_build_lock/2 public --- lib/mix/lib/mix/project.ex | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/mix/lib/mix/project.ex b/lib/mix/lib/mix/project.ex index f37b1e51b1b..4ccc5d7f7ea 100644 --- a/lib/mix/lib/mix/project.ex +++ b/lib/mix/lib/mix/project.ex @@ -882,7 +882,18 @@ defmodule Mix.Project do end end - @doc false + @doc """ + Acquires a lock on the project build path and runs the given function. + + When another process (across all OS processes) is holding the lock, + a message is printed and this call blocks until the lock is acquired. + This function can also be called if this process already has the + lock. In such case the function is executed immediately. + + This lock is primarily useful by compiler tasks that alter the build + artifacts to avoid conflicts with a concurrent compilation. + """ + @spec with_build_lock(keyword, (-> term())) :: term() def with_build_lock(config \\ config(), fun) do # To avoid duplicated compilation, we wrap compilation tasks, such # as compile.all, deps.compile, compile.elixir, compile.erlang in From 26b7ce59b02b466ec802dd8c5d4b77ed111717ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonatan=20K=C5=82osko?= Date: Mon, 21 Oct 2024 09:24:05 +0200 Subject: [PATCH 2/2] Update lib/mix/lib/mix/project.ex --- lib/mix/lib/mix/project.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/mix/lib/mix/project.ex b/lib/mix/lib/mix/project.ex index 4ccc5d7f7ea..d5f1f57ecf2 100644 --- a/lib/mix/lib/mix/project.ex +++ b/lib/mix/lib/mix/project.ex @@ -890,7 +890,7 @@ defmodule Mix.Project do This function can also be called if this process already has the lock. In such case the function is executed immediately. - This lock is primarily useful by compiler tasks that alter the build + This lock is primarily useful for compiler tasks that alter the build artifacts to avoid conflicts with a concurrent compilation. """ @spec with_build_lock(keyword, (-> term())) :: term()