Merge branch 'master' of https://github.com/abeimler/setup-cpp into feature/cross-mingw

This commit is contained in:
abeimler 2023-07-19 23:31:19 +02:00
commit a884ad83aa
137 changed files with 6896 additions and 4860 deletions

View File

@ -1,4 +1,20 @@
.parcel-cache/ .git/
node_modules/ # OS metadata
dev/docker/ **/.DS_Store
dev/container-tests/ **/Thumbs.db
# Node
**/node_modules
**/package-lock.json
**/temp-*
# TypeScript
**/*.tsbuildinfo
# Build directories
**/packages/*/dist/
**/.parcel-cache
**/exe/
**/*.log
**/*.exe
**/.cache/

View File

@ -1,4 +1,16 @@
{ {
"extends": "eslint-config-atomic", "extends": "eslint-config-atomic",
"ignorePatterns": ["dist/", "node_modules/", "dev/cpp_vcpkg_project"] "ignorePatterns": ["dist/", "node_modules/", "dev/cpp_vcpkg_project"],
"rules": {
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": [
"warn",
{
"argsIgnorePattern": "^_",
"varsIgnorePattern": "^_",
"caughtErrorsIgnorePattern": "^_",
"destructuredArrayIgnorePattern": "^_"
}
]
}
} }

View File

@ -11,6 +11,7 @@ on:
jobs: jobs:
Test: Test:
name: ${{ matrix.os }}
if: ${{ !contains(github.event.head_commit.message, '[skip ci]') }} if: ${{ !contains(github.event.head_commit.message, '[skip ci]') }}
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
strategy: strategy:
@ -21,15 +22,12 @@ jobs:
- windows-2019 - windows-2019
- ubuntu-22.04 - ubuntu-22.04
- ubuntu-20.04 - ubuntu-20.04
- ubuntu-18.04
- macos-12 - macos-12
- macos-11 - macos-11
node: node:
- 16 - 20
pnpm: pnpm:
- 7 - 8
cache_reset_counter:
- 0
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
with: with:
@ -41,6 +39,7 @@ jobs:
path: | path: |
~/.pnpm-store ~/.pnpm-store
D:\.pnpm-store D:\.pnpm-store
./node_modules
key: "setupcpp-cache-OS:${{ matrix.os }}-node:${{ matrix.node }}-pnpm:${{ matrix.pnpm }}-${{ hashFiles('./.npmrc') }}-deps:${{ hashFiles('./package.json') }}" key: "setupcpp-cache-OS:${{ matrix.os }}-node:${{ matrix.node }}-pnpm:${{ matrix.pnpm }}-${{ hashFiles('./.npmrc') }}-deps:${{ hashFiles('./package.json') }}"
restore-keys: | restore-keys: |
"setupcpp-cache-OS:${{ matrix.os }}-" "setupcpp-cache-OS:${{ matrix.os }}-"
@ -63,14 +62,13 @@ jobs:
# uses: mxschmitt/action-tmate@v3 # uses: mxschmitt/action-tmate@v3
- name: Test - name: Test
if: "!contains(github.event.head_commit.message, '[skip test]')" if: "${{ !contains(github.event.head_commit.message, '[skip test]') }}"
run: | run: |
pnpm run test pnpm run test
continue-on-error: ${{ contains(matrix.os, 'ubuntu-18.04') }}
# Create self-contained executable that bundles Nodejs # Create self-contained executable that bundles Nodejs
- name: Create Executable - name: Create Executable
if: "contains(matrix.os, 'windows-2022') || contains(matrix.os, 'ubuntu-22.04') || contains(matrix.os, 'macos-12')" if: "${{ contains(matrix.os, 'windows-2022') || contains(matrix.os, 'ubuntu-22.04') || contains(matrix.os, 'macos-12') }}"
run: | run: |
pnpm run pack.exe pnpm run pack.exe
@ -83,6 +81,22 @@ jobs:
./dist ./dist
retention-days: 1 retention-days: 1
- name: Setup Node 12
uses: actions/setup-node@v3
with:
node-version: 12
- name: Smoke Test Node 12
run: |
node ./dist/legacy/setup-cpp.js --help
- name: Setup Node 16
uses: actions/setup-node@v3
with:
node-version: 16
- name: Smoke Test Node 16
run: |
node ./dist/actions/setup-cpp.js --help
Release: Release:
needs: Test needs: Test
if: startsWith(github.ref, 'refs/tags/') if: startsWith(github.ref, 'refs/tags/')
@ -103,38 +117,32 @@ jobs:
gzip: folders gzip: folders
draft: true draft: true
files: > files: >
./exe/setup_cpp_windows.exe ./exe/setup-cpp-x64-windows.exe
./exe/setup_cpp_linux ./exe/setup-cpp-x64-linux
./exe/setup_cpp_mac ./exe/setup-cpp-x64-macos
./dist/node12/setup_cpp.js ./dist/legacy/setup-cpp.js
./dist/node12/setup_cpp.js.map ./dist/legacy/setup-cpp.js.map
./dist/node12/ ./dist/legacy/
./dist/node16/ ./dist/actions/
./dist/modern/
Docker: Docker:
if: ${{ !contains(github.event.head_commit.message, '[skip ci]') && !contains(github.event.head_commit.message, '[skip docker]') }} name: ${{ matrix.container }}
if: ${{ !contains(github.event.head_commit.message, '[skip ci]') && !contains(github.event.head_commit.message, '[skip test]') }}
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
os: os:
- ubuntu-20.04 - ubuntu-22.04
container:
- "ubuntu_node.dockerfile"
- "ubuntu_node_16.dockerfile"
- "ubuntu_node.mingw.dockerfile"
- "ubuntu_22.04_node.dockerfile"
- "ubuntu_20.04_node.dockerfile"
- "arch_node.dockerfile"
- "arch_node.mingw.dockerfile"
- "fedora_node.dockerfile"
- "fedora_node.mingw.dockerfile"
node: node:
- 14 - 20
pnpm: pnpm:
- 6 - 8
cache_reset_counter: container:
- 0 - "arch.dockerfile"
- "fedora.dockerfile"
- "ubuntu.dockerfile"
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
with: with:
@ -146,9 +154,11 @@ jobs:
path: | path: |
~/.pnpm-store ~/.pnpm-store
D:\.pnpm-store D:\.pnpm-store
key: "setupcpp-docker-cache-OS:${{ matrix.os }}-node:${{ matrix.node }}-pnpm:${{ matrix.pnpm }}-${{ hashFiles('./.npmrc') }}-deps:${{ hashFiles('./package.json') }}-${{ matrix.cache_reset_counter }}" ./node_modules
key: "setupcpp-docker-cache-OS:${{ matrix.os }}-${{ hashFiles('./.npmrc') }}-deps:${{ hashFiles('./package.json') }}"
restore-keys: | restore-keys: |
"setupcpp-docker-cache-OS:${{ matrix.os }}" "setupcpp-docker-cache-OS:${{ matrix.os }}"
- name: Setup Node - name: Setup Node
uses: actions/setup-node@v3 uses: actions/setup-node@v3
with: with:
@ -162,8 +172,9 @@ jobs:
- name: Install and build - name: Install and build
run: | run: |
pnpm install pnpm install
pnpm build.docker_tests
- name: Build - name: Build
id: docker_build id: docker_build
run: | run: |
docker build -f ./dev/docker/${{ matrix.container }} -t setup_cpp . docker build -f ./dev/docker/__tests__/${{ matrix.container }} -t setup-cpp .

1
.nvm Normal file
View File

@ -0,0 +1 @@
v18.15.0

View File

@ -1,4 +1,5 @@
node_modules node_modules
package.json
pnpm-lock.yaml pnpm-lock.yaml
package-lock.json package-lock.json
CHANGELOG.md CHANGELOG.md

View File

@ -1,22 +0,0 @@
const terserConfig = require("terser-config-atomic")
const compress =
typeof terserConfig.compress !== "boolean"
? {
...terserConfig.compress,
global_defs: {
...terserConfig.compress.global_defs,
"process.env.NODE_DEBUG": false,
"process.env.RUNNER_DEBUG": "0",
},
}
: terserConfig.compress
module.exports = {
...terserConfig,
compress,
format: {
...terserConfig.format,
comments: false,
},
}

3
.vscode/extensions.json vendored Normal file
View File

@ -0,0 +1,3 @@
{
"recommendations": ["orta.vscode-jest", "esbenp.prettier-vscode", "dbaeumer.vscode-eslint"]
}

15
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,15 @@
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Jest Current File",
"runtimeExecutable": "sh",
"program": "node_modules/.bin/jest",
"args": ["${relativeFile}"],
"console": "integratedTerminal",
"internalConsoleOptions": "openOnFirstSessionStart"
}
]
}

153
README.md
View File

@ -24,75 +24,64 @@ Setting up a **cross-platform** environment for building and testing C++/C proje
| coverage | gcovr, opencppcoverage, kcov | | coverage | gcovr, opencppcoverage, kcov |
| other | python, powershell, sevenzip | | other | python, powershell, sevenzip |
`setup-cpp` automatically installs the dependencies above tools if needed for the selected tool (e.g., `python` is required for `conan`). `setup-cpp` automatically handles the dependencies of the selected tool (e.g., `python` is required for `conan`).
## Usage ## Usage
### From Terminal ### 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. Run `setup-cpp` with the available options.
#### Executable ```shell
# Windows example (open PowerShell as admin)
npx setup-cpp --compiler llvm --cmake true --ninja true --ccache true --vcpkg true
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. RefreshEnv.cmd # activate the environment
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
``` ```
```ps1 ```shell
# linux example # Linux/Macos example
wget "https://github.com/aminya/setup-cpp/releases/download/v0.24.1/setup_cpp_linux" sudo npx setup-cpp --compiler llvm --cmake true --ninja true --ccache true --vcpkg true
chmod +x setup_cpp_linux
sudo ./setup_cpp_linux --compiler llvm --cmake true --ninja true --ccache true --vcpkg true
source ~/.cpprc # activate cpp environment variables source ~/.cpprc
```
```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
source ~/.cpprc # activate cpp environment variables
``` ```
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: 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, 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.32.1), 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 ```shell
# windows example (open PowerShell as admin)
```ps1 curl -LJO "https://github.com/aminya/setup-cpp/releases/download/v0.32.1/setup-cpp-x64-windows.exe"
# open shell as admin ./setup-cpp-x64-windows --compiler llvm --cmake true --ninja true --ccache true --vcpkg true
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
RefreshEnv.cmd # activate cpp environment variables RefreshEnv.cmd # activate cpp environment variables
``` ```
On Linux or Mac: ```shell
# linux example
wget "https://github.com/aminya/setup-cpp/releases/download/v0.32.1/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 source ~/.cpprc # activate cpp environment variables
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
```shell
# macos example
wget "https://github.com/aminya/setup-cpp/releases/download/v0.32.1/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 source ~/.cpprc # activate cpp environment variables
``` ```
@ -160,35 +149,53 @@ jobs:
### Inside Docker ### 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 ```dockerfile
#### Base Image #### Base Image
FROM ubuntu:22.04 AS base FROM ubuntu:22.04 as setup-cpp-ubuntu
# add setup_cpp RUN apt-get update -qq && \
WORKDIR "/" # install nodejs
RUN apt-get update -qq apt-get install -y --no-install-recommends nodejs npm && \
RUN apt-get install -y --no-install-recommends wget # install setup-cpp
RUN wget --no-verbose "https://github.com/aminya/setup-cpp/releases/download/v0.24.1/setup_cpp_linux" npm install -g setup-cpp@v0.32.1 && \
RUN chmod +x ./setup_cpp_linux # install the compiler and tools
setup-cpp \
--nala true \
--compiler llvm \
--cmake true \
--ninja true \
--task true \
--vcpkg true \
--python true \
--make true \
--cppcheck true \
--gcovr true \
--doxygen true \
--ccache true && \
# cleanup
nala autoremove -y && \
nala autopurge -y && \
apt-get clean && \
nala clean --lists && \
rm -rf /var/lib/apt/lists/* && \
rm -rf /tmp/*
# install llvm, cmake, ninja, and ccache
RUN ./setup_cpp_linux --compiler llvm --cmake true --ninja true --ccache true --vcpkg true --make true
CMD source ~/.cpprc
ENTRYPOINT ["/bin/bash"] ENTRYPOINT ["/bin/bash"]
#### Building #### Building (example)
FROM base AS builder FROM setup-cpp-ubuntu AS builder
ADD ./dev/cpp_vcpkg_project /home/app
COPY ./dev/cpp_vcpkg_project /home/app
WORKDIR /home/app WORKDIR /home/app
RUN bash -c 'source ~/.cpprc \ RUN bash -c 'source ~/.cpprc \
&& make build' && task build'
#### Running environment
# use a fresh image as the runner
FROM ubuntu:22.04 as runner
### Running environment
# use a distroless image or ubuntu:22.04 if you wish
FROM gcr.io/distroless/cc
# copy the built binaries and their runtime dependencies # copy the built binaries and their runtime dependencies
COPY --from=builder /home/app/build/my_exe/Release/ /home/app/ COPY --from=builder /home/app/build/my_exe/Release/ /home/app/
WORKDIR /home/app/ WORKDIR /home/app/
@ -199,18 +206,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: If you want to build the ones included, then run:
```ps1 ```shell
git clone --recurse-submodules https://github.com/aminya/setup-cpp git clone --recurse-submodules https://github.com/aminya/setup-cpp
cd ./setup-cpp cd ./setup-cpp
docker build -f ./dev/docker/ubuntu.dockerfile -t setup_cpp . docker build -f ./dev/docker/setup-cpp-ubuntu.dockerfile -t setup-cpp-ubuntu .
``` ```
Where you should use the path to the dockerfile after `-f`. Where you should use the path to the dockerfile after `-f`.
After build, run the following to start an interactive shell in your container After build, run the following to start an interactive shell in your container
```ps1 ```shell
docker run -it setup_cpp docker run -it setup-cpp
``` ```
### Inside Docker inside GitHub Actions ### Inside Docker inside GitHub Actions
@ -230,7 +237,7 @@ jobs:
- name: Build - name: Build
id: docker_build id: docker_build
run: | run: |
docker build -f ./dev/docker/debian.dockerfile -t setup_cpp . docker build -f ./dev/docker/ubuntu.dockerfile -t setup-cpp .
``` ```
### Inside GitLab pipelines ### Inside GitLab pipelines
@ -261,10 +268,10 @@ stages:
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 40976EAF437D05B5 apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 40976EAF437D05B5
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 1E9377A2BA9EF27F apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 1E9377A2BA9EF27F
.setup_cpp: &setup_cpp | .setup-cpp: &setup-cpp |
curl -LJO "https://github.com/aminya/setup-cpp/releases/download/v0.24.1/setup_cpp_linux" curl -LJO "https://github.com/aminya/setup-cpp/releases/download/v0.32.1/setup-cpp-x64-linux"
chmod +x setup_cpp_linux chmod +x setup-cpp-x64-linux
./setup_cpp_linux --compiler $compiler --cmake true --ninja true --ccache true --vcpkg true ./setup-cpp-x64-linux --compiler $compiler --cmake true --ninja true --ccache true --vcpkg true
source ~/.cpprc source ~/.cpprc
.test: &test | .test: &test |
@ -277,7 +284,7 @@ test_linux_llvm:
compiler: llvm compiler: llvm
script: script:
- *setup_linux - *setup_linux
- *setup_cpp - *setup-cpp
- *test - *test
test_linux_gcc: test_linux_gcc:
@ -286,7 +293,7 @@ test_linux_gcc:
compiler: gcc compiler: gcc
script: script:
- *setup_linux - *setup_linux
- *setup_cpp - *setup-cpp
- *test - *test
``` ```

View File

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

View File

@ -9,6 +9,7 @@ ignorePaths:
- dist/ - dist/
- dev/cpp_vcpkg_project - dev/cpp_vcpkg_project
- "**/node_modules/" - "**/node_modules/"
- .vscode/extensions.json
words: words:
- aarch - aarch
- aminya - aminya
@ -19,7 +20,9 @@ words:
- caxa - caxa
- ccache - ccache
- choco - choco
- clangd
- cmake - cmake
- cobertura
- copr - copr
- CPATH - CPATH
- Cppcheck - Cppcheck
@ -45,6 +48,7 @@ words:
- LDFLAGS - LDFLAGS
- lefticus - lefticus
- libbinutils - libbinutils
- libc
- libdw - libdw
- libstdc - libstdc
- libtinfo - libtinfo
@ -72,15 +76,18 @@ words:
- setx - setx
- Syuu - Syuu
- terserrc - terserrc
- Trofimovich
- tsbuildinfo - tsbuildinfo
- ucrt - ucrt
- untildify - untildify
- upleveled
- vbatts - vbatts
- vcpkg - vcpkg
- vcvarsall - vcvarsall
- visualc - visualc
- visualcpp - visualcpp
- vsversion - vsversion
- whatwg
- xcrun - xcrun
- Yahyaabadi - Yahyaabadi
- VCPKG - VCPKG

View File

@ -1,51 +0,0 @@
schemaVersion: 2.0.0
commandTests:
- name: gcc compiler
command: gcc
args: ["--version"]
expectedOutput: [".*gcc.*"]
- name: g++ compiler
command: g++
args: ["--version"]
expectedOutput: [".*g\\+\\+.*"]
- name: make
command: make
args: ["--version"]
expectedOutput: [".*GNU Make.*"]
- name: ninja
command: /root/ninja/ninja
args: ["--version"]
expectedOutput: [".*1.*"]
- name: gcovr
command: gcovr
args: ["--version"]
expectedOutput: [".*gcovr.*"]
- name: ccache
command: ccache
args: ["--version"]
expectedOutput: [".*ccache.*"]
- name: doxygen
command: doxygen
args: ["--version"]
expectedOutput: [".*1.*"]
- name: cppcheck
command: cppcheck
args: ["--version"]
expectedOutput: [".*Cppcheck.*"]
- name: clang
command: /root/llvm/bin/clang
args: ["--version"]
expectedOutput: [".*clang.*"]
- name: node
command: node
args: ["-v"]
expectedOutput: [".*v16.*"]
fileExistenceTests:
- name: "vcpkg"
path: "/root/vcpkg"
shouldExist: true
- name: "llvm"
path: "/root/llvm"
shouldExist: true

View File

@ -0,0 +1,46 @@
## base image
FROM archlinux:base as setup-cpp-arch
COPY "./dist/legacy" "/usr/lib/setup-cpp/"
RUN pacman -Syuu --noconfirm && \
pacman-db-upgrade && \
# install nodejs
pacman -S --noconfirm --needed nodejs npm && \
# install the compiler and tools
node /usr/lib/setup-cpp/setup-cpp.js \
--compiler llvm \
--cmake true \
--ninja true \
--task true \
--vcpkg true \
--python true \
--make true \
--cppcheck true \
--gcovr true \
--doxygen true \
--ccache true && \
# arch cleanup
pacman -Scc --noconfirm && \
rm -rf /var/cache/pacman/pkg/* && \
rm -rf /tmp/*
ENTRYPOINT ["/bin/bash"]
#### Building (example)
FROM setup-cpp-arch AS builder
COPY ./dev/cpp_vcpkg_project /home/app
WORKDIR /home/app
RUN bash -c 'source ~/.cpprc \
&& task build'
#### Running environment
# use a fresh image as the runner
FROM archlinux:base as runner
# copy the built binaries and their runtime dependencies
COPY --from=builder /home/app/build/my_exe/Release/ /home/app/
WORKDIR /home/app/
ENTRYPOINT ["./my_exe"]

View File

@ -0,0 +1,39 @@
## base image
FROM archlinux:base as setup-cpp-arch-mingw
COPY "./dist/legacy" "/usr/lib/setup-cpp/"
RUN pacman -Syuu --noconfirm && \
pacman-db-upgrade && \
# install nodejs
pacman -S --noconfirm --needed nodejs npm && \
# install the compiler and tools
node /usr/lib/setup-cpp/setup-cpp.js \
--compiler mingw \
--cmake true \
--ninja true \
--task true \
--vcpkg true \
--python true \
--make true \
--cppcheck true \
--gcovr true \
--doxygen true \
--ccache true \
--powerchell true && \
# arch cleanup
pacman -Scc --noconfirm && \
rm -rf /var/cache/pacman/pkg/* && \
rm -rf /tmp/*
ENTRYPOINT ["/bin/bash"]
#### Building (example)
FROM setup-cpp-arch AS builder
COPY ./dev/cpp_vcpkg_project /home/app
WORKDIR /home/app
RUN bash -c 'source ~/.cpprc \
&& task build_cross_mingw'

View File

@ -0,0 +1,43 @@
## base image
FROM fedora:38 as setup-cpp-fedora
COPY "./dist/legacy" "/usr/lib/setup-cpp/"
# install nodejs
RUN dnf -y install nodejs npm && \
# install the compiler and tools
node /usr/lib/setup-cpp/setup-cpp.js \
--compiler llvm \
--cmake true \
--ninja true \
--task true \
--vcpkg true \
--python true \
--make true \
--cppcheck true \
--gcovr true \
--doxygen true \
--ccache true && \
# cleanup
dnf clean all && \
rm -rf /tmp/*
ENTRYPOINT ["/bin/bash"]
#### Building (example)
FROM setup-cpp-fedora AS builder
COPY ./dev/cpp_vcpkg_project /home/app
WORKDIR /home/app
RUN bash -c 'source ~/.cpprc \
&& task build'
#### Running environment
# use a fresh image as the runner
FROM fedora:38 as runner
# copy the built binaries and their runtime dependencies
COPY --from=builder /home/app/build/my_exe/Release/ /home/app/
WORKDIR /home/app/
ENTRYPOINT ["./my_exe"]

View File

@ -0,0 +1,36 @@
## base image
FROM fedora:38 as setup-cpp-fedora-mingw
COPY "./dist/legacy" "/usr/lib/setup-cpp/"
# install nodejs
RUN dnf -y install nodejs npm && \
# install the compiler and tools
node /usr/lib/setup-cpp/setup-cpp.js \
--compiler mingw \
--cmake true \
--ninja true \
--task true \
--vcpkg true \
--python true \
--make true \
--cppcheck true \
--gcovr true \
--doxygen true \
--ccache true \
--powerchell true && \
# cleanup
dnf clean all && \
rm -rf /tmp/*
ENTRYPOINT ["/bin/bash"]
#### Building (example)
FROM setup-cpp-fedora AS builder
COPY ./dev/cpp_vcpkg_project /home/app
WORKDIR /home/app
RUN bash -c 'source ~/.cpprc \
&& task build_cross_mingw'

View File

@ -0,0 +1,49 @@
#### Base Image
FROM ubuntu:22.04 as setup-cpp-ubuntu
COPY "./dist/legacy" "/usr/lib/setup-cpp/"
RUN apt-get update -qq && \
# install nodejs
apt-get install -y --no-install-recommends nodejs npm && \
# install the compiler and tools
node /usr/lib/setup-cpp/setup-cpp.js \
--nala true \
--compiler llvm \
--cmake true \
--ninja true \
--task true \
--vcpkg true \
--python true \
--make true \
--cppcheck true \
--gcovr true \
--doxygen true \
--ccache true && \
# cleanup
nala autoremove -y && \
nala autopurge -y && \
apt-get clean && \
nala clean --lists && \
rm -rf /var/lib/apt/lists/* && \
rm -rf /tmp/*
ENTRYPOINT ["/bin/bash"]
#### Building (example)
FROM setup-cpp-ubuntu AS builder
COPY ./dev/cpp_vcpkg_project /home/app
WORKDIR /home/app
RUN bash -c 'source ~/.cpprc \
&& task build'
#### Running environment
# use a fresh image as the runner
FROM ubuntu:22.04 as runner
# copy the built binaries and their runtime dependencies
COPY --from=builder /home/app/build/my_exe/Release/ /home/app/
WORKDIR /home/app/
ENTRYPOINT ["./my_exe"]

View File

@ -0,0 +1,42 @@
#### Base Image
FROM ubuntu:22.04 as setup-cpp-ubuntu-mingw
COPY "./dist/legacy" "/usr/lib/setup-cpp/"
RUN apt-get update -qq && \
# install nodejs
apt-get install -y --no-install-recommends nodejs npm && \
# install the compiler and tools
node /usr/lib/setup-cpp/setup-cpp.js \
--nala true \
--compiler mingw \
--cmake true \
--ninja true \
--task true \
--vcpkg true \
--python true \
--make true \
--cppcheck true \
--gcovr true \
--doxygen true \
--ccache true \
--powerchell true && \
# cleanup
nala autoremove -y && \
nala autopurge -y && \
apt-get clean && \
nala clean --lists && \
rm -rf /var/lib/apt/lists/* && \
rm -rf /tmp/*
ENTRYPOINT ["/bin/bash"]
#### Building (example)
FROM setup-cpp-ubuntu AS builder
COPY ./dev/cpp_vcpkg_project /home/app
WORKDIR /home/app
RUN bash -c 'source ~/.cpprc \
&& task build_cross_mingw'

View File

@ -0,0 +1,24 @@
#### Building (example)
FROM setup-cpp-arch AS builder
COPY ./dev/cpp_vcpkg_project /home/app
WORKDIR /home/app
RUN bash -c 'source ~/.cpprc \
&& task build'
#### Running environment
# use a fresh image as the runner
FROM archlinux:base as runner
# copy the built binaries and their runtime dependencies
COPY --from=builder /home/app/build/my_exe/Release/ /home/app/
WORKDIR /home/app/
ENTRYPOINT ["./my_exe"]
#### Cross Building (example)
FROM setup-cpp-arch-mingw AS builder-mingw
COPY ./dev/cpp_vcpkg_project /home/app
WORKDIR /home/app
RUN bash -c 'source ~/.cpprc \
&& task build_cross_mingw'

View File

@ -1,40 +0,0 @@
## base image
FROM archlinux as base
RUN pacman -Syuu --noconfirm
RUN pacman-db-upgrade
# nodejs
RUN pacman -S --noconfirm --needed nodejs
# curl for downloading setup-cpp
RUN pacman -S --noconfirm --needed curl
# 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
# clean up
RUN pacman -Scc --noconfirm
RUN rm -rf /tmp/*
CMD source ~/.cpprc
ENTRYPOINT [ "/bin/bash" ]
#### Building
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
# copy the built binaries and their runtime dependencies
COPY --from=builder /home/app/build/my_exe/Release/ /home/app/
WORKDIR /home/app/
ENTRYPOINT ["./my_exe"]

View File

@ -1,51 +0,0 @@
## base image
FROM archlinux as base
RUN pacman -Syuu --noconfirm
RUN pacman-db-upgrade
# yay for AUR installs
RUN pacman -S --noconfirm --needed git base-devel
## can't run makepkg as root, "ERROR: Running makepkg as root is not allowed as it can cause permanent, catastrophic damage to your system."
## add new user
RUN useradd -m -G nobody -s /bin/bash yay && passwd -d yay && echo "yay ALL=(ALL) ALL" >> /etc/sudoers
RUN git clone --depth 1 https://aur.archlinux.org/yay.git /opt/yay && \
chown -R yay:root /opt/yay && chmod -R 775 /opt/yay
USER yay
RUN cd /opt/yay && makepkg -si --noprogressbar --noconfirm
USER root
RUN rm -rf /tmp/yay
# nodejs
RUN pacman -S --noconfirm --needed nodejs
# curl for downloading setup-cpp
RUN pacman -S --noconfirm --needed curl
# add setup_cpp.js
COPY "./dist/node12" "/"
WORKDIR "/"
# run installation
RUN node ./setup_cpp.js --cmake true --ninja true --ccache true --vcpkg true --doxygen true --gcovr true --task true
## ERROR: Running makepkg as root is not allowed as it can cause permanent,
## Error: Command failed with exit code 1: sudo 'yay' '-S' '--noconfirm' 'powershell-bin'
## need to run this as yay-user so I can install powershell and mingw
USER yay
RUN node ./setup_cpp.js --compiler mingw --powershell true
USER root
# clean up
RUN pacman -Scc --noconfirm
RUN rm -rf /tmp/*
CMD source ~/.cpprc
ENTRYPOINT [ "/bin/bash" ]
#### Building
FROM base AS builder
COPY ./dev/cpp_vcpkg_project /home/app
WORKDIR /home/app
RUN bash -c 'source ~/.cpprc \
&& task build_cross_mingw'

View File

@ -0,0 +1,24 @@
#### Building (example)
FROM setup-cpp-fedora AS builder
COPY ./dev/cpp_vcpkg_project /home/app
WORKDIR /home/app
RUN bash -c 'source ~/.cpprc \
&& task build'
#### Running environment
# use a fresh image as the runner
FROM fedora:38 as runner
# copy the built binaries and their runtime dependencies
COPY --from=builder /home/app/build/my_exe/Release/ /home/app/
WORKDIR /home/app/
ENTRYPOINT ["./my_exe"]
#### Cross Building (example)
FROM setup-cpp-fedora-mingw AS builder-mingw
COPY ./dev/cpp_vcpkg_project /home/app
WORKDIR /home/app
RUN bash -c 'source ~/.cpprc \
&& task build_cross_mingw'

View File

@ -1,36 +0,0 @@
## base image
FROM fedora as base
# nodejs
RUN dnf -y install nodejs
# curl for downloading setup-cpp
RUN dnf -y install curl
# 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
# clean up
RUN rm -rf /tmp/*
CMD source ~/.cpprc
ENTRYPOINT [ "/bin/bash" ]
#### Building
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
# copy the built binaries and their runtime dependencies
COPY --from=builder /home/app/build/my_exe/Release/ /home/app/
WORKDIR /home/app/
ENTRYPOINT ["./my_exe"]

View File

@ -1,28 +0,0 @@
## base image
FROM fedora as base
# nodejs
RUN dnf -y install nodejs
# curl for downloading setup-cpp
RUN dnf -y install curl
# add setup_cpp.js
COPY "./dist/node12" "/"
WORKDIR "/"
# run installation
RUN node ./setup_cpp.js --compiler mingw --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
ENTRYPOINT [ "/bin/bash" ]
#### Building
FROM base AS builder
COPY ./dev/cpp_vcpkg_project /home/app
WORKDIR /home/app
RUN bash -c 'source ~/.cpprc \
&& task build_cross_mingw'

View File

@ -0,0 +1,28 @@
## base image
FROM archlinux:base as setup-cpp-arch
RUN pacman -Syuu --noconfirm && \
pacman-db-upgrade && \
# install nodejs
pacman -S --noconfirm --needed nodejs npm && \
# install setup-cpp
npm install -g setup-cpp@v0.32.1 && \
# install the compiler and tools
setup-cpp \
--compiler llvm \
--cmake true \
--ninja true \
--task true \
--vcpkg true \
--python true \
--make true \
--cppcheck true \
--gcovr true \
--doxygen true \
--ccache true && \
# arch cleanup
pacman -Scc --noconfirm && \
rm -rf /var/cache/pacman/pkg/* && \
rm -rf /tmp/*
ENTRYPOINT ["/bin/bash"]

View File

@ -0,0 +1,25 @@
## base image
FROM fedora:38 as setup-cpp-fedora
# install nodejs
RUN dnf -y install nodejs npm && \
# install setup-cpp
npm install -g setup-cpp@v0.32.1 && \
# install the compiler and tools
setup-cpp \
--compiler llvm \
--cmake true \
--ninja true \
--task true \
--vcpkg true \
--python true \
--make true \
--cppcheck true \
--gcovr true \
--doxygen true \
--ccache true && \
# cleanup
dnf clean all && \
rm -rf /tmp/*
ENTRYPOINT ["/bin/bash"]

View File

@ -0,0 +1,31 @@
#### Base Image
FROM ubuntu:22.04 as setup-cpp-ubuntu
RUN apt-get update -qq && \
# install nodejs
apt-get install -y --no-install-recommends nodejs npm && \
# install setup-cpp
npm install -g setup-cpp@v0.32.1 && \
# install the compiler and tools
setup-cpp \
--nala true \
--compiler llvm \
--cmake true \
--ninja true \
--task true \
--vcpkg true \
--python true \
--make true \
--cppcheck true \
--gcovr true \
--doxygen true \
--ccache true && \
# cleanup
nala autoremove -y && \
nala autopurge -y && \
apt-get clean && \
nala clean --lists && \
rm -rf /var/lib/apt/lists/* && \
rm -rf /tmp/*
ENTRYPOINT ["/bin/bash"]

View File

@ -1,30 +1,24 @@
#### Base Image #### Building (example)
FROM ubuntu:22.04 AS base FROM setup-cpp-ubuntu AS builder
# add setup_cpp COPY ./dev/cpp_vcpkg_project /home/app
WORKDIR "/"
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
# install llvm, cmake, ninja, and ccache
RUN ./setup_cpp_linux --compiler llvm --cmake true --ninja true --ccache true --vcpkg true --task true
CMD source ~/.cpprc
ENTRYPOINT [ "/bin/bash" ]
#### Building
FROM base AS builder
ADD ./dev/cpp_vcpkg_project /home/app
WORKDIR /home/app WORKDIR /home/app
RUN bash -c 'source ~/.cpprc \ RUN bash -c 'source ~/.cpprc \
&& task build' && task build'
### Running environment #### Running environment
# use a distroless image or ubuntu:22.04 if you wish # use a fresh image as the runner
FROM gcr.io/distroless/cc FROM ubuntu:22.04 as runner
# copy the built binaries and their runtime dependencies # copy the built binaries and their runtime dependencies
COPY --from=builder /home/app/build/my_exe/Release/ /home/app/ COPY --from=builder /home/app/build/my_exe/Release/ /home/app/
WORKDIR /home/app/ WORKDIR /home/app/
ENTRYPOINT ["./my_exe"] ENTRYPOINT ["./my_exe"]
#### Cross Building (example)
FROM setup-cpp-ubuntu-mingw AS builder-mingw
COPY ./dev/cpp_vcpkg_project /home/app
WORKDIR /home/app
RUN bash -c 'source ~/.cpprc \
&& task build_cross_mingw'

View File

@ -1,37 +0,0 @@
FROM ubuntu:20.04 AS base
# 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:20.04 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
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
CMD source ~/.cpprc
ENTRYPOINT [ "/bin/bash" ]
#### Building
FROM base AS builder
ADD ./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
# copy the built binaries and their runtime dependencies
COPY --from=builder /home/app/build/my_exe/Release/ /home/app/
WORKDIR /home/app/
ENTRYPOINT ["./my_exe"]

View File

@ -1,37 +0,0 @@
FROM ubuntu:22.04 AS base
# 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:20.04 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
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
CMD source ~/.cpprc
ENTRYPOINT [ "/bin/bash" ]
#### Building
FROM base AS builder
ADD ./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
# copy the built binaries and their runtime dependencies
COPY --from=builder /home/app/build/my_exe/Release/ /home/app/
WORKDIR /home/app/
ENTRYPOINT ["./my_exe"]

View File

@ -1,33 +0,0 @@
FROM ubuntu:22.04 AS base
RUN apt-get update -qq
RUN apt-get install -y --no-install-recommends nodejs
# 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
# clean up
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
RUN rm -rf /tmp/*
CMD source ~/.cpprc
ENTRYPOINT [ "/bin/bash" ]
#### Building
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
# copy the built binaries and their runtime dependencies
COPY --from=builder /home/app/build/my_exe/Release/ /home/app/
WORKDIR /home/app/
ENTRYPOINT ["./my_exe"]

View File

@ -1,25 +0,0 @@
FROM ubuntu:22.04 AS base
RUN apt-get update -qq
RUN apt-get install -y --no-install-recommends nodejs
# add setup_cpp.js
COPY "./dist/node12" "/"
WORKDIR "/"
# run installation
RUN node ./setup_cpp.js --compiler mingw --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
ENTRYPOINT [ "/bin/bash" ]
#### Building
FROM base AS builder
COPY ./dev/cpp_vcpkg_project /home/app
WORKDIR /home/app
RUN bash -c 'source ~/.cpprc \
&& task build_cross_mingw'

View File

@ -1,38 +0,0 @@
FROM ubuntu:22.04 AS base
RUN apt-get update -qq && apt-get install -y \
curl \
&& rm -rf /var/lib/apt/lists/*
RUN curl -s https://deb.nodesource.com/setup_16.x | bash
RUN apt-get update -qq
RUN apt-get install -y --no-install-recommends nodejs
# add setup_cpp.js
COPY "./dist/node16" "/"
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
# clean up
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
RUN rm -rf /tmp/*
CMD source ~/.cpprc
ENTRYPOINT [ "/bin/bash" ]
#### Building
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
# copy the built binaries and their runtime dependencies
COPY --from=builder /home/app/build/my_exe/Release/ /home/app/
WORKDIR /home/app/
ENTRYPOINT ["./my_exe"]

View File

@ -5,7 +5,7 @@ const { join, dirname } = require("path")
async function main() { async function main() {
console.log("Disabling debug messages inside @actions/core") 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") }) const { code, map } = await minify(readFileSync(file, "utf8"), { sourceMap: true, ...require("../.terserrc.js") })
writeFileSync(file, code) writeFileSync(file, code)

View File

@ -0,0 +1,26 @@
import { readFile, writeFile } from "fs/promises"
async function main() {
const dockerFiles = ["ubuntu", "arch", "fedora"]
await Promise.all(
dockerFiles.map(async (dockerFile) => {
const dockerFileContent = await readFile(`./dev/docker/setup-cpp-${dockerFile}.dockerfile`, "utf-8")
const builderExample = await readFile(`./dev/docker/${dockerFile}.dockerfile`, "utf-8")
const modifiedDockerFile = dockerFileContent
// load the externally built setup-cpp
.replace(/FROM (.*)/g, `FROM $1\n\nCOPY "./dist/legacy" "/usr/lib/setup-cpp/"`)
.replace("setup-cpp ", "node /usr/lib/setup-cpp/setup-cpp.js ")
// remove the npm install line
.replace(/# install setup-cpp\n\s*npm install -g setup-cpp.*/, "")
// concat the two files
const newDockerFileContent = `${modifiedDockerFile}\n${builderExample}`
// write the new file in dev/docker/__tests__
await writeFile(`./dev/docker/__tests__/${dockerFile}.dockerfile`, newDockerFileContent)
})
)
}
await main()

View File

@ -1,5 +1,5 @@
/* eslint-disable import/no-extraneous-dependencies */ /* eslint-disable import/no-extraneous-dependencies */
import { node } from "execa" import { execaNode } from "execa"
function getPlatformName() { function getPlatformName() {
switch (process.platform) { switch (process.platform) {
@ -7,7 +7,7 @@ function getPlatformName() {
return "windows" return "windows"
} }
case "darwin": { case "darwin": {
return "mac" return "macos"
} }
default: { default: {
return process.platform return process.platform
@ -27,14 +27,14 @@ function main() {
return Promise.all( return Promise.all(
exes.map((exe) => exes.map((exe) =>
node("./node_modules/caxa/build/index.mjs", [ execaNode("./node_modules/caxa/build/index.mjs", [
"--input", "--input",
"./dist/node16", "./dist/modern",
"--output", "--output",
`./exe/setup_cpp_${getPlatformName()}${exe}`, `./exe/setup-cpp-${process.arch}-${getPlatformName()}${exe}`,
"--", "--",
`{{caxa}}/node_modules/.bin/node${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

40
dist/actions/setup-cpp.js vendored Normal file

File diff suppressed because one or more lines are too long

1
dist/actions/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

40
dist/legacy/setup-cpp.js vendored Normal file

File diff suppressed because one or more lines are too long

1
dist/legacy/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

17
dist/modern/gcc_matcher.json vendored Normal file
View File

@ -0,0 +1,17 @@
{
"problemMatcher": [
{
"owner": "gcc",
"pattern": [
{
"regexp": "^(.*?):(\\d+):(\\d*):?\\s+(?:fatal\\s+)?(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
]
}
]
}

17
dist/modern/llvm_matcher.json vendored Normal file
View File

@ -0,0 +1,17 @@
{
"problemMatcher": [
{
"owner": "llvm",
"pattern": [
{
"regexp": "^(.*?):(\\d+):(\\d*):?\\s+(?:fatal\\s+)?(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
]
}
]
}

18
dist/modern/msvc_matcher.json vendored Normal file
View File

@ -0,0 +1,18 @@
{
"problemMatcher": [
{
"owner": "msvc",
"pattern": [
{
"regexp": "^(?:\\s+\\d+>)?(\\S.*)\\((\\d+),?(\\d+)?(?:,\\d+,\\d+)?\\)\\s*:\\s+(error|warning|info)\\s+(\\w{1,2}\\d+)\\s*:\\s*(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"code": 5,
"message": 6
}
]
}
]
}

18
dist/modern/python_matcher.json vendored Normal file
View File

@ -0,0 +1,18 @@
{
"problemMatcher": [
{
"owner": "python",
"pattern": [
{
"regexp": "^\\s*File\\s\\\"(.*)\\\",\\sline\\s(\\d+),\\sin\\s(.*)$",
"file": 1,
"line": 2
},
{
"regexp": "^\\s*raise\\s(.*)\\(\\'(.*)\\'\\)$",
"message": 2
}
]
}
]
}

40
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

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

File diff suppressed because one or more lines are too long

View File

@ -1,12 +1,26 @@
module.exports = { /** @typedef {import("jest")} jestConfig */
const jestConfig = {
preset: "ts-jest/presets/js-with-ts-esm", preset: "ts-jest/presets/js-with-ts-esm",
extensionsToTreatAsEsm: [".ts"], extensionsToTreatAsEsm: [".ts"],
transformIgnorePatterns: [], // transform everything transformIgnorePatterns: [], // transform everything
testEnvironment: "node", testEnvironment: "node",
testMatch: ["**/*.test.ts"], testMatch: ["**/*.test.ts"],
testPathIgnorePatterns: ["<rootDir>/src/python/setup-python/"], testPathIgnorePatterns: ["<rootDir>/src/python/setup-python/"],
// tsconfig
transform: {
"^.+\\.tsx?$": [
"ts-jest",
/** @type {import("ts-jest")} */
{
importHelpers: true,
useESM: true,
},
],
},
// coverage // coverage
collectCoverageFrom: ["src/**/*.{ts,tsx}"], collectCoverageFrom: ["src/**/*.{ts,tsx}"],
coveragePathIgnorePatterns: ["assets", ".css.d.ts"], coveragePathIgnorePatterns: ["assets", ".css.d.ts"],
verbose: true, verbose: true,
} }
export default jestConfig

4
package-version.json Normal file
View File

@ -0,0 +1,4 @@
{
"name": "setup-cpp",
"version": "0.32.1"
}

View File

@ -1,34 +1,41 @@
{ {
"name": "setup-cpp", "name": "setup-cpp",
"version": "0.24.1", "version": "0.32.1",
"description": "Install all the tools required for building and testing C++/C projects.", "description": "Install all the tools required for building and testing C++/C projects.",
"repository": "https://github.com/aminya/setup-cpp", "repository": "https://github.com/aminya/setup-cpp",
"license": "Apache-2.0", "license": "Apache-2.0",
"author": "Amin Yahyaabadi", "author": "Amin Yahyaabadi",
"exports": { "main": "dist/legacy/setup-cpp.js",
"import": "./dist/node12/setup-cpp.mjs", "actions": "./dist/actions/setup-cpp.js",
"require": "./dist/node12/setup-cpp.js" "modern": "./dist/modern/setup-cpp.js",
},
"main": "./dist/node12/setup_cpp.js",
"source": "./src/main.ts", "source": "./src/main.ts",
"bin": { "bin": {
"setup-cpp": "./dist/node12/setup_cpp.js", "setup-cpp": "dist/legacy/setup-cpp.js"
"setup_cpp": "./dist/node12/setup_cpp.js"
}, },
"files": [
"action.yml",
".dockerignore",
"dist",
"src",
"packages",
"dev/docker",
"dev/docker/__tests__",
"README.md",
"LICENSE.txt",
"LICENSE.dependencies.txt",
"package.json",
"package-version.json",
"tsconfig.json"
],
"scripts": { "scripts": {
"build": "shx rm -rf dist/ && shx mkdir -p ./dist/node12 ./dist/node16 && run-p lint.tsc build.parcel copy.matchers", "build": "shx rm -rf dist/ && shx mkdir -p ./dist/legacy ./dist/actions ./dist/modern && run-p lint.tsc build.parcel copy.matchers",
"build.docker": "pnpm build && docker build -f ./dev/docker/ubuntu_node.dockerfile -t setup_cpp .", "build.parcel": "cross-env NODE_ENV=production parcel build && babel ./dist --out-dir dist --plugins @upleveled/babel-plugin-remove-node-prefix --compact --no-babelrc --source-maps true",
"build.docker.arch": "pnpm build && docker build -f ./dev/docker/arch_node.dockerfile -t setup_cpp:arch .", "bump": "ncu -u -x numerous && pnpm update",
"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.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.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",
"bump": "ncu -u -x execa,numerous,path-exists && pnpm update",
"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/node12/ && shx cp ./src/msvc/msvc_matcher.json ./dist/node12/ && shx cp ./src/python/python_matcher.json ./dist/node12/ && shx cp ./src/llvm/llvm_matcher.json ./dist/node12/ && shx cp ./dist/node12/*.json ./dist/node16/", "copy.matchers": "run-p copy.matchers.legacy copy.matchers.actions copy.matchers.modern",
"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", "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", "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.prettier", "format": "run-s lint.prettier",
@ -37,85 +44,88 @@
"lint.eslint": "eslint **/*.{ts,tsx,js,jsx,cjs,mjs,json,yaml} --no-error-on-unmatched-pattern --cache --cache-location ./.cache/eslint/ --fix", "lint.eslint": "eslint **/*.{ts,tsx,js,jsx,cjs,mjs,json,yaml} --no-error-on-unmatched-pattern --cache --cache-location ./.cache/eslint/ --fix",
"lint.prettier": "prettier --list-different --write .", "lint.prettier": "prettier --list-different --write .",
"lint.tsc": "tsc --noEmit", "lint.tsc": "tsc --noEmit",
"pack.exe": "shx rm -rf ./dist/tsconfig.tsbuildinfo && ts-node --esm ./dev/scripts/pack-exe.ts", "pack.exe": "shx rm -rf ./dist/tsconfig.tsbuildinfo && node ./dev/scripts/pack-exe.mjs",
"prepare": "pnpm run -r build && pnpm run -w build", "prepare": "pnpm run -r build && pnpm run -w build && rm ./dist/tsconfig.tsbuildinfo",
"start.docker": "docker run -t setup_cpp .", "start.docker": "docker run -t setup-cpp .",
"start.docker.arch": "docker run -t setup_cpp:arch .", "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": "docker run -t setup_cpp:fedora .", "start.docker.ubuntu": "docker run -t setup-cpp:ubuntu .",
"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": "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": "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.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.lint.prettier": "prettier . --check",
"test.unit": "jest --runInBand" "test.unit": "jest --runInBand",
"build.docker_tests": "pnpm build && node ./dev/scripts/generate-docker-tests.mjs",
"build.docker.arch": "pnpm build.docker_tests && docker build -f ./dev/docker/__tests__/arch.dockerfile -t setup-cpp:arch .",
"build.docker.fedora": "pnpm build.docker_tests && docker build -f ./dev/docker/__tests__/fedora.dockerfile -t setup-cpp:fedora .",
"build.docker.ubuntu": "pnpm build.docker_tests && docker build -f ./dev/docker/__tests__/ubuntu.dockerfile -t setup-cpp:ubuntu .",
"test.docker.arch": "pnpm build.docker.arch && container-structure-test test --image setup-cpp:arch --config ./dev/docker/__tests__/arch.yml",
"test.docker.fedora": "pnpm build.docker.fedora && container-structure-test test --image setup-cpp:fedora --config ./dev/docker/__tests__/fedora.yml",
"test.docker.ubuntu": "pnpm build.docker.ubuntu && container-structure-test test --image setup-cpp:ubuntu --config ./dev/docker/__tests__/ubuntu.yml"
}, },
"prettier": "prettier-config-atomic", "prettier": "prettier-config-atomic",
"dependencies": { "devDependencies": {
"@actions/core": "^1.10.0", "@actions/core": "^1.10.0",
"@actions/exec": "^1.1.1", "@actions/exec": "^1.1.1",
"@actions/io": "^1.1.2", "@actions/io": "^1.1.3",
"@actions/tool-cache": "^2.0.1", "@actions/tool-cache": "^2.0.1",
"@npmcli/ci-detect": "github:aminya/ci-detect#37fe40075bebec96794ba0a7c4a6d5c70cbea00d", "@babel/cli": "^7.22.9",
"admina": "^0.1.3",
"ci-log": "workspace:1.0.0",
"escape-path-with-spaces": "github:aminya/escape-path-with-spaces#d9f81ee649203ddc55783a2f96ada59df06118e3",
"escape-quotes": "^1.0.2",
"escape-string-regexp": "^5.0.0",
"exec-powershell": "workspace:1.0.0",
"execa": "^5.1.1",
"is-url-online": "^1.5.0",
"mri": "^1.2.0",
"msvc-dev-cmd": "github:aminya/msvc-dev-cmd#9f672c1",
"numerous": "1.0.3",
"path-exists": "^4.0.0",
"patha": "^0.4.1",
"quote-unquote": "^1.0.0",
"retry-as-promised": "^7.0.3",
"semver": "7.3.8",
"setup-python": "github:actions/setup-python#v4.3.1",
"time-delta": "github:aminya/time-delta#69d91a41cef28e569be9a2991129f5f7d1f0d00e",
"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/cross-spawn": "^6.0.2",
"@types/jest": "^29.2.4", "@types/eslint": "^8.44.0",
"@types/jest": "^29.5.3",
"@types/mri": "^1.1.1", "@types/mri": "^1.1.1",
"@types/node": "^18.11.15", "@types/node": "^20.4.2",
"@types/semver": "^7.3.13", "@types/npmcli__ci-detect": "^2.0.0",
"@types/which": "^2.0.1", "@types/prettier": "2.7.3",
"@types/semver": "^7.5.0",
"@types/which": "^3.0.0",
"@upleveled/babel-plugin-remove-node-prefix": "github:aminya/babel-plugin-remove-node-prefix#95fcbd92405b99a6eece48c493548996f12e6519",
"admina": "^0.1.3",
"caxa": "^3.0.1", "caxa": "^3.0.1",
"ci-info": "^3.8.0",
"ci-log": "workspace:*",
"cross-env": "7.0.3", "cross-env": "7.0.3",
"cross-spawn": "^7.0.3", "cross-spawn": "^7.0.3",
"cspell": "^6.17.0", "cspell": "^6.31.1",
"eslint": "^8.29.0", "escape-path-with-spaces": "^1.0.2",
"eslint-config-atomic": "^1.18.1", "escape-quotes": "^1.0.2",
"escape-string-regexp": "^5.0.0",
"eslint": "^8.45.0",
"eslint-config-atomic": "^1.19.3",
"exec-powershell": "workspace:*",
"execa": "^7.1.1",
"fast-glob": "^3.3.0",
"find-up": "^6.3.0",
"gen-readme": "^1.6.0", "gen-readme": "^1.6.0",
"jest": "^29.3.1", "is-url-online": "^1.5.0",
"npm-check-updates": "^16.6.0", "jest": "^29.6.1",
"npm-run-all2": "^6.0.4", "micro-memoize": "^4.1.2",
"parcel": "2.8.1", "mri": "^1.2.0",
"prettier": "2.7.1", "msvc-dev-cmd": "github:aminya/msvc-dev-cmd#9f672c1",
"npm-check-updates": "^16.10.15",
"npm-run-all2": "^6.0.6",
"numerous": "1.0.3",
"parcel": "2.9.3",
"path-exists": "^5.0.0",
"patha": "^0.4.1",
"prettier": "2.8.8",
"prettier-config-atomic": "^3.1.0", "prettier-config-atomic": "^3.1.0",
"quote-unquote": "^1.0.0",
"readme-md-generator": "^1.0.0", "readme-md-generator": "^1.0.0",
"retry-as-promised": "^7.0.4",
"semver": "7.5.3",
"setup-python": "github:actions/setup-python#v4.6.1",
"shx": "0.3.4", "shx": "0.3.4",
"terser-config-atomic": "^0.1.1", "simple-update-notifier": "^2.0.0",
"ts-jest": "^29.0.3", "time-delta": "github:aminya/time-delta#69d91a41cef28e569be9a2991129f5f7d1f0d00e",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1", "ts-node": "^10.9.1",
"ts-readme": "^1.1.3", "ts-readme": "^1.1.3",
"typescript": "^4.9.4" "typescript": "^5.1.6",
"ubuntu-version": "^2.0.0",
"untildify-user": "workspace:*",
"user-access": "workspace:*",
"which": "^3.0.1"
}, },
"engines": { "engines": {
"node": ">=12.x" "node": ">=12.x"
@ -141,22 +151,12 @@
], ],
"alias": { "alias": {
"electron": false, "electron": false,
"patha": "patha/dist/index.node.mjs" "patha": "patha/dist/index.node.mjs",
"admina": "admina/dist/index.mjs"
}, },
"main.actions": "./dist/node16/setup_cpp.js",
"pnpm": { "pnpm": {
"overrides": { "overrides": {
"semver": "7.3.8", "whatwg-url": "^12"
"eslint": "^8.28.0",
"prettier": "2.7.1",
"lru-cache": "7.8.1",
"core-js": "*",
"babel-eslint": "npm:@babel/eslint-parser"
},
"peerDependencyRules": {
"allowedVersions": {
"eslint": "*"
}
} }
}, },
"targets": { "targets": {
@ -165,15 +165,28 @@
"engines": { "engines": {
"node": ">=12.x" "node": ">=12.x"
}, },
"includeNodeModules": true, "includeNodeModules": {
"update-notifier": false
},
"optimize": true, "optimize": true,
"outputFormat": "commonjs" "outputFormat": "commonjs"
}, },
"main.actions": { "actions": {
"context": "node", "context": "node",
"engines": { "engines": {
"node": ">=16.x" "node": ">=16.x"
}, },
"includeNodeModules": {
"update-notifier": false
},
"optimize": true,
"outputFormat": "commonjs"
},
"modern": {
"context": "node",
"engines": {
"node": ">=20.x"
},
"includeNodeModules": true, "includeNodeModules": true,
"optimize": true, "optimize": true,
"outputFormat": "commonjs" "outputFormat": "commonjs"

View File

@ -11,8 +11,8 @@
"build": "tsc" "build": "tsc"
}, },
"dependencies": { "dependencies": {
"@actions/core": "^1.9.1", "@actions/core": "^1.10.0",
"@npmcli/ci-detect": "github:aminya/ci-detect#37fe40075bebec96794ba0a7c4a6d5c70cbea00d" "ci-info": "^3.8.0"
}, },
"keywords": [ "keywords": [
"log", "log",

View File

@ -1,8 +1,8 @@
import * as core from "@actions/core" import * as core from "@actions/core"
import ciDetect from "@npmcli/ci-detect" import { GITHUB_ACTIONS } from "ci-info"
export function error(err: string | Error) { export function error(err: string | Error) {
return ciDetect() === "github-actions" ? core.error(err) : console.log(`\x1b[31m${err}\x1b[0m`) return GITHUB_ACTIONS ? core.error(err) : console.log(`\x1b[31m${err}\x1b[0m`)
} }
export function success(msg: string) { export function success(msg: string) {
@ -10,13 +10,13 @@ export function success(msg: string) {
} }
export function warning(msg: string) { export function warning(msg: string) {
return ciDetect() === "github-actions" ? core.warning(msg) : console.log(`\x1b[33m${msg}\x1b[0m`) return GITHUB_ACTIONS ? core.warning(msg) : console.log(`\x1b[33m${msg}\x1b[0m`)
} }
export function notice(msg: string) { export function notice(msg: string) {
return ciDetect() === "github-actions" ? core.notice(msg) : console.log(`\x1b[94m${msg}\x1b[0m`) return GITHUB_ACTIONS ? core.notice(msg) : console.log(`\x1b[94m${msg}\x1b[0m`)
} }
export function info(msg: string) { export function info(msg: string) {
return ciDetect() === "github-actions" ? core.info(msg) : console.log(msg) return GITHUB_ACTIONS ? core.info(msg) : console.log(msg)
} }

View File

@ -38,7 +38,7 @@ Execute a powershell command.
- command (`string`) - The powershell command to execute - command (`string`) - The powershell command to execute
- startupFlags (`string[]`) - The optional startup flags to be passed to powershell. Defaults to `["-NoProfile", "-NoLogo", "-NonInteractive"]`. This means that the Powershell profile is not sourced first. - startupFlags (`string[]`) - The optional startup flags to be passed to powershell. Defaults to `["-NoProfile", "-NoLogo", "-NonInteractive"]`. This means that the Powershell profile is not sourced first.
- execOptions (`execa.SyncOptions`) - The options passed to `execa`. Defaults to `{ stdio: "inherit" }` - execOptions (`execaSyncOptions`) - The options passed to `execa`. Defaults to `{ stdio: "inherit" }`
**returns:** execa.ExecaSyncReturnValue<string> **returns:** execa.ExecaSyncReturnValue<string>

View File

@ -11,11 +11,11 @@
"build": "tsc" "build": "tsc"
}, },
"dependencies": { "dependencies": {
"execa": "^5.1.1", "execa": "^7.1.1",
"which": "^2.0.2" "which": "^2.0.2"
}, },
"devDependencies": { "devDependencies": {
"@types/which": "^2.0.1" "@types/which": "^2.0.2"
}, },
"keywords": [ "keywords": [
"powershell", "powershell",

View File

@ -1,4 +1,4 @@
import execa from "execa" import * as execa from "execa"
import which from "which" import which from "which"
/** The cached powershell path */ /** The cached powershell path */
@ -19,7 +19,7 @@ export function execPowershell(
startupFlags: string[] = ["-NoProfile", "-NoLogo", "-NonInteractive"], startupFlags: string[] = ["-NoProfile", "-NoLogo", "-NonInteractive"],
execOptions: execa.Options = { stdio: "inherit" } execOptions: execa.Options = { stdio: "inherit" }
): execa.ExecaChildProcess<string> { ): execa.ExecaChildProcess<string> {
return execa(getPowerShell(), [...startupFlags, "-c", command], execOptions) return execa.execa(getPowerShell(), [...startupFlags, "-c", command], execOptions)
} }
/** /**
@ -37,7 +37,7 @@ export function execPowershellSync(
startupFlags: string[] = ["-NoProfile", "-NoLogo", "-NonInteractive"], startupFlags: string[] = ["-NoProfile", "-NoLogo", "-NonInteractive"],
execOptions: execa.SyncOptions = { stdio: "inherit" } execOptions: execa.SyncOptions = { stdio: "inherit" }
): execa.ExecaSyncReturnValue<string> { ): execa.ExecaSyncReturnValue<string> {
return execa.sync(getPowerShell(), [...startupFlags, "-c", command], execOptions) return execa.execaSync(getPowerShell(), [...startupFlags, "-c", command], execOptions)
} }
/** /**

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,7 @@
import { syncVersions, getVersion } from "../versions/versions" import { syncVersions, getVersion } from "../versions/versions"
import { getCompilerInfo, Inputs, parseArgs } from "../main" import { parseArgs } from "../cli-options"
import { Inputs } from "../tool"
import { getCompilerInfo } from "../compilers"
jest.setTimeout(300000) jest.setTimeout(300000)
describe("getCompilerInfo", () => { describe("getCompilerInfo", () => {
@ -29,9 +31,22 @@ describe("syncVersion", () => {
expect(syncVersions(parseArgs(["--llvm", "13.0.0", "--clangtidy", "true"]), llvmTools)).toBe(true) 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) expect(syncVersions(parseArgs(["--llvm", "13.0.0", "--clangtidy", "12.0.0"]), llvmTools)).toBe(false)
const opts = parseArgs(["--llvm", "14.0.0", "--clangtidy", "true"]) const opts1 = parseArgs(["--llvm", "14.0.0", "--clangtidy", "true"])
expect(syncVersions(opts, llvmTools)).toBe(true) expect(syncVersions(opts1, llvmTools)).toBe(true)
expect(opts.llvm).toBe(opts.clangtidy) 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

@ -23,9 +23,9 @@ export async function setupBazel(version: string, _setupDir: string, _arch: stri
throw new Error("installing bazel on Arch linux is not supported yet") throw new Error("installing bazel on Arch linux is not supported yet")
} else if (hasDnf()) { } else if (hasDnf()) {
// https://bazel.build/install/redhat // https://bazel.build/install/redhat
setupDnfPack("dnf-plugins-core", undefined) await setupDnfPack([{ name: "dnf-plugins-core" }])
execRootSync("dnf", ["copr", "enable", "vbatts/bazel"]) execRootSync("dnf", ["copr", "enable", "vbatts/bazel"])
return setupDnfPack("bazel4", undefined) return setupDnfPack([{ name: "bazel4" }])
} else if (isUbuntu()) { } else if (isUbuntu()) {
// https://bazel.build/install/ubuntu // https://bazel.build/install/ubuntu
const keyFileName = await addAptKeyViaDownload( const keyFileName = await addAptKeyViaDownload(

View File

@ -1,4 +1,4 @@
import execa from "execa" import { execaSync } from "execa"
import { dirname } from "patha" import { dirname } from "patha"
import which from "which" import which from "which"
import { tmpdir } from "os" import { tmpdir } from "os"
@ -7,6 +7,7 @@ import { mkdirP } from "@actions/io"
import { readFileSync } from "fs" import { readFileSync } from "fs"
import { addPath } from "../utils/env/addEnv" import { addPath } from "../utils/env/addEnv"
/* eslint-disable require-atomic-updates */
let binDir: string | undefined let binDir: string | undefined
// eslint-disable-next-line @typescript-eslint/no-unused-vars // eslint-disable-next-line @typescript-eslint/no-unused-vars
@ -25,10 +26,10 @@ export async function setupBrew(_version: string, _setupDir: string, _arch: stri
} }
// brew is not thread-safe // brew is not thread-safe
const brewTempDirectory = path.join(tmpdir(), "setup_cpp", "brew") const brewTempDirectory = path.join(tmpdir(), "setup-cpp", "brew")
await mkdirP(brewTempDirectory) await mkdirP(brewTempDirectory)
execa.sync("curl", ["-LJO", "https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh"], { execaSync("curl", ["-LJO", "https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh"], {
cwd: brewTempDirectory, cwd: brewTempDirectory,
}) })
const installSh = join(brewTempDirectory, "install.sh") const installSh = join(brewTempDirectory, "install.sh")
@ -39,7 +40,7 @@ export async function setupBrew(_version: string, _setupDir: string, _arch: stri
installShContent.replace("#!/bin/bash", "") installShContent.replace("#!/bin/bash", "")
} }
execa.sync("/bin/bash", [installSh], { execaSync("/bin/bash", [installSh], {
stdio: "inherit", stdio: "inherit",
env: { env: {
NONINTERACTIVE: "1", NONINTERACTIVE: "1",

View File

@ -20,7 +20,7 @@ export function setupCcache(version: string, _setupDir: string, _arch: string) {
if (isArch()) { if (isArch()) {
return setupPacmanPack("ccache", version) return setupPacmanPack("ccache", version)
} else if (hasDnf()) { } else if (hasDnf()) {
return setupDnfPack("ccache", version) return setupDnfPack([{ name: "ccache", version }])
} else if (isUbuntu()) { } else if (isUbuntu()) {
return setupAptPack([{ name: "ccache", version }]) return setupAptPack([{ name: "ccache", version }])
} }

12
src/check-updates.ts Normal file
View File

@ -0,0 +1,12 @@
import { warning } from "ci-log"
import updateNotifier from "simple-update-notifier"
import packageJson from "../package-version.json"
// auto self update notifier
export async function checkUpdates() {
try {
await updateNotifier({ pkg: packageJson })
} catch (err) {
warning(`Failed to check for updates: ${err instanceof Error ? err.message + err.stack : err}`)
}
}

View File

@ -1,7 +1,6 @@
/* eslint-disable require-atomic-updates */ /* eslint-disable require-atomic-updates */
import execa from "execa" import { execaSync } from "execa"
import { pathExists } from "path-exists"
import pathExists from "path-exists"
import { dirname } from "patha" import { dirname } from "patha"
import which from "which" import which from "which"
import { addPath } from "../utils/env/addEnv" import { addPath } from "../utils/env/addEnv"
@ -40,7 +39,7 @@ export async function setupChocolatey(
} }
// https://docs.chocolatey.org/en-us/choco/setup#install-with-cmd.exe // https://docs.chocolatey.org/en-us/choco/setup#install-with-cmd.exe
execa.sync( execaSync(
powershell, powershell,
[ [
"-NoProfile", "-NoProfile",

72
src/cli-options.ts Normal file
View File

@ -0,0 +1,72 @@
import { getInput } from "@actions/core"
import { info } from "ci-log"
import mri from "mri"
import { InstallationInfo } from "./utils/setup/setupBin"
import { Inputs, inputs } from "./tool"
export function parseArgs(args: string[]): Opts {
return mri<Record<Inputs, string | undefined> & { help: boolean }>(args, {
string: inputs,
default: Object.fromEntries(inputs.map((inp) => [inp, maybeGetInput(inp)])),
alias: { h: "help" },
boolean: "help",
})
}
export function printHelp() {
info(`
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.
--architecture\t the cpu architecture to install the tools for. By default it uses the current CPU architecture.
--compiler\t the <compiler> to install.
\t You can specify the version instead of specifying just the name e.g: --compiler 'llvm-13.0.0'
--$tool_name\t pass "true" or pass the <version> you would like to install for this tool. e.g. --conan true or --conan "1.42.1"
All the available tools:
`)
console.table(
{
"compiler and analyzer": { tools: `--llvm, --gcc, --msvc, --vcvarsall, --cppcheck, --clangtidy, --clangformat` },
"build system": { tools: `--cmake, --ninja, --meson, --make, --task, --bazel` },
"package manager": { tools: `--vcpkg, --conan, --choco, --brew, --nala` },
cache: { tools: `--cppcache, --sccache` },
documentation: { tools: `--doxygen, --graphviz` },
coverage: { tools: `--gcovr, --opencppcoverage, --kcov` },
other: { tools: `--python, --powershell, --sevenzip` },
},
["tools"]
)
}
/** Get an object from github actions */
export function maybeGetInput(key: string) {
const value = getInput(key.toLowerCase())
if (value !== "false" && value !== "") {
return value
}
return undefined // skip installation
}
export type Opts = mri.Argv<
Record<Inputs, string | undefined> & {
help: boolean
}
>
export function getSuccessMessage(tool: string, installationInfo: InstallationInfo | undefined | void) {
let msg = `${tool} was installed successfully:`
if (installationInfo === undefined) {
return msg
}
if ("installDir" in installationInfo) {
msg += `\n- The installation directory is ${installationInfo.installDir}`
}
if (installationInfo.binDir !== "") {
msg += `\n- The binary directory is ${installationInfo.binDir}`
}
return msg
}

View File

@ -1,6 +1,6 @@
import { setupCmake } from "../cmake" import { setupCmake } from "../cmake"
import { setupTmpDir, cleanupTmpDir, testBin } from "../../utils/tests/test-helpers" import { setupTmpDir, cleanupTmpDir, testBin } from "../../utils/tests/test-helpers"
import ciDetect from "@npmcli/ci-detect" import { GITHUB_ACTIONS } from "ci-info"
import { getVersion } from "../../versions/versions" import { getVersion } from "../../versions/versions"
jest.setTimeout(300000) jest.setTimeout(300000)
@ -19,7 +19,7 @@ describe("setup-cmake", () => {
it("should find CMake in the cache", async () => { it("should find CMake in the cache", async () => {
const { binDir } = await setupCmake(getVersion("cmake", "true"), directory, process.arch) const { binDir } = await setupCmake(getVersion("cmake", "true"), directory, process.arch)
await testBin("cmake", ["--version"], binDir) await testBin("cmake", ["--version"], binDir)
if (ciDetect() === "github-actions") { if (GITHUB_ACTIONS) {
expect(binDir).toMatch(process.env.RUNNER_TOOL_CACHE ?? "hostedtoolcache") expect(binDir).toMatch(process.env.RUNNER_TOOL_CACHE ?? "hostedtoolcache")
} }
}) })

114
src/compilers.ts Normal file
View File

@ -0,0 +1,114 @@
import { endGroup, notice, startGroup } from "@actions/core"
import { error, info } from "ci-log"
import { join } from "path"
import semverValid from "semver/functions/valid"
import { getSuccessMessage } from "./cli-options"
import { setupGcc, setupMingw } from "./gcc/gcc"
import { activateGcovGCC, activateGcovLLVM } from "./gcovr/gcovr"
import { setupLLVM } from "./llvm/llvm"
import { setupMSVC } from "./msvc/msvc"
import { addEnv } from "./utils/env/addEnv"
import { getVersion } from "./versions/versions"
/** Detecting the compiler version. Divide the given string by `-` and use the second element as the version */
export function getCompilerInfo(compilerAndVersion: string) {
const compilerAndMaybeVersion = compilerAndVersion.split("-")
const compiler = compilerAndMaybeVersion[0]
if (1 in compilerAndMaybeVersion) {
const maybeVersion = compilerAndMaybeVersion[1]
if (semverValid(maybeVersion) !== null) {
return { compiler, version: maybeVersion }
} else {
info(`Invalid semver version ${maybeVersion} used for the compiler.`)
return { compiler, version: maybeVersion }
}
}
return { compiler, version: undefined }
}
/** Installing the specified compiler */
export async function installCompiler(
compilerAndVersion: string,
osVersion: number[] | null,
setupCppDir: string,
arch: string,
successMessages: string[],
hasLLVM: boolean,
errorMessages: string[]
) {
try {
const { compiler, version } = getCompilerInfo(compilerAndVersion)
// install the compiler. We allow some aliases for the compiler name
startGroup(`Installing ${compiler} ${version ?? ""}`)
switch (compiler) {
case "llvm":
case "clang":
case "clang++": {
const installationInfo = await setupLLVM(
getVersion("llvm", version, osVersion),
join(setupCppDir, "llvm"),
arch
)
await activateGcovLLVM()
successMessages.push(getSuccessMessage("llvm", installationInfo))
break
}
case "gcc":
case "mingw":
case "cygwin":
case "msys": {
const gccVersion = getVersion("gcc", version, osVersion)
const installationInfo = (compiler === "mingw")? await setupMingw(gccVersion, join(setupCppDir, "gcc"), arch) : await setupGcc(gccVersion, join(setupCppDir, "gcc"), arch)
if (hasLLVM) {
// remove back the added CPPFLAGS of LLVM that include the LLVM headers
await addEnv("CPPFLAGS", "")
}
await activateGcovGCC(gccVersion)
successMessages.push(getSuccessMessage("gcc", installationInfo))
break
}
case "cl":
case "msvc":
case "msbuild":
case "vs":
case "visualstudio":
case "visualcpp":
case "visualc++": {
const installationInfo = await setupMSVC(
getVersion("msvc", version, osVersion),
join(setupCppDir, "msvc"),
arch
)
if (hasLLVM) {
// remove the CPPFLAGS of LLVM that include the LLVM headers
await addEnv("CPPFLAGS", "")
}
successMessages.push(getSuccessMessage("msvc", installationInfo))
break
}
case "appleclang":
case "applellvm": {
notice("Assuming apple-clang is already installed")
await Promise.all([addEnv("CC", "clang"), addEnv("CXX", "clang++")])
successMessages.push(getSuccessMessage("apple-clang", undefined))
break
}
default: {
errorMessages.push(`Unsupported compiler ${compiler}`)
}
}
} catch (err) {
error(err as string | Error)
errorMessages.push(`Failed to install the ${compilerAndVersion}`)
}
endGroup()
}

View File

@ -23,7 +23,7 @@ export async function setupCppcheck(version: string | undefined, _setupDir: stri
if (isArch()) { if (isArch()) {
return setupPacmanPack("cppcheck", version) return setupPacmanPack("cppcheck", version)
} else if (hasDnf()) { } else if (hasDnf()) {
return setupDnfPack("ccache", version) return setupDnfPack([{ name: "ccache", version }])
} else if (isUbuntu()) { } else if (isUbuntu()) {
return setupAptPack([{ name: "cppcheck", version }]) return setupAptPack([{ name: "cppcheck", version }])
} }

View File

@ -14,8 +14,9 @@ import { isArch } from "../utils/env/isArch"
import { hasDnf } from "../utils/env/hasDnf" import { hasDnf } from "../utils/env/hasDnf"
import { setupDnfPack } from "../utils/setup/setupDnfPack" import { setupDnfPack } from "../utils/setup/setupDnfPack"
import { isUbuntu } from "../utils/env/isUbuntu" import { isUbuntu } from "../utils/env/isUbuntu"
import pathExists from "path-exists" import { pathExists } from "path-exists"
import retry from "retry-as-promised" import retry from "retry-as-promised"
import { ubuntuVersion } from "../utils/env/ubuntu_version"
/** Get the platform data for cmake */ /** Get the platform data for cmake */
// eslint-disable-next-line @typescript-eslint/no-unused-vars // eslint-disable-next-line @typescript-eslint/no-unused-vars
@ -70,9 +71,9 @@ export async function setupDoxygen(version: string, setupDir: string, arch: stri
let installationInfo: InstallationInfo let installationInfo: InstallationInfo
if (version === "" || isArch() || hasDnf()) { if (version === "" || isArch() || hasDnf()) {
if (isArch()) { if (isArch()) {
installationInfo = setupPacmanPack("doxygen", version) installationInfo = await setupPacmanPack("doxygen", version)
} else if (hasDnf()) { } else if (hasDnf()) {
return setupDnfPack("doxygen", version) return setupDnfPack([{ name: "doxygen", version }])
} else if (isUbuntu()) { } else if (isUbuntu()) {
installationInfo = await setupAptPack([{ name: "doxygen", version }]) installationInfo = await setupAptPack([{ name: "doxygen", version }])
} else { } else {
@ -90,7 +91,7 @@ export async function setupDoxygen(version: string, setupDir: string, arch: stri
} else { } else {
throw new Error(`Unsupported linux distributions`) throw new Error(`Unsupported linux distributions`)
} }
await setupGraphviz(getVersion("graphviz", undefined), "", arch) await setupGraphviz(getVersion("graphviz", undefined, await ubuntuVersion()), "", arch)
return installationInfo return installationInfo
} }
default: { default: {

View File

@ -2,7 +2,7 @@ import { cleanupTmpDir, setupTmpDir, testBin } from "../../utils/tests/test-help
import { setupGcc } from "../gcc" import { setupGcc } from "../gcc"
import { getVersion } from "../../versions/versions" import { getVersion } from "../../versions/versions"
import { join, addExeExt } from "patha" import { join, addExeExt } from "patha"
import execa from "execa" import { execaSync } from "execa"
import { chmodSync } from "fs" import { chmodSync } from "fs"
import { ubuntuVersion } from "../../utils/env/ubuntu_version" import { ubuntuVersion } from "../../utils/env/ubuntu_version"
@ -29,11 +29,11 @@ describe("setup-gcc", () => {
// test compilation // test compilation
const file = join(__dirname, "main.cpp") const file = join(__dirname, "main.cpp")
const main_exe = join(__dirname, addExeExt("main")) const main_exe = join(__dirname, addExeExt("main"))
execa.sync("g++", [file, "-o", main_exe], { cwd: __dirname }) execaSync("g++", [file, "-o", main_exe], { cwd: __dirname })
if (process.platform !== "win32") { if (process.platform !== "win32") {
chmodSync(main_exe, "755") chmodSync(main_exe, "755")
} }
execa.sync(main_exe, { cwd: __dirname, stdio: "inherit" }) execaSync(main_exe, { cwd: __dirname, stdio: "inherit" })
}) })
afterAll(async () => { afterAll(async () => {

View File

@ -9,14 +9,15 @@ import semverCoerce from "semver/functions/coerce"
import { setupMacOSSDK } from "../macos-sdk/macos-sdk" import { setupMacOSSDK } from "../macos-sdk/macos-sdk"
import { join, addExeExt } from "patha" import { join, addExeExt } from "patha"
import { warning, info } from "ci-log" import { warning, info } from "ci-log"
import ciDetect from "@npmcli/ci-detect" import { GITHUB_ACTIONS } from "ci-info"
import { InstallationInfo, PackageInfo, setupBin } from "../utils/setup/setupBin" import { InstallationInfo, PackageInfo, setupBin } from "../utils/setup/setupBin"
import { extract7Zip } from "../utils/setup/extract" import { extract7Zip } from "../utils/setup/extract"
import { isArch } from "../utils/env/isArch" import { isArch } from "../utils/env/isArch"
import { isUbuntu } from "../utils/env/isUbuntu" import { isUbuntu } from "../utils/env/isUbuntu"
import { hasDnf } from "../utils/env/hasDnf" import { hasDnf } from "../utils/env/hasDnf"
import { setupDnfPack } from "../utils/setup/setupDnfPack" import { setupDnfPack } from "../utils/setup/setupDnfPack"
import pathExists from "path-exists" import { pathExists } from "path-exists"
import { ExecaReturnValue } from "execa"
interface MingwInfo { interface MingwInfo {
releaseName: string releaseName: string
@ -25,7 +26,12 @@ interface MingwInfo {
// https://github.com/brechtsanders/winlibs_mingw/releases // https://github.com/brechtsanders/winlibs_mingw/releases
const GccToMingwInfo = { const GccToMingwInfo = {
"12": { releaseName: "12.2.0-14.0.6-10.0.0-ucrt-r2", fileSuffix: "12.2.0-mingw-w64ucrt-10.0.0-r2" }, "13": { releaseName: "13.1.0posix-16.0.3-11.0.0-ucrt-r1", fileSuffix: "13.1.0-mingw-w64ucrt-11.0.0-r1" },
"13.1-ucrt": { releaseName: "13.1.0posix-16.0.3-11.0.0-ucrt-r1", fileSuffix: "13.1.0-mingw-w64ucrt-11.0.0-r1" },
"13.1-msvcrt": { releaseName: "13.1.0posix-16.0.3-11.0.0-msvcrt-r1", fileSuffix: "13.1.0-mingw-w64msvcrt-11.0.0-r1" },
"12": { releaseName: "12.3.0-16.0.4-11.0.0-ucrt-r1", fileSuffix: "12.3.0-mingw-w64ucrt-11.0.0-r1" },
"12.3.0-ucrt": { releaseName: "12.3.0-16.0.4-11.0.0-ucrt-r1", fileSuffix: "12.3.0-mingw-w64ucrt-11.0.0-r1" },
"12.3.0-msvcrt": { releaseName: "12.3.0-16.0.4-11.0.0-msvcrt-r1", fileSuffix: "12.3.0-mingw-w64msvcrt-11.0.0-r1" },
"12.2.0-ucrt": { releaseName: "12.2.0-14.0.6-10.0.0-ucrt-r2", fileSuffix: "12.2.0-mingw-w64ucrt-10.0.0-r2" }, "12.2.0-ucrt": { releaseName: "12.2.0-14.0.6-10.0.0-ucrt-r2", fileSuffix: "12.2.0-mingw-w64ucrt-10.0.0-r2" },
"12.2.0-msvcrt": { releaseName: "12.2.0-14.0.6-10.0.0-msvcrt-r2", fileSuffix: "12.2.0-mingw-w64msvcrt-10.0.0-r2" }, "12.2.0-msvcrt": { releaseName: "12.2.0-14.0.6-10.0.0-msvcrt-r2", fileSuffix: "12.2.0-mingw-w64msvcrt-10.0.0-r2" },
"12.1.0-ucrt": { releaseName: "12.1.0-14.0.4-10.0.0-ucrt-r2", fileSuffix: "12.1.0-mingw-w64ucrt-10.0.0-r2" }, "12.1.0-ucrt": { releaseName: "12.1.0-14.0.4-10.0.0-ucrt-r2", fileSuffix: "12.1.0-mingw-w64ucrt-10.0.0-r2" },
@ -90,11 +96,13 @@ export async function setupGcc(version: string, setupDir: string, arch: string)
case "linux": { case "linux": {
if (arch === "x64") { if (arch === "x64") {
if (isArch()) { if (isArch()) {
installationInfo = setupPacmanPack("gcc", version) installationInfo = await setupPacmanPack("gcc", version)
} else if (hasDnf()) { } else if (hasDnf()) {
installationInfo = setupDnfPack("gcc", version) installationInfo = await setupDnfPack([
setupDnfPack("gcc-c++", version) { name: "gcc", version },
setupDnfPack("libstdc++-devel", undefined) { name: "gcc-c++", version },
{ name: "libstdc++-devel" },
])
} else if (isUbuntu()) { } else if (isUbuntu()) {
installationInfo = await setupAptPack([ installationInfo = await setupAptPack([
{ name: "gcc", version, repositories: ["ppa:ubuntu-toolchain-r/test"] }, { name: "gcc", version, repositories: ["ppa:ubuntu-toolchain-r/test"] },
@ -104,7 +112,7 @@ export async function setupGcc(version: string, setupDir: string, arch: string)
} else { } else {
info(`Install g++-multilib because gcc for ${arch} was requested`) info(`Install g++-multilib because gcc for ${arch} was requested`)
if (isArch()) { if (isArch()) {
setupPacmanPack("gcc-multilib", version) await setupPacmanPack("gcc-multilib", version)
} else if (isUbuntu()) { } else if (isUbuntu()) {
await setupAptPack([{ name: "gcc-multilib", version, repositories: ["ppa:ubuntu-toolchain-r/test"] }]) await setupAptPack([{ name: "gcc-multilib", version, repositories: ["ppa:ubuntu-toolchain-r/test"] }])
} }
@ -137,30 +145,22 @@ export async function setupGcc(version: string, setupDir: string, arch: string)
export async function setupMingw(version: string, setupDir: string, arch: string) { export async function setupMingw(version: string, setupDir: string, arch: string) {
let installationInfo: InstallationInfo | undefined let installationInfo: InstallationInfo | undefined
switch (process.platform) { switch (process.platform) {
case "win32": { case "win32":
if (arch === "arm" || arch === "arm64") { case "darwin": {
await setupChocoPack("gcc-arm-embedded", version) return setupGcc(version, setupDir, arch)
}
try {
installationInfo = await setupBin("g++", version, getGccPackageInfo, setupDir, arch)
} catch (err) {
info(`Failed to download g++ binary. ${err}. Falling back to chocolatey.`)
installationInfo = await setupChocoMingw(version, arch)
}
break
} }
case "linux": { case "linux": {
if (arch === "x64" || arch === "x32") {
if (isArch()) { if (isArch()) {
return setupPacmanPack("mingw-w64", version, "yay") installationInfo = await setupPacmanPack("mingw-w64", version, "yay")
} else if (hasDnf()) { } else if (hasDnf()) {
return setupDnfPack("mingw64-gcc", version) installationInfo = await setupDnfPack([
{ name: "mingw64-gcc", version },
])
} else if (isUbuntu()) { } else if (isUbuntu()) {
installationInfo = await setupAptPack([ installationInfo = await setupAptPack([
{ name: "mingw-w64", version, repositories: ["ppa:ubuntu-toolchain-r/test"] }, { name: "mingw-w64", version, repositories: ["ppa:ubuntu-toolchain-r/test"] },
]) ])
} }
}
break break
} }
default: { default: {
@ -198,7 +198,7 @@ async function setupChocoMingw(version: string, arch: string): Promise<Installat
} }
async function activateGcc(version: string, binDir: string) { async function activateGcc(version: string, binDir: string) {
const promises: Promise<any>[] = [] const promises: Promise<void | ExecaReturnValue<string>>[] = []
// Setup gcc as the compiler // Setup gcc as the compiler
// TODO // TODO
@ -243,7 +243,7 @@ async function activateGcc(version: string, binDir: string) {
promises.push(setupMacOSSDK()) promises.push(setupMacOSSDK())
if (ciDetect() === "github-actions") { if (GITHUB_ACTIONS) {
await addGccLoggingMatcher() await addGccLoggingMatcher()
} }
@ -253,7 +253,7 @@ async function activateGcc(version: string, binDir: string) {
async function addGccLoggingMatcher() { async function addGccLoggingMatcher() {
const matcherPath = join(__dirname, "gcc_matcher.json") const matcherPath = join(__dirname, "gcc_matcher.json")
if (!(await pathExists(matcherPath))) { 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}`) info(`::add-matcher::${matcherPath}`)
} }

View File

@ -2,6 +2,7 @@ import { setupGraphviz } from "../graphviz"
import { cleanupTmpDir, setupTmpDir, testBin } from "../../utils/tests/test-helpers" import { cleanupTmpDir, setupTmpDir, testBin } from "../../utils/tests/test-helpers"
import { InstallationInfo } from "../../utils/setup/setupBin" import { InstallationInfo } from "../../utils/setup/setupBin"
import { getVersion } from "../../versions/versions" import { getVersion } from "../../versions/versions"
import { ubuntuVersion } from "../../utils/env/ubuntu_version"
jest.setTimeout(300000) jest.setTimeout(300000)
describe("setup-graphviz", () => { describe("setup-graphviz", () => {
@ -11,7 +12,11 @@ describe("setup-graphviz", () => {
}) })
it("should setup graphviz", async () => { it("should setup graphviz", async () => {
const installInfo = await setupGraphviz(getVersion("graphviz", undefined), directory, process.arch) const installInfo = await setupGraphviz(
getVersion("graphviz", undefined, await ubuntuVersion()),
directory,
process.arch
)
await testBin("dot", ["-V"], (installInfo as InstallationInfo | undefined)?.binDir) await testBin("dot", ["-V"], (installInfo as InstallationInfo | undefined)?.binDir)
}) })

View File

@ -23,7 +23,7 @@ export async function setupGraphviz(version: string, _setupDir: string, _arch: s
if (isArch()) { if (isArch()) {
return setupPacmanPack("graphviz", version) return setupPacmanPack("graphviz", version)
} else if (hasDnf()) { } else if (hasDnf()) {
return setupDnfPack("graphviz", version) return setupDnfPack([{ name: "graphviz", version }])
} else if (isUbuntu()) { } else if (isUbuntu()) {
return setupAptPack([{ name: "graphviz", version }]) return setupAptPack([{ name: "graphviz", version }])
} }

View File

@ -11,6 +11,18 @@ describe("setup-Kcov", () => {
return return
} }
it("should build and setup kcov-41", async () => {
const directory = await setupTmpDir("kcov-v41")
const { binDir } = (await setupKcov("41", directory, "")) as InstallationInfo
// the prebuild binary only works on ubuntu 20.04
try {
await testBin("kcov", ["--version"], binDir)
} catch (err) {
info((err as Error).message)
}
await cleanupTmpDir("kcov-v41")
})
it("should setup Kcov v40 via downloading the binaries", async () => { it("should setup Kcov v40 via downloading the binaries", async () => {
const directory = await setupTmpDir("kcov-v40") const directory = await setupTmpDir("kcov-v40")
const { binDir } = (await setupKcov("40-binary", directory, "")) as InstallationInfo const { binDir } = (await setupKcov("40-binary", directory, "")) as InstallationInfo
@ -39,7 +51,7 @@ describe("setup-Kcov", () => {
// it("should find Kcov in the cache", async () => { // it("should find Kcov in the cache", async () => {
// const binDir = await testKcov("v39", directory) // const binDir = await testKcov("v39", directory)
// if (ciDetect() === "github-actions") { // if (GITHUB_ACTIONS) {
// expect(binDir).toMatch(process.env.RUNNER_TOOL_CACHE ?? "hostedtoolcache") // expect(binDir).toMatch(process.env.RUNNER_TOOL_CACHE ?? "hostedtoolcache")
// } // }
// await cleanupTmpDir("kcov-v39") // await cleanupTmpDir("kcov-v39")

54
src/kcov/gcc13.patch Normal file
View File

@ -0,0 +1,54 @@
From b63754b53b3a7cf43e13ec56bd0be76cb6175437 Mon Sep 17 00:00:00 2001
From: Sergei Trofimovich <slyich@gmail.com>
Date: Thu, 15 Sep 2022 19:55:21 +0100
Subject: [PATCH] Fix build on gcc-13: add missing <stdint.h> include
[ 15%] Building CXX object src/CMakeFiles/kcov.dir/writers/cobertura-writer.cc.o
In file included from kcov/src/writers/cobertura-writer.cc:6:
kcov/src/include/reporter.hh:24:90: error: 'uint64_t' has not been declared
24 | LineExecutionCount(unsigned int hits, unsigned int possibleHits, uint64_t order) :
| ^~~~~~~~
---
src/include/collector.hh | 2 ++
src/include/reporter.hh | 1 +
src/include/source-file-cache.hh | 2 ++
3 files changed, 5 insertions(+)
diff --git a/src/include/collector.hh b/src/include/collector.hh
index 79e5d5f2..1369a416 100644
--- a/src/include/collector.hh
+++ b/src/include/collector.hh
@@ -2,6 +2,8 @@
#include <string>
+#include <stdint.h>
+
namespace kcov
{
class IFileParser;
diff --git a/src/include/reporter.hh b/src/include/reporter.hh
index bc058e69..98d8e56b 100644
--- a/src/include/reporter.hh
+++ b/src/include/reporter.hh
@@ -3,6 +3,7 @@
#include <string>
#include <stddef.h>
+#include <stdint.h>
namespace kcov
{
diff --git a/src/include/source-file-cache.hh b/src/include/source-file-cache.hh
index c0cb00ee..cfc73b81 100644
--- a/src/include/source-file-cache.hh
+++ b/src/include/source-file-cache.hh
@@ -3,6 +3,8 @@
#include <vector>
#include <string>
+#include <stdint.h>
+
namespace kcov
{
/**

Some files were not shown because too many files have changed in this diff Show More