Giter Site home page Giter Site logo

aminya / setup-cpp Goto Github PK

View Code? Open in Web Editor NEW
163.0 7.0 27.0 81.66 MB

Install all the tools required for building and testing C++/C projects.

License: Apache License 2.0

JavaScript 3.74% TypeScript 89.50% Dockerfile 6.25% C++ 0.51%
cpp github-actions llvm gcc msvc conan cmake ccache doxygen meson

setup-cpp's Introduction

setup-cpp

Install all the tools required for building and testing C++/C projects.

Build Status (Github Actions)

Setting up a cross-platform environment for building and testing C++/C projects is a bit tricky. Each platform has its own compilers, and each of them requires a different installation procedure. This package aims to fix this issue.

setup-cpp can be used locally from terminal, from CI services like GitHub Actions and GitLab Pipelines, and inside containers like Docker.

setup-cpp is supported on many platforms. It is continuously tested on several configurations including Windows (11, 10, 2022, 2019), Linux (Ubuntu 22.04, Ubuntu 20.04, Fedora, ArchLinux), and macOS (13, 12, 11, 10.15). setup-cpp is backed by unit tests for each tool and integration tests for compiling cpp projects.

Features

setup-cpp is modular and you can choose to install any of these tools:

category tools
compiler and analyzer llvm, gcc, msvc, vcvarsall, cppcheck, clangtidy, clangformat
build system cmake, ninja, meson, make, task, bazel
package manager vcpkg, conan, choco, brew, nala
cache cppcache, sccache
documentation doxygen, graphviz
coverage gcovr, opencppcoverage, kcov
other python, powershell, sevenzip

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

Usage

From Terminal

With npm and Nodejs

Run setup-cpp with the available options.

# Windows example (open PowerShell as admin)
npx setup-cpp --compiler llvm --cmake true --ninja true --ccache true --vcpkg true

RefreshEnv.cmd # activate the environment
# Linux/Macos example
sudo npx setup-cpp --compiler llvm --cmake true --ninja true --ccache true --vcpkg true

source ~/.cpprc

NOTE: In the compiler entry, you can specify the version after - like llvm-11.0.0. For the tools, you can pass a specific version instead of true that chooses the default version

NOTE: On Unix systems, when setup-cpp is used locally or in other CI services like GitLab, the environment variables are added to ~/.cpprc. You should run source ~/.cpprc to immediately activate the environment variables. This file is automatically sourced in the next shell restart from ~/.bashrc or ~/.profile if SOURCE_CPPRC is not set to 0. To deactivate .cpprc in the next shell restart, rename/remove ~/.cpprc.

NOTE: On Unix systems, if you are already a root user (e.g., in a GitLab runner or Docker), you will not need to use sudo.

NOTE: setup-cpp requires Nodejs 12 or higher. If Nodejs shipped with your distribution is older than 12, install the latest Node (e.g. for Ubuntu 20.04), or alternatively you can use the executables that are self-contained (see the next section).

With executable

Download the executable for your platform from here, and run it with the available options. You can also automate downloading using wget, curl, or other similar tools.

An example that installs llvm, cmake, ninja, ccache, and vcpkg:

# windows example (open PowerShell as admin)
curl -LJO "https://github.com/aminya/setup-cpp/releases/download/v0.37.0/setup-cpp-x64-windows.exe"
./setup-cpp-x64-windows --compiler llvm --cmake true --ninja true --ccache true --vcpkg true

RefreshEnv.cmd # activate cpp environment variables
# linux example
wget "https://github.com/aminya/setup-cpp/releases/download/v0.37.0/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

source ~/.cpprc # activate cpp environment variables
# macos example
wget "https://github.com/aminya/setup-cpp/releases/download/v0.37.0/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

Inside GitHub Actions

Here is a complete cross-platform example that tests llvm, gcc, and msvc. It also uses cmake, ninja, vcpkg, and cppcheck.

.github/workflows/ci.yml:

name: ci
on:
  pull_request:
  push:
    branches:
      - main
      - master

jobs:
  Test:
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os:
          - windows-2022
          - ubuntu-22.04
          - macos-12
        compiler:
          - llvm
          - gcc
          # you can specify the version after `-` like `llvm-13.0.0`.
        include:
          - os: "windows-2022"
            compiler: "msvc"
    steps:
      - uses: actions/checkout@v3
      - name: Cache
        uses: actions/cache@v3
        with:
          path: |
            ~/vcpkg
            ./build/vcpkg_installed
            ${{ env.HOME }}/.cache/vcpkg/archives
            ${{ env.XDG_CACHE_HOME }}/vcpkg/archives
            ${{ env.LOCALAPPDATA }}\vcpkg\archives
            ${{ env.APPDATA }}\vcpkg\archives
          key: ${{ runner.os }}-${{ matrix.compiler }}-${{ env.BUILD_TYPE }}-${{ hashFiles('**/CMakeLists.txt') }}-${{ hashFiles('./vcpkg.json')}}
          restore-keys: |
            ${{ runner.os }}-${{ env.BUILD_TYPE }}-

      - name: Setup Cpp
        uses: aminya/setup-cpp@v1
        with:
          compiler: ${{ matrix.compiler }}
          vcvarsall: ${{ contains(matrix.os, 'windows') }}
          cmake: true
          ninja: true
          vcpkg: true
          cppcheck: true
          clangtidy: true # instead of `true`, which chooses the default version, you can pass a specific version.
          # ...

Prebuilt Docker Images

To provide fast development environments, setup-cpp provides several prebuilt docker images that have the tools you need (e.g. llvm, cmake, ninja, task, vcpkg, python, make, cppcheck, gcovr, doxygen, ccache).

You can use these images as a base image for your project.

FROM aminya/setup-cpp-ubuntu-llvm:22.04-0.37.0 AS builder
FROM aminya/setup-cpp-ubuntu-mingw:22.04-0.37.0 AS builder
FROM aminya/setup-cpp-fedora-llvm:40-0.37.0 AS builder
FROM aminya/setup-cpp-arch-llvm:base-0.37.0 AS builder

The names are in the format aminya/setup-cpp-<platform>-<compiler>:<platform_version>-<setup_cpp_version>.

If you need to install the tools selectively, see the next section.

Inside Docker

Here is an example for using setup-cpp to make a builder image that has the Cpp tools you need.

#### 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 [email protected] && \
    # 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"]

#### 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"]

See this folder, for some dockerfile examples.

If you want to build the ones included, then run:

git clone --recurse-submodules https://github.com/aminya/setup-cpp
cd ./setup-cpp
docker build -f ./dev/docker/setup-cpp/setup-cpp-ubuntu.dockerfile -t setup-cpp-ubuntu-llvm:22.04-17 ./

Where you should use the path to the dockerfile after -f.

After build, run the following to start an interactive shell in your container

docker run -it setup-cpp-ubuntu-llvm:22.04-17

Inside Docker inside GitHub Actions

You can use the docker file discussed in the previous section inside GitHub Actions like the following:

jobs:
  Docker:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os:
          - ubuntu-22.04
    steps:
      - uses: actions/checkout@v3
      - name: Build
        id: docker_build
        run: |
          docker build -f ./dev/docker/ubuntu.dockerfile -t setup-cpp .

Inside GitLab pipelines

The following gives an example for setting up a C++ environment inside GitLab pipelines.

.gitlab-ci.yaml

image: ubuntu:22.04

stages:
  - test

.setup_linux: &setup_linux |
  DEBIAN_FRONTEND=noninteractive

  # set time-zone
  TZ=Canada/Pacific
  ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

  # for downloading
  apt-get update -qq
  apt-get install -y --no-install-recommends curl gnupg ca-certificates

.setup-cpp: &setup-cpp |
  # install nodejs
  apt-get install -y --no-install-recommends nodejs npm

  # install setup-cpp
  npm install -g [email protected]

  # install the compiler and tools
  ./setup-cpp-x64-linux --compiler $compiler --cmake true --ninja true --ccache true --vcpkg true
  source ~/.cpprc

.test: &test |
  # Build and Test
  # ...

test_linux_llvm:
  stage: test
  variables:
    compiler: llvm
  script:
    - *setup_linux
    - *setup-cpp
    - *test

test_linux_gcc:
  stage: test
  variables:
    compiler: gcc
  script:
    - *setup_linux
    - *setup-cpp
    - *test

Articles

Setup-Cpp on Dev.to

Usage Examples

See all of the usage examples on GitHub here.

setup-cpp's People

Contributors

abeimler avatar aminya avatar iainchesworth avatar lefticus avatar renovate[bot] avatar stevenvdschoot avatar tchaikov avatar wihmajster avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

setup-cpp's Issues

Add a `.setup_cpp_profile` file + Source in .bashrc

.profile is not automatically sourced on Linux. It is also useful to have a separate profile file. Then, this file should be sourced in the .bashrc and .profile files (with some checks to avoid recursion).

Improve LLVM dependency on GCC

Currently, the installation of LLVM installs GCC 11. This is fine for new operating systems, but for some old Ubuntu systems, GCC 11 might not be available.

Setup LLVM with RTTI

Is it possible to setup LLVM with RTTI?

I always get undefined reference to 'typeinfo for llvm::cl::GenericOptionValue' in my workflows.

Syncing GCOV env and GCC version to prevent empty uploads

Gcovr's documentation is pretty clear in that you should supply the version of gcov when calling the tool. Either by set GCOV=gcov-12 or --gcov-executable gcov-12, if you don't you run the risk of this happening. This took me a couple of days to figure out unfortunately. Luckily this is configurable in the workflow easily enough, I would just specify gcc-11 and gcov-11 to make it clear the versions are tied together to prevent future users from going down this path. 😄

Issues for local installation

  • addPath fails on a local install.

  • setup-python seems to fail. We should probably shell out in case of an error.

  • pip is not installed on a clean Ubuntu, while Python is!

Missing dependency for Clang 7-10 on Ubuntu 22

Hi there,

when using setup-cpp in GitHub Actions with os: ubuntu-22.04 and compiler: llvm-7 to llvm-10, I get the following error when building my source:

/home/runner/llvm/bin/clang++: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory

This is solved by adding this step to my workflow:

sudo apt-get install libtinfo5

I hence suggest that this dependency should be installed by setup-cpp for these compilers automaticlly.

Cheers and so long
Lucas

Add ARM CI and builds

Upvote & Fund

  • I am using Polar.sh so you can upvote and help fund this issue. The funding is received once the issue is completed & confirmed by you.

  • Thank you in advance for helping prioritize & fund our backlog.

Fund with Polar

MSVC installation issues

This is now mostly fixed for VS2019 and VS2017. But still requires some more testing. The best way to fix it is to run the tests and debug the issues.

Old Description

Copied from jberezanski/ChocolateyPackages#117

I am using visualstudio2017buildtools and visualstudio2019buildtools to set up MSVC. However, my tests fail because vcvars.bat cannot find the toolset.

https://github.com/aminya/setup-cpp

    invalid parameters
    [ERROR:vcvars.bat] Toolset directory for version '15.9' was not found.
    [ERROR:VsDevCmd.bat] *** VsDevCmd.bat encountered errors. Environment may be incomplete and/or incorrect. ***
    [ERROR:VsDevCmd.bat] In an uninitialized command prompt, please 'set VSCMD_DEBUG=[value]' and then re-run
    [ERROR:VsDevCmd.bat] vsdevcmd.bat [args] for additional details.
    [ERROR:VsDevCmd.bat] Where [value] is:
    [ERROR:VsDevCmd.bat]    1 : basic debug logging
    [ERROR:VsDevCmd.bat]    2 : detailed debug logging
    [ERROR:VsDevCmd.bat]    3 : trace level logging. Redirection of output to a file when using this level is recommended.
    [ERROR:VsDevCmd.bat] Example: set VSCMD_DEBUG=3
    [ERROR:VsDevCmd.bat]          vsdevcmd.bat > vsdevcmd.trace.txt 2>&1

https://github.com/aminya/setup-cpp/runs/3618796745?check_suite_focus=true#step:7:302

Upvote & Fund

  • I am using Polar.sh so you can upvote and help fund this issue. The funding is received once the issue is completed & confirmed by you.

  • Thank you in advance for helping prioritize & fund our backlog.

Fund with Polar

Docker: clean up after setup

Hello,
I'm using setup-cpp in my Dockerfile and saw the generated Layer is big (when installing a lot of tools).

Problem

image
16.3 GB

(it's hard to upload something this big to docker hub)

Dockerfile

## base image
FROM ubuntu:latest as base

ARG extra_libraries

ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update -y && apt-get install --no-install-recommends -y gnupg software-properties-common
# Install packages available from standard repos
RUN apt-get update -y && \
    apt-get install --no-install-recommends -yq \
        wget curl pkg-config zip unzip tar git && \
    apt-get clean && rm -rf /var/lib/apt/lists/*

# add setup_cpp
RUN wget --no-verbose "https://github.com/aminya/setup-cpp/releases/download/v0.13.1/setup_cpp_linux"
RUN chmod +x ./setup_cpp_linux
RUN ./setup_cpp_linux --compiler llvm --cmake true --ninja true --ccache true --clangformat true --clangtidy true

I add rm -rf /tmp/* && apt-get clean && rm -rf /var/lib/apt/lists/* for clean up and got: 14.3 GB

RUN ./setup_cpp_linux --compiler llvm \
    --cmake true --ninja true --ccache true \
    --cppcheck true --clangtidy true --clangformat true \
    --gcovr true --conan true --doxygen true && \
    rm -rf /tmp/* && apt-get clean && rm -rf /var/lib/apt/lists/*

(cleaning up the /tmp-folder seem to a bit help ?)

different setups

Readme example

RUN ./setup_cpp_linux --compiler llvm --cmake true --ninja true --ccache true --vcpkg true

image

gcc + conan

RUN ./setup_cpp_linux --compiler gcc --cmake true --ninja true --ccache true --conan true

Layer Size: 303.4 MB

with clang tools

idk why but the clang-tools seems huge after setup.

RUN ./setup_cpp_linux --compiler llvm --cmake true --ninja true --ccache true --conan true --cppcheck true --clangtidy true --clangformat true

Layer Size: 16 GB

with clangtidy

RUN ./setup_cpp_linux --compiler llvm --cmake true --ninja true --ccache true --clangtidy true

Layer Size: 11 GB

with clangformat

RUN ./setup_cpp_linux --compiler llvm --cmake true --ninja true --ccache true --clangformat true

Layer Size: 11 GB

My old setup

apt-get install --no-install-recommends -yq 
          gcc wget curl pkg-config zip unzip tar git build-essential &&     
apt-get install --no-install-recommends -y
          clang binutils bison
          python3 python3-pip doxygen graphviz         
          cmake make ninja-build ccache cppcheck cmake-extras   
          clang-tidy clang-format    
          valgrind gcovr linux-tools-common linux-tools-generic google-perftools         
          neovim emacs nano &&     
apt-get clean && rm -rf /var/lib/apt/lists/*

My old version with only apt-get setup was 1.1 GB (Layer Size)

Directory sizes in (docker) image

RUN du -sh /root/cmake
RUN du -sh /root/ninja
RUN du -sh /root/clangtidy
RUN du -sh /root/clangformat
RUN du -sh /root/llvm

Output

141M    /root/cmake
224K    /root/ninja
4.4G    /root/clangtidy
4.4G    /root/clangformat
4.4G    /root/llvm

Seems like llvm, clangtidy and clangformat are the same.
when installing llvm, and clang-tools, clang+llvm-14.0.0-x86_64-linux-gnu-ubuntu-18.04.tar.xz gets downloaded multiple times. (and extract into /root/llvm, /root/clang... ?)

Graphviz fails to install on Windows

Graphviz that is used by Doxygen fails to install on windows. I have disabled Graphviz for now.

 Graphviz v2.49.0 [Approved] graphviz package files install completed. Performing other installation steps.
 graphviz not installed. An error occurred during installation: Item has already been added. Key in dictionary:
 'Path' Key being added: 'PATH'

     Chocolatey installed 0/0 packages.
      See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).
     The process cannot access the file 'C:\ProgramData\chocolatey\lib\Graphviz\.chocolateyPending' because it is being used by another process.

       18 |     execa.sync("choco", ["install", "-y", name, `--version=${version}`, ...args])
       19 |   } else {
     > 20 |     execa.sync("choco", ["install", "-y", name, ...args])
          |           ^
       21 |   }
       22 |
       23 |   const binDir = "C:/ProgramData/Chocolatey/bin/"

       at makeError (node_modules/.pnpm/execa@5.1.1/node_modules/execa/lib/error.js:60:11)
       at Function.Object.<anonymous>.module.exports.sync (node_modules/.pnpm/execa@5.1.1/node_modules/execa/index.js:194:17)
       at setupChocoPack (src/utils/setup/setupChocoPack.ts:20:11)
       at setupDoxygen (src/doxygen/doxygen.ts:11:27)
       at Object.<anonymous> (src/doxygen/__tests__/doxygen.test.ts:8:25)

Integrate GitHub Actions Logging (problem matchers)

https://github.com/actions/toolkit/blob/master/docs/problem-matchers.md

example:

ThinLTO: CMakeFiles/main.dir/Release/src/main/main.cpp.o0: error: Invalid record
LLVM ERROR: Can't load module, abort.
clang-14: error: unable to execute command: Abort trap: 6
clang-14: error: linker command failed due to signal (use -v to see invocation)
CMake Warning at /Users/runner/work/project_options/project_options/src/Cache.cmake:33 (message):
  ccache is enabled but was not found.  Not using it
Call Stack (most recent call first):
  /Users/runner/work/project_options/project_options/src/Index.cmake:145 (enable_cache)
  CMakeLists.txt:31 (project_options)
  • meson
  • ld
    example:
ld: warning: dylib (/Users/runner/hostedtoolcache/llvm/14.0.0/x64/lib/libc++.dylib) was built for newer macOS version (11.6) than being linked (11.0)
  • python #35
  • ninja:
ninja: build stopped: subcommand failed.

  • task:
task: Failed to run task "test_release": exit status 1

How to contribute:

Here is an example for GCC:

setup-cpp/src/gcc/gcc.ts

Lines 120 to 131 in 016b16a

if (isGitHubCI()) {
addGccLoggingMatcher()
}
}
function addGccLoggingMatcher() {
const matcherPath = path.join(__dirname, "gcc_matcher.json")
if (!existsSync(matcherPath)) {
return warning("the gcc_matcher.json file does not exist in the same folder as setup_cpp.js")
}
info(`::add-matcher::${matcherPath}`)
}

The matcher file has a regex for matching the errors/warnings of the tool (escape " and \ in regex).
https://github.com/aminya/setup-cpp/blob/master/src/gcc/gcc_matcher.json

Script for copying the matcher to dist

"copy.matchers": "shx cp ./src/gcc/gcc_matcher.json ./dist/ && shx cp ./src/msvc/msvc_matcher.json ./dist && shx cp ./src/python/python_matcher.json ./dist/",

Upvote & Fund

  • I am using Polar.sh so you can upvote and help fund this issue. The funding is received once the issue is completed & confirmed by you.

  • Thank you in advance for helping prioritize & fund our backlog.

Fund with Polar

Specifying version of cppcheck fails on MacOS and Linux

Attempting to set cppcheck: 2.6 on MacOS or Linux fails to install a package.

However, it succeeds with no problem on Windows.

lefticus/json2cpp#7

(invalid syntax for brew?)
MacOS failure: https://github.com/lefticus/json2cpp/runs/5147554453?check_suite_focus=true#step:6:76

(ubuntu 20.04 package manager doesn't know cppcheck version 2.6)
Ubuntu Failure: https://github.com/lefticus/json2cpp/runs/5147554297?check_suite_focus=true#step:6:111

Upvote & Fund

  • I am using Polar.sh so you can upvote and help fund this issue. The funding is received once the issue is completed & confirmed by you.

  • Thank you in advance for helping prioritize & fund our backlog.

Fund with Polar

Support Arch-based Linux for apt installed packages

Currently, some of the packages like gcc are installed using apt on Linux. We can add support for Arch-based systems by either

  • downloading binaries or packages directly
  • using packman instead.

Packages to support on Arch:

  • python
  • ccache
  • sevenzip
  • doxygen
  • make
  • cppcheck
  • vcpkg dependencies (curl, zip, unzip, tar, git, pkg-config)
  • llvm dependencies (ld, etc)

https://github.com/aminya/setup-cpp/search?p=1&q=setupAptPack

Upvote & Fund

@aminya is using Polar.sh so you can upvote and help fund this issue. The funding is received once the issue is completed & confirmed by you.

Thank you in advance for helping prioritize & fund our backlog!


Fund with Polar

setup-cpp step fails in Node 12

The latest version appears to have a syntax error somewhere, leading to a very noisy error log. I suspect this is caused by a change within a8d76c6.

SyntaxError: Unexpected token '?'
    at wrapSafe (internal/modules/cjs/loader.js:915:16)
    at Module._compile (internal/modules/cjs/loader.js:963:[27](https://github.com/SK83RJOSH/nifly-utils/actions/runs/3079336898/jobs/4975505857#step:5:28))
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
    at internal/main/run_main_module.js:17:47

Better handling of a the GCC version installed for a LLVM version

So it turns out LLVM-15 doesn't fully support ranges in libc++, and as a result I've managed to get myself into a bit of a jam again with CI. 😢

That said, GCC-12 does support ranges, and ideally llvm versions >= 15 should install 12 instead of the default 11 as is done here. I would submit a PR for this, but I'm not 100% certain what the best way to go about this should be. Since GCC-12 still isn't available on ubuntu-latest images it doesn't make a whole lot of sense to bump the default version to 12, so perhaps a monkey patch checking for this LLVM version is most ideal?

Activating the already installed tools

setup-cpp should be able to reuse the already installed tools and only perform the activation steps (adding environment variables, adding to PATH, etc).

This is already done for some of the packages. We need to verify that this is done for all of them.

  • llvm
  • gcc
  • cmake
  • ninja
  • meson
  • conan
  • ccache
  • cppcheck
  • doxygen
  • gcovr
  • opencppcoverage
  • python
  • choco
  • brew
  • msvc

Publish the utility functions as separate packages

The utility functions I have written for setup-cpp are general, and they can be published as a separate package on npm to allow others to use them.
https://github.com/aminya/setup-cpp/tree/master/src/utils

Upvote & Fund

  • I am using Polar.sh so you can upvote and help fund this issue. The funding is received once the issue is completed & confirmed by you.

  • Thank you in advance for helping prioritize & fund our backlog.

Fund with Polar

LLVM 14 incompatible with MacOS 11?

https://github.com/aminya/project_options/runs/6100965907?check_suite_focus=true

ld: warning: dylib (/Users/runner/hostedtoolcache/llvm/14.0.0/x64/lib/libc++.dylib) was built for newer macOS version (11.6) than being linked (11.0)
ld: warning: dylib (/Users/runner/hostedtoolcache/llvm/14.0.0/x64/lib/libunwind.dylib) was built for newer macOS version (11.6) than being linked (11.0)
ld: warning: dylib (/Users/runner/hostedtoolcache/llvm/14.0.0/x64/lib/libunwind.dylib) was built for newer macOS version (11.6) than being linked (11.0)
ThinLTO: CMakeFiles/main.dir/Release/src/main/main.cpp.o0: error: Invalid record
LLVM ERROR: Can't load module, abort.
clang-14: error: unable to execute command: Abort trap: 6
clang-14: error: linker command failed due to signal (use -v to see invocation)

aminya/project_options#122 (comment)

Cppcheck has started to fail to install on Windows

The new version on choco is faulty
https://community.chocolatey.org/packages/cppcheck#versionhistory

https://github.com/aminya/cpp_vcpkg_project/runs/6600149257?check_suite_focus=true#step:4:428

  Progress: 100% - Completed download of C:\Users\runneradmin\AppData\Local\Temp\chocolatey\cppcheck\2.8\cppcheck-2.8-x64-Setup.msi (16.49 MB).
  Download of cppcheck-2.8-x64-Setup.msi (16.49 MB) completed.
  Hashes match.
  Installing cppcheck...
  ERROR: Running ["C:\Windows\System32\msiexec.exe" /i "C:\Users\runneradmin\AppData\Local\Temp\chocolatey\cppcheck\2.8\cppcheck-2.8-x64-Setup.msi" /quiet ADDLOCAL=CppcheckCore,CLI,GUI,Translations,ConfigFiles,PlatformFiles,PythonAddons,CRT /norestart ] was not successful. Exit code was '3010'​【917 m】. See log for possible error messages.
    cppcheck may be able to be automatically uninstalled.
   The install of cppcheck was successful.
    Software installed as 'MSI', install location is likely default.
  
  Chocolatey installed 2/2 packages. 
   See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).
  
  Packages requiring reboot:
   - cppcheck (exit code 3010)
  
  The recent package changes indicate a reboot is necessary.
   Please reboot at your earliest convenience.
  Error: Error: Command failed with exit code 3010: choco install -y cppcheck

Windows usage example fails in Windows 10

Example usage for windows works neither in PowerShell nor in command prompt (tested in Windows 10 sandbox).

curl -LJO "https://github.com/aminya/setup-cpp/releases/download/v0.14.0/setup_cpp_windows.exe"

That works in command prompt. However, it fails in PowerShell. Curl is an alias for Invoke-WebRequest in PowerShell. Replacing curl with curl.exe should work:

curl.exe -LJO "https://github.com/aminya/setup-cpp/releases/download/v0.14.0/setup_cpp_windows.exe"

./setup_cpp_windows --compiler llvm --cmake true --ninja true --ccache true --vcpkg true

That works in PowerShell but fails in the command prompt. Replacing Forward Slash with Backslash should work:

.\setup_cpp_windows --compiler llvm --cmake true --ninja true --ccache true --vcpkg true

Moreover, RefreshEnv.cmd fails If chocolatey has just been installed by setup_cpp. I am not sure what is the best solution in this case.

\ProgramData\chocolatey\bin\RefreshEnv.cmd

The above command works unless you have changed chocolatey default install location. However, both fails when you don't have choco installed, and setup_cpp does not install it either.

LLVM 15 fails the integration tests on MacOS

The MacOS cpp build tests are failing. It seems that the Clang 13 is not properly deleted from the previous test, and so the MacOS SDK is not set properly, so the std headers are not correctly included.

https://github.com/aminya/setup-cpp/actions/runs/3255107927/jobs/5344078514#step:9:131

Installing llvm 13.0.0 x64 via direct downloading

llvm 13.0.0 was found in the cache at /Users/runner/hostedtoolcache/llvm/13.0.0/x64/bin.
  console.log
    Testing the existence of /Users/runner/hostedtoolcache/llvm/13.0.0/x64/bin

      at testBin (src/utils/tests/test-helpers.ts:39:13)

  console.log
    Running /Users/runner/hostedtoolcache/llvm/13.0.0/x64/bin/clang-tidy --version

      at testBin (src/utils/tests/test-helpers.ts:47:13)

LLVM (http://llvm.org/):
  LLVM version 13.0.0
  Optimized build.
  Default target: x86_64-apple-darwin21.6.0
  Host CPU: ivybridge
  console.log
    Testing the existence of /Users/runner/hostedtoolcache/llvm/13.0.0/x64/bin

      at testBin (src/utils/tests/test-helpers.ts:39:13)

  console.log
    Running /Users/runner/hostedtoolcache/llvm/13.0.0/x64/bin/clang-format --version

      at testBin (src/utils/tests/test-helpers.ts:47:13)

clang-format version 13.0.0
Installing llvm 15.0.2 x64 via direct downloading

Add /var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/setup cpp temp/llvm/bin to PATH
/usr/bin/xcrun --sdk macosx --show-sdk-path
/Applications/Xcode_14.0.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk
  console.log
    Testing the existence of /var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/setup cpp temp/llvm/bin

      at testBin (src/utils/tests/test-helpers.ts:39:13)

  console.log
    Running /var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/setup cpp temp/llvm/bin/clang++ --version

      at testBin (src/utils/tests/test-helpers.ts:47:13)

clang version 13.0.0
Target: x86_64-apple-darwin21.6.0
Thread model: posix
InstalledDir: /var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/setup cpp temp/llvm/bin
FAIL src/llvm/__tests__/llvm.test.ts (139.453 s)
  setup-llvm
     Finds URL for ubuntu version (247 ms)
     Finds valid LLVM URLs (7384 ms)
     should setup LLVM (85600 ms)
     should find llvm in the cache (1726 ms)
     should setup clang-tidy and clang-format (903 ms)
     should setup LLVM 15.0.2 (19090 ms)

   setup-llvm  should setup LLVM 15.0.2

    Command failed with exit code 1: clang++ /Users/runner/work/setup-cpp/setup-cpp/src/llvm/__tests__/main.cpp -o /Users/runner/work/setup-cpp/setup-cpp/src/llvm/__tests__/main
    In file included from /Users/runner/work/setup-cpp/setup-cpp/src/llvm/__tests__/main.cpp:2:
    In file included from /var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/setup cpp temp/llvm/bin/../include/c++/v1/iostream:37:
    In file included from /var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/setup cpp temp/llvm/bin/../include/c++/v1/ios:214:
    In file included from /var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/setup cpp temp/llvm/bin/../include/c++/v1/__locale:15:
    In file included from /var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/setup cpp temp/llvm/bin/../include/c++/v1/string:520:
    In file included from /var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/setup cpp temp/llvm/bin/../include/c++/v1/__functional_base:22:
    In file included from /var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/setup cpp temp/llvm/bin/../include/c++/v1/exception:83:
    In file included from /var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/setup cpp temp/llvm/bin/../include/c++/v1/cstdlib:85:
    In file included from /var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/setup cpp temp/llvm/bin/../include/c++/v1/stdlib.h:93:
    In file included from /Applications/Xcode_14.0.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/usr/include/stdlib.h:66:
    In file included from /Applications/Xcode_14.0.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/usr/include/sys/wait.h:[110](https://github.com/aminya/setup-cpp/actions/runs/3255107927/jobs/5344078514#step:9:111):
Error:     /Applications/Xcode_14.0.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/usr/include/sys/resource.h:202:2: error: unknown type name 'uint8_t'
            uint8_t  ri_uuid[16];
            ^
Error:     /Applications/Xcode_14.0.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/usr/include/sys/resource.h:203:2: error: unknown type name 'uint64_t'
            uint64_t ri_user_time;
            ^
Error:     /Applications/Xcode_14.0.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/usr/include/sys/resource.h:204:2: error: unknown type name 'uint64_t'
            uint64_t ri_system_time;
            ^
Error:     /Applications/Xcode_14.0.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/usr/include/sys/resource.h:205:2: error: unknown type name 'uint64_t'
            uint64_t ri_pkg_idle_wkups;
            ^
Error:     /Applications/Xcode_14.0.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/usr/include/sys/resource.h:206:2: error: unknown type name 'uint64_t'
            uint64_t ri_interrupt_wkups;
            ^
Error:     /Applications/Xcode_14.0.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/usr/include/sys/resource.h:207:2: error: unknown type name 'uint64_t'
            uint64_t ri_pageins;
            ^
Error:     /Applications/Xcode_14.0.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/usr/include/sys/resource.h:208:2: error: unknown type name 'uint64_t'
            uint64_t ri_wired_size;
            ^
Error:     /Applications/Xcode_14.0.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/usr/include/sys/resource.h:209:2: error: unknown type name 'uint64_t'
            uint64_t ri_resident_size;
            ^
Error:     /Applications/Xcode_14.0.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/usr/include/sys/resource.h:210:2: error: unknown type name 'uint64_t'
            uint64_t ri_phys_footprint;
            ^
Error:     /Applications/Xcode_14.0.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/usr/include/sys/resource.h:211:2: error: unknown type name 'uint64_t'
            uint64_t ri_proc_start_abstime;
            ^
Error:     /Applications/Xcode_14.0.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/usr/include/sys/resource.h:212:2: error: unknown type name 'uint64_t'
            uint64_t ri_proc_exit_abstime;
            ^
Error:     /Applications/Xcode_14.0.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/usr/include/sys/resource.h:216:2: error: unknown type name 'uint8_t'
            uint8_t  ri_uuid[16];
            ^
Error:     /Applications/Xcode_14.0.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/usr/include/sys/resource.h:217:2: error: unknown type name 'uint64_t'
            uint64_t ri_user_time;
            ^
Error:     /Applications/Xcode_14.0.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/usr/include/sys/resource.h:218:2: error: unknown type name 'uint64_t'
            uint64_t ri_system_time;
            ^
Error:     /Applications/Xcode_14.0.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/usr/include/sys/resource.h:219:2: error: unknown type name 'uint64_t'
            uint64_t ri_pkg_idle_wkups;
            ^
Error:     /Applications/Xcode_14.0.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/usr/include/sys/resource.h:220:2: error: unknown type name 'uint64_t'
            uint64_t ri_interrupt_wkups;
            ^
Error:     /Applications/Xcode_14.0.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/usr/include/sys/resource.h:221:2: error: unknown type name 'uint64_t'
            uint64_t ri_pageins;
            ^
Error:     /Applications/Xcode_14.0.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/usr/include/sys/resource.h:222:2: error: unknown type name 'uint64_t'
            uint64_t ri_wired_size;
            ^
Error:     /Applications/Xcode_14.0.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/usr/include/sys/resource.h:223:2: error: unknown type name 'uint64_t'
            uint64_t ri_resident_size;
            ^
    fatal error: too many errors emitted, stopping now [-ferror-limit=]
    20 errors generated.

      [136](https://github.com/aminya/setup-cpp/actions/runs/3255107927/jobs/5344078514#step:9:137) |     const file = path.join(__dirname, "main.cpp")
      [137](https://github.com/aminya/setup-cpp/actions/runs/3255107927/jobs/5344078514#step:9:138) |     const main_exe = path.join(__dirname, addExeExt("main"))
    > [138](https://github.com/aminya/setup-cpp/actions/runs/3255107927/jobs/5344078514#step:9:139) |     execa.sync("clang++", [file, "-o", main_exe], { cwd: __dirname })
          |           ^
      [139](https://github.com/aminya/setup-cpp/actions/runs/3255107927/jobs/5344078514#step:9:140) |     if (process.platform !== "win32") {
      [140](https://github.com/aminya/setup-cpp/actions/runs/3255107927/jobs/5344078514#step:9:141) |       chmodSync(main_exe, "755")
      [141](https://github.com/aminya/setup-cpp/actions/runs/3255107927/jobs/5344078514#step:9:142) |     }

      at makeError (node_modules/.pnpm/execa@5.1.1/node_modules/execa/lib/error.js:60:11)
      at Function.Object.<anonymous>.module.exports.sync (node_modules/.pnpm/execa@5.1.1/node_modules/execa/index.js:[194](https://github.com/aminya/setup-cpp/actions/runs/3255107927/jobs/5344078514#step:9:195):17)
      at Object.<anonymous> (src/llvm/__tests__/llvm.test.ts:138:11)

Reusing pre-installed tools on the GitHub images

We can add an option to reuse pre-installed tools on the GitHub images. This can reduce the CI times.

Upvote & Fund

  • I am using Polar.sh so you can upvote and help fund this issue. The funding is received once the issue is completed & confirmed by you.

  • Thank you in advance for helping prioritize & fund our backlog.

Fund with Polar

Defaulting to LLVM 15

Currently, setup-cpp defaults to LLVM 13 because it is widely supported on several platforms including Ubuntu 18, Ubuntu 20, Ubuntu 22, MacOS 10.15, MacOS 11, MacOS 12, and Windows.

But we should probably default to LLVM 15 if it doesn't break the C++ integration tests.

Docker: add distroless image example

The docker example in the buildings folder produces a dev/build image. This should be only used for building once in the CI system.
Once the building is done, to run the app, one should use a distroless image.
https://github.com/GoogleContainerTools/distroless

FROM ubuntu:devel as builder
# ... setup-cpp

# then build your app (e.g. using CMake)

FROM gcr.io/distroless/cc
COPY --from=builder /build/your_binary /
COPY --from=builder /build/your_dll_files /
CMD ["./your_binary"]

We should add an example docker file that uses distroless images.

See #59

LLVM LDFLAGS with quotation marks

Hi there,

I'm having a weird issue in the interaction of my GitHub Actions CI environment and a C library called htslib.

The htslib Makefile defines some preprocessor values using quotation marks such as

echo '#define HTS_LDFLAGS "$(LDFLAGS)"' >> $@

In my GitHub Actions, I'm using setup-cpp with clang/llvm, which also uses quotation marks around flags such as

addEnv("LDFLAGS", `-L"${directory}/lib"`),

which causes the preprocessor value of htslib to become for example

#define HTS_LDFLAGS "-L"/home/runner/llvm/lib" -fvisibility=hidden "

That of course fails to compile, as the path in there is not part of the quoted string.

I'm currently working around this by having

export LDFLAGS=`echo ${LDFLAGS} | sed 's/"//g'`
export CPPFLAGS=`echo ${CPPFLAGS} | sed 's/"//g'`

in my CI setup, but that does not seam ideal.

Honestly, I'm not entirely sure who is right here. On the one hand, putting a path in quotation marks seems okay on the setup-cpp side. On the other hand, having flags in a quoted string seems necessary from the point of view of htslib. My guess is that htslib should escape quotation marks within the $(LDFLAGS) when processing the Makefile. I have opened an issue on their end.

However, I'm also opening this issue here, as I am not sure that those paths should necessarily be quoted in setup-cpp.

Cheers and thanks
Lucas

Support llvm-15.0.0

My project makes use of ranges and fails to compile with llvm-14.0.0 and thus I cannot use setup-cpp to for my CI.

install vcpkg dependencies on Windows and Macos

Currently, only the dependencies for Linux are installed.

Upvote & Fund

  • I am using Polar.sh so you can upvote and help fund this issue. The funding is received once the issue is completed & confirmed by you.

  • Thank you in advance for helping prioritize & fund our backlog.

Fund with Polar

invalid $HOME dir used on OSX?

bash-3.2$ wget "https://github.com/aminya/setup-cpp/releases/download/v0.13.0/setup_cpp_mac"
--2022-04-24 18:26:41--  https://github.com/aminya/setup-cpp/releases/download/v0.13.0/setup_cpp_mac
Auflösen des Hostnamens github.com (github.com)… 140.82.121.4
Verbindungsaufbau zu github.com (github.com)|140.82.121.4|:443 … verbunden.
HTTP-Anforderung gesendet, auf Antwort wird gewartet … 302 Found
Platz: https://objects.githubusercontent.com/github-production-release-asset-2e65be/406308261/bfdce48f-687f-480a-b19f-89ac66d15973?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20220424%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20220424T162641Z&X-Amz-Expires=300&X-Amz-Signature=52c1a545655cdff667b66f3669de059dfa95df4fea31f69aeb4f524b6e177e81&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=406308261&response-content-disposition=attachment%3B%20filename%3Dsetup_cpp_mac&response-content-type=application%2Foctet-stream [folgend]
--2022-04-24 18:26:41--  https://objects.githubusercontent.com/github-production-release-asset-2e65be/406308261/bfdce48f-687f-480a-b19f-89ac66d15973?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20220424%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20220424T162641Z&X-Amz-Expires=300&X-Amz-Signature=52c1a545655cdff667b66f3669de059dfa95df4fea31f69aeb4f524b6e177e81&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=406308261&response-content-disposition=attachment%3B%20filename%3Dsetup_cpp_mac&response-content-type=application%2Foctet-stream
Auflösen des Hostnamens objects.githubusercontent.com (objects.githubusercontent.com)… 185.199.108.133, 185.199.109.133, 185.199.110.133, ...
Verbindungsaufbau zu objects.githubusercontent.com (objects.githubusercontent.com)|185.199.108.133|:443 … verbunden.
HTTP-Anforderung gesendet, auf Antwort wird gewartet … 200 OK
Länge: 29593873 (28M) [application/octet-stream]
Wird in »setup_cpp_mac« gespeichert.

setup_cpp_mac                                  100%[=================================================================================================>]  28,22M  6,30MB/s    in 4,7s    

2022-04-24 18:26:47 (6,05 MB/s) - »setup_cpp_mac« gespeichert [29593873/29593873]

bash-3.2$ chmod +x setup_cpp_mac 
bash-3.2$ sudo ./setup_cpp_mac --compiler llvm-14.0.0
Password:
::group::Installing llvm 14.0.0
Installing llvm 14.0.0 x64 via direct downloading

::set-output name=version::14.0.0
Download and extract llvm 14.0.0
::debug::Downloading https://github.com/llvm/llvm-project/releases/download/llvmorg-14.0.0/clang+llvm-14.0.0-x86_64-apple-darwin.tar.xz
::debug::Destination /tmp/347b2dd2-f1ba-4a58-8494-c6be266b67a7
::debug::download complete
tar: could not chdir to '/home/clausklein/llvm'

Add /home/clausklein/llvm/bin to PATH
Error: ENOENT: no such file or directory, open '/home/clausklein/.cpprc'
Error: ENOENT: no such file or directory, open '/home/clausklein/.cpprc'
Failed to add /home/clausklein/llvm/bin to the percistent PATH. You should add it manually.
Error: ENOENT: no such file or directory, open '/home/clausklein/.cpprc'
Error: ENOENT: no such file or directory, open '/home/clausklein/.cpprc'
Failed to export environment variable LLVM_PATH=/home/clausklein/llvm. You should add it manually.
Error: ENOENT: no such file or directory, open '/home/clausklein/.cpprc'
Error: ENOENT: no such file or directory, open '/home/clausklein/.cpprc'
Failed to export environment variable LD_LIBRARY_PATH=/home/clausklein/llvm/lib:. You should add it manually.
Error: ENOENT: no such file or directory, open '/home/clausklein/.cpprc'
Error: ENOENT: no such file or directory, open '/home/clausklein/.cpprc'
Failed to export environment variable DYLD_LIBRARY_PATH=/home/clausklein/llvm/lib:. You should add it manually.
Error: ENOENT: no such file or directory, open '/home/clausklein/.cpprc'
Error: ENOENT: no such file or directory, open '/home/clausklein/.cpprc'
Failed to export environment variable LDFLAGS=-L/home/clausklein/llvm/lib. You should add it manually.
Error: ENOENT: no such file or directory, open '/home/clausklein/.cpprc'
Error: ENOENT: no such file or directory, open '/home/clausklein/.cpprc'
Failed to export environment variable CPPFLAGS=-I/home/clausklein/llvm/include. You should add it manually.
Error: ENOENT: no such file or directory, open '/home/clausklein/.cpprc'
Error: ENOENT: no such file or directory, open '/home/clausklein/.cpprc'
Failed to export environment variable CC=/home/clausklein/llvm/bin/clang. You should add it manually.
Error: ENOENT: no such file or directory, open '/home/clausklein/.cpprc'
Error: ENOENT: no such file or directory, open '/home/clausklein/.cpprc'
Failed to export environment variable CXX=/home/clausklein/llvm/bin/clang++. You should add it manually.
Error: ENOENT: no such file or directory, open '/home/clausklein/.cpprc'
Error: ENOENT: no such file or directory, open '/home/clausklein/.cpprc'
Failed to export environment variable LIBRARY_PATH=/home/clausklein/llvm/lib. You should add it manually.
[command]/usr/bin/xcrun --sdk macosx --show-sdk-path
2022-04-24 18:30:48.649 xcodebuild[22971:13218588] Requested but did not find extension point with identifier Xcode.IDEKit.ExtensionSentinelHostApplications for extension Xcode.DebuggerFoundation.AppExtensionHosts.watchOS of plug-in com.apple.dt.IDEWatchSupportCore
2022-04-24 18:30:48.649 xcodebuild[22971:13218588] Requested but did not find extension point with identifier Xcode.IDEKit.ExtensionPointIdentifierToBundleIdentifier for extension Xcode.DebuggerFoundation.AppExtensionToBundleIdentifierMap.watchOS of plug-in com.apple.dt.IDEWatchSupportCore
2022-04-24 18:30:52.989 xcodebuild[22973:13218640] Requested but did not find extension point with identifier Xcode.IDEKit.ExtensionSentinelHostApplications for extension Xcode.DebuggerFoundation.AppExtensionHosts.watchOS of plug-in com.apple.dt.IDEWatchSupportCore
2022-04-24 18:30:52.989 xcodebuild[22973:13218640] Requested but did not find extension point with identifier Xcode.IDEKit.ExtensionPointIdentifierToBundleIdentifier for extension Xcode.DebuggerFoundation.AppExtensionToBundleIdentifierMap.watchOS of plug-in com.apple.dt.IDEWatchSupportCore
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk
Error: ENOENT: no such file or directory, open '/home/clausklein/.cpprc'
Error: ENOENT: no such file or directory, open '/home/clausklein/.cpprc'
Failed to export environment variable SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk. You should add it manually.
::endgroup::
took 1 minute, 40 seconds
✅ llvm was installed successfully:
- The installation directory is /home/clausklein/llvm
- The binary directory is /home/clausklein/llvm/bin
setup_cpp finished
Run `source ~/.cpprc` or restart your shell to update the environment.
bash-3.2$ echo $HOME
/Users/clausklein
bash-3.2$ 

Add powershell tool

Add powershell for different platforms.
(For example needed for cross-compiling with vcpkg and x64-mingw-dynamic windows triplets, #103)
cmake/vcpkg error: Could not find Z_VCPKG_BUILTIN_POWERSHELL_PATH using the following names powershell

Old Powershell doesn't extract Zip files in Windows 10

Cmake, ninja, and task fail to install in Windows 10 because the Expand-Archive tool, used in extractZip function, requires files to have the zip extension. Adding it to the file before extracting it should fix the error.

PS C:\Users\WDAGUtilityAccount> .\setup_cpp_windows --cmake true --ninja true --task true                                                                                                 ::group::Installing cmake true
Installing cmake 3.23.1 x64 via direct downloading
Download and extract cmake 3.23.1
::debug::Downloading https://github.com/Kitware/CMake/releases/download/v3.23.1/cmake-3.23.1-windows-x86_64.zip
::debug::Destination C:\Users\WDAGUtilityAccount\AppData\Local\Temp\54ac4c22-6eea-403d-99e9-fcf92d7efa49
::debug::download complete
::debug::Using powershell at path: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe                                                                                              [command]C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoLogo -Sta -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command "$ErrorActionPreference = 'Stop' ; try { Add-Type -AssemblyName System.IO.Compression.FileSystem } catch { } ; if ((Get-Command -Name Expand-Archive -Module Microsoft.PowerShell.Archive -ErrorAction Ignore)) { Expand-Archive -LiteralPath 'C:\Users\WDAGUtilityAccount\AppData\Local\Temp\54ac4c22-6eea-403d-99e9-fcf92d7efa49' -DestinationPath 'C:\Users\WDAGUtilityAccount\cmake' -Force } else {[System.IO.Compression.ZipFile]::ExtractToDirectory('C:\Users\WDAGUtilityAccount\AppData\Local\Temp\54ac4c22-6eea-403d-99e9-fcf92d7efa49', 'C:\Users\WDAGUtilityAccount\cmake', $true) }"                     Expand-Archive :  is not a supported archive file format. .zip is the only supported archive file format.
At line:1 char:210
+ ...  Ignore)) { Expand-Archive -LiteralPath 'C:\Users\WDAGUtilityAccount\ ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:String) [Expand-Archive], IOException
    + FullyQualifiedErrorId : NotSupportedArchiveFileExtension,Expand-Archive

Error: Failed to download cmake 3.23.1 x64: Error: The process 'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe' failed with exit code 1
::endgroup::
took 8 seconds
::group::Installing ninja true
Installing ninja 1.10.2 x64 via direct downloading
Download and extract ninja 1.10.2
::debug::Downloading https://github.com/ninja-build/ninja/releases/download/v1.10.2/ninja-win.zip
::debug::Destination C:\Users\WDAGUtilityAccount\AppData\Local\Temp\65b659cf-18f2-47c0-a1da-91bb82ee90b4
::debug::download complete
::debug::Using powershell at path: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
[command]C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoLogo -Sta -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command "$ErrorActionPreference = 'Stop' ; try { Add-Type -AssemblyName System.IO.Compression.FileSystem } catch { } ; if ((Get-Command -Name Expand-Archive -Module Microsoft.PowerShell.Archive -ErrorAction Ignore)) { Expand-Archive -LiteralPath 'C:\Users\WDAGUtilityAccount\AppData\Local\Temp\65b659cf-18f2-47c0-a1da-91bb82ee90b4' -DestinationPath 'C:\Users\WDAGUtilityAccount\ninja' -Force } else {[System.IO.Compression.ZipFile]::ExtractToDirectory('C:\Users\WDAGUtilityAccount\AppData\Local\Temp\65b659cf-18f2-47c0-a1da-91bb82ee90b4', 'C:\Users\WDAGUtilityAccount\ninja', $true) }"
Expand-Archive :  is not a supported archive file format. .zip is the only supported archive file format.
At line:1 char:210
+ ...  Ignore)) { Expand-Archive -LiteralPath 'C:\Users\WDAGUtilityAccount\ ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:String) [Expand-Archive], IOException
    + FullyQualifiedErrorId : NotSupportedArchiveFileExtension,Expand-Archive

Error: Failed to download ninja 1.10.2 x64: Error: The process 'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe' failed with exit code 1
::endgroup::
took 3 seconds
::group::Installing task true
Installing task 3.12.0 x64 via direct downloading
Download and extract task 3.12.0
::debug::Downloading https://github.com/go-task/task/releases/download/v3.12.0/task_windows_amd64.zip
::debug::Destination C:\Users\WDAGUtilityAccount\AppData\Local\Temp\7ec4a653-ba1a-4af6-acdf-c6a9df7e5cb6
::debug::download complete
::debug::Using powershell at path: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
[command]C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoLogo -Sta -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command "$ErrorActionPreference = 'Stop' ; try { Add-Type -AssemblyName System.IO.Compression.FileSystem } catch { } ; if ((Get-Command -Name Expand-Archive -Module Microsoft.PowerShell.Archive -ErrorAction Ignore)) { Expand-Archive -LiteralPath 'C:\Users\WDAGUtilityAccount\AppData\Local\Temp\7ec4a653-ba1a-4af6-acdf-c6a9df7e5cb6' -DestinationPath 'C:\Users\WDAGUtilityAccount\task' -Force } else {[System.IO.Compression.ZipFile]::ExtractToDirectory('C:\Users\WDAGUtilityAccount\AppData\Local\Temp\7ec4a653-ba1a-4af6-acdf-c6a9df7e5cb6', 'C:\Users\WDAGUtilityAccount\task', $true) }"
Expand-Archive :  is not a supported archive file format. .zip is the only supported archive file format.
At line:1 char:210
+ ...  Ignore)) { Expand-Archive -LiteralPath 'C:\Users\WDAGUtilityAccount\ ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:String) [Expand-Archive], IOException
    + FullyQualifiedErrorId : NotSupportedArchiveFileExtension,Expand-Archive

Error: Failed to download task 3.12.0 x64: Error: The process 'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe' failed with exit code 1
::endgroup::
took 4 seconds
cmake failed to install
ninja failed to install
task failed to install
setup_cpp finished
Run `RefreshEnv.cmd` or restart your shell to update the environment.
PS C:\Users\WDAGUtilityAccount>

Some LLVM versions are not available for Ubuntu

I added the following to my action that is using ubuntu 22.04 (jammy):

    - uses: aminya/[email protected]
      with:
        llvm: 14.0.6

And instead of installing llvm 14.0.6, or even the claimed fallback of llvm 15.0.2, it tries to install gcc 11, and fails.

Installing llvm 14.0.6
  Installing llvm 14.0.6 x64 via direct downloading
  Warning: Falling back to LLVM version 15.0.2 -rhel86 for the Ubuntu.
  Installing gcc 11 via apt-get

The URL that the action tries to pull from the llvm releases page has not been published since llvm 14.0.0:

https://github.com/llvm/llvm-project/releases/tag/llvmorg-14.0.0 has 62 assets, while https://github.com/llvm/llvm-project/releases/tag/llvmorg-14.0.6 only has 44.

That is to say, https://github.com/llvm/llvm-project/releases/download/llvmorg-14.0.6/clang+llvm-14.0.6-x86_64-unknown-linux-gnu-rhel86.tar.xz does not exist.

So there are two issues:

  • Pulling x86_64 ubuntu packages from llvm-project github releases does not work anymore
  • The fallback to 15.0.2 failed, and installed gcc 11 instead, which is not an equivalent compiler. (it should probably be gcc 12)

Add an option to prefer the system package manager instead of directly downloading for download based packages

Some of the packages setup-cpp installs are installed by directly downloading the binaries (usually from GitHub) and storing them under ~/tool. This is flexible, clean, and reliable.

For example, setup-cpp can install all the versions of LLVM on any system without worrying about missing system dependencies. The uninstallation of them is as easy as deleting ~/llvm.

However, it might be useful to use the package manager of a system for local installations (apt, brew, and choco) to allow automatic updates. setup-cpp can add an option for preferring this method.

The packages that are installed by direct downloading:

  • llvm
  • ninja
  • cmake

These packages that are not available on all package managers:

  • kcov
  • task

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.