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

Commit 7832a5a

Browse files
committed
fix: windows e2e tests
1 parent 18e958e commit 7832a5a

File tree

4 files changed

+34
-24
lines changed

4 files changed

+34
-24
lines changed

engine/extensions/local-engine/local_engine.cc

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "utils/curl_utils.h"
66
#include "utils/json_helper.h"
77
#include "utils/logging_utils.h"
8+
#include "utils/process/utils.h"
89
#include "utils/url_parser.h"
910

1011
namespace cortex::local {
@@ -548,11 +549,7 @@ void LocalEngine::LoadModel(std::shared_ptr<Json::Value> json_body,
548549
auto log_path =
549550
(file_manager_utils::GetCortexLogPath() / "logs" / "cortex.log").string();
550551
CTL_DBG("log: " << 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());
552+
auto result = cortex::process::SpawnProcess(v, log_path, log_path);
556553
if (result.has_error()) {
557554
CTL_ERR("Fail to spawn process. " << result.error());
558555
Json::Value error;

engine/services/engine_service.cc

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,24 @@ cpp::result<void, std::string> EngineService::DownloadEngine(
329329
std::filesystem::perms::others_exec,
330330
std::filesystem::perm_options::add);
331331

332+
const std::vector<std::string> windows_deps = {
333+
"msvcp140.dll", "vcruntime140.dll", "vcruntime140_1.dll"};
334+
for (auto const& win_dep : windows_deps) {
335+
if (std::filesystem::exists(
336+
file_manager_utils::GetExecutableFolderContainerPath() /
337+
win_dep)) {
338+
CTL_INF("Copy file "
339+
<< (file_manager_utils::GetExecutableFolderContainerPath() /
340+
win_dep)
341+
.string()
342+
<< " to " << extract_path.string());
343+
std::filesystem::copy_file(
344+
file_manager_utils::GetExecutableFolderContainerPath() / win_dep,
345+
extract_path / win_dep,
346+
std::filesystem::copy_options::overwrite_existing);
347+
}
348+
}
349+
332350
} catch (const std::exception& e) {
333351
CTL_INF(e.what());
334352
}
@@ -563,7 +581,7 @@ EngineService::GetEngineVariants(const std::string& engine,
563581
#endif
564582
});
565583
}
566-
584+
567585
if (engine_release_ggml.has_value()) {
568586
// In case of macos, if os version is 12, we get binary from menlo
569587
std::copy_if(

engine/utils/process/utils.cc

Lines changed: 12 additions & 16 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, const std::string& current_directory) {
45+
const std::string& stderr_file) {
4646
std::stringstream ss;
4747
for (const auto& item : command) {
4848
ss << item << " ";
@@ -109,21 +109,17 @@ 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(
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-
)) {
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+
)) {
127123
if (hStdOut != NULL)
128124
CloseHandle(hStdOut);
129125
if (hStdErr != NULL)

engine/utils/process/utils.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ 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 = "",
40-
const std::string& current_directory = "");
39+
const std::string& stdout_file = "", const std::string& stderr_file = "");
4140
bool IsProcessAlive(ProcessInfo& proc_info);
4241
bool WaitProcess(ProcessInfo& proc_info);
4342
bool KillProcess(ProcessInfo& proc_info);

0 commit comments

Comments
 (0)