Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use the default GCC version on Linux/macOS + feat: use GitHub API to match MinGW assets #277

Merged
merged 8 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion biome.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"**/.venv/",
"**/.*cache/",
"coverage/",
"**/coverage/"
"**/coverage/",
"**/github_brechtsanders_winlibs_mingw.json"
],
"ignoreUnknown": true
},
Expand Down
1 change: 1 addition & 0 deletions cspell.config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ ignorePaths:
- "**/node_modules/"
- .vscode/extensions.json
- patches/*.patch
- "**/github_brechtsanders_winlibs_mingw.json"
words:
- aarch
- aminya
Expand Down
1 change: 1 addition & 0 deletions dist/actions/github_brechtsanders_winlibs_mingw.json

Large diffs are not rendered by default.

34 changes: 17 additions & 17 deletions dist/actions/setup-cpp.js

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/legacy/github_brechtsanders_winlibs_mingw.json

Large diffs are not rendered by default.

34 changes: 17 additions & 17 deletions 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/modern/github_brechtsanders_winlibs_mingw.json

Large diffs are not rendered by default.

34 changes: 17 additions & 17 deletions dist/modern/setup-cpp.js

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dprint.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"./.cache/",
"**/build",
"**/dist",
"**/github_brechtsanders_winlibs_mingw.json",
"dev/cpp_vcpkg_project"
],
"plugins": [
Expand Down
11 changes: 8 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@
"build.modern": "shx cp -r ./dist/actions/* ./dist/modern",
"bump": "ncu -u -x numerous,execa,prettier,@types/node,eslint,@types/eslint && pnpm update && pnpx typesync && pnpm run clean",
"clean": "shx rm -rf ./dist ./packages/*/dist ./exe ./.parcel-cache && shx mkdir -p ./dist/legacy ./dist/actions ./dist/modern ",
"copy.matchers": "run-p copy.matchers.legacy copy.matchers.actions",
"copy.matchers.legacy": "shx cp ./src/gcc/gcc_matcher.json ./dist/legacy/ && shx cp ./src/msvc/msvc_matcher.json ./dist/legacy/ && shx cp ./src/python/python_matcher.json ./dist/legacy/ && shx cp ./src/llvm/llvm_matcher.json ./dist/legacy/",
"copy.matchers.actions": "shx cp ./src/gcc/gcc_matcher.json ./dist/actions/ && shx cp ./src/msvc/msvc_matcher.json ./dist/actions/ && shx cp ./src/python/python_matcher.json ./dist/actions/ && shx cp ./src/llvm/llvm_matcher.json ./dist/actions/",
"copy.matchers": "shx cp ./src/*/*.json ./dist/legacy/ && shx cp ./dist/legacy/*.json ./dist/actions",
"dev.parcel": "cross-env NODE_ENV=development parcel watch",
"dev.packages": "turbo dev",
"dev": "run-p dev.packages dev.parcel",
Expand Down Expand Up @@ -67,6 +65,12 @@
"@babel/plugin-transform-private-methods": "^7.25.4",
"@biomejs/biome": "^1.8.3",
"@iarna/toml": "^2.2.5",
"@octokit/core": "^6.1.2",
"@octokit/openapi-types": "^22.2.0",
"@octokit/plugin-paginate-rest": "^11.3.3",
"@octokit/plugin-rest-endpoint-methods": "^13.2.4",
"@octokit/rest": "^21.0.2",
"@octokit/types": "^13.5.0",
"@shockpkg/archive-files": "github:aminya/archive-files#54ec59fad46aca736ac6feb6c7bb526528141b9d",
"@swc/jest": "^0.2.36",
"@types/cross-spawn": "^6.0.6",
Expand Down Expand Up @@ -115,6 +119,7 @@
"prettier-config-atomic": "^4.0.0",
"readme-md-generator": "^1.0.0",
"retry-as-promised": "^7.0.4",
"safe-stable-stringify": "^2.5.0",
"semver": "7.6.3",
"setup-apt": "workspace:*",
"setup-brew": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion packages/setup-brew/src/install-pack.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { join } from "path"
import { info } from "ci-log"
/* eslint-disable require-atomic-updates */
import { execaSync } from "execa"
import which from "which"
import type { InstallationInfo } from "./InstallationInfo.js"
import { getBrewBinDir, setupBrew } from "./install.js"

/* eslint-disable require-atomic-updates */
let hasBrew = false

export type BrewPackOptions = {
Expand Down
150 changes: 150 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 31 additions & 3 deletions src/gcc/__tests__/gcc.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { execaSync } from "execa"
import { chmod } from "fs/promises"
import { addExeExt, join } from "patha"
import { isUbuntu } from "../../utils/env/isUbuntu.js"
import { ubuntuVersion } from "../../utils/env/ubuntu_version.js"
import { cleanupTmpDir, setupTmpDir, testBin } from "../../utils/tests/test-helpers.js"
import { getVersion } from "../../versions/versions.js"
Expand All @@ -14,13 +15,40 @@ describe("setup-gcc", () => {
})

it("should setup gcc", async () => {
const version = getVersion("gcc", undefined, await ubuntuVersion())
const ubuntuVersionOutput = await ubuntuVersion()
const version = getVersion("gcc", undefined, ubuntuVersionOutput)
const installInfo = await setupGcc(version, directory, process.arch)

let gpp = "g++"
if (process.platform !== "win32") {
gpp = `g++-${version}`
if (isUbuntu()) {
const ubuntuMajorVersion = ubuntuVersionOutput?.[0]
// https://packages.ubuntu.com/search?keywords=gcc
switch (ubuntuMajorVersion) {
case 26:
case 25:
gpp = "g++-14"
break
case 24:
case 23:
gpp = "g++-13"
break
case 22:
case 21:
gpp = "g++-11"
break
case 20:
gpp = "g++-9"
break
default: {
// ignore
}
}
} else if (process.platform === "darwin") {
// https://formulae.brew.sh/formula/gcc
// As of 3, Sep, 2024
gpp = "g++-14"
}

await testBin(gpp, ["--version"], installInfo?.binDir)

expect(process.env.CC?.includes("gcc")).toBeTruthy()
Expand Down
14 changes: 14 additions & 0 deletions src/gcc/assets-list.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { saveGitHubAssetList } from "../utils/github/fetch-assets.ts"

/**
* Generate the list of all releases of a GitHub repository and save it to a json file
*/
async function main() {
// https://github.com/brechtsanders/winlibs_mingw/releases
await saveGitHubAssetList("brechtsanders", "winlibs_mingw", "./src/gcc/github_brechtsanders_winlibs_mingw.json")
}

main().catch((err) => {
console.error(err)
process.exit(1)
})
Loading
Loading