Skip to content

Commit

Permalink
Support TruffleRuby-jvm
Browse files Browse the repository at this point in the history
  • Loading branch information
yanecc committed Jun 9, 2024
1 parent 40304ee commit 3c47818
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 17 deletions.
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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?** <br>
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?** <br>
No! Due to the non-compiled implementation, vfox-ruby is only intended to provide CRuby and TruffleRuby.
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.
36 changes: 24 additions & 12 deletions lib/util.lua
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion metadata.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 3c47818

Please sign in to comment.