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

Commit c31c1ee

Browse files
committed
chore: Move to C++17 and fix extra warnings
1 parent 948396b commit c31c1ee

File tree

79 files changed

+880
-711
lines changed

Some content is hidden

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

79 files changed

+880
-711
lines changed

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: 56 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,16 +28,16 @@ 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+
/* std::unique_ptr<system_info_utils::SystemInfo> GetSystemInfoWithUniversal() {
3132
auto system_info = system_info_utils::GetSystemInfo();
3233
if (system_info->os == "mac") {
3334
CTL_INF("Change arch from " << system_info->arch << " to universal");
3435
system_info->arch = "universal";
3536
}
3637
return system_info;
37-
}
38+
} */
3839

39-
std::string GetNightlyInstallerName(const std::string& v,
40+
/* std::string GetNightlyInstallerName(const std::string& v,
4041
const std::string& os_arch) {
4142
const std::string kCortex = "cortex";
4243
// Remove 'v' in file name
@@ -66,7 +67,7 @@ std::string GetInstallCmd(const std::string& exe_path) {
6667
return "start /wait \"\" " + exe_path +
6768
" /VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SkipPostInstall";
6869
#endif
69-
}
70+
} */
7071

7172
std::string GetInstallCmdLinux(const std::string& script_path,
7273
const std::string& channel,
@@ -133,6 +134,7 @@ bool InstallNewVersion(const std::filesystem::path& dst,
133134

134135
std::optional<std::string> CheckNewUpdate(
135136
std::optional<std::chrono::milliseconds> timeout) {
137+
(void) timeout;
136138
// Get info from .cortexrc
137139
auto should_check_update = false;
138140
auto config = file_manager_utils::GetCortexConfig();
@@ -152,9 +154,10 @@ std::optional<std::string> CheckNewUpdate(
152154
}
153155

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

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

266269
auto url_obj = url_parser::Url{
267-
.protocol = "https",
268-
.host = GetHostName(),
269-
.pathParams = GetReleasePath(),
270+
/* .protocol = */ "https",
271+
/* .host = */ GetHostName(),
272+
/* .pathParams = */ GetReleasePath(),
273+
/* .queries = */ {},
270274
};
271275
CTL_INF("Engine release path: " << url_obj.ToFullPath());
272276

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

320324
auto url_obj = url_parser::Url{
321-
.protocol = "https",
322-
.host = GetHostName(),
323-
.pathParams = GetReleasePath(),
325+
/* .protocol = */ "https",
326+
/* .host = */ GetHostName(),
327+
/* .pathParams = */ GetReleasePath(),
328+
/* queries = */ {},
324329
};
325330
CTL_INF("Engine release path: " << url_obj.ToFullPath());
326331
auto res = curl_utils::SimpleGetJson(url_obj.ToFullPath());
@@ -410,12 +415,16 @@ std::optional<std::string> CortexUpdCmd::HandleGithubRelease(
410415
return std::nullopt;
411416
}
412417
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,
418+
/* .id = */ "cortex",
419+
/* .status = */ DownloadTask::Status::Pending,
420+
/* .type = */ DownloadType::Cortex,
421+
/* .items = */ {DownloadItem{
422+
/* .id = */ "cortex",
423+
/* .downloadUrl = */ download_url,
424+
/* .localPath = */ local_path,
425+
/* .checksum = */ std::nullopt,
426+
/* .bytes = */ std::nullopt,
427+
/* .downloadedBytes = */ std::nullopt,
419428
}},
420429
}};
421430

@@ -456,9 +465,10 @@ bool CortexUpdCmd::GetNightly(const std::string& v) {
456465
};
457466
std::vector<std::string> path_list(paths, std::end(paths));
458467
auto url_obj = url_parser::Url{
459-
.protocol = "https",
460-
.host = kNightlyHost,
461-
.pathParams = path_list,
468+
./* protocol = */ "https",
469+
/* .host = */ kNightlyHost,
470+
/* .pathParams = */ path_list,
471+
/* .queries = */ {},
462472
};
463473

464474
CTL_INF("Cortex release path: " << url_parser::FromUrl(url_obj));
@@ -474,12 +484,16 @@ bool CortexUpdCmd::GetNightly(const std::string& v) {
474484
return false;
475485
}
476486
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,
487+
DownloadTask{/* .id = */ "cortex",
488+
/* .status = */ DownloadTask::Status::Pending,
489+
/* .type = */ DownloadType::Cortex,
490+
./* items = */ {DownloadItem{
491+
/* .id = */ "cortex",
492+
/* .downloadUrl = */ url_parser::FromUrl(url_obj),
493+
/* .localPath = */ localPath,
494+
/* .checksum = */ std::nullopt,
495+
/* .bytes = */ std::nullopt,
496+
/* .downloadedBytes = */ std::nullopt,
483497
}}};
484498

485499
auto result = download_service_->AddDownloadTask(
@@ -522,9 +536,10 @@ bool CortexUpdCmd::GetLinuxInstallScript(const std::string& v,
522536
"templates", "linux", "install.sh"};
523537
}
524538
auto url_obj = url_parser::Url{
525-
.protocol = "https",
526-
.host = "raw.githubusercontent.com",
527-
.pathParams = path_list,
539+
/* .protocol = */ "https",
540+
/* .host = */ "raw.githubusercontent.com",
541+
/* .pathParams = */ path_list,
542+
/* .queries = */ {},
528543
};
529544

530545
CTL_INF("Linux installer script path: " << url_parser::FromUrl(url_obj));
@@ -540,12 +555,16 @@ bool CortexUpdCmd::GetLinuxInstallScript(const std::string& v,
540555
return false;
541556
}
542557
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,
558+
DownloadTask{/* .id = */ "cortex",
559+
/* .status = */ DownloadTask::Status::Pending,
560+
/* .type = */ DownloadType::Cortex,
561+
/* .items = */ {DownloadItem{
562+
/* .id = */ "cortex",
563+
/* .downloadUrl = */ url_parser::FromUrl(url_obj),
564+
/* .localPath = */ localPath,
565+
/* .checksum = */ std::nullopt,
566+
/* .bytes = */ std::nullopt,
567+
/* .downloadedBytes = */ std::nullopt,
549568
}}};
550569

551570
auto result = download_service_->AddDownloadTask(

engine/cli/commands/engine_get_cmd.cc

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

3131
auto url = url_parser::Url{
32-
.protocol = "http",
33-
.host = host + ":" + std::to_string(port),
34-
.pathParams = {"v1", "engines", engine_name},
32+
/* .protocol = */ "http",
33+
/* .host = */ host + ":" + std::to_string(port),
34+
/* .pathParams = */ {"v1", "engines", engine_name},
35+
/* .queries = */ {}
3536
};
3637
auto result = curl_utils::SimpleGetJson(url.ToFullPath());
3738
if (result.has_error()) {
@@ -50,9 +51,10 @@ void EngineGetCmd::Exec(const std::string& host, int port,
5051
auto installed_variants = result.value();
5152
for (const auto& variant : installed_variants) {
5253
output.push_back(EngineVariantResponse{
53-
.name = variant["name"].asString(),
54-
.version = variant["version"].asString(),
55-
.engine = engine_name,
54+
/* .name = */ variant["name"].asString(),
55+
/* .version = */ variant["version"].asString(),
56+
/* .engine = */ engine_name,
57+
/* .type = */ "",
5658
});
5759
}
5860

engine/cli/commands/engine_install_cmd.cc

Lines changed: 16 additions & 12 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 =
74+
/* .protocol = */ "http",
75+
/* .host = */ host_ + ":" + std::to_string(port_),
76+
/* .pathParams = */
7677
{
7778
"v1",
7879
"engines",
7980
engine,
8081
"releases",
8182
selected_release.value(),
8283
},
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 =
122+
/* .protocol = */ "http",
123+
/* .host = */ host_ + ":" + std::to_string(port_),
124+
/* .pathParams = */
123125
{
124126
"v1",
125127
"engines",
126128
engine,
127129
"install",
128130
},
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+
/* .protocol = */ "http",
167+
/* .host = */ host_ + ":" + std::to_string(port_),
168+
/* .pathParams = */
166169
{
167170
"v1",
168171
"engines",
169172
engine,
170173
"install",
171174
},
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 = "");

engine/cli/commands/engine_list_cmd.cc

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@ bool EngineListCmd::Exec(const std::string& host, int port) {
2727
table.add_row({"#", "Name", "Version", "Variant", "Status"});
2828

2929
auto url = url_parser::Url{
30-
.protocol = "http",
31-
.host = host + ":" + std::to_string(port),
32-
.pathParams = {"v1", "engines"},
30+
/* .protocol = */ "http",
31+
/* .host = */ host + ":" + std::to_string(port),
32+
/* .pathParams = */ {"v1", "engines"},
33+
/* .queries = */ {},
3334
};
3435
auto result = curl_utils::SimpleGetJson(url.ToFullPath());
3536
if (result.has_error()) {
@@ -45,18 +46,20 @@ bool EngineListCmd::Exec(const std::string& host, int port) {
4546
auto installed_variants = result.value()[engine];
4647
for (const auto& variant : installed_variants) {
4748
engine_map[engine].push_back(EngineVariantResponse{
48-
.name = variant["name"].asString(),
49-
.version = variant["version"].asString(),
50-
.engine = engine,
49+
/* .name = */ variant["name"].asString(),
50+
/* .version = */ variant["version"].asString(),
51+
/* .engine = */ engine,
52+
/* .type = */ "",
5153
});
5254
}
5355
}
5456

5557
// TODO: namh support onnx and tensorrt
5658
auto default_engine_url = url_parser::Url{
57-
.protocol = "http",
58-
.host = host + ":" + std::to_string(port),
59-
.pathParams = {"v1", "engines", kLlamaEngine, "default"},
59+
/* .protocol = */ "http",
60+
/* .host = */ host + ":" + std::to_string(port),
61+
/* .pathParams = */ {"v1", "engines", kLlamaEngine, "default"},
62+
/* .queries = */ {},
6063
};
6164
auto selected_variant_result =
6265
curl_utils::SimpleGetJson(default_engine_url.ToFullPath());

engine/cli/commands/engine_load_cmd.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ cpp::result<void, std::string> EngineLoadCmd::Exec(const std::string& host,
1919
}
2020

2121
auto load_engine_url = url_parser::Url{
22-
.protocol = "http",
23-
.host = host + ":" + std::to_string(port),
24-
.pathParams = {"v1", "engines", engine, "load"},
22+
/* .protocol = */ "http",
23+
/* .host = */ host + ":" + std::to_string(port),
24+
/* .pathParams = */ {"v1", "engines", engine, "load"},
25+
/* .queries = */ {},
2526
};
2627
auto load_engine_result =
2728
curl_utils::SimplePostJson(load_engine_url.ToFullPath());

0 commit comments

Comments
 (0)