From 62acc7c194bbf69b5b7996147ed4d8728d2899d2 Mon Sep 17 00:00:00 2001 From: Fred Hebert Date: Wed, 27 May 2020 13:31:27 +0000 Subject: [PATCH] Support ENV var for mix in the bare compiler None of the version checks are considered safe enough by mix maintainers, and so the agreed upon mechanism is to just set this environment variable, which will be supported implicitly by rebar3 versions that can handle it. This lets build artifacts (aside from some priv/ issues with plugins) to properly be located within their build folder rather than the deps folder, as the --outdir switch would otherwise have done. --- src/rebar_prv_bare_compile.erl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/rebar_prv_bare_compile.erl b/src/rebar_prv_bare_compile.erl index 0ad20917..f1f91ba2 100644 --- a/src/rebar_prv_bare_compile.erl +++ b/src/rebar_prv_bare_compile.erl @@ -53,7 +53,11 @@ do(State) -> {RawOpts, _} = rebar_state:command_parsed_args(State), Paths = proplists:get_value(paths, RawOpts), Sep = proplists:get_value(separator, RawOpts, " "), - OutDir = proplists:get_value(outdir, RawOpts, rebar_dir:get_cwd()), + %% Because mix won't check for versions, it instead sets this variable + %% that it knows older rebar3 version will ignore so we play nice and + %% honor it. + DefaultOutDir = os:getenv("REBAR_BARE_COMPILER_OUTPUT_DIR", rebar_dir:get_cwd()), + OutDir = proplists:get_value(outdir, RawOpts, DefaultOutDir), [ code:add_pathsa(filelib:wildcard(PathWildcard)) || PathWildcard <- rebar_string:lexemes(Paths, Sep) ],