Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/workflow.yml → .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,13 @@ jobs:
- 5.3.6
- 5.4.8
- 5.5.0
- LuaJIT-2.0.5
os:
- macos-latest
- ubuntu-latest
exclude:
- os: macos-latest
version: LuaJIT-2.0.5

runs-on: ${{ matrix.os }}

Expand Down
15 changes: 15 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
precommit: fmt lint test test_luajit

test:
asdf plugin test plugin . --asdf-tool-version 5.5.0

test_luajit:
asdf plugin test plugin . --asdf-tool-version LuaJIT-2.0.5

fmt:
shfmt --language-dialect bash --indent 2 --write bin/*

lint:
shellcheck --shell bash --external-sources bin/*

.PHONY: precommit test test_luajit lint
45 changes: 31 additions & 14 deletions bin/install
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,16 @@ install_lua() {
cd "$(untar_path "$install_type" "$version" "$download_dir")" || exit 1

# Target is OS-specific
target="$(get_target)"
target="$(get_target "$version")"

# Build Lua
if version_5x_or_greater "$version"; then
# Build Lua or LuaJIT
local lua_type
lua_type="$(get_lua_type "$version")"

if [ "${lua_type}" = "LuaJIT" ]; then
make || exit 1
make install PREFIX="$install_path" || exit 1
elif version_5x_or_greater "$version"; then
make "$target" || exit 1
make test || exit 1
make local || exit 1
Expand All @@ -56,18 +62,21 @@ install_lua() {
make install INSTALL_ROOT=install || exit 1
fi

# `make local` target changed in version 5x
if version_5_2x_or_greater "$version"; then
cp -r install/* "$install_path" || exit 1
elif version_5x_or_greater "$version"; then
cp -r ./* "$install_path" || exit 1
else
# We install version 4 and lesser in install/
cp -r install/* "$install_path" || exit 1
# Copy files for regular Lua only (LuaJIT installs directly)
if [ "${lua_type}" != "LuaJIT" ]; then
# `make local` target changed in version 5x
if version_5_2x_or_greater "$version"; then
cp -r install/* "$install_path" || exit 1
elif version_5x_or_greater "$version"; then
cp -r ./* "$install_path" || exit 1
else
# We install version 4 and lesser in install/
cp -r install/* "$install_path" || exit 1
fi
fi

# If we are installing Lua 5.x or greater install LuaRocks as well
if version_5x_or_greater "$version"; then
# If we are installing Lua 5.x or greater install LuaRocks as well (not for LuaJIT)
if [ "${lua_type}" != "LuaJIT" ] && version_5x_or_greater "$version"; then
local luarocks_version
luarocks_version="${ASDF_LUA_LUAROCKS_VERSION:-$(get_latest_luarocks_version)}"
local luarocks_name="luarocks-$luarocks_version"
Expand Down Expand Up @@ -103,20 +112,28 @@ untar_path() {
local dir_name="lua"
fi
elif [ "${lua_type}" = "LuaJIT" ]; then
local dir_name="luajit-${lua_version}"
local dir_name="LuaJIT-${lua_version}"
fi

echo "$tmp_download_dir/$dir_name"
}

get_target() {
local version="$1"
local os
local lua_type

os="$(uname -s)"
lua_type="$(get_lua_type "$version")"

# If on OSX (Darwin) then the target is macosx
if [ "$os" = "Darwin" ]; then
echo "macosx"
elif [ "${ASDF_LUA_LINUX_READLINE-}" == "1" ]; then
echo "linux-readline"
elif [ "${lua_type}" = "LuaJIT" ]; then
# LuaJIT doesn't use targets like regular Lua
echo ""
else # Otherwise let the lua Makefile guess for us
if less_than_version_5_4x "$version"; then
echo "linux"
Expand Down
9 changes: 9 additions & 0 deletions bin/list-all
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,15 @@ versions_list=(
5.4.7
5.4.8
5.5.0
# LuaJIT versions
LuaJIT-2.0.1
LuaJIT-2.0.2
LuaJIT-2.0.3
LuaJIT-2.0.4
LuaJIT-2.0.5
LuaJIT-2.1.0-beta1
LuaJIT-2.1.0-beta2
LuaJIT-2.1.0-beta3
)

versions=""
Expand Down
22 changes: 11 additions & 11 deletions lib/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ get_download_url() {
if [ "${lua_type}" = "Lua" ]; then
echo "https://www.lua.org/ftp/lua-${version}.tar.gz"
elif [ "${lua_type}" = "LuaJIT" ]; then
echo "https://luajit.org/download/LuaJIT-${version}.tar.gz"
local lua_version
lua_version="$(get_lua_version "$version")"
echo "https://github.com/LuaJIT/LuaJIT/archive/refs/tags/v${lua_version}.tar.gz"
fi
}

Expand All @@ -38,18 +40,14 @@ get_lua_type() {
}

get_lua_version() {
IFS='-' read -ra version_info <<<"$1"
local version="$1"

if [ "${version_info[0]}" = "LuaJIT" ]; then
# TODO LuaJIT
echo "${version_info[1]}-${version_info[2]}"
if [[ "$version" == LuaJIT-* ]]; then
# For LuaJIT, remove the "LuaJIT-" prefix
echo "${version#LuaJIT-}"
else
# Lua
if [ "${#version_info[@]}" -eq 1 ]; then
echo "${version_info[0]}"
else
echo "${version_info[0]}-${version_info[1]}"
fi
# For regular Lua, return as-is
echo "$version"
fi
}

Expand All @@ -65,6 +63,8 @@ get_download_file_path() {

if [ "${lua_type}" = "Lua" ]; then
local pkg_name="lua-${lua_version}.tar.gz"
else
local pkg_name="v${lua_version}.tar.gz"
fi

echo "$tmp_download_dir/$pkg_name"
Expand Down
Loading