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

Commit bdd62f0

Browse files
committed
chore: add -DCORTEX_CONFIG_FILE_NAME
1 parent 703368b commit bdd62f0

File tree

5 files changed

+19
-10
lines changed

5 files changed

+19
-10
lines changed

engine/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ if(DEBUG)
5959
add_compile_definitions(ALLOW_ALL_CORS)
6060
endif()
6161

62+
if(NOT DEFINED CORTEX_CONFIG_FILE_NAME)
63+
add_compile_definitions(CORTEX_CONFIG_FILE_NAME=".cortexrc")
64+
endif()
65+
6266
if(NOT DEFINED CORTEX_CPP_VERSION)
6367
set(CORTEX_CPP_VERSION "default_version")
6468
endif()
Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#pragma once
2-
#include <array>
2+
33
#include <string>
44

55
namespace commands {
@@ -11,8 +11,5 @@ class EngineUninstallCmd {
1111

1212
private:
1313
std::string engine_;
14-
15-
static constexpr std::array<const char*, 3> supportedEngines_ = {
16-
"cortex.llamacpp", "cortex.onnx", "cortex.tensorrt-llm"};
1714
};
1815
} // namespace commands

engine/controllers/command_line_parser.cc

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
#include "utils/cortex_utils.h"
1818
#include "utils/logging_utils.h"
1919

20-
CommandLineParser::CommandLineParser() : app_("Cortex.cpp CLI") {}
20+
CommandLineParser::CommandLineParser()
21+
: app_("Cortex.cpp CLI"), engine_service_{EngineService()} {}
2122

2223
bool CommandLineParser::SetupCommand(int argc, char** argv) {
2324
std::string model_id;
@@ -127,9 +128,10 @@ bool CommandLineParser::SetupCommand(int argc, char** argv) {
127128
command.Exec();
128129
});
129130

130-
EngineManagement(engines_cmd, "cortex.llamacpp", version);
131-
EngineManagement(engines_cmd, "cortex.onnx", version);
132-
EngineManagement(engines_cmd, "cortex.tensorrt-llm", version);
131+
for (auto& engine : engine_service_.kSupportEngines) {
132+
std::string engine_name{engine};
133+
EngineManagement(engines_cmd, engine_name, version);
134+
}
133135

134136
EngineGet(engines_cmd);
135137
}
@@ -186,9 +188,8 @@ void CommandLineParser::EngineManagement(CLI::App* parent,
186188

187189
void CommandLineParser::EngineGet(CLI::App* parent) {
188190
auto get_cmd = parent->add_subcommand("get", "Get an engine info");
189-
auto engine_service = EngineService();
190191

191-
for (auto& engine : engine_service.kSupportEngines) {
192+
for (auto& engine : engine_service_.kSupportEngines) {
192193
std::string engine_name{engine};
193194
std::string desc = "Get " + engine_name + " status";
194195

engine/controllers/command_line_parser.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#pragma once
22

33
#include "CLI/CLI.hpp"
4+
#include "services/engine_service.h"
45

56
class CommandLineParser {
67
public:
@@ -14,4 +15,5 @@ class CommandLineParser {
1415
void EngineGet(CLI::App* parent);
1516

1617
CLI::App app_;
18+
EngineService engine_service_;
1719
};

engine/utils/file_manager_utils.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,12 @@
1414
#endif
1515

1616
namespace file_manager_utils {
17+
#ifdef CORTEX_CONFIG_FILE_NAME
18+
constexpr std::string_view kCortexConfigurationFileName =
19+
CORTEX_CONFIG_FILE_NAME;
20+
#else
1721
constexpr std::string_view kCortexConfigurationFileName = ".cortexrc";
22+
#endif
1823

1924
inline std::filesystem::path GetExecutableFolderContainerPath() {
2025
#if defined(__APPLE__) && defined(__MACH__)

0 commit comments

Comments
 (0)