fix: extract CMake packages using tar exe

This commit is contained in:
Amin Yahyaabadi 2024-08-08 13:28:20 -07:00
parent f7abbbcc5d
commit 76b3fd37b4
No known key found for this signature in database
GPG Key ID: F52AF77F636088F0
15 changed files with 97 additions and 26 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

2
dist/modern/hdi.c45e802a.js vendored Normal file

File diff suppressed because one or more lines are too long

1
dist/modern/hdi.c45e802a.js.map vendored Normal file

File diff suppressed because one or more lines are too long

72
dist/modern/setup-cpp.js vendored Normal file

File diff suppressed because one or more lines are too long

1
dist/modern/setup-cpp.js.map vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -29,14 +29,13 @@
"scripts": {
"build": "run-s clean build.packages && run-p lint.tsc build.parcel copy.matchers",
"build.packages": "pnpm run -r build",
"build.parcel": "cross-env NODE_ENV=production parcel build --detailed-report 10 && run-s build.babel",
"build.parcel": "cross-env NODE_ENV=production parcel build && run-s build.babel && shx cp -r ./dist/actions/* ./dist/modern",
"build.babel": "babel ./dist --out-dir dist --plugins @upleveled/babel-plugin-remove-node-prefix --plugins @babel/plugin-transform-private-methods --compact --no-babelrc --source-maps true",
"bump": "ncu -u -x numerous,execa,prettier,@types/node,eslint,@types/eslint && pnpm update && pnpx typesync",
"clean": "shx rm -rf ./dist ./exe ./packages/*/dist/ ./.parcel-cache && shx mkdir -p ./dist/legacy ./dist/actions ./dist/modern ",
"copy.matchers": "run-p copy.matchers.legacy copy.matchers.actions copy.matchers.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.modern": "shx cp ./src/gcc/gcc_matcher.json ./dist/modern/ && shx cp ./src/msvc/msvc_matcher.json ./dist/modern/ && shx cp ./src/python/python_matcher.json ./dist/modern/ && shx cp ./src/llvm/llvm_matcher.json ./dist/modern/",
"dev": "cross-env NODE_ENV=development parcel watch",
"docs": "shx rm -rf packages/*/README.md && pnpm -r exec readme --path ../../dev/readme/template.md -y && pnpm -r exec ts-readme",
"format": "run-s lint.dprint",
@ -203,15 +202,6 @@
"includeNodeModules": true,
"optimize": true,
"outputFormat": "commonjs"
},
"modern": {
"context": "node",
"engines": {
"node": ">=20.x"
},
"includeNodeModules": true,
"optimize": true,
"outputFormat": "commonjs"
}
}
}

View File

@ -1,8 +1,7 @@
import { extractTar } from "@actions/tool-cache"
import { addExeExt } from "patha"
import semverCoerce from "semver/functions/coerce"
import semverLte from "semver/functions/lte"
import { extractZip } from "../utils/setup/extract"
import { extractTarByExe, extractZip } from "../utils/setup/extract"
import { type InstallationInfo, type PackageInfo, setupBin } from "../utils/setup/setupBin"
/** Get the platform data for cmake */
@ -34,7 +33,7 @@ function getCmakePackageInfo(version: string, platform: NodeJS.Platform, arch: s
binRelativeDir: "CMake.app/Contents/bin/",
binFileName: addExeExt("cmake"),
extractedFolderName: folderName,
extractFunction: extractTar,
extractFunction: extractTarByExe,
url: `https://github.com/Kitware/CMake/releases/download/v${version}/${folderName}.tar.gz`,
}
}
@ -51,7 +50,7 @@ function getCmakePackageInfo(version: string, platform: NodeJS.Platform, arch: s
binRelativeDir: "bin/",
binFileName: addExeExt("cmake"),
extractedFolderName: folderName,
extractFunction: extractTar,
extractFunction: extractTarByExe,
url: `https://github.com/Kitware/CMake/releases/download/v${version}/${folderName}.tar.gz`,
}
}

View File

@ -38,7 +38,7 @@ function getBuildKcovPackageInfo(version: string): PackageInfo {
}
async function buildKcov(file: string, dest: string) {
const out = await extractTarByExe(file, dest, ["--strip-components=1"])
const out = await extractTarByExe(file, dest, 1)
// build after extraction using CMake
const cmake = await getCmake()

View File

@ -332,7 +332,7 @@ export async function getLLVMPackageInfo(
extractFunction: platform === "win32"
? extractExe
: (file: string, dest: string) => {
return extractTarByExe(file, dest, ["--strip-components=1"])
return extractTarByExe(file, dest, 1)
},
}
}

View File

@ -37,7 +37,7 @@ export function extractZip(file: string, dest: string) {
return extract7Zip(file, dest)
}
export async function extractTarByExe(file: string, dest: string, flags = ["--strip-components=0"]) {
export async function extractTarByExe(file: string, dest: string, stripComponents: number = 0, flags: string[] = []) {
try {
await mkdirP(dest)
} catch {
@ -48,7 +48,9 @@ export async function extractTarByExe(file: string, dest: string, flags = ["--st
// https://github.com/heroku/heroku-slugs/issues/3
try {
await execa("tar", ["xf", file, "-C", dest, ...flags], { stdio: "inherit" })
await execa("tar", ["xf", file, "-C", dest, `--strip-components=${stripComponents}`, ...flags], {
stdio: "inherit",
})
} catch (e) {
if (process.platform === "win32" && (e as Error).message.includes("Can't create '\\\\?\\C:")) {
warning(`Failed to extract symlink ${file} to ${dest}. Ignoring this symlink.`)