diff options
author | José Valim <jose.valim@plataformatec.com.br> | 2020-01-03 17:22:22 +0100 |
---|---|---|
committer | José Valim <jose.valim@plataformatec.com.br> | 2020-01-03 17:29:51 +0100 |
commit | 67606525829c1f7d09f8376d8b9fb1807f7941fd (patch) | |
tree | 07e97f0da571b114063b460b36b6c748f92b50ce | |
parent | b64d7488d0b73d2007916ff1c1b652a5a2a685e2 (diff) | |
download | elixir-67606525829c1f7d09f8376d8b9fb1807f7941fd.tar.gz |
Revert "MIX_BUILD_PATH specifies only the build_path prefix"
This reverts commit 3490a146be731cbede5e78e35dc85156bfd9bc6d
which contained a breaking change. Therefore we document the
current behaviour to avoid further confusion.
-rw-r--r-- | lib/mix/lib/mix.ex | 4 | ||||
-rw-r--r-- | lib/mix/lib/mix/project.ex | 4 | ||||
-rw-r--r-- | lib/mix/test/mix/project_test.exs | 22 |
3 files changed, 16 insertions, 14 deletions
diff --git a/lib/mix/lib/mix.ex b/lib/mix/lib/mix.ex index 127f1ae9e..04e5e466a 100644 --- a/lib/mix/lib/mix.ex +++ b/lib/mix/lib/mix.ex @@ -234,7 +234,9 @@ defmodule Mix do Mix responds to the following variables: * `MIX_ARCHIVES` - specifies the directory into which the archives should be installed - * `MIX_BUILD_PATH` - sets the project `Mix.Project.build_path/0` config + * `MIX_BUILD_PATH` - sets the project `Mix.Project.build_path/0` config. This option + must always point to a subdirectory inside a temporary directory. For instance, + never "/tmp" or "_build" but "_build/PROD" or "/tmp/PROD", as required by Mix * `MIX_DEPS_PATH` - sets the project `Mix.Project.deps_path/0` config * `MIX_DEBUG` - outputs debug information about each task before running it * `MIX_ENV` - specifies which environment should be used. See [Environments](#module-environments) diff --git a/lib/mix/lib/mix/project.ex b/lib/mix/lib/mix/project.ex index 82c1b9ee5..1a4b453c1 100644 --- a/lib/mix/lib/mix/project.ex +++ b/lib/mix/lib/mix/project.ex @@ -499,11 +499,11 @@ defmodule Mix.Project do """ @spec build_path(keyword) :: Path.t() def build_path(config \\ config()) do - config[:env_path] || env_path(config) + System.get_env("MIX_BUILD_PATH") || config[:env_path] || env_path(config) end defp env_path(config) do - dir = System.get_env("MIX_BUILD_PATH") || config[:build_path] || "_build" + dir = config[:build_path] || "_build" subdir = build_target() <> build_per_environment(config) Path.expand(dir <> "/" <> subdir) end diff --git a/lib/mix/test/mix/project_test.exs b/lib/mix/test/mix/project_test.exs index a81ccb61f..9df270f20 100644 --- a/lib/mix/test/mix/project_test.exs +++ b/lib/mix/test/mix/project_test.exs @@ -30,9 +30,19 @@ defmodule Mix.ProjectTest do Path.join(File.cwd!(), "_build/shared") end + test "considers the target" do + Mix.target(:rpi3) + + assert Mix.Project.build_path(build_per_environment: true) == + Path.join(File.cwd!(), "_build/rpi3_dev") + + assert Mix.Project.build_path(build_per_environment: false) == + Path.join(File.cwd!(), "_build/rpi3_shared") + end + test "considers MIX_BUILD_PATH" do System.put_env("MIX_BUILD_PATH", "_build") - assert Mix.Project.build_path() == Path.join(File.cwd!(), "_build/dev") + assert Mix.Project.build_path() == "_build" after System.delete_env("MIX_BUILD_PATH") end @@ -43,16 +53,6 @@ defmodule Mix.ProjectTest do after System.delete_env("MIX_DEPS_PATH") end - - test "considers the target" do - Mix.target(:rpi3) - - assert Mix.Project.build_path(build_per_environment: true) == - Path.join(File.cwd!(), "_build/rpi3_dev") - - assert Mix.Project.build_path(build_per_environment: false) == - Path.join(File.cwd!(), "_build/rpi3_shared") - end end test "push and pop projects" do |