Skip to content

Commit

Permalink
update & add c/cpp/dotnet
Browse files Browse the repository at this point in the history
  • Loading branch information
Sunrisepeak committed Dec 16, 2024
1 parent bb727e0 commit fce363c
Show file tree
Hide file tree
Showing 7 changed files with 141 additions and 10 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ package = {
docs = "https://example.com/docs",

-- xim pkg info
type = "package" -- package, auto-config
archs = {"x86_64"},
status = "stable", -- dev, stable, deprecated
categories = {"category1", "category2"},
Expand Down Expand Up @@ -159,9 +160,7 @@ local mdbook_file = {
}

function installed()
local output = os.iorun("mdbook --version")
local version = runtime.get_pkginfo().version
return output:find(version)
return os.iorun("mdbook --version")
end

function install()
Expand Down
1 change: 1 addition & 0 deletions pkgs/c/c.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package = { ref = "cpp" }
62 changes: 62 additions & 0 deletions pkgs/c/cpp.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package = {
-- base info

homepage = "https://github.com/d2learn/xim-pkgindex",

name = "cpp",
description = "C++ language toolchain",
maintainers = "xim team",
contributors = "https://github.com/d2learn/xim-pkgindex/graphs/contributors",

-- xim pkg info
type = "auto-config",
status = "stable", -- dev, stable, deprecated
categories = {"plang", "compiler", "c"},

xpm = {
windows = {
deps = {"msvc"},
["latest"] = { ref = "msvc" },
["msvc"] = {},
},
ubuntu = {
deps = {"gcc"},
["latest"] = { ref = "gnu" },
["gnu"] = {},
},
debain = { ref = "ubuntu" },
},
}

import("core.tool.toolchain")

import("xim.base.runtime")
import("xim.xuninstall")


local pkginfo = runtime.get_pkginfo()

function installed()
if pkginfo.version == "msvc" then
return toolchain.load("mingw"):check()
elseif pkginfo.version == "gnu" then
local output = os.iorun("gcc --version")
return string.find(output, "gcc") ~= nil
else
return true
end
end

function install()
-- install by deps
return true
end

function uninstall()
if pkginfo.version == "msvc" then
xuninstall("msvc")
elseif pkginfo.version == "gnu" then
xuninstall("gcc")
end
return true
end
59 changes: 59 additions & 0 deletions pkgs/d/dotnet.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
-- https://learn.microsoft.com/en-gb/dotnet/core/install/linux-scripted-manual
-- https://learn.microsoft.com/en-us/dotnet/core/install/remove-runtime-sdk-versions?pivots=os-linux#scripted-or-manual

local installer_url = "https://dot.net/v1/dotnet-install.sh"

package = {
name = "dotnet",
description = ".NET is the free, open-source, cross-platform framework",
homepage = "https://dotnet.microsoft.com/",
maintainers = "Microsoft",
license = "MIT",
repo = "https://github.com/dotnet/sdk",
docs = "https://learn.microsoft.com/dotnet",

-- xim pkg info
archs = {"x86_64"},
status = "stable", -- dev, stable, deprecated
categories = {"dotnet"},
keywords = {"cross-platform", ".net", "dotnet"},

xpm = {
debain = {
["latest"] = { ref = "9.0" },
["9.0"] = { url = installer_url, sha256 = nil },
["8.0"] = { url = installer_url, sha256 = nil },
},
ubuntu = { ref = "debain" },
archlinux = { ref = "debain" },
},
}

import("xim.base.utils")
import("xim.base.runtime")

local pkginfo = runtime.get_pkginfo()
local dotnetdir = path.join(os.getenv("HOME"), ".dotnet")

function installed()
os.addenv("PATH", dotnetdir)
return os.iorun("dotnet --version")
end

function install()
os.exec("chmod +x " .. pkginfo.install_file)
local cmd = pkginfo.install_file .. " --channel " .. pkginfo.version
print("exec: " .. cmd)
os.exec(cmd)
return true
end

function config()
utils.add_env_path(dotnetdir)
return true
end

function uninstall()
os.exec("rm -r " .. dotnetdir)
return true
end
4 changes: 1 addition & 3 deletions pkgs/m/mdbook.lua
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ local mdbook_file = {
}

function installed()
local output = os.iorun("mdbook --version")
local version = runtime.get_pkginfo().version
return output:find(version)
return os.iorun("mdbook --version")
end

function install()
Expand Down
6 changes: 4 additions & 2 deletions pkgs/r/rust.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ package = {
},
}

import("xim.xinstall")

function installed()
os.exec("rustc --version")
os.exec("cargo --version")
Expand Down Expand Up @@ -98,8 +100,8 @@ function _choice_toolchain()

if confirm == "2" then
toolchain_abi = "x86_64-pc-windows-msvc"
-- TODO: install visual studio
--CmdProcessor.new("visual-studio", {"-y"}):install(true)
-- TODO: install msvc toolchain
xinstall("msvc")
end

return toolchain_abi
Expand Down
14 changes: 12 additions & 2 deletions pmwrapper.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,23 @@
-- for complex package/software/config, please use pkgs/xpm

pmwrapper = {
["java"] = {
["gcc"] = {
ubuntu = {"apt", "gcc"},
archlinux = {"pacman", "gcc"},
},
["g++"] = { ref = "gcc" },
["java"] = { ref = "openjdk8" },
["java8"] = { ref = "openjdk8" },
["jdk8"] = { ref = "openjdk8" },
["msvc"] = { ref = "vs-build-tools" },
["openjdk"] = { ref = "openjdk8" },
["openjdk8"] = {
windows = {"winget", "AdoptOpenJDK.OpenJDK.8"},
ubuntu = {"apt", "openjdk-8-jdk"},
archlinux = {"pacman", "jdk8-openjdk"},
},
["vim"] = {
winget = {"winget", "vim.vim"},
windows = {"winget", "vim.vim"},
ubuntu = {"apt", "vim"},
},
["visual-studio"] = {
Expand Down

0 comments on commit fce363c

Please sign in to comment.