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

Commit 3d0b847

Browse files
committed
Merge branch 's/feat/spawn-llama-cpp' of https://github.com/menloresearch/cortex.cpp into s/feat/spawn-llama-cpp
2 parents f866d5f + 87b2aa4 commit 3d0b847

File tree

9 files changed

+33
-16
lines changed

9 files changed

+33
-16
lines changed
-13.7 KB
Binary file not shown.
20.8 KB
Binary file not shown.
5.3 KB
Binary file not shown.

engine/CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,3 +223,12 @@ set_target_properties(${TARGET_NAME} PROPERTIES
223223
RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}
224224
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}
225225
)
226+
227+
if(MSVC)
228+
add_custom_command(
229+
TARGET ${TARGET_NAME} POST_BUILD
230+
COMMAND ${CMAKE_COMMAND} -E copy_directory
231+
${CMAKE_CURRENT_SOURCE_DIR}/../.github/patches/windows
232+
${CMAKE_BINARY_DIR}/
233+
)
234+
endif()

engine/cli/main.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,6 @@ int main(int argc, char* argv[]) {
171171
};
172172

173173
auto res = get_latest_version();
174-
175174
if (res.has_error()) {
176175
CTL_ERR("Failed to get latest llama.cpp version: " << res.error());
177176
return;

engine/extensions/local-engine/local_engine.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,11 @@ void LocalEngine::LoadModel(std::shared_ptr<Json::Value> json_body,
548548
auto log_path =
549549
(file_manager_utils::GetCortexLogPath() / "logs" / "cortex.log").string();
550550
CTL_DBG("log: " << log_path);
551-
auto result = cortex::process::SpawnProcess(v, log_path, log_path);
551+
CTL_INF("exe path: "
552+
<< file_manager_utils::GetExecutableFolderContainerPath().string());
553+
auto result = cortex::process::SpawnProcess(
554+
v, log_path, log_path,
555+
file_manager_utils::GetExecutableFolderContainerPath().string());
552556
if (result.has_error()) {
553557
CTL_ERR("Fail to spawn process. " << result.error());
554558
Json::Value error;

engine/utils/dylib_path_manager.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ cpp::result<void, std::string> DylibPathManager::RegisterPath(
2626
}
2727
return cpp::fail("Failed to add DLL directory: " + path.string());
2828
} else {
29-
CTL_DBG("Added DLL directory: " << path.string());
29+
CTL_INF("Added DLL directory: " << path.string());
3030
}
3131

3232
dylib_paths.push_back({path, cookie});

engine/utils/process/utils.cc

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ std::vector<char*> ConvertToArgv(const std::vector<std::string>& args) {
4242

4343
cpp::result<ProcessInfo, std::string> SpawnProcess(
4444
const std::vector<std::string>& command, const std::string& stdout_file,
45-
const std::string& stderr_file) {
45+
const std::string& stderr_file, const std::string& current_directory) {
4646
std::stringstream ss;
4747
for (const auto& item : command) {
4848
ss << item << " ";
@@ -109,17 +109,21 @@ cpp::result<ProcessInfo, std::string> SpawnProcess(
109109

110110
// create a suspended process. we will resume it later after adding it to
111111
// a job (see below)
112-
if (!CreateProcessA(NULL, // lpApplicationName
113-
command_buffer, // lpCommandLine
114-
NULL, // lpProcessAttributes
115-
NULL, // lpThreadAttributes
116-
TRUE, // bInheritHandles
117-
CREATE_SUSPENDED, // dwCreationFlags
118-
NULL, // lpEnvironment
119-
NULL, // lpCurrentDirectory
120-
&si, // lpStartupInfo
121-
&pi // lpProcessInformation
122-
)) {
112+
if (!CreateProcessA(
113+
NULL, // lpApplicationName
114+
command_buffer, // lpCommandLine
115+
NULL, // lpProcessAttributes
116+
NULL, // lpThreadAttributes
117+
TRUE, // bInheritHandles
118+
CREATE_SUSPENDED, // dwCreationFlags
119+
NULL, // lpEnvironment
120+
current_directory.empty()
121+
? NULL
122+
: const_cast<char*>(
123+
current_directory.c_str()), // lpCurrentDirectory
124+
&si, // lpStartupInfo
125+
&pi // lpProcessInformation
126+
)) {
123127
if (hStdOut != NULL)
124128
CloseHandle(hStdOut);
125129
if (hStdErr != NULL)

engine/utils/process/utils.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ std::vector<char*> ConvertToArgv(const std::vector<std::string>& args);
3636

3737
cpp::result<ProcessInfo, std::string> SpawnProcess(
3838
const std::vector<std::string>& command,
39-
const std::string& stdout_file = "", const std::string& stderr_file = "");
39+
const std::string& stdout_file = "", const std::string& stderr_file = "",
40+
const std::string& current_directory = "");
4041
bool IsProcessAlive(ProcessInfo& proc_info);
4142
bool WaitProcess(ProcessInfo& proc_info);
4243
bool KillProcess(ProcessInfo& proc_info);

0 commit comments

Comments
 (0)