From 3c47818658b1a7c2648a5334c8edff4b65b180b7 Mon Sep 17 00:00:00 2001 From: Sunrise Date: Mon, 10 Jun 2024 02:03:39 +0800 Subject: [PATCH] Support TruffleRuby-jvm --- README.md | 5 +---- lib/util.lua | 36 ++++++++++++++++++++++++------------ metadata.lua | 2 +- 3 files changed, 26 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 821ba27..92e07bb 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,4 @@ export GITHUB_URL=https://mirror.ghproxy.com/https://github.com/ Currently, vfox-ruby uses precompiled packages from conda-forge and Homebrew on Linux and macOS. You could open an issue in the [ruby-feedstock](https://github.com/conda-forge/ruby-feedstock/issues) repository to remind the maintainers to provide the latest build. Once the latest version is available, the plugin will be updated soon. - **Are there any dependencies required to use this plugin?**
-On Windows, vfox-ruby uses standalone 7-ZIP archives provided by [RubyInstaller](https://github.com/oneclick/rubyinstaller2/wiki/faq). On Linux and macOS, installing Ruby requires no dependencies other than the built-in commands. Installing TruffleRuby requires `bash`, `make`, `gcc`, `g++` and `zlib-dev`. For more details, refer to the [dependencies](https://github.com/oracle/truffleruby/blob/master/README.md#Dependencies) section. - -- **I want JRuby, Rubinius ... Can vfox-ruby provide them?**
-No! Due to the non-compiled implementation, vfox-ruby is only intended to provide CRuby and TruffleRuby. \ No newline at end of file +On Windows, vfox-ruby uses standalone 7-ZIP archives provided by [RubyInstaller](https://github.com/oneclick/rubyinstaller2/wiki/faq). On Linux and macOS, installing Ruby requires no dependencies other than the built-in commands. Installing TruffleRuby requires `bash`, `make`, `gcc`, `g++` and `zlib-dev`. For more details, refer to the [dependencies](https://github.com/oracle/truffleruby/blob/master/README.md#Dependencies) section. \ No newline at end of file diff --git a/lib/util.lua b/lib/util.lua index bb3f288..fbd6257 100644 --- a/lib/util.lua +++ b/lib/util.lua @@ -1,5 +1,10 @@ local http = require("http") local strings = require("vfox.strings") +local HomebrewRubyVersions = { + "3.3.2", + "3.3.1", + "3.1.4", +} local RubyVersions = { "3.3.2", "3.3.1", @@ -42,11 +47,11 @@ local RubyVersions = { "20.2.0", "20.1.0", "20.0.0", -} -local HomebrewRubyVersions = { - "3.3.2", - "3.3.1", - "3.1.4", + "24.0.1.jvm", + "24.0.0.jvm", + "23.1.2.jvm", + "23.1.1.jvm", + "23.1.0.jvm", } -- available.lua @@ -230,26 +235,27 @@ end function generateHomebrewRuby(version, osType, archType) local file local githubURL = os.getenv("GITHUB_URL") or "https://github.com/" + local releaseURL = githubURL:gsub("/$", "") .. "/Homebrew/homebrew-portable-ruby/releases/" if osType == "linux" and archType == "amd64" then - file = "/Homebrew/homebrew-portable-ruby/releases/download/%s/portable-ruby-%s.x86_64_linux.bottle.tar.gz" + file = releaseURL .. "download/%s/portable-ruby-%s.x86_64_linux.bottle.tar.gz" elseif osType == "darwin" and archType == "amd64" then - file = "/Homebrew/homebrew-portable-ruby/releases/download/%s/portable-ruby-%s.el_capitan.bottle.tar.gz" + file = releaseURL .. "download/%s/portable-ruby-%s.el_capitan.bottle.tar.gz" elseif osType == "darwin" and archType == "arm64" then - file = "/Homebrew/homebrew-portable-ruby/releases/download/%s/portable-ruby-%s.arm64_big_sur.bottle.tar.gz" + file = releaseURL .. "download/%s/portable-ruby-%s.arm64_big_sur.bottle.tar.gz" else print("Unsupported environment: " .. osType .. "-" .. archType) os.exit(1) end - file = githubURL:gsub("/$", "") .. file:format(version, version) + file = file:format(version, version) return file end function generateTruffleRuby(version, osType, archType) - local file + local tag, file local githubURL = os.getenv("GITHUB_URL") or "https://github.com/" - local tag = compareVersion(version, "23.0.0") >= 0 and "graal-" .. version or "vm-" .. version + local releaseURL = githubURL:gsub("/$", "") .. "/oracle/truffleruby/releases/" if compareVersion(version, "22.2.0") < 0 and archType == "arm64" then print("Unsupported version " .. version .. " for " .. archType) @@ -261,7 +267,13 @@ function generateTruffleRuby(version, osType, archType) if osType == "darwin" then osType = "macos" end - file = githubURL:gsub("/$", "") .. "/oracle/truffleruby/releases/download/%s/truffleruby-%s-%s-%s.tar.gz" + if version:sub(-3) == "jvm" and compareVersion(version, "23.1.0") >= 0 then + version = version:gsub("%.jvm$", "") + file = releaseURL .. "download/%s/truffleruby-jvm-%s-%s-%s.tar.gz" + else + file = releaseURL .. "download/%s/truffleruby-%s-%s-%s.tar.gz" + end + tag = compareVersion(version, "23.0.0") >= 0 and "graal-" .. version or "vm-" .. version file = file:format(tag, version, osType, archType) return file diff --git a/metadata.lua b/metadata.lua index 6bcc4de..c653cf3 100644 --- a/metadata.lua +++ b/metadata.lua @@ -5,7 +5,7 @@ PLUGIN = {} --- Plugin name PLUGIN.name = "ruby" --- Plugin version -PLUGIN.version = "0.4.0" +PLUGIN.version = "0.4.1" --- Plugin homepage PLUGIN.homepage = "https://github.com/yanecc/vfox-ruby" --- Plugin license, please choose a correct license according to your needs.