Merge branch 'master' into feature/cross-mingw

This commit is contained in:
abeimler 2023-04-02 01:32:43 +02:00
parent ae58022c4b
commit a2d7d8fb1b
41 changed files with 1700 additions and 1352 deletions

View File

@ -103,16 +103,16 @@ jobs:
gzip: folders
draft: true
files: >
./exe/setup_cpp_windows.exe
./exe/setup_cpp_linux
./exe/setup_cpp_mac
./dist/node12/setup_cpp.js
./dist/node12/setup_cpp.js.map
./exe/setup-cpp-x64-windows.exe
./exe/setup-cpp-x64-linux
./exe/setup-cpp-x64-macos
./dist/node12/setup-cpp.js
./dist/node12/setup-cpp.js.map
./dist/node12/
./dist/node16/
Docker:
if: ${{ !contains(github.event.head_commit.message, '[skip ci]') && !contains(github.event.head_commit.message, '[skip docker]') }}
if: ${{ !contains(github.event.head_commit.message, '[skip ci]') && !contains(github.event.head_commit.message, '[skip test]') }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
@ -166,4 +166,4 @@ jobs:
- name: Build
id: docker_build
run: |
docker build -f ./dev/docker/${{ matrix.container }} -t setup_cpp .
docker build -f ./dev/docker/${{ matrix.container }} -t setup-cpp .

View File

@ -7,3 +7,4 @@ stats.html
src/python/setup-python/
src/msvc/msvc-dev-cmd/
dev/cpp_vcpkg_project
package.json

109
README.md
View File

@ -30,69 +30,64 @@ Setting up a **cross-platform** environment for building and testing C++/C proje
### From Terminal
You should download the executable file or the js file (if Nodejs installed), and run it with the available options.
#### With npm and Nodejs
Tip: You can automate downloading using `wget`, `curl`, or other similar tools.
Install setup-cpp with npm:
#### Executable
Download the executable for your platform from [here](https://github.com/aminya/setup-cpp/releases/tag/v0.24.1), and run it with the available options.
An example that installs llvm, cmake, ninja, ccache, and vcpkg:
```ps1
# windows example (open shell as admin)
curl.exe -LJO "https://github.com/aminya/setup-cpp/releases/download/v0.24.1/setup_cpp_windows.exe"
.\setup_cpp_windows --compiler llvm --cmake true --ninja true --ccache true --vcpkg true
RefreshEnv.cmd # activate cpp environment variables
```shell
npm install -g setup-cpp
```
```ps1
# linux example
wget "https://github.com/aminya/setup-cpp/releases/download/v0.24.1/setup_cpp_linux"
chmod +x setup_cpp_linux
sudo ./setup_cpp_linux --compiler llvm --cmake true --ninja true --ccache true --vcpkg true
Then run `setup-cpp` with the available options.
source ~/.cpprc # activate cpp environment variables
```shell
# windows example (open PowerShell as admin)
setup-cpp --compiler llvm --cmake true --ninja true --ccache true --vcpkg true
RefreshEnv.cmd # activate the environment
```
```ps1
# mac example
wget "https://github.com/aminya/setup-cpp/releases/download/v0.24.1/setup_cpp_mac"
chmod +x setup_cpp_mac
sudo ./setup_cpp_mac --compiler llvm --cmake true --ninja true --ccache true --vcpkg true
```shell
# linux/macos example
sudo setup-cpp --compiler llvm --cmake true --ninja true --ccache true --vcpkg true
source ~/.cpprc # activate cpp environment variables
source ~/.cpprc
```
NOTE: In the `compiler` entry, you can specify the version after `-` like `llvm-11.0.0`. For the tools, you can pass a specific version instead of `true` that chooses the default version
NOTE: On Unix systems, when `setup-cpp` is used locally or in other CI services like GitLab, the environment variables are added to `~/.cpprc`. You should run `source ~/.cpprc` to immediately activate the environment variables. This file is automatically sourced in the next shell restart from `~/.bashrc` or `~/.profile` if `SOURCE_CPPRC` is not set to `0`. To deactivate `.cpprc` in the next shell restart, rename/remove `~/.cpprc`.
NOTE: On Unix systems, you will not need `sudo` if you are already a root user (e.g., in a GitLab runner or Docker).
NOTE: On Unix systems, if you are already a root user (e.g., in a GitLab runner or Docker), you will not need to use `sudo`.
#### With Nodejs
#### With executable
Download the `setup_cpp.js` file form [here](https://github.com/aminya/setup-cpp/releases/download/v0.24.1/setup_cpp.js), and run it with the available options.
Download the executable for your platform from [here](https://github.com/aminya/setup-cpp/releases/tag/v0.26.2), and run it with the available options. You can also automate downloading using `wget`, `curl`, or other similar tools.
On Windows:
An example that installs llvm, cmake, ninja, ccache, and vcpkg:
Open the shell as admin, download via `curl`, then install
```ps1
# open shell as admin
curl.exe -LJO "https://github.com/aminya/setup-cpp/releases/download/v0.24.1/setup_cpp.js"
node ./setup_cpp.js --compiler llvm --cmake true --ninja true --ccache true --vcpkg true
```shell
# windows example (open PowerShell as admin)
curl -LJO "https://github.com/aminya/setup-cpp/releases/download/v0.26.2/setup-cpp-x64-windows.exe"
./setup-cpp-x64-windows --compiler llvm --cmake true --ninja true --ccache true --vcpkg true
RefreshEnv.cmd # activate cpp environment variables
```
On Linux or Mac:
```shell
# linux example
wget "https://github.com/aminya/setup-cpp/releases/download/v0.26.2/setup-cpp-x64-linux"
chmod +x ./setup-cpp-x64-linux
sudo ./setup-cpp-x64-linux --compiler llvm --cmake true --ninja true --ccache true --vcpkg true
```ps1
wget "https://github.com/aminya/setup-cpp/releases/download/v0.24.1/setup_cpp.js"
sudo node ./setup_cpp.js --compiler llvm --cmake true --ninja true --ccache true --vcpkg true
source ~/.cpprc # activate cpp environment variables
```
```shell
# macos example
wget "https://github.com/aminya/setup-cpp/releases/download/v0.26.2/setup-cpp-x64-macos"
chmod +x ./setup-cpp-x64-macos
sudo ./setup-cpp-x64-macos --compiler llvm --cmake true --ninja true --ccache true --vcpkg true
source ~/.cpprc # activate cpp environment variables
```
@ -160,21 +155,19 @@ jobs:
### Inside Docker
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
#### Base Image
FROM ubuntu:22.04 AS base
# add setup_cpp
WORKDIR "/"
# add setup-cpp
RUN apt-get update -qq
RUN apt-get install -y --no-install-recommends wget
RUN wget --no-verbose "https://github.com/aminya/setup-cpp/releases/download/v0.24.1/setup_cpp_linux"
RUN chmod +x ./setup_cpp_linux
RUN apt-get install -y --no-install-recommends npm
RUN npm install -g setup-cpp
# install llvm, cmake, ninja, and ccache
RUN ./setup_cpp_linux --compiler llvm --cmake true --ninja true --ccache true --vcpkg true --make true
RUN setup-cpp --compiler llvm --cmake true --ninja true --ccache true --vcpkg true --make true
CMD source ~/.cpprc
ENTRYPOINT [ "/bin/bash" ]
@ -199,18 +192,18 @@ See [this folder](https://github.com/aminya/setup-cpp/tree/master/dev/docker), f
If you want to build the ones included, then run:
```ps1
```shell
git clone --recurse-submodules https://github.com/aminya/setup-cpp
cd ./setup-cpp
docker build -f ./dev/docker/ubuntu.dockerfile -t setup_cpp .
docker build -f ./dev/docker/ubuntu.dockerfile -t setup-cpp .
```
Where you should use the path to the dockerfile after `-f`.
After build, run the following to start an interactive shell in your container
```ps1
docker run -it setup_cpp
```shell
docker run -it setup-cpp
```
### Inside Docker inside GitHub Actions
@ -230,7 +223,7 @@ jobs:
- name: Build
id: docker_build
run: |
docker build -f ./dev/docker/debian.dockerfile -t setup_cpp .
docker build -f ./dev/docker/debian.dockerfile -t setup-cpp .
```
### Inside GitLab pipelines
@ -261,10 +254,10 @@ stages:
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 40976EAF437D05B5
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 1E9377A2BA9EF27F
.setup_cpp: &setup_cpp |
curl -LJO "https://github.com/aminya/setup-cpp/releases/download/v0.24.1/setup_cpp_linux"
chmod +x setup_cpp_linux
./setup_cpp_linux --compiler $compiler --cmake true --ninja true --ccache true --vcpkg true
.setup-cpp: &setup-cpp |
curl -LJO "https://github.com/aminya/setup-cpp/releases/download/v0.26.2/setup-cpp-x64-linux"
chmod +x setup-cpp-x64-linux
./setup-cpp-x64-linux --compiler $compiler --cmake true --ninja true --ccache true --vcpkg true
source ~/.cpprc
.test: &test |
@ -277,7 +270,7 @@ test_linux_llvm:
compiler: llvm
script:
- *setup_linux
- *setup_cpp
- *setup-cpp
- *test
test_linux_gcc:
@ -286,7 +279,7 @@ test_linux_gcc:
compiler: gcc
script:
- *setup_linux
- *setup_cpp
- *setup-cpp
- *test
```

View File

@ -81,10 +81,13 @@ inputs:
nala:
description: 'The nala version to install ("" or "legacy").'
required: false
powershell:
description: "The powershell version to install."
required: false
runs:
using: "node16"
main: "dist/node16/setup_cpp.js"
main: "dist/node16/setup-cpp.js"
branding:
icon: "award"

View File

@ -10,30 +10,28 @@ RUN pacman -S --noconfirm --needed nodejs
# curl for downloading setup-cpp
RUN pacman -S --noconfirm --needed curl
# add setup_cpp.js
# add setup-cpp.js
COPY "./dist/node12" "/"
WORKDIR "/"
# run installation
RUN node ./setup_cpp.js --compiler llvm --cmake true --ninja true --cppcheck true --ccache true --vcpkg true --doxygen true --gcovr true --task true
RUN node ./setup-cpp.js --compiler llvm --cmake true --ninja true --cppcheck true --ccache true --vcpkg true --doxygen true --gcovr true --task true
# clean up
RUN pacman -Scc --noconfirm
RUN rm -rf /tmp/*
CMD ["source", "~/.cpprc"]
ENTRYPOINT ["/bin/bash"]
CMD source ~/.cpprc
ENTRYPOINT [ "/bin/bash" ]
#### Building
FROM base AS builder
FROM base as builder
COPY ./dev/cpp_vcpkg_project /home/app
WORKDIR /home/app
RUN bash -c 'source ~/.cpprc \
&& task build'
### Running environment
# use a distroless image or ubuntu:22.04 if you wish
FROM gcr.io/distroless/cc
FROM gcr.io/distroless/cc as runner
# copy the built binaries and their runtime dependencies
COPY --from=builder /home/app/build/my_exe/Release/ /home/app/
WORKDIR /home/app/

View File

@ -1,35 +1,31 @@
## base image
FROM fedora as base
# nodejs
RUN dnf -y install nodejs
# nodejs and curl for downloading setup-cpp
RUN dnf -y install nodejs curl
# curl for downloading setup-cpp
RUN dnf -y install curl
# add setup_cpp.js
# add setup-cpp.js
COPY "./dist/node12" "/"
WORKDIR "/"
# run installation
RUN node ./setup_cpp.js --compiler llvm --cmake true --ninja true --cppcheck true --ccache true --vcpkg true --doxygen true --gcovr true --task true --powershell true
RUN node ./setup-cpp.js --compiler llvm --cmake true --ninja true --cppcheck true --ccache true --vcpkg true --doxygen true --gcovr true --task true --powershell true
# clean up
RUN rm -rf /tmp/*
CMD source ~/.cpprc
CMD ["source", "~/.cpprc"]
ENTRYPOINT [ "/bin/bash" ]
#### Building
FROM base AS builder
FROM base as builder
COPY ./dev/cpp_vcpkg_project /home/app
WORKDIR /home/app
RUN bash -c 'source ~/.cpprc \
&& task build'
### Running environment
# use a distroless image or ubuntu:22.04 if you wish
FROM gcr.io/distroless/cc
FROM gcr.io/distroless/cc as runner
# copy the built binaries and their runtime dependencies
COPY --from=builder /home/app/build/my_exe/Release/ /home/app/
WORKDIR /home/app/

View File

@ -1,29 +1,29 @@
#### Base Image
FROM ubuntu:22.04 AS base
FROM ubuntu:22.04 as base
# add setup_cpp
WORKDIR "/"
# install setup-cpp
RUN apt-get update -qq
RUN apt-get install -y --no-install-recommends wget
RUN wget --no-verbose "https://github.com/aminya/setup-cpp/releases/download/v0.24.1/setup_cpp_linux"
RUN chmod +x ./setup_cpp_linux
RUN apt-get install -y --no-install-recommends npm
RUN npm install -g setup-cpp
# install llvm, cmake, ninja, and ccache
RUN ./setup_cpp_linux --compiler llvm --cmake true --ninja true --ccache true --vcpkg true --task true
RUN setup-cpp --compiler llvm --cmake true --ninja true --ccache true --vcpkg true --task true
CMD ["source", "~/.cpprc"]
ENTRYPOINT ["/bin/bash"]
CMD source ~/.cpprc
ENTRYPOINT [ "/bin/bash" ]
#### Building
FROM base AS builder
ADD ./dev/cpp_vcpkg_project /home/app
FROM base as builder
COPY ./dev/cpp_vcpkg_project /home/app
WORKDIR /home/app
RUN bash -c 'source ~/.cpprc \
&& task build'
### Running environment
# use a distroless image or ubuntu:22.04 if you wish
FROM gcr.io/distroless/cc
FROM gcr.io/distroless/cc as runner
# copy the built binaries and their runtime dependencies
COPY --from=builder /home/app/build/my_exe/Release/ /home/app/
WORKDIR /home/app/

View File

@ -1,4 +1,4 @@
FROM ubuntu:20.04 AS base
FROM ubuntu:20.04 as base
# set time-zone
ENV TZ=Canada/Pacific
@ -8,29 +8,31 @@ RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
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 ["/bin/bash", "-c", "set -o pipefail && curl -fsSL https://deb.nodesource.com/setup_lts.x | bash -"]
RUN apt-get install -y --no-install-recommends nodejs
# add setup_cpp.js
# add setup-cpp.js
COPY "./dist/node12" "/"
WORKDIR "/"
# run installation
RUN node ./setup_cpp.js --compiler llvm --cmake true --ninja true --cppcheck true --ccache true --vcpkg true --doxygen true --gcovr true --task true
RUN node ./setup-cpp.js --compiler llvm --cmake true --ninja true --cppcheck true --ccache true --vcpkg true --doxygen true --gcovr true --task true
CMD ["source", "~/.cpprc"]
ENTRYPOINT ["/bin/bash"]
CMD source ~/.cpprc
ENTRYPOINT [ "/bin/bash" ]
#### Building
FROM base AS builder
ADD ./dev/cpp_vcpkg_project /home/app
FROM base as builder
COPY ./dev/cpp_vcpkg_project /home/app
WORKDIR /home/app
RUN bash -c 'source ~/.cpprc \
&& task build'
### Running environment
# use a distroless image or ubuntu:20.04 if you wish
FROM gcr.io/distroless/cc
FROM gcr.io/distroless/cc as runner
# copy the built binaries and their runtime dependencies
COPY --from=builder /home/app/build/my_exe/Release/ /home/app/
WORKDIR /home/app/

View File

@ -3,20 +3,17 @@ FROM ubuntu:22.04 AS base
RUN apt-get update -qq
RUN apt-get install -y --no-install-recommends nodejs
# add setup_cpp.js
# add setup-cpp.js
COPY "./dist/node12" "/"
WORKDIR "/"
# run installation
RUN node ./setup_cpp.js --compiler llvm --cmake true --ninja true --cppcheck true --ccache true --vcpkg true --doxygen true --gcovr true --task true --powershell true
RUN node ./setup-cpp.js --compiler llvm --cmake true --ninja true --cppcheck true --ccache true --vcpkg true --doxygen true --gcovr true --task true --powershell true
# clean up
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
RUN rm -rf /tmp/*
CMD source ~/.cpprc
CMD ["source", "~/.cpprc"]
ENTRYPOINT [ "/bin/bash" ]
#### Building
FROM base AS builder
COPY ./dev/cpp_vcpkg_project /home/app
@ -24,9 +21,10 @@ WORKDIR /home/app
RUN bash -c 'source ~/.cpprc \
&& task build'
### Running environment
# use a distroless image or ubuntu:22.04 if you wish
FROM gcr.io/distroless/cc
FROM gcr.io/distroless/cc as runner
# copy the built binaries and their runtime dependencies
COPY --from=builder /home/app/build/my_exe/Release/ /home/app/
WORKDIR /home/app/

View File

@ -5,7 +5,7 @@ const { join, dirname } = require("path")
async function main() {
console.log("Disabling debug messages inside @actions/core")
const file = join(dirname(__dirname), "dist", "setup_cpp.js")
const file = join(dirname(__dirname), "dist", "setup-cpp.js")
const { code, map } = await minify(readFileSync(file, "utf8"), { sourceMap: true, ...require("../.terserrc.js") })
writeFileSync(file, code)

View File

@ -7,7 +7,7 @@ function getPlatformName() {
return "windows"
}
case "darwin": {
return "mac"
return "macos"
}
default: {
return process.platform
@ -31,10 +31,10 @@ function main() {
"--input",
"./dist/node16",
"--output",
`./exe/setup_cpp_${getPlatformName()}${exe}`,
`./exe/setup-cpp-${process.arch}-${getPlatformName()}${exe}`,
"--",
`{{caxa}}/node_modules/.bin/node${exe}`,
`{{caxa}}/setup_cpp.js`,
`{{caxa}}/setup-cpp.js`,
])
)
)

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

3
dist/node12/setup-cpp.js vendored Normal file

File diff suppressed because one or more lines are too long

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

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

File diff suppressed because one or more lines are too long

3
dist/node16/setup-cpp.js vendored Normal file

File diff suppressed because one or more lines are too long

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

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

View File

@ -1,6 +1,6 @@
{
"name": "setup-cpp",
"version": "0.24.1",
"version": "0.26.2",
"description": "Install all the tools required for building and testing C++/C projects.",
"repository": "https://github.com/aminya/setup-cpp",
"license": "Apache-2.0",
@ -9,20 +9,29 @@
"import": "./dist/node12/setup-cpp.mjs",
"require": "./dist/node12/setup-cpp.js"
},
"main": "./dist/node12/setup_cpp.js",
"main": "./dist/node12/setup-cpp.js",
"source": "./src/main.ts",
"bin": {
"setup-cpp": "./dist/node12/setup_cpp.js",
"setup_cpp": "./dist/node12/setup_cpp.js"
"setup-cpp": "./dist/node12/setup-cpp.js"
},
"files": [
"dist",
"src",
"packages",
"dev",
"README.md",
"LICENSE.txt",
"LICENSE.dependencies.txt",
"package.json",
"tsconfig.json"
],
"scripts": {
"build": "shx rm -rf dist/ && shx mkdir -p ./dist/node12 ./dist/node16 && run-p lint.tsc build.parcel copy.matchers",
"build.docker": "pnpm build && docker build -f ./dev/docker/ubuntu_node.dockerfile -t setup_cpp .",
"build.docker.arch": "pnpm build && docker build -f ./dev/docker/arch_node.dockerfile -t setup_cpp:arch .",
"build.docker.arch.mingw": "pnpm build && docker build -f ./dev/docker/arch_node.mingw.dockerfile -t setup_cpp:arch-mingw .",
"build.docker.fedora": "pnpm build && docker build -f ./dev/docker/fedora_node.dockerfile -t setup_cpp:fedora .",
"build.docker": "pnpm build && docker build -f ./dev/docker/ubuntu_node.dockerfile -t setup-cpp .",
"build.docker.arch": "pnpm build && docker build -f ./dev/docker/arch_node.dockerfile -t setup-cpp:arch .",
"build.docker.fedora": "pnpm build && docker build -f ./dev/docker/fedora_node.dockerfile -t setup-cpp:fedora .",
"build.docker.fedora.mingw": "pnpm build && docker build -f ./dev/docker/fedora_node.mingw.dockerfile -t setup_cpp:fedora-mingw .",
"build.docker.ubuntu": "pnpm build && docker build -f ./dev/docker/ubuntu_node.dockerfile -t setup_cpp:ubuntu .",
"build.docker.ubuntu": "pnpm build && docker build -f ./dev/docker/ubuntu_node.dockerfile -t setup-cpp:ubuntu .",
"build.docker.ubuntu.mingw": "pnpm build && docker build -f ./dev/docker/ubuntu_node.mingw.dockerfile -t setup_cpp:ubuntu-mingw .",
"build.docker.ubuntu.node16": "pnpm build && docker build -f ./dev/docker/ubuntu_node_16.dockerfile -t setup_cpp:ubuntu-node16 .",
"build.parcel": "cross-env NODE_ENV=production parcel build",
@ -41,82 +50,73 @@
"prepare": "pnpm run -r build && pnpm run -w build",
"start.docker": "docker run -t setup_cpp .",
"start.docker.arch": "docker run -t setup_cpp:arch .",
"start.docker.arch.mingw": "docker run -t setup_cpp:arch-mingw .",
"start.docker.fedora": "docker run -t setup_cpp:fedora .",
"start.docker.fedora.mingw": "docker run -t setup_cpp:fedora-mingw .",
"start.docker.ubuntu": "docker run -t setup_cpp:ubuntu .",
"start.docker.ubuntu.mingw": "docker run -t setup_cpp:ubuntu-mingw .",
"test": "run-p --continue-on-error test.lint test.unit",
"test.docker.arch": "docker build -f ./dev/docker/arch_node.dockerfile --target base -t setup_cpp:arch-base . && container-structure-test test --image setup_cpp:arch-base --config ./dev/container-tests/arch.yml",
"test.docker.arch.mingw": "docker build -f ./dev/docker/arch_node.mingw.dockerfile --target base -t setup_cpp:arch-mingw . && container-structure-test test --image setup_cpp:arch-mingw --config ./dev/container-tests/arch.mingw.yml",
"test.docker.fedora": "docker build -f ./dev/docker/fedora_node.dockerfile --target base -t setup_cpp:fedora-base . && container-structure-test test --image setup_cpp:fedora-base --config ./dev/container-tests/fedora.yml",
"test.docker.fedora.mingw": "docker build -f ./dev/docker/fedora_node.mingw.dockerfile --target base -t setup_cpp:fedora-mingw . && container-structure-test test --image setup_cpp:fedora-mingw --config ./dev/container-tests/fedora.mingw.yml",
"test.docker.ubuntu": "docker build -f ./dev/docker/ubuntu_node.dockerfile --target base -t setup_cpp:ubuntu-base . && container-structure-test test --image setup_cpp:ubuntu-base --config ./dev/container-tests/ubuntu.yml",
"test.docker.ubuntu.mingw": "docker build -f ./dev/docker/ubuntu_node.mingw.dockerfile --target base -t setup_cpp:ubuntu-mingw . && container-structure-test test --image setup_cpp:ubuntu-mingw --config ./dev/container-tests/ubuntu.mingw.yml",
"test.docker.ubuntu.node16": "docker build -f ./dev/docker/ubuntu_node_16.dockerfile --target base -t setup_cpp:ubuntu-node16 . && container-structure-test test --image setup_cpp:ubuntu-node16 --config ./dev/container-tests/ubuntu.node16.yml",
"test.lint": "run-p --aggregate-output --continue-on-error lint.cspell test.lint.eslint test.lint.prettier lint.tsc",
"test.lint.eslint": "eslint **/*.{ts,tsx,js,jsx,cjs,mjs,json,yaml} --no-error-on-unmatched-pattern --cache --cache-location ./.cache/eslint/",
"test.lint.prettier": "prettier . --check",
"test.unit": "jest --runInBand"
},
"prettier": "prettier-config-atomic",
"dependencies": {
"devDependencies": {
"@actions/core": "^1.10.0",
"@actions/exec": "^1.1.1",
"@actions/io": "^1.1.2",
"@actions/tool-cache": "^2.0.1",
"@npmcli/ci-detect": "github:aminya/ci-detect#37fe40075bebec96794ba0a7c4a6d5c70cbea00d",
"@types/cross-spawn": "^6.0.2",
"@types/jest": "^29.2.6",
"@types/mri": "^1.1.1",
"@types/node": "^18.11.18",
"@types/semver": "^7.3.13",
"@types/which": "^2.0.1",
"admina": "^0.1.3",
"caxa": "^3.0.1",
"ci-log": "workspace:1.0.0",
"cross-env": "7.0.3",
"cross-spawn": "^7.0.3",
"cspell": "^6.19.2",
"escape-path-with-spaces": "github:aminya/escape-path-with-spaces#d9f81ee649203ddc55783a2f96ada59df06118e3",
"escape-quotes": "^1.0.2",
"escape-string-regexp": "^5.0.0",
"eslint": "^8.32.0",
"eslint-config-atomic": "^1.18.2",
"exec-powershell": "workspace:1.0.0",
"execa": "^5.1.1",
"gen-readme": "^1.6.0",
"is-url-online": "^1.5.0",
"jest": "^29.3.1",
"mri": "^1.2.0",
"msvc-dev-cmd": "github:aminya/msvc-dev-cmd#9f672c1",
"npm-check-updates": "^16.6.2",
"npm-run-all2": "^6.0.4",
"numerous": "1.0.3",
"parcel": "2.8.3",
"path-exists": "^4.0.0",
"patha": "^0.4.1",
"prettier": "2.7.1",
"prettier-config-atomic": "^3.1.0",
"quote-unquote": "^1.0.0",
"readme-md-generator": "^1.0.0",
"retry-as-promised": "^7.0.3",
"semver": "7.3.8",
"setup-python": "github:actions/setup-python#v4.3.1",
"setup-python": "github:actions/setup-python#v4.5.0",
"shx": "0.3.4",
"terser-config-atomic": "^0.1.1",
"time-delta": "github:aminya/time-delta#69d91a41cef28e569be9a2991129f5f7d1f0d00e",
"ts-jest": "^29.0.5",
"ts-node": "^10.9.1",
"ts-readme": "^1.1.3",
"typescript": "^4.9.4",
"ubuntu-version": "^2.0.0",
"untildify-user": "workspace:1.0.0",
"user-access": "workspace:1.0.0",
"which": "^3.0.0"
},
"devDependencies": {
"@types/cross-spawn": "^6.0.2",
"@types/jest": "^29.2.4",
"@types/mri": "^1.1.1",
"@types/node": "^18.11.15",
"@types/semver": "^7.3.13",
"@types/which": "^2.0.1",
"caxa": "^3.0.1",
"cross-env": "7.0.3",
"cross-spawn": "^7.0.3",
"cspell": "^6.17.0",
"eslint": "^8.29.0",
"eslint-config-atomic": "^1.18.1",
"gen-readme": "^1.6.0",
"jest": "^29.3.1",
"npm-check-updates": "^16.6.0",
"npm-run-all2": "^6.0.4",
"parcel": "2.8.1",
"prettier": "2.7.1",
"prettier-config-atomic": "^3.1.0",
"readme-md-generator": "^1.0.0",
"shx": "0.3.4",
"terser-config-atomic": "^0.1.1",
"ts-jest": "^29.0.3",
"ts-node": "^10.9.1",
"ts-readme": "^1.1.3",
"typescript": "^4.9.4"
},
"engines": {
"node": ">=12.x"
},
@ -143,7 +143,7 @@
"electron": false,
"patha": "patha/dist/index.node.mjs"
},
"main.actions": "./dist/node16/setup_cpp.js",
"main.actions": "./dist/node16/setup-cpp.js",
"pnpm": {
"overrides": {
"semver": "7.3.8",

File diff suppressed because it is too large Load Diff

View File

@ -29,9 +29,22 @@ describe("syncVersion", () => {
expect(syncVersions(parseArgs(["--llvm", "13.0.0", "--clangtidy", "true"]), llvmTools)).toBe(true)
expect(syncVersions(parseArgs(["--llvm", "13.0.0", "--clangtidy", "12.0.0"]), llvmTools)).toBe(false)
const opts = parseArgs(["--llvm", "14.0.0", "--clangtidy", "true"])
expect(syncVersions(opts, llvmTools)).toBe(true)
expect(opts.llvm).toBe(opts.clangtidy)
const opts1 = parseArgs(["--llvm", "14.0.0", "--clangtidy", "true"])
expect(syncVersions(opts1, llvmTools)).toBe(true)
expect(opts1.llvm).toBe(opts1.clangtidy)
expect(opts1.clangformat).toBe(undefined)
const opts2 = parseArgs(["--clangtidy", "15.0.0", "--clangformat", "true"])
expect(syncVersions(opts2, llvmTools)).toBe(true)
expect(opts2.llvm).toBe(undefined)
expect(opts2.clangtidy).toBe("15.0.0")
expect(opts2.clangformat).toBe("15.0.0")
const opts3 = parseArgs(["--llvm", "true", "--clangformat", "true"])
expect(syncVersions(opts3, llvmTools)).toBe(true)
expect(opts3.llvm).toBe("true")
expect(opts3.clangtidy).toBe(undefined)
expect(opts3.clangformat).toBe("true")
})
})

View File

@ -25,7 +25,7 @@ export async function setupBrew(_version: string, _setupDir: string, _arch: stri
}
// brew is not thread-safe
const brewTempDirectory = path.join(tmpdir(), "setup_cpp", "brew")
const brewTempDirectory = path.join(tmpdir(), "setup-cpp", "brew")
await mkdirP(brewTempDirectory)
execa.sync("curl", ["-LJO", "https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh"], {

View File

@ -253,7 +253,7 @@ async function activateGcc(version: string, binDir: string) {
async function addGccLoggingMatcher() {
const matcherPath = join(__dirname, "gcc_matcher.json")
if (!(await pathExists(matcherPath))) {
return warning("the gcc_matcher.json file does not exist in the same folder as setup_cpp.js")
return warning("the gcc_matcher.json file does not exist in the same folder as setup-cpp.js")
}
info(`::add-matcher::${matcherPath}`)
}

View File

@ -132,7 +132,7 @@ export async function setupClangTools(version: string, setupDir: string, arch: s
async function addLLVMLoggingMatcher() {
const matcherPath = join(__dirname, "llvm_matcher.json")
if (!(await pathExists(matcherPath))) {
return warning("the llvm_matcher.json file does not exist in the same folder as setup_cpp.js")
return warning("the llvm_matcher.json file does not exist in the same folder as setup-cpp.js")
}
info(`::add-matcher::${matcherPath}`)
}

View File

@ -1,53 +1,50 @@
import { getInput, endGroup, startGroup, notice } from "@actions/core"
#!/usr/bin/env node
/* eslint-disable node/shebang */
import { endGroup, getInput, notice, startGroup } from "@actions/core"
import ciDetect from "@npmcli/ci-detect"
import { error, info, success, warning } from "ci-log"
import mri from "mri"
import * as numerous from "numerous"
import numerousLocale from "numerous/locales/en.js"
import { join } from "patha"
import semverValid from "semver/functions/valid"
import * as timeDelta from "time-delta"
import timeDeltaLocale from "time-delta/locales/en.js"
import { untildifyUser } from "untildify-user"
import { setupBazel } from "./bazel/bazel"
import { setupBrew } from "./brew/brew"
import { setupCcache } from "./ccache/ccache"
import { setupMake } from "./make/make"
import { setupTask } from "./task/task"
import { setupChocolatey } from "./chocolatey/chocolatey"
import { setupCmake } from "./cmake/cmake"
import { setupConan } from "./conan/conan"
import { setupCppcheck } from "./cppcheck/cppcheck"
import { setupDoxygen } from "./doxygen/doxygen"
import { setupGcc, setupMingw } from "./gcc/gcc"
import { activateGcovGCC, activateGcovLLVM, setupGcovr } from "./gcovr/gcovr"
import { setupLLVM, setupClangTools } from "./llvm/llvm"
import { setupGraphviz } from "./graphviz/graphviz"
import { setupKcov } from "./kcov/kcov"
import { setupClangTools, setupLLVM } from "./llvm/llvm"
import { setupMake } from "./make/make"
import { setupMeson } from "./meson/meson"
import { setupMSVC } from "./msvc/msvc"
import { setupNala } from "./nala/nala"
import { setupNinja } from "./ninja/ninja"
import { setupOpencppcoverage } from "./opencppcoverage/opencppcoverage"
import { setupPython } from "./python/python"
import mri from "mri"
import { untildifyUser } from "untildify-user"
import ciDetect from "@npmcli/ci-detect"
import * as timeDelta from "time-delta"
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import timeDeltaLocale from "time-delta/locales/en.js"
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import * as numerous from "numerous"
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import numerousLocale from "numerous/locales/en.js"
import { ubuntuVersion } from "./utils/env/ubuntu_version"
import semverValid from "semver/functions/valid"
import { getVersion, syncVersions } from "./versions/versions"
import { setupGcc, setupMingw } from "./gcc/gcc"
import { InstallationInfo } from "./utils/setup/setupBin"
import { error, info, success, warning } from "ci-log"
import { setupVcpkg } from "./vcpkg/vcpkg"
import { join } from "patha"
import { setupVCVarsall } from "./vcvarsall/vcvarsall"
import { setupKcov } from "./kcov/kcov"
import { addEnv, finalizeCpprc } from "./utils/env/addEnv"
import { setupSevenZip } from "./sevenzip/sevenzip"
import { setupGraphviz } from "./graphviz/graphviz"
import { setupNala } from "./nala/nala"
import { setupBazel } from "./bazel/bazel"
import { setupPowershell } from "./powershell/powershell"
import { isArch } from "./utils/env/isArch"
import { setupPacmanPack } from "./utils/setup/setupPacmanPack"
import { setupPython } from "./python/python"
import { setupSccache } from "./sccache/sccache"
import { setupSevenZip } from "./sevenzip/sevenzip"
import { setupTask } from "./task/task"
import { addEnv, finalizeCpprc } from "./utils/env/addEnv"
import { isArch } from "./utils/env/isArch"
import { ubuntuVersion } from "./utils/env/ubuntu_version"
import { InstallationInfo } from "./utils/setup/setupBin"
import { setupPacmanPack } from "./utils/setup/setupPacmanPack"
import { setupVcpkg } from "./vcpkg/vcpkg"
import { setupVCVarsall } from "./vcvarsall/vcvarsall"
import { getVersion, syncVersions } from "./versions/versions"
/** The setup functions */
const setups = {
@ -117,7 +114,7 @@ export async function main(args: string[]): Promise<number> {
const timeFormatter = timeDelta.create({ autoloadLocales: true })
timeDelta.addLocale(timeDeltaLocale as timeDelta.Locale)
numerous.addLocale(numerousLocale)
numerous.addLocale(numerousLocale as numerous.Locale)
let time1: number
let time2: number
@ -279,7 +276,7 @@ export async function main(args: string[]): Promise<number> {
await finalizeCpprc()
if (successMessages.length === 0 && errorMessages.length === 0) {
warning("setup_cpp was called without any arguments. Nothing to do.")
warning("setup-cpp was called without any arguments. Nothing to do.")
return 0
}
@ -287,7 +284,7 @@ export async function main(args: string[]): Promise<number> {
successMessages.forEach((tool) => success(tool))
errorMessages.forEach((tool) => error(tool))
info("setup_cpp finished")
info("setup-cpp finished")
if (ciDetect() !== "github-actions") {
switch (process.platform) {
@ -352,8 +349,8 @@ export function getCompilerInfo(maybeCompiler: string) {
function printHelp() {
info(`
setup_cpp [options]
setup_cpp --compiler llvm --cmake true --ninja true --ccache true --vcpkg true
setup-cpp [options]
setup-cpp --compiler llvm --cmake true --ninja true --ccache true --vcpkg true
Install all the tools required for building and testing C++/C projects.

View File

@ -74,7 +74,7 @@ export async function setupMSVC(
async function addMSVCLoggingMatcher() {
const matcherPath = join(__dirname, "msvc_matcher.json")
if (!(await pathExists(matcherPath))) {
return warning("the msvc_matcher.json file does not exist in the same folder as setup_cpp.js")
return warning("the msvc_matcher.json file does not exist in the same folder as setup-cpp.js")
}
info(`::add-matcher::${matcherPath}`)
}

View File

@ -61,7 +61,7 @@ export async function setupActionsPython(version: string, _setupDir: string, arc
async function addPythonLoggingMatcher() {
const matcherPath = join(__dirname, "python_matcher.json")
if (!(await pathExists(matcherPath))) {
return warning("the python_matcher.json file does not exist in the same folder as setup_cpp.js")
return warning("the python_matcher.json file does not exist in the same folder as setup-cpp.js")
}
info(`::add-matcher::${matcherPath}`)
}

13
src/types/numerous.d.ts vendored Normal file
View File

@ -0,0 +1,13 @@
declare module "numerous" {
export type Locale = unknown
/** Adds pluralization data for the specified locale. Should be called in browser. */
export function addLocale(localeData: Locale | Locale[])
}
declare module "numerous/locales/en.js" {
import { Locale } from "numerous"
declare const En = Locale
export = En
}

6
src/types/time-delta.d.ts vendored Normal file
View File

@ -0,0 +1,6 @@
declare module "time-delta/locales/en.js" {
import { Locale } from "time-delta"
declare const En = Locale
export = En
}

View File

@ -93,7 +93,7 @@ async function addPathSystem(path: string) {
case "win32": {
// We do not use `execa.sync(`setx PATH "${path};%PATH%"`)` because of its character limit and also because %PATH% is different for user and system
await execPowershell(
`$USER_PATH=([Environment]::GetEnvironmentVariable("patha", "User")); [Environment]::SetEnvironmentVariable("patha", "${path};$USER_PATH", "User")`
`$USER_PATH=([Environment]::GetEnvironmentVariable("PATH", "User")); [Environment]::SetEnvironmentVariable("PATH", "${path};$USER_PATH", "User")`
)
info(`"${path}" was added to the PATH.`)
return

View File

@ -20,13 +20,13 @@ export const DefaultVersions: Record<string, string> = {
clangtidy: getLLVMDefault(),
clangformat: getLLVMDefault(),
ninja: "1.11.1", // https://github.com/ninja-build/ninja/releases
cmake: "3.25.0", // https://github.com/Kitware/CMake/releases
cmake: "3.25.1", // https://github.com/Kitware/CMake/releases
gcovr: "5.2", // https://pypi.org/project/gcovr/
conan: "1.54.0", // https://github.com/conan-io/conan/releases
meson: "0.64.0", // https://github.com/mesonbuild/meson/releases
conan: "1.57.0", // https://github.com/conan-io/conan/releases
meson: "1.0.0", // https://github.com/mesonbuild/meson/releases
kcov: "40", // https://github.com/SimonKagstrom/kcov/releases
task: "3.18.0", // https://github.com/go-task/task/releases
doxygen: isArch() ? "1.9.5-1" : "1.9.5", // https://www.doxygen.nl/download.html // https://packages.ubuntu.com/search?suite=all&arch=any&searchon=names&keywords=doxygen // https://formulae.brew.sh/formula/doxygen // https://archlinux.org/packages/extra/x86_64/doxygen/
task: "3.20.0", // https://github.com/go-task/task/releases
doxygen: isArch() ? "1.9.6-1" : "1.9.6", // https://www.doxygen.nl/download.html // https://packages.ubuntu.com/search?suite=all&arch=any&searchon=names&keywords=doxygen // https://formulae.brew.sh/formula/doxygen // https://archlinux.org/packages/extra/x86_64/doxygen/
gcc: isArch() ? "11" : "12", // https://github.com/brechtsanders/winlibs_mingw/releases and // https://packages.ubuntu.com/search?suite=all&arch=any&searchon=names&keywords=gcc
}
@ -68,7 +68,7 @@ export const DefaultLinuxVersion: Record<string, Record<number, string>> = {
18: "5.0",
},
meson: {
20: "0.63.3",
20: "1.0.0",
18: "0.61.4",
},
nala: {

View File

@ -29,26 +29,25 @@ export function isDefault(version: string | undefined, name: string) {
return version === "true" || (version === undefined && name in DefaultVersions)
}
/**
* Sync the versions for the given inputs
*
* If the return is false, it means that versions don't match the target version
*/
export function syncVersions(opts: Opts, tools: Inputs[]): boolean {
for (let i = 0; i < tools.length; i++) {
// tools excluding i_tool
const otherTools = tools.slice(0, i).concat(tools.slice(i + 1))
const toolsInUse = tools.filter((tool) => opts[tool] !== undefined)
const toolsNonDefaultVersion = toolsInUse.filter((tool) => !isDefault(opts[tool], tool))
const tool = tools[i]
const targetVersion = toolsNonDefaultVersion.length >= 1 ? opts[toolsNonDefaultVersion[0]] : "true"
if (!isDefault(opts[tool], tool)) {
for (let i_other = 0; i_other < otherTools.length; i_other++) {
const otherTool = otherTools[i_other]
const useDefaultOtherTool = isDefault(opts[otherTool], otherTools[i_other])
if (useDefaultOtherTool) {
// use the same version if the other tool was requested with the default
opts[otherTool] = opts[tool]
} else if (opts[tool] !== opts[otherTools[i_other]]) {
// error if different from the other given versions
return false
}
}
}
if (toolsNonDefaultVersion.some((tool) => opts[tool] !== targetVersion)) {
// error if any explicit versions don't match the target version
return false
}
toolsInUse.forEach((tool) => {
opts[tool] = targetVersion
})
return true
}