Skip to content

Commit

Permalink
Merge branch 'master' into feature/cross-mingw
Browse files Browse the repository at this point in the history
  • Loading branch information
furudbat committed Apr 1, 2023
2 parents ae58022 + aefaf6c commit 20db333
Show file tree
Hide file tree
Showing 41 changed files with 1,703 additions and 1,355 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,16 +103,16 @@ jobs:
gzip: folders
draft: true
files: >
./exe/setup_cpp_windows.exe
./exe/setup_cpp_linux
./exe/setup_cpp_mac
./dist/node12/setup_cpp.js
./dist/node12/setup_cpp.js.map
./exe/setup-cpp-x64-windows.exe
./exe/setup-cpp-x64-linux
./exe/setup-cpp-x64-macos
./dist/node12/setup-cpp.js
./dist/node12/setup-cpp.js.map
./dist/node12/
./dist/node16/
Docker:
if: ${{ !contains(github.event.head_commit.message, '[skip ci]') && !contains(github.event.head_commit.message, '[skip docker]') }}
if: ${{ !contains(github.event.head_commit.message, '[skip ci]') && !contains(github.event.head_commit.message, '[skip test]') }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
Expand Down Expand Up @@ -166,4 +166,4 @@ jobs:
- name: Build
id: docker_build
run: |
docker build -f ./dev/docker/${{ matrix.container }} -t setup_cpp .
docker build -f ./dev/docker/${{ matrix.container }} -t setup-cpp .
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ stats.html
src/python/setup-python/
src/msvc/msvc-dev-cmd/
dev/cpp_vcpkg_project
package.json
109 changes: 51 additions & 58 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,69 +30,64 @@ Setting up a **cross-platform** environment for building and testing C++/C proje

### From Terminal

You should download the executable file or the js file (if Nodejs installed), and run it with the available options.
#### With npm and Nodejs

Tip: You can automate downloading using `wget`, `curl`, or other similar tools.
Install setup-cpp with npm:

#### Executable

Download the executable for your platform from [here](https://github.com/aminya/setup-cpp/releases/tag/v0.24.1), and run it with the available options.

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

```ps1
# windows example (open shell as admin)
curl.exe -LJO "https://github.com/aminya/setup-cpp/releases/download/v0.24.1/setup_cpp_windows.exe"
.\setup_cpp_windows --compiler llvm --cmake true --ninja true --ccache true --vcpkg true
RefreshEnv.cmd # activate cpp environment variables
```shell
npm install -g setup-cpp
```

```ps1
# linux example
wget "https://github.com/aminya/setup-cpp/releases/download/v0.24.1/setup_cpp_linux"
chmod +x setup_cpp_linux
sudo ./setup_cpp_linux --compiler llvm --cmake true --ninja true --ccache true --vcpkg true
Then run `setup-cpp` with the available options.

source ~/.cpprc # activate cpp environment variables
```shell
# windows example (open PowerShell as admin)
setup-cpp --compiler llvm --cmake true --ninja true --ccache true --vcpkg true

RefreshEnv.cmd # activate the environment
```

```ps1
# mac example
wget "https://github.com/aminya/setup-cpp/releases/download/v0.24.1/setup_cpp_mac"
chmod +x setup_cpp_mac
sudo ./setup_cpp_mac --compiler llvm --cmake true --ninja true --ccache true --vcpkg true
```shell
# linux/macos example
sudo setup-cpp --compiler llvm --cmake true --ninja true --ccache true --vcpkg true

source ~/.cpprc # activate cpp environment variables
source ~/.cpprc
```

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

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

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

#### With Nodejs
#### With executable

Download the `setup_cpp.js` file form [here](https://github.com/aminya/setup-cpp/releases/download/v0.24.1/setup_cpp.js), and run it with the available options.
Download the executable for your platform from [here](https://github.com/aminya/setup-cpp/releases/tag/v0.26.2), and run it with the available options. You can also automate downloading using `wget`, `curl`, or other similar tools.

On Windows:

Open the shell as admin, download via `curl`, then install
An example that installs llvm, cmake, ninja, ccache, and vcpkg:

```ps1
# open shell as admin
curl.exe -LJO "https://github.com/aminya/setup-cpp/releases/download/v0.24.1/setup_cpp.js"
node ./setup_cpp.js --compiler llvm --cmake true --ninja true --ccache true --vcpkg true
```shell
# windows example (open PowerShell as admin)
curl -LJO "https://github.com/aminya/setup-cpp/releases/download/v0.26.2/setup-cpp-x64-windows.exe"
./setup-cpp-x64-windows --compiler llvm --cmake true --ninja true --ccache true --vcpkg true

RefreshEnv.cmd # activate cpp environment variables
```

On Linux or Mac:
```shell
# linux example
wget "https://github.com/aminya/setup-cpp/releases/download/v0.26.2/setup-cpp-x64-linux"
chmod +x ./setup-cpp-x64-linux
sudo ./setup-cpp-x64-linux --compiler llvm --cmake true --ninja true --ccache true --vcpkg true

source ~/.cpprc # activate cpp environment variables
```

```ps1
wget "https://github.com/aminya/setup-cpp/releases/download/v0.24.1/setup_cpp.js"
sudo node ./setup_cpp.js --compiler llvm --cmake true --ninja true --ccache true --vcpkg true
```shell
# macos example
wget "https://github.com/aminya/setup-cpp/releases/download/v0.26.2/setup-cpp-x64-macos"
chmod +x ./setup-cpp-x64-macos
sudo ./setup-cpp-x64-macos --compiler llvm --cmake true --ninja true --ccache true --vcpkg true

source ~/.cpprc # activate cpp environment variables
```
Expand Down Expand Up @@ -160,21 +155,19 @@ jobs:

### Inside Docker

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

```dockerfile
#### Base Image
FROM ubuntu:22.04 AS base

# add setup_cpp
WORKDIR "/"
# add setup-cpp
RUN apt-get update -qq
RUN apt-get install -y --no-install-recommends wget
RUN wget --no-verbose "https://github.com/aminya/setup-cpp/releases/download/v0.24.1/setup_cpp_linux"
RUN chmod +x ./setup_cpp_linux
RUN apt-get install -y --no-install-recommends npm
RUN npm install -g setup-cpp

# install llvm, cmake, ninja, and ccache
RUN ./setup_cpp_linux --compiler llvm --cmake true --ninja true --ccache true --vcpkg true --make true
RUN setup-cpp --compiler llvm --cmake true --ninja true --ccache true --vcpkg true --make true

CMD source ~/.cpprc
ENTRYPOINT [ "/bin/bash" ]
Expand All @@ -199,18 +192,18 @@ See [this folder](https://github.com/aminya/setup-cpp/tree/master/dev/docker), f

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

```ps1
```shell
git clone --recurse-submodules https://github.com/aminya/setup-cpp
cd ./setup-cpp
docker build -f ./dev/docker/ubuntu.dockerfile -t setup_cpp .
docker build -f ./dev/docker/ubuntu.dockerfile -t setup-cpp .
```

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

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

```ps1
docker run -it setup_cpp
```shell
docker run -it setup-cpp
```

### Inside Docker inside GitHub Actions
Expand All @@ -230,7 +223,7 @@ jobs:
- name: Build
id: docker_build
run: |
docker build -f ./dev/docker/debian.dockerfile -t setup_cpp .
docker build -f ./dev/docker/debian.dockerfile -t setup-cpp .
```
### Inside GitLab pipelines
Expand Down Expand Up @@ -261,10 +254,10 @@ stages:
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 40976EAF437D05B5
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 1E9377A2BA9EF27F

.setup_cpp: &setup_cpp |
curl -LJO "https://github.com/aminya/setup-cpp/releases/download/v0.24.1/setup_cpp_linux"
chmod +x setup_cpp_linux
./setup_cpp_linux --compiler $compiler --cmake true --ninja true --ccache true --vcpkg true
.setup-cpp: &setup-cpp |
curl -LJO "https://github.com/aminya/setup-cpp/releases/download/v0.26.2/setup-cpp-x64-linux"
chmod +x setup-cpp-x64-linux
./setup-cpp-x64-linux --compiler $compiler --cmake true --ninja true --ccache true --vcpkg true
source ~/.cpprc

.test: &test |
Expand All @@ -277,7 +270,7 @@ test_linux_llvm:
compiler: llvm
script:
- *setup_linux
- *setup_cpp
- *setup-cpp
- *test

test_linux_gcc:
Expand All @@ -286,7 +279,7 @@ test_linux_gcc:
compiler: gcc
script:
- *setup_linux
- *setup_cpp
- *setup-cpp
- *test
```

Expand Down
5 changes: 4 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,13 @@ inputs:
nala:
description: 'The nala version to install ("" or "legacy").'
required: false
powershell:
description: "The powershell version to install."
required: false

runs:
using: "node16"
main: "dist/node16/setup_cpp.js"
main: "dist/node16/setup-cpp.js"

branding:
icon: "award"
Expand Down
16 changes: 7 additions & 9 deletions dev/docker/arch_node.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,28 @@ RUN pacman -S --noconfirm --needed nodejs
# curl for downloading setup-cpp
RUN pacman -S --noconfirm --needed curl

# add setup_cpp.js
# add setup-cpp.js
COPY "./dist/node12" "/"
WORKDIR "/"

# run installation
RUN node ./setup_cpp.js --compiler llvm --cmake true --ninja true --cppcheck true --ccache true --vcpkg true --doxygen true --gcovr true --task true
RUN node ./setup-cpp.js --compiler llvm --cmake true --ninja true --cppcheck true --ccache true --vcpkg true --doxygen true --gcovr true --task true

# clean up
RUN pacman -Scc --noconfirm
RUN rm -rf /tmp/*
CMD ["source", "~/.cpprc"]
ENTRYPOINT ["/bin/bash"]

CMD source ~/.cpprc
ENTRYPOINT [ "/bin/bash" ]

#### Building
FROM base AS builder
FROM base as builder
COPY ./dev/cpp_vcpkg_project /home/app
WORKDIR /home/app
RUN bash -c 'source ~/.cpprc \
&& task build'


### Running environment
# use a distroless image or ubuntu:22.04 if you wish
FROM gcr.io/distroless/cc
FROM gcr.io/distroless/cc as runner
# copy the built binaries and their runtime dependencies
COPY --from=builder /home/app/build/my_exe/Release/ /home/app/
WORKDIR /home/app/
Expand Down
22 changes: 9 additions & 13 deletions dev/docker/fedora_node.dockerfile
Original file line number Diff line number Diff line change
@@ -1,35 +1,31 @@
## base image
FROM fedora as base

# nodejs
RUN dnf -y install nodejs
# nodejs and curl for downloading setup-cpp
RUN dnf -y install nodejs curl

# curl for downloading setup-cpp
RUN dnf -y install curl

# add setup_cpp.js
# add setup-cpp.js
COPY "./dist/node12" "/"
WORKDIR "/"

# run installation
RUN node ./setup_cpp.js --compiler llvm --cmake true --ninja true --cppcheck true --ccache true --vcpkg true --doxygen true --gcovr true --task true --powershell true

# clean up
RUN rm -rf /tmp/*
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

CMD source ~/.cpprc
CMD ["source", "~/.cpprc"]
ENTRYPOINT [ "/bin/bash" ]


#### Building
FROM base AS builder
FROM base as builder
COPY ./dev/cpp_vcpkg_project /home/app
WORKDIR /home/app
RUN bash -c 'source ~/.cpprc \
&& task build'


### Running environment
# use a distroless image or ubuntu:22.04 if you wish
FROM gcr.io/distroless/cc
FROM gcr.io/distroless/cc as runner
# copy the built binaries and their runtime dependencies
COPY --from=builder /home/app/build/my_exe/Release/ /home/app/
WORKDIR /home/app/
Expand Down
24 changes: 12 additions & 12 deletions dev/docker/ubuntu.dockerfile
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
#### Base Image
FROM ubuntu:22.04 AS base
FROM ubuntu:22.04 as base

# add setup_cpp
WORKDIR "/"
# install setup-cpp
RUN apt-get update -qq
RUN apt-get install -y --no-install-recommends wget
RUN wget --no-verbose "https://github.com/aminya/setup-cpp/releases/download/v0.24.1/setup_cpp_linux"
RUN chmod +x ./setup_cpp_linux
RUN apt-get install -y --no-install-recommends npm
RUN npm install -g setup-cpp

# install llvm, cmake, ninja, and ccache
RUN ./setup_cpp_linux --compiler llvm --cmake true --ninja true --ccache true --vcpkg true --task true
RUN setup-cpp --compiler llvm --cmake true --ninja true --ccache true --vcpkg true --task true

CMD ["source", "~/.cpprc"]
ENTRYPOINT ["/bin/bash"]

CMD source ~/.cpprc
ENTRYPOINT [ "/bin/bash" ]

#### Building
FROM base AS builder
ADD ./dev/cpp_vcpkg_project /home/app
FROM base as builder
COPY ./dev/cpp_vcpkg_project /home/app
WORKDIR /home/app
RUN bash -c 'source ~/.cpprc \
&& task build'


### Running environment
# use a distroless image or ubuntu:22.04 if you wish
FROM gcr.io/distroless/cc
FROM gcr.io/distroless/cc as runner
# copy the built binaries and their runtime dependencies
COPY --from=builder /home/app/build/my_exe/Release/ /home/app/
WORKDIR /home/app/
Expand Down
Loading

0 comments on commit 20db333

Please sign in to comment.