Skip to content

Commit 80c8d15

Browse files
committed
Linux
1 parent 455a775 commit 80c8d15

File tree

10 files changed

+92
-87
lines changed

10 files changed

+92
-87
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,3 +346,7 @@ healthchecksdb
346346
MigrationBackup/
347347

348348
out/
349+
350+
.idea/
351+
352+
.vscode/

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@
44
[submodule "vendor/minhook"]
55
path = vendor/minhook
66
url = https://github.com/KimihikoAkayasaki/minhook
7+
[submodule "vendor/capnp"]
8+
path = vendor/capnp
9+
url = https://github.com/capnproto/capnproto

CMakePresets.json

Lines changed: 19 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -41,28 +41,6 @@
4141
"USE_HOOKS": "ON"
4242
}
4343
},
44-
{
45-
"name": "x86-debug",
46-
"displayName": "x86 Debug",
47-
"inherits": "windows-base",
48-
"architecture": {
49-
"value": "x86",
50-
"strategy": "external"
51-
},
52-
"cacheVariables": {
53-
"CMAKE_BUILD_TYPE": "Debug",
54-
"USE_HOOKS": "ON"
55-
}
56-
},
57-
{
58-
"name": "x86-release",
59-
"displayName": "x86 Release",
60-
"inherits": "x86-debug",
61-
"cacheVariables": {
62-
"CMAKE_BUILD_TYPE": "Release",
63-
"USE_HOOKS": "ON"
64-
}
65-
},
6644
{
6745
"name": "x64-debug-nohooks",
6846
"displayName": "x64 Debug",
@@ -84,33 +62,14 @@
8462
}
8563
},
8664
{
87-
"name": "x86-debug-nohooks",
88-
"displayName": "x86 Debug",
89-
"inherits": "windows-base",
90-
"architecture": {
91-
"value": "x86",
92-
"strategy": "external"
93-
},
94-
"cacheVariables": {
95-
"CMAKE_BUILD_TYPE": "Debug"
96-
}
97-
},
98-
{
99-
"name": "x86-release-nohooks",
100-
"displayName": "x86 Release",
101-
"inherits": "x86-debug",
102-
"cacheVariables": {
103-
"CMAKE_BUILD_TYPE": "Release"
104-
}
105-
},
106-
{
107-
"name": "linux-debug",
108-
"displayName": "Linux Debug",
65+
"name": "linux-base",
66+
"hidden": true,
10967
"generator": "Ninja",
11068
"binaryDir": "${sourceDir}/out/build/${presetName}",
11169
"installDir": "${sourceDir}/out/install/${presetName}",
11270
"cacheVariables": {
113-
"CMAKE_BUILD_TYPE": "Debug"
71+
"CMAKE_TOOLCHAIN_FILE": "/home/akaya/.vcpkg/scripts/buildsystems/vcpkg.cmake",
72+
"VCPKG_TARGET_TRIPLET": "x64-linux"
11473
},
11574
"condition": {
11675
"type": "equals",
@@ -124,23 +83,23 @@
12483
}
12584
},
12685
{
127-
"name": "macos-debug",
128-
"displayName": "macOS Debug",
129-
"generator": "Ninja",
130-
"binaryDir": "${sourceDir}/out/build/${presetName}",
131-
"installDir": "${sourceDir}/out/install/${presetName}",
86+
"name": "linux-x64-debug",
87+
"displayName": "Linux x64 Debug",
88+
"inherits": "linux-base",
89+
"architecture": {
90+
"value": "x64",
91+
"strategy": "external"
92+
},
13293
"cacheVariables": {
13394
"CMAKE_BUILD_TYPE": "Debug"
134-
},
135-
"condition": {
136-
"type": "equals",
137-
"lhs": "${hostSystemName}",
138-
"rhs": "Darwin"
139-
},
140-
"vendor": {
141-
"microsoft.com/VisualStudioRemoteSettings/CMake/1.0": {
142-
"sourceDir": "$env{HOME}/.vs/$ms{projectDirName}"
143-
}
95+
}
96+
},
97+
{
98+
"name": "linux-x64-release",
99+
"displayName": "Linux x64 Release",
100+
"inherits": "linux-base",
101+
"cacheVariables": {
102+
"CMAKE_BUILD_TYPE": "Release"
144103
}
145104
}
146105
]

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,6 @@ and use them in Visual Studio (recommended) or straight from the DotNet CLI.
4141
The project templates already contain most of the needed documentation,
4242
although please feel free to check out [the official wesite](https://docs.k2vr.tech/) for more docs sometime.
4343

44-
The build and publishment workflow is the same as in this repo (excluding vendor deps).
44+
The build and publishment workflow is the same as in this repo (excluding vendor deps).
45+
46+
capnp: autoreconf -i && ./configure && make -j6 check

driver_Amethyst/CMakeLists.txt

Lines changed: 46 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,8 @@ endif()
3737
add_library(${DRIVER_TARGET_NAME} SHARED ${driver_HDR} ${driver_SRC} ${driver_IDL})
3838
target_include_directories(${DRIVER_TARGET_NAME} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/include")
3939

40-
if (CMAKE_VERSION VERSION_GREATER 3.12)
41-
set_property(TARGET ${DRIVER_TARGET_NAME} PROPERTY CXX_STANDARD 20)
42-
endif()
40+
set_property(TARGET ${DRIVER_TARGET_NAME} PROPERTY CXX_STANDARD 20)
41+
set_property(TARGET ${DRIVER_TARGET_NAME} PROPERTY CXX_STANDARD_REQUIRED ON)
4342

4443
# ----------------------- MinHook support ----------------------
4544
if (WIN32 AND USE_HOOKS)
@@ -69,11 +68,25 @@ elseif (DEFINED CAPNP_EXECUTABLE)
6968
set(CAPNP_COMPILER "${CAPNP_EXECUTABLE}")
7069
endif()
7170

71+
# Set up the capnp compile command with PATH modification on Linux
72+
if(UNIX AND NOT APPLE)
73+
if (TARGET CapnProto::capnp_tool)
74+
set(CAPNP_COMPILE_COMMAND ${CMAKE_COMMAND} -E env "PATH=$<TARGET_FILE_DIR:CapnProto::capnp_tool>:$ENV{PATH}" ${CAPNP_COMPILER} compile -o c++:. "driver.capnp")
75+
elseif (DEFINED CAPNP_EXECUTABLE)
76+
get_filename_component(CAPNP_DIR "${CAPNP_EXECUTABLE}" DIRECTORY)
77+
set(CAPNP_COMPILE_COMMAND ${CMAKE_COMMAND} -E env "PATH=${CAPNP_DIR}:$ENV{PATH}" ${CAPNP_COMPILER} compile -o c++:. "driver.capnp")
78+
else()
79+
set(CAPNP_COMPILE_COMMAND ${CAPNP_COMPILER} compile -o c++:. "driver.capnp")
80+
endif()
81+
else()
82+
set(CAPNP_COMPILE_COMMAND ${CAPNP_COMPILER} compile -o c++:. "driver.capnp")
83+
endif()
84+
7285
add_custom_command(
7386
OUTPUT "${CAPNP_GEN_HDR}" "${CAPNP_GEN_SRC}"
7487
COMMAND ${CMAKE_COMMAND} -E make_directory "${CAPNP_OUT_DIR}"
7588
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CAPNP_SCHEMA}" "${CAPNP_SCHEMA_COPY}"
76-
COMMAND ${CAPNP_COMPILER} compile -o c++:. "driver.capnp"
89+
COMMAND ${CAPNP_COMPILE_COMMAND}
7790
DEPENDS "${CAPNP_SCHEMA}"
7891
WORKING_DIRECTORY "${CAPNP_OUT_DIR}"
7992
COMMENT "Generating Cap'n Proto C++ from driver.capnp"
@@ -96,25 +109,16 @@ set(OPENVR_ROOT "${CMAKE_CURRENT_LIST_DIR}/../vendor/openvr")
96109
set(OPENVR_INCLUDE_DIR "${OPENVR_ROOT}/headers")
97110

98111
if (WIN32)
99-
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
100-
set(OPENVR_IMPLIB "${OPENVR_ROOT}/lib/win64/openvr_api.lib")
101-
set(OPENVR_RUNTIME "${OPENVR_ROOT}/bin/win64/openvr_api.dll")
102-
else()
103-
set(OPENVR_IMPLIB "${OPENVR_ROOT}/lib/win32/openvr_api.lib")
104-
set(OPENVR_RUNTIME "${OPENVR_ROOT}/bin/win32/openvr_api.dll")
105-
endif()
112+
set(OPENVR_IMPLIB "${OPENVR_ROOT}/lib/win64/openvr_api.lib")
113+
set(OPENVR_RUNTIME "${OPENVR_ROOT}/bin/win64/openvr_api.dll")
106114
add_library(openvr::openvr SHARED IMPORTED)
107115
set_target_properties(openvr::openvr PROPERTIES
108116
IMPORTED_IMPLIB "${OPENVR_IMPLIB}"
109117
IMPORTED_LOCATION "${OPENVR_RUNTIME}"
110118
INTERFACE_INCLUDE_DIRECTORIES "${OPENVR_INCLUDE_DIR}"
111119
)
112120
elseif(UNIX AND NOT APPLE)
113-
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
114-
set(OPENVR_RUNTIME "${OPENVR_ROOT}/lib/linux64/libopenvr_api.so")
115-
else()
116-
set(OPENVR_RUNTIME "${OPENVR_ROOT}/lib/linux32/libopenvr_api.so")
117-
endif()
121+
set(OPENVR_RUNTIME "${OPENVR_ROOT}/lib/linux64/libopenvr_api.so")
118122
add_library(openvr::openvr SHARED IMPORTED)
119123
set_target_properties(openvr::openvr PROPERTIES
120124
IMPORTED_LOCATION "${OPENVR_RUNTIME}"
@@ -147,13 +151,10 @@ else()
147151
endif()
148152

149153
if (WIN32)
150-
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
151-
set(PACK_BIN_DIR "${PACK_ROOT}/bin/win64")
152-
else()
153-
set(PACK_BIN_DIR "${PACK_ROOT}/bin/win32")
154-
endif()
154+
set(PACK_BIN_DIR "${PACK_ROOT}/bin/win64")
155+
elseif(UNIX AND NOT APPLE)
156+
set(PACK_BIN_DIR "${PACK_ROOT}/bin/linux64")
155157
else()
156-
# Default bin directory if non-Windows
157158
set(PACK_BIN_DIR "${PACK_ROOT}/bin")
158159
endif()
159160

@@ -165,9 +166,31 @@ endif()
165166

166167
add_custom_command(TARGET ${DRIVER_TARGET_NAME} POST_BUILD
167168
COMMAND ${CMAKE_COMMAND} -E make_directory "${PACK_BIN_DIR}"
168-
COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_FILE:${DRIVER_TARGET_NAME}>" "${PACK_BIN_DIR}"
169169
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${MANIFEST_SRC}" "${PACK_ROOT}/driver.vrdrivermanifest"
170170
COMMENT "Packing driver files to ${PACK_ROOT}"
171171
VERBATIM
172172
)
173+
174+
if(UNIX AND NOT APPLE)
175+
add_custom_command(TARGET ${DRIVER_TARGET_NAME} POST_BUILD
176+
COMMAND ${CMAKE_COMMAND} -E copy_if_different
177+
"$<TARGET_FILE:${DRIVER_TARGET_NAME}>"
178+
"${PACK_BIN_DIR}/$<TARGET_FILE_BASE_NAME:${DRIVER_TARGET_NAME}>$<TARGET_FILE_SUFFIX:${DRIVER_TARGET_NAME}>"
179+
COMMENT "Copying driver library without lib prefix"
180+
VERBATIM
181+
)
182+
else()
183+
add_custom_command(TARGET ${DRIVER_TARGET_NAME} POST_BUILD
184+
COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_FILE:${DRIVER_TARGET_NAME}>" "${PACK_BIN_DIR}"
185+
COMMENT "Copying driver library"
186+
VERBATIM
187+
)
188+
endif()
189+
190+
191+
if (TARGET openvr::openvr)
192+
add_custom_command(TARGET ${DRIVER_TARGET_NAME} POST_BUILD
193+
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${OPENVR_RUNTIME}" "${PACK_BIN_DIR}"
194+
VERBATIM)
195+
endif()
173196
# --------------------------------------------------------------

driver_Amethyst/include/BodyTracker.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#pragma once
33
#include <filesystem>
44
#include <map>
5+
#include <format>
56
#include <openvr_driver.h>
67
#include <driver.capnp.h>
78

driver_Amethyst/src/ServerProvider.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,16 @@ namespace amethyst::driver::implementation
322322
};
323323
}
324324

325-
extern "C" __declspec(dllexport) void* HmdDriverFactory(const char* pInterfaceName, int* pReturnCode)
325+
#if defined(_MSC_VER)
326+
#define EXPORT __declspec(dllexport)
327+
#elif defined(__GNUC__)
328+
#define EXPORT __attribute__((visibility("default")))
329+
#else
330+
#define EXPORT
331+
#pragma warning Unknown dynamic link import/export semantics.
332+
#endif
333+
334+
extern "C" EXPORT void* HmdDriverFactory(const char* pInterfaceName, int* pReturnCode)
326335
{
327336
static amethyst::driver::implementation::ServerProvider k2_server_provider;
328337
static amethyst::driver::implementation::DriverWatchdog k2_watchdog_driver;
@@ -340,4 +349,6 @@ extern "C" __declspec(dllexport) void* HmdDriverFactory(const char* pInterfaceNa
340349

341350
if (pReturnCode)
342351
*pReturnCode = vr::VRInitError_Init_InterfaceNotFound;
352+
353+
return nullptr;
343354
}

plugin_OpenVR/OpenVR.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -807,7 +807,7 @@ private async Task<int> InitAmethystServerAsync(int target)
807807
await Dispatcher.InvokeAsync(() =>
808808
{
809809
Host?.Log("Searching for the driver service...");
810-
TcpClient = new TcpRpcClient("localhost", target);
810+
TcpClient = new TcpRpcClient("127.0.0.1", target);
811811
//MidlayerExtensions.AddBuffering(client);
812812

813813
TcpClient.WhenConnected!.Wait(1000);

plugin_OpenVR/plugin_OpenVR.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
<PackageReference Include="Avalonia" Version="11.3.2" />
3131
<PackageReference Include="Avalonia.AvaloniaEdit" Version="11.3.0" />
3232
<PackageReference Include="Capnp.Net.Runtime" Version="1.3.118" />
33-
<PackageReference Include="CapnpC.CSharp.MsBuild.Generation" Version="1.3.118" />
33+
<!-- <PackageReference Include="CapnpC.CSharp.MsBuild.Generation" Version="1.3.118" />-->
34+
<PackageReference Include="FluentAvaloniaUI" Version="2.4.0" />
3435
<PackageReference Include="FluentAvaloniaUI" Version="2.4.0" />
3536
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="4.14.0" />
3637
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />

vendor/capnp

Submodule capnp added at d135c9c

0 commit comments

Comments
 (0)