Skip to content

Commit 486347d

Browse files
committed
Initial commit: vfox plugin for chezscheme
0 parents  commit 486347d

File tree

8 files changed

+226
-0
lines changed

8 files changed

+226
-0
lines changed

.github/workflows/test.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
workflow_dispatch:
8+
9+
jobs:
10+
test:
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
os: [ubuntu-latest, macos-latest]
15+
# Windows requires .exe installer, not source compilation
16+
runs-on: ${{ matrix.os }}
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Install mise
21+
uses: jdx/mise-action@v2
22+
23+
- name: List available versions
24+
run: mise ls-remote "vfox:${{ github.repository }}" | head -20
25+
26+
- name: Install and test chezscheme
27+
run: |
28+
mise install "vfox:${{ github.repository }}@10.0.0"
29+
mise exec "vfox:${{ github.repository }}@10.0.0" -- scheme --version

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 mise-plugins
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# vfox-chezscheme
2+
3+
[vfox](https://github.com/version-fox/vfox) plugin for [Chez Scheme](https://github.com/cisco/ChezScheme).
4+
5+
Chez Scheme is both a programming language and an implementation of that language, with supporting tools and documentation.
6+
7+
**Note:** This plugin compiles Chez Scheme from source. You will need a C compiler (gcc or clang) and make installed on your system.
8+
9+
## Usage with mise
10+
11+
```bash
12+
# Install a specific version (compiles from source)
13+
mise install chezscheme@10.0.0
14+
15+
# Use in current shell
16+
mise use chezscheme@10.0.0
17+
18+
# Run scheme
19+
scheme --version
20+
```
21+
22+
## Usage with vfox
23+
24+
```bash
25+
# Add the plugin
26+
vfox add chezscheme
27+
28+
# Install a version (compiles from source)
29+
vfox install chezscheme@10.0.0
30+
31+
# Use the version
32+
vfox use chezscheme@10.0.0
33+
```
34+
35+
## Requirements
36+
37+
- C compiler (gcc or clang)
38+
- make
39+
- Basic build tools
40+
41+
On Ubuntu/Debian:
42+
```bash
43+
apt-get install build-essential
44+
```
45+
46+
On macOS:
47+
```bash
48+
xcode-select --install
49+
```

hooks/available.lua

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
local http = require("http")
2+
local json = require("json")
3+
4+
--- Returns all available versions of Chez Scheme from GitHub tags.
5+
--- @param ctx table Context
6+
--- @return table Available versions
7+
function PLUGIN:Available(ctx)
8+
local results = {}
9+
10+
-- Fetch releases from GitHub API (tags show up as releases)
11+
local resp, err = http.get({
12+
url = "https://api.github.com/repos/cisco/ChezScheme/tags?per_page=100"
13+
})
14+
15+
if err ~= nil then
16+
error("Failed to fetch versions: " .. err)
17+
end
18+
19+
if resp.status_code ~= 200 then
20+
error("Failed to fetch versions: HTTP " .. resp.status_code)
21+
end
22+
23+
local tags = json.decode(resp.body)
24+
25+
for _, tag in ipairs(tags) do
26+
local version = tag.name
27+
-- Remove 'v' prefix if present
28+
if version:sub(1, 1) == "v" then
29+
version = version:sub(2)
30+
end
31+
-- Only include version-like tags (e.g., 10.3.0, 9.5.8)
32+
if version:match("^%d+%.%d+") then
33+
table.insert(results, {
34+
version = version,
35+
note = ""
36+
})
37+
end
38+
end
39+
40+
return results
41+
end

hooks/env_keys.lua

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--- Returns environment variables to set for this tool.
2+
--- @param ctx table
3+
--- @field ctx.path string Installation path
4+
--- @return table Environment variables
5+
function PLUGIN:EnvKeys(ctx)
6+
return {
7+
{
8+
key = "PATH",
9+
value = ctx.path .. "/bin"
10+
}
11+
}
12+
end

hooks/post_install.lua

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
--- Called after extraction to compile Chez Scheme from source.
2+
--- @param ctx table
3+
--- @field ctx.rootPath string Installation root path
4+
function PLUGIN:PostInstall(ctx)
5+
local os_type = RUNTIME.osType
6+
7+
-- Windows uses the .exe installer, not source compilation
8+
if os_type == "windows" then
9+
print("Windows installation requires the ChezScheme.exe installer from GitHub releases")
10+
print("Please download and run it manually from:")
11+
print("https://github.com/cisco/ChezScheme/releases")
12+
return
13+
end
14+
15+
local root_path = ctx.rootPath
16+
17+
-- The tarball extracts with contents at root level (no top-level directory to strip)
18+
-- We need to run configure and make install
19+
print("Compiling Chez Scheme from source...")
20+
21+
-- Configure with install prefix
22+
local configure_cmd = "cd " .. root_path .. " && ./configure --installprefix=" .. root_path
23+
print("Running: " .. configure_cmd)
24+
local result = os.execute(configure_cmd)
25+
if result ~= 0 and result ~= true then
26+
error("Configure failed")
27+
end
28+
29+
-- Build
30+
local make_cmd = "cd " .. root_path .. " && make"
31+
print("Running: make")
32+
result = os.execute(make_cmd)
33+
if result ~= 0 and result ~= true then
34+
error("Make failed")
35+
end
36+
37+
-- Install to the prefix directory
38+
local install_cmd = "cd " .. root_path .. " && make install"
39+
print("Running: make install")
40+
result = os.execute(install_cmd)
41+
if result ~= 0 and result ~= true then
42+
error("Make install failed")
43+
end
44+
45+
-- Clean up build artifacts to save space (optional)
46+
os.execute("cd " .. root_path .. " && rm -rf boot c examples mats s unicode workarea Makefile configure LOG NOTICE 2>/dev/null")
47+
48+
print("Chez Scheme compilation complete!")
49+
end

hooks/pre_install.lua

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
--- Called before installation to return the download URL.
2+
--- Chez Scheme only provides source tarballs, which need to be compiled.
3+
--- @param ctx table
4+
--- @field ctx.version string Version to install
5+
--- @return table File info with URL
6+
function PLUGIN:PreInstall(ctx)
7+
local version = ctx.version
8+
9+
-- Source tarball URL pattern: csv{version}.tar.gz
10+
local url = "https://github.com/cisco/ChezScheme/releases/download/v" .. version .. "/csv" .. version .. ".tar.gz"
11+
12+
return {
13+
url = url,
14+
version = version
15+
}
16+
end

metadata.lua

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
PLUGIN = {}
2+
3+
PLUGIN.name = "chezscheme"
4+
PLUGIN.version = "0.1.0"
5+
PLUGIN.homepage = "https://github.com/mise-plugins/vfox-chezscheme"
6+
PLUGIN.license = "MIT"
7+
PLUGIN.description = "Chez Scheme - a programming language and implementation"
8+
PLUGIN.minRuntimeVersion = "0.3.0"
9+
PLUGIN.notes = { "Compiles from source - requires C compiler (gcc/clang) and make" }

0 commit comments

Comments
 (0)