mirror of
https://github.com/CachyOS/New-Cli-Installer.git
synced 2025-01-23 14:32:22 +08:00
♻ cleanup
This commit is contained in:
parent
dc5f12e92d
commit
4d8f1a08e0
@ -39,8 +39,8 @@ FetchContent_Declare(nlohmann_json
|
||||
FetchContent_MakeAvailable(nlohmann_json)
|
||||
|
||||
FetchContent_Declare(cpr
|
||||
GIT_REPOSITORY "https://github.com/libcpr/cpr.git"
|
||||
GIT_TAG "bcb7729dd6d930820fb858f63c97ad559241b789"
|
||||
GIT_REPOSITORY "https://github.com/vnepogodin/cpr.git"
|
||||
GIT_TAG "824358455f61629ca43422adce0243bb05e99bf8"
|
||||
)
|
||||
FetchContent_MakeAvailable(cpr)
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
function(set_project_warnings project_name)
|
||||
option(WARNINGS_AS_ERRORS "Treat compiler warnings as error" OFF)
|
||||
option(WARNINGS_AS_ERRORS "Treat compiler warnings as error" ON)
|
||||
|
||||
set(MSVC_WARNINGS
|
||||
/W4 # Base
|
||||
|
@ -42,5 +42,5 @@ endif()
|
||||
|
||||
# Enables STL container checker if not building a release.
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
add_definitions(-D_GLIBCXX_ASSERTIONS)
|
||||
add_definitions(-D_GLIBCXX_ASSERTIONS)
|
||||
endif()
|
||||
|
58
meson.build
58
meson.build
@ -5,21 +5,21 @@ project('cachyos-installer', 'cpp',
|
||||
default_options: ['cpp_std=c++20',
|
||||
'buildtype=debugoptimized',
|
||||
'warning_level=3',
|
||||
'werror=false',
|
||||
'werror=true',
|
||||
'b_ndebug=if-release'])
|
||||
|
||||
is_debug_build = get_option('buildtype').startswith('debug')
|
||||
cc = meson.get_compiler('cpp')
|
||||
if cc.get_id() == 'clang'
|
||||
specific_cc_flags = [
|
||||
'-nostdlib++',
|
||||
'-nodefaultlibs',
|
||||
]
|
||||
specific_link_flags = [
|
||||
'-fuse-ld=lld',
|
||||
]
|
||||
add_global_arguments(cc.get_supported_arguments(specific_cc_flags), language : 'cpp')
|
||||
add_global_link_arguments(cc.get_supported_link_arguments(specific_link_flags), language : 'cpp')
|
||||
specific_cc_flags = [
|
||||
'-nostdlib++',
|
||||
'-nodefaultlibs',
|
||||
]
|
||||
specific_link_flags = [
|
||||
'-fuse-ld=lld',
|
||||
]
|
||||
add_global_arguments(cc.get_supported_arguments(specific_cc_flags), language : 'cpp')
|
||||
add_global_link_arguments(cc.get_supported_link_arguments(specific_link_flags), language : 'cpp')
|
||||
endif
|
||||
|
||||
# Common dependencies
|
||||
@ -37,36 +37,36 @@ src_files = files(
|
||||
)
|
||||
|
||||
possible_cc_flags = [
|
||||
'-Wshadow',
|
||||
'-Wshadow',
|
||||
|
||||
'-Wnon-virtual-dtor',
|
||||
'-Wnon-virtual-dtor',
|
||||
|
||||
'-Wcast-align',
|
||||
'-Wunused',
|
||||
'-Woverloaded-virtual',
|
||||
'-Wcast-align',
|
||||
'-Wunused',
|
||||
'-Woverloaded-virtual',
|
||||
|
||||
'-Wpedantic', # non-standard C++
|
||||
'-Wconversion', # type conversion that may lose data
|
||||
'-Wnull-dereference',
|
||||
'-Wdouble-promotion', # float to double
|
||||
'-Wpedantic', # non-standard C++
|
||||
'-Wconversion', # type conversion that may lose data
|
||||
'-Wnull-dereference',
|
||||
'-Wdouble-promotion', # float to double
|
||||
|
||||
'-Wformat=2',
|
||||
'-Wformat=2',
|
||||
]
|
||||
|
||||
if cc.get_id() == 'gcc'
|
||||
possible_cc_flags += [
|
||||
'-Wmisleading-indentation',
|
||||
possible_cc_flags += [
|
||||
'-Wmisleading-indentation',
|
||||
|
||||
'-Wduplicated-cond',
|
||||
'-Wduplicated-branches',
|
||||
'-Wlogical-op',
|
||||
]
|
||||
'-Wduplicated-cond',
|
||||
'-Wduplicated-branches',
|
||||
'-Wlogical-op',
|
||||
]
|
||||
endif
|
||||
|
||||
if is_debug_build
|
||||
possible_cc_flags += [
|
||||
'-D_GLIBCXX_ASSERTIONS',
|
||||
]
|
||||
possible_cc_flags += [
|
||||
'-D_GLIBCXX_ASSERTIONS',
|
||||
]
|
||||
else
|
||||
if cc.get_id() == 'gcc'
|
||||
possible_cc_flags += [
|
||||
|
@ -17,14 +17,14 @@
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
namespace utils {
|
||||
static constexpr int32_t CONNECTION_TIMEOUT = 15;
|
||||
static constexpr std::int32_t CONNECTION_TIMEOUT = 15;
|
||||
|
||||
bool is_connected() noexcept {
|
||||
/* clang-format off */
|
||||
auto r = cpr::Get(cpr::Url{"https://www.google.com"},
|
||||
cpr::Timeout{1000});
|
||||
/* clang-format on */
|
||||
return cpr::status::is_success(r.status_code);
|
||||
return cpr::status::is_success(static_cast<std::int32_t>(r.status_code));
|
||||
}
|
||||
|
||||
bool check_root() noexcept {
|
||||
@ -38,7 +38,7 @@ void clear_screen() noexcept {
|
||||
|
||||
std::string exec(const std::string_view& command, bool capture_output) noexcept {
|
||||
if (!capture_output) {
|
||||
int32_t status{};
|
||||
std::int32_t status{};
|
||||
auto pid = fork();
|
||||
if (pid == 0) {
|
||||
/* clang-format off */
|
||||
@ -73,7 +73,7 @@ std::string exec(const std::string_view& command, bool capture_output) noexcept
|
||||
bool prompt_char(const char* prompt, const char* color, char* read) noexcept {
|
||||
fmt::print("{}{}{}\n", color, prompt, RESET);
|
||||
|
||||
std::string tmp;
|
||||
std::string tmp{};
|
||||
if (std::getline(std::cin, tmp)) {
|
||||
char read_char{};
|
||||
if (tmp.length() == 1) {
|
||||
@ -127,12 +127,12 @@ void id_system() noexcept {
|
||||
}
|
||||
|
||||
bool handle_connection() noexcept {
|
||||
bool connected;
|
||||
bool connected{};
|
||||
|
||||
if (!(connected = utils::is_connected())) {
|
||||
warning("An active network connection could not be detected, waiting 15 seconds ...\n");
|
||||
|
||||
int32_t time_waited = 0;
|
||||
std::int32_t time_waited{};
|
||||
|
||||
while (!(connected = utils::is_connected())) {
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||
@ -143,7 +143,7 @@ bool handle_connection() noexcept {
|
||||
}
|
||||
|
||||
if (!connected) {
|
||||
char type = '\0';
|
||||
char type{};
|
||||
|
||||
while (utils::prompt_char("An active network connection could not be detected, do you want to connect using wifi? [y/n]", RED, &type)) {
|
||||
if (type != 'n') {
|
||||
|
@ -1,6 +1,6 @@
|
||||
[wrap-git]
|
||||
url = https://github.com/libcpr/cpr.git
|
||||
revision = bcb7729dd6d930820fb858f63c97ad559241b789
|
||||
url = https://github.com/vnepogodin/cpr.git
|
||||
revision = 824358455f61629ca43422adce0243bb05e99bf8
|
||||
|
||||
patch_directory = cpr
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user