Skip to content

Commit d857140

Browse files
authored
Merge pull request #425 from aminya/windows-llvm
fix: prefer complete Window LLVM package + add tar tool
2 parents d09e6b8 + aa0fcb9 commit d857140

File tree

14 files changed

+165
-79
lines changed

14 files changed

+165
-79
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Setting up a **cross-platform** environment for building and testing C++/C proje
3636
| cache | ccache, sccache |
3737
| documentation | doxygen, graphviz |
3838
| coverage | gcovr, opencppcoverage, kcov |
39-
| other | python, powershell, sevenzip |
39+
| other | python, powershell, sevenzip, tar |
4040

4141
`setup-cpp` automatically handles the dependencies of the selected tool (e.g., `python` is required for `conan`).
4242

action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,9 @@ inputs:
166166
git:
167167
description: "Wether to install git (true/false) or the specific version to install."
168168
required: false
169+
tar:
170+
description: "Wether to install tar (true/false) or the specific version to install."
171+
required: false
169172

170173
runs:
171174
using: "node20"

cspell.config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ words:
6060
- gcovr
6161
- ghes
6262
- Graphviz
63+
- gtar
6364
- hadolint
6465
- iarna
6566
- inja

dist/legacy/setup-cpp.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/legacy/setup-cpp.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/modern/setup-cpp.mjs

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

dist/modern/setup-cpp.mjs.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/llvm/llvm_url.ts

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@ import { loadAssetList, matchAsset } from "../utils/asset/load-assets.js"
77
import { arm64, armv7, powerpc64le, sparc64, sparcv9, x86, x86_64 } from "../utils/env/arch.js"
88
import { hasDnf } from "../utils/env/hasDnf.js"
99
import { ubuntuVersion } from "../utils/env/ubuntu_version.js"
10-
import { extractTarByExe, getArchiveType, getExtractFunction } from "../utils/setup/extract.js"
10+
import {
11+
ArchiveType,
12+
extract7Zip,
13+
extractTarByExe,
14+
getArchiveType,
15+
getExtractFunction,
16+
} from "../utils/setup/extract.js"
1117
import type { PackageInfo } from "../utils/setup/setupBin.js"
1218

1319
const dirname = typeof __dirname === "string" ? __dirname : path.dirname(fileURLToPath(import.meta.url))
@@ -20,16 +26,20 @@ export async function getLLVMPackageInfo(
2026
const url = await getLLVMAssetURL(platform, arch, version)
2127
info(`Downloading LLVM from ${url}`)
2228

29+
const archiveType = getArchiveType(url)
2330
return {
2431
url,
2532
extractedFolderName: "",
2633
binRelativeDir: "bin",
2734
binFileName: addExeExt("clang"),
28-
extractFunction: platform === "win32"
29-
? getExtractFunction(getArchiveType(url))
30-
: (file: string, dest: string) => {
31-
return extractTarByExe(file, dest, 1)
32-
},
35+
extractFunction:
36+
(archiveType === ArchiveType.Tar || archiveType === ArchiveType.TarGz || archiveType === ArchiveType.TarXz)
37+
? (file: string, dest: string) => {
38+
return process.platform === "win32"
39+
? extract7Zip(file, dest, true)
40+
: extractTarByExe(file, dest, 1)
41+
}
42+
: getExtractFunction(archiveType),
3343
}
3444
}
3545

@@ -83,8 +93,8 @@ async function getAssetKeywords(platform: string, arch: string) {
8393

8494
switch (platform) {
8595
case "win32": {
86-
// prefer exe over tar.xz for windows
87-
optionalKeywords.push(".exe", ".exe")
96+
// prefer tar.xz packages of LLVM over exe as they provide a more complete LLVM package
97+
optionalKeywords.push(".tar.xz", ".tar.xz")
8898
const osKeywordsChoice: string[] = []
8999
if (x86_64.includes(arch)) {
90100
osKeywordsChoice.push("win64")

src/setup-cpp.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ All the available tools:
134134
cache: { tools: "--ccache, --sccache" },
135135
documentation: { tools: "--doxygen, --graphviz" },
136136
coverage: { tools: "--gcovr, --opencppcoverage, --kcov" },
137-
other: { tools: "--python, --powershell, --sevenzip" },
137+
other: { tools: "--python, --powershell, --sevenzip, --tar" },
138138
},
139139
["tools"],
140140
)

src/tar/__tests__/tar.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import type { InstallationInfo } from "../../utils/setup/setupBin.js"
2+
import { testBin } from "../../utils/tests/test-helpers.js"
3+
import { setupTar } from "../tar.js"
4+
5+
jest.setTimeout(300000)
6+
describe("setup-tar", () => {
7+
it("should setup tar", async () => {
8+
const installInfo = await setupTar("", "", process.arch)
9+
10+
await testBin("tar", ["--version"], (installInfo as InstallationInfo | undefined)?.binDir)
11+
})
12+
})

0 commit comments

Comments
 (0)