Skip to content
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2082,7 +2082,13 @@ cc_binary(
] + select({
"//conditions:default": [],
"//src:windows" : ["main_windows.hpp", "main_windows.cpp",],}),
linkopts = LINKOPTS_ADJUSTED,
linkopts = LINKOPTS_ADJUSTED + select({
"//conditions:default": [],
"//src:windows" : [
"runtimeobject.lib",
"oleaut32.lib",
],
}),
copts = COMMON_STATIC_LIBS_COPTS,
deps = [
"//src:ovms_lib",
Expand Down
28 changes: 28 additions & 0 deletions src/main_windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@
#include <windows.h>
#include <tchar.h>
#include <errors.h>
#pragma warning(push)
#pragma warning(disable : 28252 28253 6101)
#include <winrt/Windows.ApplicationModel.h>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also add #include <winrt/base.h>
It's valid comment

#include <winrt/Windows.Foundation.Collections.h>
#include <winrt/Windows.Storage.h>
#pragma warning(pop)

#include "main_windows.hpp"
#include "module_names.hpp"
Expand Down Expand Up @@ -107,8 +113,30 @@ inline std::wstring stringToWstring(const std::string& str, UINT codePage = CP_T
return str2;
}

static void setOpenvinoTokenizersPathFromMsixDependencies() {
constexpr wchar_t PACKAGE_NAME[] = L"Intel.OpenVINO.Tokenizers.2026.3.0.0";
constexpr wchar_t TOKENIZERS_RELATIVE_PATH[] = L"\\runtime\\bin\\intel64\\Release\\openvino_tokenizers.dll";

try {
winrt::Windows::Foundation::Collections::IVectorView<winrt::Windows::ApplicationModel::Package> deps =
winrt::Windows::ApplicationModel::Package::Current().Dependencies();
for (const winrt::Windows::ApplicationModel::Package& dep : deps) {
if (dep.Id().Name() == PACKAGE_NAME) {
const std::wstring dllPath = std::wstring(dep.InstalledLocation().Path().c_str()) + TOKENIZERS_RELATIVE_PATH;
SetEnvironmentVariableW(L"OPENVINO_TOKENIZERS_PATH_GENAI", dllPath.c_str());
DEBUG_LOG("OPENVINO_TOKENIZERS_PATH_GENAI initialized from package dependency.");
return;
}
}
} catch (const winrt::hresult_error&) {
// Not all deployments are packaged; keep default behavior when package metadata is unavailable.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Not all deployments are packaged; keep default behavior when package metadata is unavailable.
// Not all deployments are packaged; keep default behavior when package metadata is unavailable.
DEBUG_LOG("Failed to resolve Tokenizers dependency: 0x%08X %S",
e.code().value, e.message().c_str());

}
}

int main_windows(int argc, char** argv) {
DEBUG_LOG("Windows Main - Entry");
setOpenvinoTokenizersPathFromMsixDependencies();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
setOpenvinoTokenizersPathFromMsixDependencies();
winrt::init_apartment();
setOpenvinoTokenizersPathFromMsixDependencies();


OvmsWindowsServiceManager::instance().ovmsParams.argc = argc;
OvmsWindowsServiceManager::instance().ovmsParams.argv = argv;
OvmsWindowsServiceManager::logParameters(argc, argv, "OVMS Main Argument");
Expand Down