aboutsummaryrefslogtreecommitdiffstats
path: root/lua/mason-registry/index/solidity/init.lua
blob: 8824d63a9c9c5857d40283100c722c34fe635185 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
local Pkg = require "mason-core.package"
local _ = require "mason-core.functional"
local github = require "mason-core.managers.github"
local platform = require "mason-core.platform"
local std = require "mason-core.managers.std"

local coalesce, when = _.coalesce, _.when

return Pkg.new {
    name = "solidity",
    desc = [[Solidity, the Smart Contract Programming Language]],
    homepage = "https://github.com/ethereum/solidity",
    categories = { Pkg.Cat.Compiler, Pkg.Cat.LSP },
    languages = { Pkg.Lang.Solidity },
    ---@async
    ---@param ctx InstallContext
    install = function(ctx)
        github
            .download_release_file({
                repo = "ethereum/solidity",
                out_file = platform.is.win and "solc.exe" or "solc",
                asset_file = coalesce(
                    when(platform.is.mac, "solc-macos"),
                    when(platform.is.linux, "solc-static-linux"),
                    when(platform.is.win, "solc-windows.exe")
                ),
            })
            .with_receipt()
        std.chmod("+x", { "solc" })
        ctx:link_bin("solc", platform.is.win and "solc.exe" or "solc")
    end,
}