Sitelet https://github.com/aminya/setup-cpp/pull/479/files
Skip to content
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Setting up a **cross-platform** environment for building and testing C++/C proje
| category | tools |
| --------------- | ----------------------------------------------------------------------------------------------------------- |
| compiler | llvm, gcc, msvc, apple-clang, vcvarsall |
| build system | cmake, ninja, meson, make, task, bazel |
| build system | cmake, ninja, meson, make, autoreconf, task, bazel |
| package manager | vcpkg, conan, choco, brew, apt-fast, nala, git, setup-cpp |
| analyzer/linter | clang-tidy, clang-format, cppcheck, cpplint, flawfinder, lizard, infer, cmakelang, cmake-format, cmake-lint |
| cache | ccache, sccache |
Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ inputs:
make:
description: "Wether to install make (true/false) or the specific version to install."
required: false
autoreconf:
description: "Wether to install autoreconf (true/false) or the specific version to install."
required: false
task:
description: "Wether to install task (true/false) or the specific version to install."
required: false
Expand Down
1 change: 1 addition & 0 deletions cspell.config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ words:
- cmakeformat
- cmakelang
- cmakelint
- autoreconf
- cobertura
- copr
- CPATH
Expand Down
124 changes: 62 additions & 62 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.

122 changes: 61 additions & 61 deletions 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.

18 changes: 17 additions & 1 deletion src/__tests__/main.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
process.env.SETUP_CPP_SKIP_MAIN = "true"
import { getCompilerInfo } from "../compilers.js"
import { parseArgs } from "../setup-cpp.js"
import { parseArgs, printHelp } from "../setup-cpp.js"
import { type Inputs, llvmTools } from "../tool.js"
import { getVersion, syncVersions } from "../versions/versions.js"

Expand Down Expand Up @@ -108,6 +108,22 @@ describe("syncVersion", () => {
})
})

describe("CLI help", () => {
it("lists autoreconf among build system tools", () => {
const table = jest.spyOn(console, "table").mockImplementation(() => undefined)

printHelp()

expect(table).toHaveBeenCalledWith(
expect.objectContaining({
"build system": { tools: "--cmake, --ninja, --meson, --make, --autoreconf, --task, --bazel" },
}),
["tools"],
)
table.mockRestore()
})
})

describe("getVersion", () => {
it("gcovr", () => {
expect(getVersion("gcovr", "5.0")).toBe("5.0")
Expand Down
18 changes: 18 additions & 0 deletions src/autoreconf/__tests__/autoreconf.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import type { InstallationInfo } from "../../utils/setup/setupBin.js"
import { testBin } from "../../utils/tests/test-helpers.js"
import { setupAutoreconf } from "../autoreconf.js"

jest.setTimeout(300000)

const unixDescribe = process.platform === "win32" ? describe.skip : describe

unixDescribe("setup-autoreconf", () => {
it("should setup autoreconf", async () => {
const installInfo = await setupAutoreconf()
const binDir = (installInfo as InstallationInfo | undefined)?.binDir

await testBin("autoreconf", ["--version"])
await testBin("automake", ["--version"])
await testBin("libtoolize", ["--version"], binDir)
})
})
50 changes: 50 additions & 0 deletions src/autoreconf/autoreconf.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { join } from "path"
import { addPath } from "envosman"
import { hasApk, installApkPack } from "setup-alpine"
import { hasAptGet, installAptPack } from "setup-apt"
import { getBrewDir, installBrewPack } from "setup-brew"
import { rcOptions } from "../options.js"
import type { SetupOptions } from "../setup-options.js"
import { hasDnf } from "../utils/env/hasDnf.js"
import { isArch } from "../utils/env/isArch.js"
import { setupDnfPack } from "../utils/setup/setupDnfPack.js"
import { setupPacmanPack } from "../utils/setup/setupPacmanPack.js"

const packages = ["autoconf", "autoconf-archive", "automake", "libtool"] as const

export async function setupAutoreconf({ version }: Partial<Pick<SetupOptions, "version">> = {}) {
switch (process.platform) {
case "darwin": {
for (const name of packages) {
// These installs are intentionally sequential so Homebrew can update its linked tool paths.
// eslint-disable-next-line no-await-in-loop
await installBrewPack(name, version)
}

const gnuBinDir = join(getBrewDir(), "opt/libtool/libexec/gnubin")
await addPath(gnuBinDir, rcOptions)
return { binDir: gnuBinDir }
}
case "linux":
if (isArch()) {
for (const name of packages) {
// pacman package setup is sequential because the shared helper initializes the repository once.
// eslint-disable-next-line no-await-in-loop
await setupPacmanPack(name, version)
}
return { binDir: "/usr/bin/" }
}
if (hasDnf()) {
return setupDnfPack(packages.map((name) => ({ name, version })))
}
if (hasAptGet()) {
return installAptPack(packages.map((name) => ({ name, version })))
}
if (await hasApk()) {
return installApkPack(packages.map((name) => ({ name, version })))
}
throw new Error("Unsupported linux distribution")
default:
throw new Error("Unsupported platform")
}
}
4 changes: 2 additions & 2 deletions src/setup-cpp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export function parseArgs(args: string[]): CliOpts {
})
}

function printHelp() {
export function printHelp() {
info(`
setup-cpp [options]
setup-cpp --compiler llvm --cmake true --ninja true --ccache true --vcpkg true
Expand All @@ -114,7 +114,7 @@ All the available tools:
tools: "--llvm, --gcc, --msvc, --apple-clang, --vcvarsall",
},
"build system": {
tools: "--cmake, --ninja, --meson, --make, --task, --bazel",
tools: "--cmake, --ninja, --meson, --make, --autoreconf, --task, --bazel",
},
"package manager": { tools: "--vcpkg, --conan, --choco, --brew, --apt-fast, --nala, --git, --setup-cpp" },
"analyzer/linter": {
Expand Down
2 changes: 2 additions & 0 deletions src/tool.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { type InstallationInfo, setupAptFast, setupNala } from "setup-apt"
import { type SetupBrewOptions, setupBrew } from "setup-brew"
import { setupAutoreconf } from "./autoreconf/autoreconf.js"
import { setupBazel } from "./bazel/bazel.js"
import { setupCcache } from "./ccache/ccache.js"
import { setupChocolatey } from "./chocolatey/chocolatey.js"
Expand Down Expand Up @@ -79,6 +80,7 @@ export const setups = {
...appleClangSetups,
...cmakeLangSetups,
cmake: setupCmake,
autoreconf: setupAutoreconf,
ninja: setupNinja,
vcpkg: setupVcpkg,
bazel: setupBazel,
Expand Down
Loading