Skip to content

Commit

Permalink
Fetch pre-compiled rebar3 instead of building it locally
Browse files Browse the repository at this point in the history
Advantages:

* faster build time (no build, actually)
* wider Erlang version range - compatibility
  (since it's build for Erlang <cur-2> by erlang/rebar3)
  • Loading branch information
kivra-pauoli committed Sep 11, 2024
1 parent 4af0770 commit 3dcc681
Showing 1 changed file with 25 additions and 20 deletions.
45 changes: 25 additions & 20 deletions bin/install
Original file line number Diff line number Diff line change
Expand Up @@ -25,30 +25,31 @@ install_rebar() {

# Running this in a subshell because we don't to disturb the current
# working directory.
(
cd "$(dirname "$source_path")" || exit 1
tar zxvf "$source_path" &>/dev/null || exit 1

cd "$(untar_path "$install_type" "$version" "$tmp_download_dir")" || exit 1

# Build rebar
./bootstrap || exit 1
if version_3x_or_greater "$version"; then
(
cd "$(dirname "$source_path")" || exit 1

# Copy (executable) rebar3 into the bin directory inside the asdf install directory
chmod +x rebar3 || exit 1
mkdir -p "$install_path/bin/" || exit 1
cp rebar3 "$install_path/bin/" || exit 1
)
else
(
cd "$(dirname "$source_path")" || exit 1
tar zxvf "$source_path" &>/dev/null || exit 1

# Copy rebar into the bin directory inside the asdf install directory
mkdir -p "$install_path/bin/" || exit 1
cd "$(untar_path "$install_type" "$version" "$tmp_download_dir")" || exit 1

if version_3x_or_greater "$version"; then
local rebar3_binary="_build/default/bin/rebar3"
# Build rebar
./bootstrap || exit 1

if [ ! -f $rebar3_binary ]; then
rebar3_binary="_build/prod/bin/rebar3"
fi
# Copy rebar into the bin directory inside the asdf install directory
mkdir -p "$install_path/bin/" || exit 1

cp "$rebar3_binary" "$install_path/bin/" || exit 1
else
cp rebar "$install_path/bin/" || exit 1
fi
)
)
fi
}

download_source() {
Expand All @@ -72,6 +73,10 @@ get_download_file_path() {

local pkg_name="${rebar_version}.tar.gz"

if version_3x_or_greater "$version"; then
pkg_name="rebar3"
fi

echo "$tmp_download_dir/$pkg_name"
}

Expand Down Expand Up @@ -100,7 +105,7 @@ get_download_url() {
local version=$2

if version_3x_or_greater "$version"; then
echo "https://github.com/erlang/rebar3/archive/${version}.tar.gz"
echo "https://github.com/erlang/rebar3/releases/download/${version}/rebar3"
else
echo "https://github.com/rebar/rebar/archive/${version}.tar.gz"
fi
Expand Down

0 comments on commit 3dcc681

Please # to comment.