Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.

Commit 2e1dfa0

Browse files
authored
chore: Move to C++17 and fix extra warnings (#2138)
* chore: Move to C++17 and fix extra warnings * Use maybe_unused attribute * curl_utils: Use unsigned to make msvc happy * Fix list init in macos code * Use unsigned in gguf_parser * fix list initialization again * use unsigned in cli_selection_utils.h * fix formatting * CMakeLists: Indicate to ensure we use c++17 * fix unit tests
1 parent 948396b commit 2e1dfa0

File tree

86 files changed

+1167
-913
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+1167
-913
lines changed

engine/CMakeLists.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,8 @@ if(CMAKE_CXX_STANDARD LESS 17)
198198
message(STATUS "use c++14")
199199
find_package(Boost 1.61.0 REQUIRED)
200200
target_include_directories(${TARGET_NAME} PRIVATE ${Boost_INCLUDE_DIRS})
201-
elseif(CMAKE_CXX_STANDARD LESS 20)
202-
message(STATUS "use c++17")
203201
else()
204-
message(STATUS "use c++20")
202+
message(STATUS "use c++17")
205203
endif()
206204

207205
aux_source_directory(controllers CTL_SRC)

engine/cli/command_line_parser.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ bool CommandLineParser::SetupCommand(int argc, char** argv) {
8686
#else
8787
CLI_LOG("default");
8888
#endif
89+
(void) c;
8990
};
9091
app_.add_flag_function("-v,--version", cb, "Get Cortex version");
9192

engine/cli/commands/config_get_cmd.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ void commands::ConfigGetCmd::Exec(const std::string& host, int port) {
1717
}
1818
}
1919
auto url = url_parser::Url{
20-
.protocol = "http",
21-
.host = host + ":" + std::to_string(port),
22-
.pathParams = {"v1", "configs"},
20+
/* .protocol = */ "http",
21+
/* .host = */ host + ":" + std::to_string(port),
22+
/* .pathParams = */ {"v1", "configs"},
23+
/* .queries = */ {},
2324
};
2425

2526
auto get_config_result = curl_utils::SimpleGetJson(url.ToFullPath());

engine/cli/commands/config_upd_cmd.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,10 @@ void commands::ConfigUpdCmd::Exec(
6363
}
6464

6565
auto url = url_parser::Url{
66-
.protocol = "http",
67-
.host = host + ":" + std::to_string(port),
68-
.pathParams = {"v1", "configs"},
66+
/* .protocol = */ "http",
67+
/* .host = */ host + ":" + std::to_string(port),
68+
/* .pathParams = */ {"v1", "configs"},
69+
/* .queries = */ {},
6970
};
7071

7172
auto json = NormalizeJson(non_null_opts);

engine/cli/commands/cortex_upd_cmd.cc

Lines changed: 60 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "cortex_upd_cmd.h"
2+
#include <optional>
23
#include "cli/commands/server_start_cmd.h"
34
#include "server_stop_cmd.h"
45
#include "utils/archive_utils.h"
@@ -27,7 +28,8 @@ std::chrono::seconds GetTimeSinceEpochMillisec() {
2728
return duration_cast<seconds>(system_clock::now().time_since_epoch());
2829
}
2930

30-
std::unique_ptr<system_info_utils::SystemInfo> GetSystemInfoWithUniversal() {
31+
[[maybe_unused]] std::unique_ptr<system_info_utils::SystemInfo>
32+
GetSystemInfoWithUniversal() {
3133
auto system_info = system_info_utils::GetSystemInfo();
3234
if (system_info->os == "mac") {
3335
CTL_INF("Change arch from " << system_info->arch << " to universal");
@@ -36,8 +38,8 @@ std::unique_ptr<system_info_utils::SystemInfo> GetSystemInfoWithUniversal() {
3638
return system_info;
3739
}
3840

39-
std::string GetNightlyInstallerName(const std::string& v,
40-
const std::string& os_arch) {
41+
[[maybe_unused]] std::string GetNightlyInstallerName(
42+
const std::string& v, const std::string& os_arch) {
4143
const std::string kCortex = "cortex";
4244
// Remove 'v' in file name
4345
std::string version = v == "latest" ? "" : (v.substr(1) + "-");
@@ -50,7 +52,7 @@ std::string GetNightlyInstallerName(const std::string& v,
5052
#endif
5153
}
5254

53-
std::string GetInstallCmd(const std::string& exe_path) {
55+
[[maybe_unused]] std::string GetInstallCmd(const std::string& exe_path) {
5456
#if defined(__APPLE__) && defined(__MACH__)
5557
return "sudo touch /var/tmp/cortex_installer_skip_postinstall_check && sudo "
5658
"installer "
@@ -133,6 +135,7 @@ bool InstallNewVersion(const std::filesystem::path& dst,
133135

134136
std::optional<std::string> CheckNewUpdate(
135137
std::optional<std::chrono::milliseconds> timeout) {
138+
(void)timeout;
136139
// Get info from .cortexrc
137140
auto should_check_update = false;
138141
auto config = file_manager_utils::GetCortexConfig();
@@ -152,9 +155,10 @@ std::optional<std::string> CheckNewUpdate(
152155
}
153156

154157
auto url = url_parser::Url{
155-
.protocol = "https",
156-
.host = GetHostName(),
157-
.pathParams = GetReleasePath(),
158+
/* .protocol = */ "https",
159+
/* .host = */ GetHostName(),
160+
/* .pathParams = */ GetReleasePath(),
161+
/* .queries = */ {},
158162
};
159163

160164
CTL_INF("Engine release path: " << url.ToFullPath());
@@ -264,9 +268,10 @@ bool CortexUpdCmd::GetStable(const std::string& v) {
264268
CTL_INF("OS: " << system_info->os << ", Arch: " << system_info->arch);
265269

266270
auto url_obj = url_parser::Url{
267-
.protocol = "https",
268-
.host = GetHostName(),
269-
.pathParams = GetReleasePath(),
271+
/* .protocol = */ "https",
272+
/* .host = */ GetHostName(),
273+
/* .pathParams = */ GetReleasePath(),
274+
/* .queries = */ {},
270275
};
271276
CTL_INF("Engine release path: " << url_obj.ToFullPath());
272277

@@ -318,9 +323,10 @@ bool CortexUpdCmd::GetBeta(const std::string& v) {
318323
CTL_INF("OS: " << system_info->os << ", Arch: " << system_info->arch);
319324

320325
auto url_obj = url_parser::Url{
321-
.protocol = "https",
322-
.host = GetHostName(),
323-
.pathParams = GetReleasePath(),
326+
/* .protocol = */ "https",
327+
/* .host = */ GetHostName(),
328+
/* .pathParams = */ GetReleasePath(),
329+
/* queries = */ {},
324330
};
325331
CTL_INF("Engine release path: " << url_obj.ToFullPath());
326332
auto res = curl_utils::SimpleGetJson(url_obj.ToFullPath());
@@ -410,12 +416,17 @@ std::optional<std::string> CortexUpdCmd::HandleGithubRelease(
410416
return std::nullopt;
411417
}
412418
auto download_task{DownloadTask{
413-
.id = "cortex",
414-
.type = DownloadType::Cortex,
415-
.items = {DownloadItem{
416-
.id = "cortex",
417-
.downloadUrl = download_url,
418-
.localPath = local_path,
419+
/* .id = */ "cortex",
420+
/* .status = */ DownloadTask::Status::Pending,
421+
/* .type = */ DownloadType::Cortex,
422+
/* .items = */
423+
{DownloadItem{
424+
/* .id = */ "cortex",
425+
/* .downloadUrl = */ download_url,
426+
/* .localPath = */ local_path,
427+
/* .checksum = */ std::nullopt,
428+
/* .bytes = */ std::nullopt,
429+
/* .downloadedBytes = */ std::nullopt,
419430
}},
420431
}};
421432

@@ -456,9 +467,10 @@ bool CortexUpdCmd::GetNightly(const std::string& v) {
456467
};
457468
std::vector<std::string> path_list(paths, std::end(paths));
458469
auto url_obj = url_parser::Url{
459-
.protocol = "https",
460-
.host = kNightlyHost,
461-
.pathParams = path_list,
470+
/* .protocol = */ "https",
471+
/* .host = */ kNightlyHost,
472+
/* .pathParams = */ path_list,
473+
/* .queries = */ {},
462474
};
463475

464476
CTL_INF("Cortex release path: " << url_parser::FromUrl(url_obj));
@@ -474,12 +486,17 @@ bool CortexUpdCmd::GetNightly(const std::string& v) {
474486
return false;
475487
}
476488
auto download_task =
477-
DownloadTask{.id = "cortex",
478-
.type = DownloadType::Cortex,
479-
.items = {DownloadItem{
480-
.id = "cortex",
481-
.downloadUrl = url_parser::FromUrl(url_obj),
482-
.localPath = localPath,
489+
DownloadTask{/* .id = */ "cortex",
490+
/* .status = */ DownloadTask::Status::Pending,
491+
/* .type = */ DownloadType::Cortex,
492+
/* .items = */
493+
{DownloadItem{
494+
/* .id = */ "cortex",
495+
/* .downloadUrl = */ url_parser::FromUrl(url_obj),
496+
/* .localPath = */ localPath,
497+
/* .checksum = */ std::nullopt,
498+
/* .bytes = */ std::nullopt,
499+
/* .downloadedBytes = */ std::nullopt,
483500
}}};
484501

485502
auto result = download_service_->AddDownloadTask(
@@ -522,9 +539,10 @@ bool CortexUpdCmd::GetLinuxInstallScript(const std::string& v,
522539
"templates", "linux", "install.sh"};
523540
}
524541
auto url_obj = url_parser::Url{
525-
.protocol = "https",
526-
.host = "raw.githubusercontent.com",
527-
.pathParams = path_list,
542+
/* .protocol = */ "https",
543+
/* .host = */ "raw.githubusercontent.com",
544+
/* .pathParams = */ path_list,
545+
/* .queries = */ {},
528546
};
529547

530548
CTL_INF("Linux installer script path: " << url_parser::FromUrl(url_obj));
@@ -540,12 +558,17 @@ bool CortexUpdCmd::GetLinuxInstallScript(const std::string& v,
540558
return false;
541559
}
542560
auto download_task =
543-
DownloadTask{.id = "cortex",
544-
.type = DownloadType::Cortex,
545-
.items = {DownloadItem{
546-
.id = "cortex",
547-
.downloadUrl = url_parser::FromUrl(url_obj),
548-
.localPath = localPath,
561+
DownloadTask{/* .id = */ "cortex",
562+
/* .status = */ DownloadTask::Status::Pending,
563+
/* .type = */ DownloadType::Cortex,
564+
/* .items = */
565+
{DownloadItem{
566+
/* .id = */ "cortex",
567+
/* .downloadUrl = */ url_parser::FromUrl(url_obj),
568+
/* .localPath = */ localPath,
569+
/* .checksum = */ std::nullopt,
570+
/* .bytes = */ std::nullopt,
571+
/* .downloadedBytes = */ std::nullopt,
549572
}}};
550573

551574
auto result = download_service_->AddDownloadTask(

engine/cli/commands/engine_get_cmd.cc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,10 @@ void EngineGetCmd::Exec(const std::string& host, int port,
2828
tabulate::Table table;
2929
table.add_row({"#", "Name", "Version", "Variant", "Status"});
3030

31-
auto url = url_parser::Url{
32-
.protocol = "http",
33-
.host = host + ":" + std::to_string(port),
34-
.pathParams = {"v1", "engines", engine_name},
35-
};
31+
auto url = url_parser::Url{/* .protocol = */ "http",
32+
/* .host = */ host + ":" + std::to_string(port),
33+
/* .pathParams = */ {"v1", "engines", engine_name},
34+
/* .queries = */ {}};
3635
auto result = curl_utils::SimpleGetJson(url.ToFullPath());
3736
if (result.has_error()) {
3837
// TODO: refactor this
@@ -50,9 +49,10 @@ void EngineGetCmd::Exec(const std::string& host, int port,
5049
auto installed_variants = result.value();
5150
for (const auto& variant : installed_variants) {
5251
output.push_back(EngineVariantResponse{
53-
.name = variant["name"].asString(),
54-
.version = variant["version"].asString(),
55-
.engine = engine_name,
52+
/* .name = */ variant["name"].asString(),
53+
/* .version = */ variant["version"].asString(),
54+
/* .engine = */ engine_name,
55+
/* .type = */ "",
5656
});
5757
}
5858

engine/cli/commands/engine_install_cmd.cc

Lines changed: 35 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,10 @@ bool EngineInstallCmd::Exec(const std::string& engine,
4747
});
4848

4949
auto releases_url = url_parser::Url{
50-
.protocol = "http",
51-
.host = host_ + ":" + std::to_string(port_),
52-
.pathParams = {"v1", "engines", engine, "releases"},
50+
/* .protocol = */ "http",
51+
/* .host = */ host_ + ":" + std::to_string(port_),
52+
/* .pathParams = */ {"v1", "engines", engine, "releases"},
53+
/* .queries = */ {},
5354
};
5455
auto releases_result = curl_utils::SimpleGetJson(releases_url.ToFullPath());
5556
if (releases_result.has_error()) {
@@ -70,16 +71,17 @@ bool EngineInstallCmd::Exec(const std::string& engine,
7071
std::cout << "Selected version: " << selected_release.value() << std::endl;
7172

7273
auto variant_url = url_parser::Url{
73-
.protocol = "http",
74-
.host = host_ + ":" + std::to_string(port_),
75-
.pathParams =
76-
{
77-
"v1",
78-
"engines",
79-
engine,
80-
"releases",
81-
selected_release.value(),
82-
},
74+
/* .protocol = */ "http",
75+
/* .host = */ host_ + ":" + std::to_string(port_),
76+
/* .pathParams = */
77+
{
78+
"v1",
79+
"engines",
80+
engine,
81+
"releases",
82+
selected_release.value(),
83+
},
84+
/* queries = */ {},
8385
};
8486
auto variant_result = curl_utils::SimpleGetJson(variant_url.ToFullPath());
8587
if (variant_result.has_error()) {
@@ -117,15 +119,16 @@ bool EngineInstallCmd::Exec(const std::string& engine,
117119
<< selected_release.value() << std::endl;
118120

119121
auto install_url = url_parser::Url{
120-
.protocol = "http",
121-
.host = host_ + ":" + std::to_string(port_),
122-
.pathParams =
123-
{
124-
"v1",
125-
"engines",
126-
engine,
127-
"install",
128-
},
122+
/* .protocol = */ "http",
123+
/* .host = */ host_ + ":" + std::to_string(port_),
124+
/* .pathParams = */
125+
{
126+
"v1",
127+
"engines",
128+
engine,
129+
"install",
130+
},
131+
/* queries = */ {},
129132
};
130133
Json::Value body;
131134
body["version"] = selected_release.value();
@@ -160,15 +163,16 @@ bool EngineInstallCmd::Exec(const std::string& engine,
160163
});
161164

162165
auto install_url = url_parser::Url{
163-
.protocol = "http",
164-
.host = host_ + ":" + std::to_string(port_),
165-
.pathParams =
166-
{
167-
"v1",
168-
"engines",
169-
engine,
170-
"install",
171-
},
166+
/* .protocol = */ "http",
167+
/* .host = */ host_ + ":" + std::to_string(port_),
168+
/* .pathParams = */
169+
{
170+
"v1",
171+
"engines",
172+
engine,
173+
"install",
174+
},
175+
/* .queries = */ {},
172176
};
173177

174178
Json::Value body;

engine/cli/commands/engine_install_cmd.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,13 @@ class EngineInstallCmd {
1313
host_(host),
1414
port_(port),
1515
show_menu_(show_menu),
16-
hw_inf_{.sys_inf = system_info_utils::GetSystemInfo(),
17-
.cuda_driver_version =
18-
system_info_utils::GetDriverAndCudaVersion().second} {};
16+
hw_inf_{
17+
system_info_utils::GetSystemInfo(), //sysinfo
18+
{}, //cpu_info
19+
20+
system_info_utils::GetDriverAndCudaVersion()
21+
.second //cuda_driver_version
22+
} {};
1923

2024
bool Exec(const std::string& engine, const std::string& version = "latest",
2125
const std::string& src = "");

0 commit comments

Comments
 (0)