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

Commit 169ec83

Browse files
committed
chore: add variant support
1 parent 8c06f78 commit 169ec83

File tree

2 files changed

+46
-4
lines changed

2 files changed

+46
-4
lines changed

engine/CMakeLists.txt

Lines changed: 5 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_VARIANT)
63+
set(CORTEX_VARIANT "prod")
64+
endif()
65+
6266
if(NOT DEFINED CORTEX_CONFIG_FILE_PATH)
6367
set(CORTEX_CONFIG_FILE_PATH "user_home")
6468
endif()
@@ -83,6 +87,7 @@ if(DEFINED CMAKE_JS_INC)
8387
add_compile_definitions(NAPI_VERSION=8)
8488
endif()
8589

90+
add_compile_definitions(CORTEX_VARIANT="${CORTEX_VARIANT}")
8691
add_compile_definitions(CORTEX_CPP_VERSION="${CORTEX_CPP_VERSION}")
8792
add_compile_definitions(CORTEX_CONFIG_FILE_PATH="${CORTEX_CONFIG_FILE_PATH}")
8893

engine/utils/file_manager_utils.h

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,34 @@ inline std::filesystem::path GetHomeDirectoryPath() {
7575
}
7676

7777
inline std::filesystem::path GetConfigurationPath() {
78+
#ifndef CORTEX_CONFIG_FILE_PATH
79+
#define CORTEX_CONFIG_FILE_PATH "user_home"
80+
#endif
81+
82+
#ifndef CORTEX_VARIANT
83+
#define CORTEX_VARIANT "prod"
84+
#endif
7885
std::string config_file_path{CORTEX_CONFIG_FILE_PATH};
7986

8087
if (config_file_path != kDefaultConfigurationPath) {
88+
std::cout << "config_file_path" << config_file_path << std::endl;
8189
return std::filesystem::path(config_file_path);
8290
}
91+
92+
std::string variant{CORTEX_VARIANT};
93+
std::string env_postfix{""};
94+
if (variant == "beta") {
95+
env_postfix = "-beta";
96+
} else if (variant == "nightly") {
97+
env_postfix = "-nightly";
98+
}
99+
100+
std::string config_file_name{kCortexConfigurationFileName};
101+
config_file_name.append(env_postfix);
102+
std::cout << "config_file_name" << config_file_name << std::endl;
103+
83104
auto home_path = GetHomeDirectoryPath();
84-
auto configuration_path = home_path / kCortexConfigurationFileName;
105+
auto configuration_path = home_path / config_file_name;
85106
return configuration_path;
86107
}
87108

@@ -91,9 +112,26 @@ inline void CreateConfigFileIfNotExist() {
91112
// already exists
92113
return;
93114
}
115+
#ifndef CORTEX_VARIANT
116+
#define CORTEX_VARIANT "prod"
117+
#endif
118+
std::string default_data_folder_name{config_yaml_utils::kCortexFolderName};
119+
120+
std::string variant{CORTEX_VARIANT};
121+
std::string env_postfix{""};
122+
if (variant == "beta") {
123+
env_postfix = "-beta";
124+
} else if (variant == "nightly") {
125+
env_postfix = "-nightly";
126+
}
127+
default_data_folder_name.append(env_postfix);
128+
94129
CLI_LOG("Config file not found. Creating one at " + config_path.string());
95130
auto defaultDataFolderPath =
96-
file_manager_utils::GetHomeDirectoryPath() / config_yaml_utils::kCortexFolderName;
131+
file_manager_utils::GetHomeDirectoryPath() / default_data_folder_name;
132+
std::cout << "default data folder path " << defaultDataFolderPath
133+
<< std::endl;
134+
97135
auto config = config_yaml_utils::CortexConfig{
98136
.dataFolderPath = defaultDataFolderPath.string(),
99137
.host = config_yaml_utils::kDefaultHost,
@@ -116,8 +154,7 @@ inline std::filesystem::path GetCortexDataPath() {
116154
auto config = GetCortexConfig();
117155
std::filesystem::path data_folder_path;
118156
if (!config.dataFolderPath.empty()) {
119-
data_folder_path =
120-
std::filesystem::path(config.dataFolderPath);
157+
data_folder_path = std::filesystem::path(config.dataFolderPath);
121158
} else {
122159
auto home_path = GetHomeDirectoryPath();
123160
data_folder_path = home_path / config_yaml_utils::kCortexFolderName;

0 commit comments

Comments
 (0)