mirror of https://github.com/aminya/setup-cpp
Merge pull request #40 from aminya/cpath [skip ci]
This commit is contained in:
commit
039cf1016b
|
@ -87,6 +87,9 @@ jobs:
|
||||||
matrix:
|
matrix:
|
||||||
os:
|
os:
|
||||||
- ubuntu-20.04
|
- ubuntu-20.04
|
||||||
|
container:
|
||||||
|
- "ubuntu_node.dockerfile"
|
||||||
|
- "ubuntu_stable_node.dockerfile"
|
||||||
node:
|
node:
|
||||||
- 14
|
- 14
|
||||||
pnpm:
|
pnpm:
|
||||||
|
@ -124,6 +127,6 @@ jobs:
|
||||||
- name: Build
|
- name: Build
|
||||||
id: docker_build
|
id: docker_build
|
||||||
run: |
|
run: |
|
||||||
pnpm build.docker
|
docker build -f ./building/docker/${{ matrix.container }} -t setup_cpp .
|
||||||
env:
|
env:
|
||||||
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
|
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
|
||||||
|
|
|
@ -178,8 +178,7 @@ jobs:
|
||||||
Here is an example for using setup_cpp to make a builder image that has the Cpp tools you need.
|
Here is an example for using setup_cpp to make a builder image that has the Cpp tools you need.
|
||||||
|
|
||||||
```dockerfile
|
```dockerfile
|
||||||
# debian
|
FROM ubuntu:devel
|
||||||
FROM debian:bullseye
|
|
||||||
|
|
||||||
# add setup_cpp
|
# add setup_cpp
|
||||||
WORKDIR "/"
|
WORKDIR "/"
|
||||||
|
@ -202,7 +201,7 @@ See [this folder](https://github.com/aminya/setup-cpp/tree/master/building/docke
|
||||||
If you want to build the ones included, then run:
|
If you want to build the ones included, then run:
|
||||||
|
|
||||||
```ps1
|
```ps1
|
||||||
docker build -f ./building/docker/debian.dockerfile -t setup_cpp .
|
docker build -f ./building/docker/ubuntu.dockerfile -t setup_cpp .
|
||||||
```
|
```
|
||||||
|
|
||||||
Where you should use the path to the dockerfile after `-f`.
|
Where you should use the path to the dockerfile after `-f`.
|
||||||
|
@ -242,7 +241,7 @@ The following gives an example for setting up a C++ environment inside GitLab pi
|
||||||
.gitlab-ci.yaml
|
.gitlab-ci.yaml
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
image: ubuntu:latest
|
image: ubuntu:devel
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
- test
|
- test
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
# a tiny debian with node installed
|
|
||||||
FROM node:16-slim
|
|
||||||
|
|
||||||
# add setup_cpp.js
|
|
||||||
ADD "./dist/" "/"
|
|
||||||
WORKDIR "/"
|
|
||||||
|
|
||||||
# run installation
|
|
||||||
RUN node ./setup_cpp.js --compiler llvm --cmake true --ninja true --ccache true --conan true --vcpkg true
|
|
||||||
|
|
||||||
# reload the environment
|
|
||||||
CMD source ~/.profile
|
|
||||||
|
|
||||||
ENTRYPOINT [ "/bin/sh" ]
|
|
|
@ -1,5 +1,4 @@
|
||||||
# debian
|
FROM ubuntu:devel
|
||||||
FROM debian:bullseye
|
|
||||||
|
|
||||||
# add setup_cpp
|
# add setup_cpp
|
||||||
WORKDIR "/"
|
WORKDIR "/"
|
|
@ -1,5 +1,7 @@
|
||||||
# debian with node installed
|
FROM ubuntu:devel
|
||||||
FROM node:16
|
|
||||||
|
RUN apt-get update -qq
|
||||||
|
RUN apt-get install -y --no-install-recommends nodejs
|
||||||
|
|
||||||
# add setup_cpp.js
|
# add setup_cpp.js
|
||||||
ADD "./dist/" "/"
|
ADD "./dist/" "/"
|
|
@ -0,0 +1,24 @@
|
||||||
|
FROM ubuntu:latest
|
||||||
|
|
||||||
|
# set time-zone
|
||||||
|
ENV TZ=Canada/Pacific
|
||||||
|
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
||||||
|
|
||||||
|
# The nodejs that ships on ubuntu:latest servers is too old.
|
||||||
|
ENV DEBIAN_FRONTEND=noninteractive
|
||||||
|
RUN apt-get update -qq
|
||||||
|
RUN apt-get install -y --no-install-recommends curl gnupg ca-certificates
|
||||||
|
RUN curl -fsSL https://deb.nodesource.com/setup_lts.x | bash -
|
||||||
|
RUN apt-get install -y --no-install-recommends nodejs
|
||||||
|
|
||||||
|
# add setup_cpp.js
|
||||||
|
ADD "./dist/" "/"
|
||||||
|
WORKDIR "/"
|
||||||
|
|
||||||
|
# run installation
|
||||||
|
RUN node ./setup_cpp.js --compiler llvm --cmake true --ninja true --cppcheck true --ccache true --vcpkg true --doxygen true --gcovr true
|
||||||
|
|
||||||
|
# reload the environment and print the versions
|
||||||
|
CMD source ~/.profile && clang --version && cmake --version && ninja --version && ccache --version && cppcheck --version && vcpkg --version && doxygen --version && dot --version && gcovr --version
|
||||||
|
|
||||||
|
ENTRYPOINT [ "/bin/sh" ]
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -13,7 +13,7 @@
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "cross-env NODE_ENV=production parcel build --detailed-report && npm run copy.matchers",
|
"build": "cross-env NODE_ENV=production parcel build --detailed-report && npm run copy.matchers",
|
||||||
"build.docker": "pnpm build && docker build -f ./building/docker/debian_node.dockerfile -t setup_cpp .",
|
"build.docker": "pnpm build && docker build -f ./building/docker/ubuntu_node.dockerfile -t setup_cpp .",
|
||||||
"bump": "ncu -u -x execa",
|
"bump": "ncu -u -x execa",
|
||||||
"clean": "shx rm -rf .parcel-cache dist exe",
|
"clean": "shx rm -rf .parcel-cache dist exe",
|
||||||
"copy.matchers": "shx cp ./src/gcc/gcc_matcher.json ./dist/ && shx cp ./src/msvc/msvc_matcher.json ./dist && shx cp ./src/python/python_matcher.json ./dist/ && shx cp ./src/llvm/llvm_matcher.json ./dist/ ",
|
"copy.matchers": "shx cp ./src/gcc/gcc_matcher.json ./dist/ && shx cp ./src/msvc/msvc_matcher.json ./dist && shx cp ./src/python/python_matcher.json ./dist/ && shx cp ./src/llvm/llvm_matcher.json ./dist/ ",
|
||||||
|
|
|
@ -10,7 +10,7 @@ const DefaultVersions: Record<string, string> = {
|
||||||
python: "3.8.10",
|
python: "3.8.10",
|
||||||
kcov: "v39",
|
kcov: "v39",
|
||||||
task: "3.10.0",
|
task: "3.10.0",
|
||||||
doxygen: process.platform === "win32" ? "1.9.3.20220106" : "1.9.3",
|
doxygen: "1.9.2",
|
||||||
gcc: process.platform === "win32" ? "11.2.0.07112021" : "11",
|
gcc: process.platform === "win32" ? "11.2.0.07112021" : "11",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
import { testBin } from "../../utils/tests/test-helpers"
|
import { testBin } from "../../utils/tests/test-helpers"
|
||||||
import { setupGcc } from "../gcc"
|
import { setupGcc } from "../gcc"
|
||||||
import { getVersion } from "../../default_versions"
|
import { getVersion } from "../../default_versions"
|
||||||
|
import path from "path"
|
||||||
|
import execa from "execa"
|
||||||
|
import { addBinExtension } from "../../utils/extension/extension"
|
||||||
|
import { chmodSync } from "fs"
|
||||||
|
|
||||||
jest.setTimeout(3000000)
|
jest.setTimeout(3000000)
|
||||||
describe("setup-gcc", () => {
|
describe("setup-gcc", () => {
|
||||||
|
@ -16,5 +20,14 @@ describe("setup-gcc", () => {
|
||||||
|
|
||||||
expect(process.env.CC?.includes("gcc")).toBeTruthy()
|
expect(process.env.CC?.includes("gcc")).toBeTruthy()
|
||||||
expect(process.env.CXX?.includes("g++")).toBeTruthy()
|
expect(process.env.CXX?.includes("g++")).toBeTruthy()
|
||||||
|
|
||||||
|
// test compilation
|
||||||
|
const file = path.join(__dirname, "main.cpp")
|
||||||
|
const main_exe = path.join(__dirname, addBinExtension("main"))
|
||||||
|
execa.sync("g++", [file, "-o", main_exe], { cwd: __dirname })
|
||||||
|
if (process.platform !== "win32") {
|
||||||
|
chmodSync(main_exe, "755")
|
||||||
|
}
|
||||||
|
execa.sync(main_exe, { cwd: __dirname, stdio: "inherit" })
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
// test std libraries
|
||||||
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
// test c libraries
|
||||||
|
#include <cassert>
|
||||||
|
#include <cctype>
|
||||||
|
#include <cstddef>
|
||||||
|
#include <cstdint>
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
const auto x = 10.0;
|
||||||
|
std::cout << "Testing " << x << '\n';
|
||||||
|
|
||||||
|
const auto y = std::to_string(x);
|
||||||
|
std::cout << "Testing " << y << '\n';
|
||||||
|
}
|
|
@ -43,13 +43,7 @@ export async function setupGcc(version: string, _setupDir: string, arch: string)
|
||||||
"deb http://dk.archive.ubuntu.com/ubuntu/ xenial universe",
|
"deb http://dk.archive.ubuntu.com/ubuntu/ xenial universe",
|
||||||
"ppa:ubuntu-toolchain-r/test",
|
"ppa:ubuntu-toolchain-r/test",
|
||||||
])
|
])
|
||||||
binDir = (
|
binDir = (await setupAptPack("g++", version, [])).binDir
|
||||||
await setupAptPack("g++", version, [
|
|
||||||
"deb http://dk.archive.ubuntu.com/ubuntu/ xenial main",
|
|
||||||
"deb http://dk.archive.ubuntu.com/ubuntu/ xenial universe",
|
|
||||||
"ppa:ubuntu-toolchain-r/test",
|
|
||||||
])
|
|
||||||
).binDir
|
|
||||||
} else {
|
} else {
|
||||||
info(`Install g++-multilib because gcc for ${arch} was requested`)
|
info(`Install g++-multilib because gcc for ${arch} was requested`)
|
||||||
await setupAptPack("gcc-multilib", version, [
|
await setupAptPack("gcc-multilib", version, [
|
||||||
|
@ -57,13 +51,7 @@ export async function setupGcc(version: string, _setupDir: string, arch: string)
|
||||||
"deb http://dk.archive.ubuntu.com/ubuntu/ xenial universe",
|
"deb http://dk.archive.ubuntu.com/ubuntu/ xenial universe",
|
||||||
"ppa:ubuntu-toolchain-r/test",
|
"ppa:ubuntu-toolchain-r/test",
|
||||||
])
|
])
|
||||||
binDir = (
|
binDir = (await setupAptPack("g++-multilib", version, [])).binDir
|
||||||
await setupAptPack("g++-multilib", version, [
|
|
||||||
"deb http://dk.archive.ubuntu.com/ubuntu/ xenial main",
|
|
||||||
"deb http://dk.archive.ubuntu.com/ubuntu/ xenial universe",
|
|
||||||
"ppa:ubuntu-toolchain-r/test",
|
|
||||||
])
|
|
||||||
).binDir
|
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,10 @@ import { getSpecificVersionAndUrl } from "../../utils/setup/version"
|
||||||
import { isValidUrl } from "../../utils/http/validate_url"
|
import { isValidUrl } from "../../utils/http/validate_url"
|
||||||
import { setupTmpDir, cleanupTmpDir, testBin } from "../../utils/tests/test-helpers"
|
import { setupTmpDir, cleanupTmpDir, testBin } from "../../utils/tests/test-helpers"
|
||||||
import { isGitHubCI } from "../../utils/env/isci"
|
import { isGitHubCI } from "../../utils/env/isci"
|
||||||
|
import execa from "execa"
|
||||||
|
import path from "path"
|
||||||
|
import { addBinExtension } from "../../utils/extension/extension"
|
||||||
|
import { chmodSync } from "fs"
|
||||||
|
|
||||||
jest.setTimeout(400000)
|
jest.setTimeout(400000)
|
||||||
async function testUrl(version: string) {
|
async function testUrl(version: string) {
|
||||||
|
@ -22,6 +26,7 @@ describe("setup-llvm", () => {
|
||||||
it("Finds valid LLVM URLs", async () => {
|
it("Finds valid LLVM URLs", async () => {
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
[
|
[
|
||||||
|
"13.0.0",
|
||||||
"12.0.0",
|
"12.0.0",
|
||||||
"12",
|
"12",
|
||||||
"11",
|
"11",
|
||||||
|
@ -43,15 +48,24 @@ describe("setup-llvm", () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should setup LLVM", async () => {
|
it("should setup LLVM", async () => {
|
||||||
const { binDir } = await setupLLVM("11.0.0", directory, process.arch)
|
const { binDir } = await setupLLVM("13.0.0", directory, process.arch)
|
||||||
await testBin("clang++", ["--version"], binDir)
|
await testBin("clang++", ["--version"], binDir)
|
||||||
|
|
||||||
expect(process.env.CC?.includes("clang")).toBeTruthy()
|
expect(process.env.CC?.includes("clang")).toBeTruthy()
|
||||||
expect(process.env.CXX?.includes("clang++")).toBeTruthy()
|
expect(process.env.CXX?.includes("clang++")).toBeTruthy()
|
||||||
|
|
||||||
|
// test compilation
|
||||||
|
const file = path.join(__dirname, "main.cpp")
|
||||||
|
const main_exe = path.join(__dirname, addBinExtension("main"))
|
||||||
|
execa.sync("clang++", [file, "-o", main_exe], { cwd: __dirname })
|
||||||
|
if (process.platform !== "win32") {
|
||||||
|
chmodSync(main_exe, "755")
|
||||||
|
}
|
||||||
|
execa.sync(main_exe, { cwd: __dirname, stdio: "inherit" })
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should find llvm in the cache", async () => {
|
it("should find llvm in the cache", async () => {
|
||||||
const { binDir } = await setupLLVM("11.0.0", directory, process.arch)
|
const { binDir } = await setupLLVM("13.0.0", directory, process.arch)
|
||||||
await testBin("clang++", ["--version"], binDir)
|
await testBin("clang++", ["--version"], binDir)
|
||||||
|
|
||||||
if (isGitHubCI()) {
|
if (isGitHubCI()) {
|
||||||
|
@ -68,7 +82,7 @@ describe("setup-llvm", () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should setup clang-tidy and clang-format", async () => {
|
it("should setup clang-tidy and clang-format", async () => {
|
||||||
const { binDir } = await setupClangTools("11.0.0", directory, process.arch)
|
const { binDir } = await setupClangTools("13.0.0", directory, process.arch)
|
||||||
await testBin("clang-tidy", ["--version"], binDir)
|
await testBin("clang-tidy", ["--version"], binDir)
|
||||||
await testBin("clang-format", ["--version"], binDir)
|
await testBin("clang-format", ["--version"], binDir)
|
||||||
})
|
})
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
// test std libraries
|
||||||
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
// test c libraries
|
||||||
|
#include <cassert>
|
||||||
|
#include <cctype>
|
||||||
|
#include <cstddef>
|
||||||
|
#include <cstdint>
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
const auto x = 10.0;
|
||||||
|
std::cout << "Testing " << x << '\n';
|
||||||
|
|
||||||
|
const auto y = std::to_string(x);
|
||||||
|
std::cout << "Testing " << y << '\n';
|
||||||
|
}
|
|
@ -13,6 +13,8 @@ import { setupAptPack } from "../utils/setup/setupAptPack"
|
||||||
import { warning } from "../utils/io/io"
|
import { warning } from "../utils/io/io"
|
||||||
import { existsSync } from "fs"
|
import { existsSync } from "fs"
|
||||||
import { isGitHubCI } from "../utils/env/isci"
|
import { isGitHubCI } from "../utils/env/isci"
|
||||||
|
import { setupGcc } from "../gcc/gcc"
|
||||||
|
import { getVersion } from "../default_versions"
|
||||||
|
|
||||||
//================================================
|
//================================================
|
||||||
// Version
|
// Version
|
||||||
|
@ -255,7 +257,7 @@ async function _setupLLVM(version: string, setupDir: string, arch: string) {
|
||||||
if (!didInit) {
|
if (!didInit) {
|
||||||
if (process.platform === "linux") {
|
if (process.platform === "linux") {
|
||||||
// install llvm build dependencies
|
// install llvm build dependencies
|
||||||
await setupAptPack("build-essential") // TODO(question) llvm needs ld. But does it need all the build-essential?
|
await setupGcc(getVersion("gcc", undefined), "", arch) // using llvm requires ld, an up to date libstdc++, etc. So, install gcc first
|
||||||
await setupAptPack("libtinfo-dev")
|
await setupAptPack("libtinfo-dev")
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line require-atomic-updates
|
// eslint-disable-next-line require-atomic-updates
|
||||||
|
@ -274,14 +276,14 @@ export async function activateLLVM(directory: string, versionGiven: string) {
|
||||||
|
|
||||||
addEnv("LLVM_PATH", directory) // the output of this action
|
addEnv("LLVM_PATH", directory) // the output of this action
|
||||||
|
|
||||||
const llvmMajor = semverMajor(version)
|
|
||||||
|
|
||||||
// Setup LLVM as the compiler
|
// Setup LLVM as the compiler
|
||||||
addEnv("LD_LIBRARY_PATH", `${lib}${path.delimiter}${ld}`)
|
addEnv("LD_LIBRARY_PATH", `${lib}${path.delimiter}${ld}`)
|
||||||
addEnv("DYLD_LIBRARY_PATH", `${lib}${path.delimiter}${dyld}`)
|
addEnv("DYLD_LIBRARY_PATH", `${lib}${path.delimiter}${dyld}`)
|
||||||
|
|
||||||
if (process.platform !== "win32") {
|
const llvmMajor = semverMajor(version)
|
||||||
// https://github.com/aminya/setup-cpp/issues/6
|
if (existsSync(`${directory}/lib/clang/${version}/include`)) {
|
||||||
|
addEnv("CPATH", `${directory}/lib/clang/${version}/include`)
|
||||||
|
} else if (existsSync(`${directory}/lib/clang/${llvmMajor}/include`)) {
|
||||||
addEnv("CPATH", `${directory}/lib/clang/${llvmMajor}/include`)
|
addEnv("CPATH", `${directory}/lib/clang/${llvmMajor}/include`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,9 @@ export async function setupAptPack(
|
||||||
"ca-certificates",
|
"ca-certificates",
|
||||||
"gnupg",
|
"gnupg",
|
||||||
])
|
])
|
||||||
|
await execSudo("apt-key", ["adv", "--keyserver", "keyserver.ubuntu.com", "--recv-keys", "3B4FE6ACC0B21F32"])
|
||||||
|
await execSudo("apt-key", ["adv", "--keyserver", "keyserver.ubuntu.com", "--recv-keys", "40976EAF437D05B5"])
|
||||||
|
await execSudo("apt-key", ["adv", "--keyserver", "keyserver.ubuntu.com", "--recv-keys", "1E9377A2BA9EF27F"])
|
||||||
didInit = true
|
didInit = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue