diff --git a/.github/workflows/workflow.yml b/.github/workflows/ci.yml similarity index 92% rename from .github/workflows/workflow.yml rename to .github/workflows/ci.yml index 2a8bb21..9af020e 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/ci.yml @@ -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 }} diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..7d48349 --- /dev/null +++ b/Makefile @@ -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 diff --git a/bin/install b/bin/install index abf0f45..8906890 100755 --- a/bin/install +++ b/bin/install @@ -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 @@ -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" @@ -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" diff --git a/bin/list-all b/bin/list-all index 4a420f8..db81005 100755 --- a/bin/list-all +++ b/bin/list-all @@ -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="" diff --git a/lib/utils.sh b/lib/utils.sh index e6cdb53..e650050 100644 --- a/lib/utils.sh +++ b/lib/utils.sh @@ -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 } @@ -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 } @@ -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"