Skip to content

Commit

Permalink
feat: store default versions in a json version file
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Oct 25, 2024
1 parent e0e749b commit 819d829
Show file tree
Hide file tree
Showing 13 changed files with 273 additions and 121 deletions.
2 changes: 1 addition & 1 deletion dist/legacy/setup-cpp.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/legacy/setup-cpp.js.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/legacy/versions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"ninja":"1.12.1","cmake":"3.30.4","task":"3.39.2","powershell":"7.4.5","pip":"22.2.0","python":"3.7.9","meson":{"linux":{"ubuntu":{"20":"1.5.2","18":"0.61.4","else":"0.61.4"},"else":"1.5.2"},"else":"1.5.2"},"kcov":{"linux":{"ubuntu":{"22":"42-binary","20":"40-binary","14":"40","else":"42"},"else":"42"},"else":"42"},"doxygen":{"linux":{"archlinux":"1.12.0-2","ubuntu":{"22":"1.12.0","18":"1.10.0","else":"1.10.0"},"else":"1.12.0"},"else":"1.12.0"},"gcc":{"win32":"14.2.0posix-18.1.8-12.0.0-ucrt-r1","else":""},"mingw":{"win32":"14.2.0posix-18.1.8-12.0.0-ucrt-r1","linux":{"ubuntu":{"22":"8.0.0-1","20":"7.0.0-2","else":"7.0.0-2"}},"else":""},"gcovr":{"linux":{"ubuntu":{"20":"","18":"5.0","else":"5.0"}},"else":""},"nala":{"win32":"14.2.0posix-18.1.8-12.0.0-ucrt-r1","linux":{"ubuntu":{"22":"","21":"legacy","else":"legacy"}},"else":""},"llvm":{"darwin":{"else":{"else":{"x64":"15.0.7","else":"18.1.8"}}},"else":"18.1.8"},"clang":{"darwin":{"else":{"else":{"x64":"15.0.7","else":"18.1.8"}}},"else":"18.1.8"},"clang++":{"darwin":{"else":{"else":{"x64":"15.0.7","else":"18.1.8"}}},"else":"18.1.8"},"clang-tidy":{"darwin":{"else":{"else":{"x64":"15.0.7","else":"18.1.8"}}},"else":"18.1.8"},"clangtidy":{"darwin":{"else":{"else":{"x64":"15.0.7","else":"18.1.8"}}},"else":"18.1.8"},"clang-format":{"darwin":{"else":{"else":{"x64":"15.0.7","else":"18.1.8"}}},"else":"18.1.8"},"clangformat":{"darwin":{"else":{"else":{"x64":"15.0.7","else":"18.1.8"}}},"else":"18.1.8"}}

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/modern/setup-cpp.mjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/modern/setup-cpp.mjs.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/modern/versions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"ninja":"1.12.1","cmake":"3.30.4","task":"3.39.2","powershell":"7.4.5","pip":"22.2.0","python":"3.7.9","meson":{"linux":{"ubuntu":{"20":"1.5.2","18":"0.61.4","else":"0.61.4"},"else":"1.5.2"},"else":"1.5.2"},"kcov":{"linux":{"ubuntu":{"22":"42-binary","20":"40-binary","14":"40","else":"42"},"else":"42"},"else":"42"},"doxygen":{"linux":{"archlinux":"1.12.0-2","ubuntu":{"22":"1.12.0","18":"1.10.0","else":"1.10.0"},"else":"1.12.0"},"else":"1.12.0"},"gcc":{"win32":"14.2.0posix-18.1.8-12.0.0-ucrt-r1","else":""},"mingw":{"win32":"14.2.0posix-18.1.8-12.0.0-ucrt-r1","linux":{"ubuntu":{"22":"8.0.0-1","20":"7.0.0-2","else":"7.0.0-2"}},"else":""},"gcovr":{"linux":{"ubuntu":{"20":"","18":"5.0","else":"5.0"}},"else":""},"nala":{"win32":"14.2.0posix-18.1.8-12.0.0-ucrt-r1","linux":{"ubuntu":{"22":"","21":"legacy","else":"legacy"}},"else":""},"llvm":{"darwin":{"else":{"else":{"x64":"15.0.7","else":"18.1.8"}}},"else":"18.1.8"},"clang":{"darwin":{"else":{"else":{"x64":"15.0.7","else":"18.1.8"}}},"else":"18.1.8"},"clang++":{"darwin":{"else":{"else":{"x64":"15.0.7","else":"18.1.8"}}},"else":"18.1.8"},"clang-tidy":{"darwin":{"else":{"else":{"x64":"15.0.7","else":"18.1.8"}}},"else":"18.1.8"},"clangtidy":{"darwin":{"else":{"else":{"x64":"15.0.7","else":"18.1.8"}}},"else":"18.1.8"},"clang-format":{"darwin":{"else":{"else":{"x64":"15.0.7","else":"18.1.8"}}},"else":"18.1.8"},"clangformat":{"darwin":{"else":{"else":{"x64":"15.0.7","else":"18.1.8"}}},"else":"18.1.8"}}
12 changes: 3 additions & 9 deletions src/__tests__/main.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { parseArgs } from "../cli-options.js"
import { getCompilerInfo } from "../compilers.js"
import { type Inputs, llvmTools } from "../tool.js"
import { DefaultUbuntuVersion, DefaultVersions } from "../versions/default_versions.js"
import { getVersion, syncVersions } from "../versions/versions.js"

jest.setTimeout(300000)
Expand Down Expand Up @@ -90,18 +89,13 @@ describe("getVersion", () => {
it("gcovr", () => {
expect(getVersion("gcovr", "5.0")).toBe("5.0")
if (process.platform === "linux") {
expect(getVersion("gcovr", "true", [22, 4])).toBe(DefaultUbuntuVersion.gcovr![22])
expect(getVersion("gcovr", "true", [20, 4])).toBe(DefaultUbuntuVersion.gcovr![20])
expect(getVersion("gcovr", "true", [18, 4])).toBe(DefaultUbuntuVersion.gcovr![18])
expect(getVersion("gcovr", "true", [22, 4])).toBe("")
expect(getVersion("gcovr", "true", [20, 4])).toBe("")
expect(getVersion("gcovr", "true", [18, 4])).toBe("5.0")
}
})

it("llvm", () => {
expect(getVersion("llvm", "13.0.0")).toBe("13.0.0")
if (process.platform === "linux") {
expect(getVersion("llvm", "true", [20, 4])).toBe(DefaultVersions.llvm)
expect(getVersion("llvm", "true", [18, 4])).toBe(DefaultVersions.llvm)
expect(getVersion("llvm", "true", [16, 4])).toBe(DefaultVersions.llvm)
}
})
})
12 changes: 8 additions & 4 deletions src/python/python.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { setupPacmanPack } from "../utils/setup/setupPacmanPack.js"
import { hasPipx, setupPipPackSystem, setupPipPackWithPython } from "../utils/setup/setupPipPack.js"
import { isBinUptoDate } from "../utils/setup/version.js"
import { unique } from "../utils/std/index.js"
import { MinVersions } from "../versions/default_versions.js"
import { getVersionDefault } from "../versions/versions.js"

export async function setupPython(
version: string,
Expand Down Expand Up @@ -214,17 +214,19 @@ async function findPython(binDir?: string) {

async function isPythonUpToDate(candidate: string, binDir?: string) {
try {
const targetVersion = getVersionDefault("python")

if (binDir !== undefined) {
const pythonBinPath = join(binDir, addExeExt(candidate))
if (await pathExists(pythonBinPath) && await isBinUptoDate(pythonBinPath, MinVersions.python!)) {
if (await pathExists(pythonBinPath) && await isBinUptoDate(pythonBinPath, targetVersion!)) {
return pythonBinPath
}
}
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
const pythonBinPaths = (await which(candidate, { nothrow: true, all: true })) ?? []
for (const pythonBinPath of pythonBinPaths) {
// eslint-disable-next-line no-await-in-loop
if (await isBinUptoDate(pythonBinPath, MinVersions.python!)) {
if (await isBinUptoDate(pythonBinPath, targetVersion!)) {
return pythonBinPath
}
}
Expand Down Expand Up @@ -260,11 +262,13 @@ async function findPip() {

async function isPipUptoDate(pip: string) {
try {
const targetVersion = getVersionDefault("pip")

// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
const pipPaths = (await which(pip, { nothrow: true, all: true })) ?? []
for (const pipPath of pipPaths) {
// eslint-disable-next-line no-await-in-loop
if (await isBinUptoDate(pipPath, MinVersions.pip!)) {
if (await isBinUptoDate(pipPath, targetVersion!)) {
return pipPath
}
}
Expand Down
83 changes: 0 additions & 83 deletions src/versions/default_versions.ts

This file was deleted.

156 changes: 156 additions & 0 deletions src/versions/versions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
{
"ninja": "1.12.1",
"cmake": "3.30.4",
"task": "3.39.2",
"powershell": "7.4.5",
"pip": "22.2.0",
"python": "3.7.9",
"meson": {
"linux": {
"ubuntu": {
"20": "1.5.2",
"18": "0.61.4",
"else": "0.61.4"
},
"else": "1.5.2"
},
"else": "1.5.2"
},
"kcov": {
"linux": {
"ubuntu": {
"22": "42-binary",
"20": "40-binary",
"14": "40",
"else": "42"
},
"else": "42"
},
"else": "42"
},
"doxygen": {
"linux": {
"archlinux": "1.12.0-2",
"ubuntu": {
"22": "1.12.0",
"18": "1.10.0",
"else": "1.10.0"
},
"else": "1.12.0"
},
"else": "1.12.0"
},
"gcc": {
"win32": "14.2.0posix-18.1.8-12.0.0-ucrt-r1",
"else": ""
},
"mingw": {
"win32": "14.2.0posix-18.1.8-12.0.0-ucrt-r1",
"linux": {
"ubuntu": {
"22": "8.0.0-1",
"20": "7.0.0-2",
"else": "7.0.0-2"
}
},
"else": ""
},
"gcovr": {
"linux": {
"ubuntu": {
"20": "",
"18": "5.0",
"else": "5.0"
}
},
"else": ""
},
"nala": {
"win32": "14.2.0posix-18.1.8-12.0.0-ucrt-r1",
"linux": {
"ubuntu": {
"22": "",
"21": "legacy",
"else": "legacy"
}
},
"else": ""
},
"llvm": {
"darwin": {
"else": {
"else": {
"x64": "15.0.7",
"else": "18.1.8"
}
}
},
"else": "18.1.8"
},
"clang": {
"darwin": {
"else": {
"else": {
"x64": "15.0.7",
"else": "18.1.8"
}
}
},
"else": "18.1.8"
},
"clang++": {
"darwin": {
"else": {
"else": {
"x64": "15.0.7",
"else": "18.1.8"
}
}
},
"else": "18.1.8"
},
"clang-tidy": {
"darwin": {
"else": {
"else": {
"x64": "15.0.7",
"else": "18.1.8"
}
}
},
"else": "18.1.8"
},
"clangtidy": {
"darwin": {
"else": {
"else": {
"x64": "15.0.7",
"else": "18.1.8"
}
}
},
"else": "18.1.8"
},
"clang-format": {
"darwin": {
"else": {
"else": {
"x64": "15.0.7",
"else": "18.1.8"
}
}
},
"else": "18.1.8"
},
"clangformat": {
"darwin": {
"else": {
"else": {
"x64": "15.0.7",
"else": "18.1.8"
}
}
},
"else": "18.1.8"
}
}
Loading

0 comments on commit 819d829

Please sign in to comment.