mirror of
https://github.com/CachyOS/New-Cli-Installer.git
synced 2025-01-23 05:52:23 +08:00
👷 apply iwyu
add docker devenv
This commit is contained in:
parent
297c353e40
commit
12d4a06b52
@ -27,7 +27,7 @@ pkg_check_modules(
|
|||||||
LIBNM
|
LIBNM
|
||||||
REQUIRED
|
REQUIRED
|
||||||
IMPORTED_TARGET
|
IMPORTED_TARGET
|
||||||
libnm>=1.32.12)
|
libnm>=1.10.6)
|
||||||
|
|
||||||
FetchContent_Declare(ftxui
|
FetchContent_Declare(ftxui
|
||||||
GIT_REPOSITORY "https://github.com/arthursonzogni/ftxui.git"
|
GIT_REPOSITORY "https://github.com/arthursonzogni/ftxui.git"
|
||||||
|
86
Dockerfile
Normal file
86
Dockerfile
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
FROM ubuntu:bionic
|
||||||
|
|
||||||
|
# Install packages available from standard repos
|
||||||
|
RUN apt-get update -qq && \
|
||||||
|
apt-get install -y --no-install-recommends \
|
||||||
|
software-properties-common wget git gpg-agent file \
|
||||||
|
python3 python3-pip graphviz ccache cppcheck build-essential \
|
||||||
|
neovim
|
||||||
|
|
||||||
|
# User-settable versions:
|
||||||
|
# This Dockerfile should support gcc-[7, 8, 9, 10] and clang-[10, 11]
|
||||||
|
# Earlier versions of clang will require significant modifications to the IWYU section
|
||||||
|
ARG GCC_VER="10"
|
||||||
|
ARG LLVM_VER="11"
|
||||||
|
|
||||||
|
# Add gcc-${GCC_VER}
|
||||||
|
RUN add-apt-repository -y ppa:ubuntu-toolchain-r/test && \
|
||||||
|
apt-get update -qq && \
|
||||||
|
apt-get install -y --no-install-recommends gcc-${GCC_VER} g++-${GCC_VER}
|
||||||
|
|
||||||
|
# Add clang-${LLVM_VER}
|
||||||
|
RUN wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - 2>/dev/null && \
|
||||||
|
add-apt-repository -y "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-${LLVM_VER} main" && \
|
||||||
|
apt-get update -qq && \
|
||||||
|
apt-get install -y --no-install-recommends \
|
||||||
|
clang-${LLVM_VER} lldb-${LLVM_VER} lld-${LLVM_VER} clangd-${LLVM_VER} \
|
||||||
|
llvm-${LLVM_VER}-dev libclang-${LLVM_VER}-dev clang-tidy-${LLVM_VER}
|
||||||
|
|
||||||
|
# Add current cmake/ccmake, from Kitware
|
||||||
|
RUN wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null \
|
||||||
|
| gpg --dearmor - | tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null && \
|
||||||
|
apt-add-repository 'deb https://apt.kitware.com/ubuntu/ bionic main' && \
|
||||||
|
apt-get update -qq && \
|
||||||
|
apt-get install -y --no-install-recommends cmake cmake-curses-gui
|
||||||
|
|
||||||
|
# Set the default clang-tidy, so CMake can find it
|
||||||
|
RUN update-alternatives --install /usr/bin/clang-tidy clang-tidy $(which clang-tidy-${LLVM_VER}) 1
|
||||||
|
|
||||||
|
# Install include-what-you-use
|
||||||
|
ENV IWYU /home/iwyu
|
||||||
|
ENV IWYU_BUILD ${IWYU}/build
|
||||||
|
ENV IWYU_SRC ${IWYU}/include-what-you-use
|
||||||
|
RUN mkdir -p ${IWYU_BUILD} && \
|
||||||
|
git clone --branch clang_${LLVM_VER} \
|
||||||
|
https://github.com/include-what-you-use/include-what-you-use.git \
|
||||||
|
${IWYU_SRC}
|
||||||
|
RUN CC=clang-${LLVM_VER} CXX=clang++-${LLVM_VER} cmake -S ${IWYU_SRC} \
|
||||||
|
-B ${IWYU_BUILD} \
|
||||||
|
-G "Unix Makefiles" -DCMAKE_PREFIX_PATH=/usr/lib/llvm-${LLVM_VER} && \
|
||||||
|
cmake --build ${IWYU_BUILD} -j && \
|
||||||
|
cmake --install ${IWYU_BUILD}
|
||||||
|
|
||||||
|
# Per https://github.com/include-what-you-use/include-what-you-use#how-to-install:
|
||||||
|
# `You need to copy the Clang include directory to the expected location before
|
||||||
|
# running (similarly, use include-what-you-use -print-resource-dir to learn
|
||||||
|
# exactly where IWYU wants the headers).`
|
||||||
|
RUN mkdir -p $(include-what-you-use -print-resource-dir 2>/dev/null)
|
||||||
|
RUN ln -s $(readlink -f /usr/lib/clang/${LLVM_VER}/include) \
|
||||||
|
$(include-what-you-use -print-resource-dir 2>/dev/null)/include
|
||||||
|
|
||||||
|
## Cleanup cached apt data we don't need anymore
|
||||||
|
#RUN apt-get clean && \
|
||||||
|
# rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# Set gcc-${GCC_VER} as default gcc
|
||||||
|
RUN update-alternatives --install /usr/bin/gcc gcc $(which gcc-${GCC_VER}) 100
|
||||||
|
RUN update-alternatives --install /usr/bin/g++ g++ $(which g++-${GCC_VER}) 100
|
||||||
|
|
||||||
|
# Set clang-${LLVM_VER} as default clang
|
||||||
|
RUN update-alternatives --install /usr/bin/clang clang $(which clang-${LLVM_VER}) 100
|
||||||
|
RUN update-alternatives --install /usr/bin/clang++ clang++ $(which clang++-${LLVM_VER}) 100
|
||||||
|
|
||||||
|
# Allow the user to set compiler defaults
|
||||||
|
ARG USE_CLANG
|
||||||
|
# if --build-arg USE_CLANG=1, set CC to 'clang' or set to null otherwise.
|
||||||
|
ENV CC=${USE_CLANG:+"clang"}
|
||||||
|
ENV CXX=${USE_CLANG:+"clang++"}
|
||||||
|
# if CC is null, set it to 'gcc' (or leave as is otherwise).
|
||||||
|
ENV CC=${CC:-"gcc"}
|
||||||
|
ENV CXX=${CXX:-"g++"}
|
||||||
|
|
||||||
|
# Include project
|
||||||
|
ADD . /starter_project
|
||||||
|
WORKDIR /starter_project
|
||||||
|
|
||||||
|
CMD ["/bin/bash"]
|
@ -36,7 +36,7 @@ fmt = dependency('fmt', version : ['>=8.0.0'], fallback : ['fmt', 'fmt_dep'])
|
|||||||
ftxui = dependency('ftxui', modules : ['ftxui::screen', 'ftxui::dom', 'ftxui::component'], fallback : ['ftxui', 'ftxui_dep'])
|
ftxui = dependency('ftxui', modules : ['ftxui::screen', 'ftxui::dom', 'ftxui::component'], fallback : ['ftxui', 'ftxui_dep'])
|
||||||
nlohmann_json = dependency('nlohmann_json', version : ['>=3.10.4'], fallback : ['nlohmann_json', 'nlohmann_json_dep'])
|
nlohmann_json = dependency('nlohmann_json', version : ['>=3.10.4'], fallback : ['nlohmann_json', 'nlohmann_json_dep'])
|
||||||
cpr = dependency('cpr', version : ['>=1.7.0'], fallback : ['cpr', 'cpr_dep'])
|
cpr = dependency('cpr', version : ['>=1.7.0'], fallback : ['cpr', 'cpr_dep'])
|
||||||
libnm = dependency('libnm', version : ['>=1.32.12'])
|
libnm = dependency('libnm', version : ['>=1.10.6'])
|
||||||
|
|
||||||
src_files = files(
|
src_files = files(
|
||||||
'src/definitions.hpp',
|
'src/definitions.hpp',
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
#ifndef DEFINITIONS_HPP
|
#ifndef DEFINITIONS_HPP
|
||||||
#define DEFINITIONS_HPP
|
#define DEFINITIONS_HPP
|
||||||
|
|
||||||
|
#include <cstdio> // for stderr
|
||||||
|
|
||||||
#include <fmt/color.h>
|
#include <fmt/color.h>
|
||||||
#include <fmt/core.h>
|
#include <fmt/core.h>
|
||||||
|
|
||||||
|
@ -3,9 +3,9 @@
|
|||||||
#include "tui.hpp"
|
#include "tui.hpp"
|
||||||
#include "utils.hpp"
|
#include "utils.hpp"
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono> // for seconds
|
||||||
#include <regex>
|
#include <regex> // for regex_search, match_results<>::_Base_type
|
||||||
#include <thread>
|
#include <thread> // for sleep_for
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
const auto& tty = utils::exec("tty");
|
const auto& tty = utils::exec("tty");
|
||||||
|
15
src/tui.cpp
15
src/tui.cpp
@ -2,12 +2,15 @@
|
|||||||
#include "definitions.hpp"
|
#include "definitions.hpp"
|
||||||
#include "utils.hpp"
|
#include "utils.hpp"
|
||||||
|
|
||||||
#include <ftxui/component/captured_mouse.hpp>
|
/* clang-format off */
|
||||||
#include <ftxui/component/component.hpp>
|
#include <memory> // for __shared_ptr_access
|
||||||
#include <ftxui/component/component_options.hpp>
|
#include <string> // for basic_string
|
||||||
#include <ftxui/component/screen_interactive.hpp>
|
#include <ftxui/component/captured_mouse.hpp> // for ftxui
|
||||||
#include <ftxui/dom/elements.hpp>
|
#include <ftxui/component/component.hpp> // for Renderer, Button
|
||||||
#include <ftxui/screen/screen.hpp>
|
#include <ftxui/component/component_options.hpp> // for ButtonOption
|
||||||
|
#include <ftxui/component/screen_interactive.hpp> // for Component, ScreenI...
|
||||||
|
#include <ftxui/dom/elements.hpp> // for operator|, size
|
||||||
|
/* clang-format on */
|
||||||
|
|
||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
|
|
||||||
|
@ -1,7 +1,11 @@
|
|||||||
#ifndef TUI_HPP
|
#ifndef TUI_HPP
|
||||||
#define TUI_HPP
|
#define TUI_HPP
|
||||||
|
|
||||||
#include <ftxui/component/component.hpp>
|
/* clang-format off */
|
||||||
|
#include <string_view> // for string_view
|
||||||
|
#include <ftxui/component/component_base.hpp> // for Component
|
||||||
|
#include <ftxui/dom/elements.hpp> // for Element
|
||||||
|
/* clang-format on */
|
||||||
|
|
||||||
namespace tui {
|
namespace tui {
|
||||||
ftxui::Element centered_widget(ftxui::Component& container, const std::string_view& title, const ftxui::Element& widget);
|
ftxui::Element centered_widget(ftxui::Component& container, const std::string_view& title, const ftxui::Element& widget);
|
||||||
|
@ -1,13 +1,19 @@
|
|||||||
#include "utils.hpp"
|
#include "utils.hpp"
|
||||||
#include "config.hpp"
|
#include "config.hpp"
|
||||||
|
|
||||||
#include <sys/mount.h>
|
#include <array> // for array
|
||||||
#include <sys/wait.h>
|
#include <chrono> // for filesystem, seconds
|
||||||
|
#include <cstdint> // for int32_t
|
||||||
#include <filesystem>
|
#include <cstdio> // for feof, fgets, pclose, perror, popen
|
||||||
#include <iostream>
|
#include <cstdlib> // for exit, WIFEXITED, WIFSIGNALED
|
||||||
#include <string>
|
#include <filesystem> // for exists, is_directory
|
||||||
#include <thread>
|
#include <iostream> // for basic_istream, cin
|
||||||
|
#include <string> // for operator==, string, basic_string, allocator
|
||||||
|
#include <sys/mount.h> // for mount
|
||||||
|
#include <sys/wait.h> // for waitpid
|
||||||
|
#include <thread> // for sleep_for
|
||||||
|
#include <unistd.h> // for execvp, fork
|
||||||
|
#include <unordered_map> // for unordered_map
|
||||||
|
|
||||||
#include <cpr/api.h>
|
#include <cpr/api.h>
|
||||||
#include <cpr/response.h>
|
#include <cpr/response.h>
|
||||||
@ -41,7 +47,7 @@ bool check_root() noexcept {
|
|||||||
|
|
||||||
void clear_screen() noexcept {
|
void clear_screen() noexcept {
|
||||||
static constexpr auto CLEAR_SCREEN_ANSI = "\033[1;1H\033[2J";
|
static constexpr auto CLEAR_SCREEN_ANSI = "\033[1;1H\033[2J";
|
||||||
write(STDOUT_FILENO, CLEAR_SCREEN_ANSI, 11);
|
output("{}", CLEAR_SCREEN_ANSI);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string exec(const std::string_view& command, bool capture_output) noexcept {
|
std::string exec(const std::string_view& command, bool capture_output) noexcept {
|
||||||
@ -50,7 +56,7 @@ std::string exec(const std::string_view& command, bool capture_output) noexcept
|
|||||||
auto pid = fork();
|
auto pid = fork();
|
||||||
if (pid == 0) {
|
if (pid == 0) {
|
||||||
/* clang-format off */
|
/* clang-format off */
|
||||||
char* args[2] = { const_cast<char*>(command.data()), NULL };
|
char* args[2] = { const_cast<char*>(command.data()), nullptr };
|
||||||
/* clang-format on */
|
/* clang-format on */
|
||||||
execvp(args[0], args);
|
execvp(args[0], args);
|
||||||
} else {
|
} else {
|
||||||
|
@ -3,7 +3,8 @@
|
|||||||
|
|
||||||
#include "definitions.hpp"
|
#include "definitions.hpp"
|
||||||
|
|
||||||
#include <string_view>
|
#include <string> // for string
|
||||||
|
#include <string_view> // for string_view
|
||||||
|
|
||||||
namespace utils {
|
namespace utils {
|
||||||
void print_banner() noexcept;
|
void print_banner() noexcept;
|
||||||
|
Loading…
Reference in New Issue
Block a user