fix: make nala optional

This commit is contained in:
Amin Yahyaabadi 2022-07-27 17:36:18 -07:00
parent e4001f3bb1
commit 17fa293627
7 changed files with 22 additions and 30 deletions

View File

@ -10,7 +10,7 @@ Setting up a **cross-platform** environment for building and testing C++/C proje
`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 (12, 11, 10.15). `setup-cpp` is backed by unit tests for each tool and integration tests for compiling cpp projects. `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 (12, 11, 10.15). `setup-cpp` is backed by unit tests for each tool and integration tests for compiling cpp projects.
# Features ## Features
`setup-cpp` is **modular** and you can choose to install any of these tools: `setup-cpp` is **modular** and you can choose to install any of these tools:
@ -18,7 +18,7 @@ Setting up a **cross-platform** environment for building and testing C++/C proje
| --------------------- | ------------------------------------------------------------ | | --------------------- | ------------------------------------------------------------ |
| compiler and analyzer | llvm, gcc, msvc, vcvarsall, cppcheck, clangtidy, clangformat | | compiler and analyzer | llvm, gcc, msvc, vcvarsall, cppcheck, clangtidy, clangformat |
| build system | cmake, ninja, meson, make, task | | build system | cmake, ninja, meson, make, task |
| package manager | vcpkg, conan, choco, brew | | package manager | vcpkg, conan, choco, brew, nala |
| cache | cppcache | | cache | cppcache |
| documentation | doxygen, graphviz | | documentation | doxygen, graphviz |
| coverage | gcovr, opencppcoverage, kcov | | coverage | gcovr, opencppcoverage, kcov |
@ -26,15 +26,15 @@ Setting up a **cross-platform** environment for building and testing C++/C proje
`setup-cpp` automatically installs the dependencies above tools if needed for the selected tool (e.g., `python` is required for `conan`). `setup-cpp` automatically installs the dependencies above tools if needed for 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. You should download the executable file or the js file (if Nodejs installed), and run it with the available options.
Tip: You can automate downloading using `wget`, `curl`, or other similar tools. Tip: You can automate downloading using `wget`, `curl`, or other similar tools.
### Executable #### Executable
Download the executable for your platform from [here](https://github.com/aminya/setup-cpp/releases/tag/v0.18.0), and run it with the available options. Download the executable for your platform from [here](https://github.com/aminya/setup-cpp/releases/tag/v0.18.0), and run it with the available options.
@ -72,7 +72,7 @@ NOTE: On Unix systems, when `setup-cpp` is used locally or in other CI services
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, you will not need `sudo` if you are already a root user (e.g., in a GitLab runner or Docker).
### With Nodejs #### With Nodejs
Download the `setup_cpp.js` file form [here](https://github.com/aminya/setup-cpp/releases/download/v0.18.0/setup_cpp.js), and run it with the available options. Download the `setup_cpp.js` file form [here](https://github.com/aminya/setup-cpp/releases/download/v0.18.0/setup_cpp.js), and run it with the available options.
@ -97,7 +97,7 @@ sudo node ./setup_cpp.js --compiler llvm --cmake true --ninja true --ccache true
source ~/.cpprc # activate cpp environment variables source ~/.cpprc # activate cpp environment variables
``` ```
## Inside GitHub Actions ### Inside GitHub Actions
Here is a complete cross-platform example that tests llvm, gcc, and msvc. It also uses cmake, ninja, vcpkg, and cppcheck. Here is a complete cross-platform example that tests llvm, gcc, and msvc. It also uses cmake, ninja, vcpkg, and cppcheck.
@ -158,7 +158,7 @@ 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.
@ -213,7 +213,7 @@ After build, run the following to start an interactive shell in your container
docker run -it setup_cpp docker run -it setup_cpp
``` ```
## Inside Docker inside GitHub Actions ### Inside Docker inside GitHub Actions
You can use the docker file discussed in the previous section inside GitHub Actions like the following: You can use the docker file discussed in the previous section inside GitHub Actions like the following:
@ -235,7 +235,7 @@ jobs:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true ACTIONS_ALLOW_UNSECURE_COMMANDS: true
``` ```
## Inside GitLab pipelines ### Inside GitLab pipelines
The following gives an example for setting up a C++ environment inside GitLab pipelines. The following gives an example for setting up a C++ environment inside GitLab pipelines.
@ -292,11 +292,11 @@ test_linux_gcc:
- *test - *test
``` ```
# Articles ## Articles
[Setup-Cpp on Dev.to](https://dev.to/aminya/setup-cpp-3ia4) [Setup-Cpp on Dev.to](https://dev.to/aminya/setup-cpp-3ia4)
# Usage Examples ## Usage Examples
- [cpp_vcpkg_project project](https://github.com/aminya/cpp_vcpkg_project) - [cpp_vcpkg_project project](https://github.com/aminya/cpp_vcpkg_project)
- [ftxui](https://github.com/ArthurSonzogni/FTXUI) - [ftxui](https://github.com/ArthurSonzogni/FTXUI)

View File

@ -75,6 +75,9 @@ inputs:
sevenzip: sevenzip:
description: "The 7z version to install." description: "The 7z version to install."
required: false required: false
nala:
description: 'The nala version to install ("" or "legacy").'
required: false
runs: runs:
using: "node12" using: "node12"

2
dist/setup_cpp.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

2
dist/setup_cpp.mjs vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -43,10 +43,10 @@ import { addEnv } from "./utils/env/addEnv"
import { setupSevenZip } from "./sevenzip/sevenzip" import { setupSevenZip } from "./sevenzip/sevenzip"
import { setupGraphviz } from "./graphviz/graphviz" import { setupGraphviz } from "./graphviz/graphviz"
import { setupNala } from "./nala/nala" import { setupNala } from "./nala/nala"
import { isUbuntu } from "./utils/env/isUbuntu"
/** The setup functions */ /** The setup functions */
const setups = { const setups = {
nala: setupNala,
cmake: setupCmake, cmake: setupCmake,
ninja: setupNinja, ninja: setupNinja,
python: setupPython, python: setupPython,
@ -71,11 +71,11 @@ const setups = {
make: setupMake, make: setupMake,
task: setupTask, task: setupTask,
sevenzip: setupSevenZip, sevenzip: setupSevenZip,
nala: setupNala,
} }
/** The tools that can be installed */ /** The tools that can be installed */
const tools: Array<keyof typeof setups> = [ const tools: Array<keyof typeof setups> = [
"nala",
"choco", "choco",
"brew", "brew",
"python", "python",
@ -100,7 +100,6 @@ const tools: Array<keyof typeof setups> = [
"make", "make",
"task", "task",
"sevenzip", "sevenzip",
"nala",
] ]
/** The possible inputs to the program */ /** The possible inputs to the program */
@ -155,17 +154,6 @@ export async function main(args: string[]): Promise<number> {
return 1 return 1
} }
// https://gitlab.com/volian/nala/-/issues/115
//
if (isUbuntu()) {
try {
setupNala(getVersion("nala", undefined, osVersion), "", arch)
} catch (err) {
warning((err as Error).toString())
// continue with apt-get
}
}
// loop over the tools and run their setup function // loop over the tools and run their setup function
for (const tool of tools) { for (const tool of tools) {
// get the version or "true" or undefined for this tool from the options // get the version or "true" or undefined for this tool from the options
@ -387,6 +375,7 @@ All the available tools:
--python --python
--choco --choco
--brew --brew
--nala
--sevenzip --sevenzip
--graphviz --graphviz
`) `)