Removing hardcoded paths for the C# wapper (#266)

Removing the hard coded paths for that the project should build easier across multiple computers.
Using a props file and XML file to let the MSBuild portion know where to get the Azure Kinect build dependencies.
This commit is contained in:
Derek M 2019-04-24 15:08:00 -07:00 коммит произвёл GitHub
Родитель 58856e8eac
Коммит 32f8375541
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
31 изменённых файлов: 588 добавлений и 426 удалений

2
.gitignore поставляемый
Просмотреть файл

@ -14,6 +14,8 @@
# Build results
[Bb]uild/
[Bb]uild32/
[Bb]uild64/
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/

Просмотреть файл

@ -185,8 +185,12 @@ set(TARGET_ARCH ${CMAKE_SYSTEM_PROCESSOR})
if ("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC")
if ("${CMAKE_SIZEOF_VOID_P}" STREQUAL "8")
set(TARGET_ARCH "amd64")
configure_file(k4a.props.in ${CMAKE_CURRENT_SOURCE_DIR}/src/csharp/k4a.x64.props)
configure_file(StubGenerator.xml.in ${CMAKE_CURRENT_SOURCE_DIR}/src/csharp/StubGenerator.x64.xml)
elseif("${CMAKE_SIZEOF_VOID_P}" STREQUAL "4")
set(TARGET_ARCH "x86")
configure_file(k4a.props.in ${CMAKE_CURRENT_SOURCE_DIR}/src/csharp/k4a.x86.props)
configure_file(StubGenerator.xml.in ${CMAKE_CURRENT_SOURCE_DIR}/src/csharp/StubGenerator.x86.xml)
else()
message(FATAL_ERROR "Unknown architecture with size of void* = ${CMAKE_SIZEOF_VOID_P}")
endif()

8
StubGenerator.xml.in Normal file
Просмотреть файл

@ -0,0 +1,8 @@
<Paths>
<K4A_BINARY_DIR>@PROJECT_BINARY_DIR@</K4A_BINARY_DIR>
<K4A_SOURCE_DIR>@PROJ_DIR@</K4A_SOURCE_DIR>
<CMAKE_CXX_COMPILER>@CMAKE_CXX_COMPILER@</CMAKE_CXX_COMPILER>
<CMAKE_LINKER>@CMAKE_LINKER@</CMAKE_LINKER>
<INCLUDE>$ENV{INCLUDE}</INCLUDE>
<LIB>$ENV{LIB}</LIB>
</Paths>

5
k4a.props.in Normal file
Просмотреть файл

@ -0,0 +1,5 @@
<Project>
<PropertyGroup>
<K4aBinaryDirectory>@PROJECT_BINARY_DIR@</K4aBinaryDirectory>
</PropertyGroup>
</Project>

6
src/csharp/.gitignore поставляемый Normal file
Просмотреть файл

@ -0,0 +1,6 @@
## Ignore CMake generated files that enable the CSharp solution to find and interact with the CMake built files.
/k4a.*.props
/StubGenerator.*.json
/StubGenerator.*.xml

Просмотреть файл

@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.28407.52
# Visual Studio 15
VisualStudioVersion = 15.0.28307.572
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AzureKinect.Examples.WPFViewer", "Microsoft.AzureKinect.Examples.WPFViewer\Microsoft.AzureKinect.Examples.WPFViewer.csproj", "{CCD99E9D-1EE2-41F5-AD3F-4110A466A9A4}"
EndProject
@ -25,122 +25,84 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AzureKinect.Examp
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{CCD99E9D-1EE2-41F5-AD3F-4110A466A9A4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CCD99E9D-1EE2-41F5-AD3F-4110A466A9A4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CCD99E9D-1EE2-41F5-AD3F-4110A466A9A4}.Debug|x64.ActiveCfg = Debug|Any CPU
{CCD99E9D-1EE2-41F5-AD3F-4110A466A9A4}.Debug|x64.Build.0 = Debug|Any CPU
{CCD99E9D-1EE2-41F5-AD3F-4110A466A9A4}.Debug|x86.ActiveCfg = Debug|Any CPU
{CCD99E9D-1EE2-41F5-AD3F-4110A466A9A4}.Debug|x86.Build.0 = Debug|Any CPU
{CCD99E9D-1EE2-41F5-AD3F-4110A466A9A4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CCD99E9D-1EE2-41F5-AD3F-4110A466A9A4}.Release|Any CPU.Build.0 = Release|Any CPU
{CCD99E9D-1EE2-41F5-AD3F-4110A466A9A4}.Release|x64.ActiveCfg = Release|Any CPU
{CCD99E9D-1EE2-41F5-AD3F-4110A466A9A4}.Release|x64.Build.0 = Release|Any CPU
{CCD99E9D-1EE2-41F5-AD3F-4110A466A9A4}.Release|x86.ActiveCfg = Release|Any CPU
{CCD99E9D-1EE2-41F5-AD3F-4110A466A9A4}.Release|x86.Build.0 = Release|Any CPU
{847B31D5-C253-4766-BF81-032F4670589D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{847B31D5-C253-4766-BF81-032F4670589D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CCD99E9D-1EE2-41F5-AD3F-4110A466A9A4}.Debug|x64.ActiveCfg = Debug|x64
{CCD99E9D-1EE2-41F5-AD3F-4110A466A9A4}.Debug|x64.Build.0 = Debug|x64
{CCD99E9D-1EE2-41F5-AD3F-4110A466A9A4}.Debug|x86.ActiveCfg = Debug|x86
{CCD99E9D-1EE2-41F5-AD3F-4110A466A9A4}.Debug|x86.Build.0 = Debug|x86
{CCD99E9D-1EE2-41F5-AD3F-4110A466A9A4}.Release|x64.ActiveCfg = Release|x64
{CCD99E9D-1EE2-41F5-AD3F-4110A466A9A4}.Release|x64.Build.0 = Release|x64
{CCD99E9D-1EE2-41F5-AD3F-4110A466A9A4}.Release|x86.ActiveCfg = Release|x86
{CCD99E9D-1EE2-41F5-AD3F-4110A466A9A4}.Release|x86.Build.0 = Release|x86
{847B31D5-C253-4766-BF81-032F4670589D}.Debug|x64.ActiveCfg = Debug|Any CPU
{847B31D5-C253-4766-BF81-032F4670589D}.Debug|x64.Build.0 = Debug|Any CPU
{847B31D5-C253-4766-BF81-032F4670589D}.Debug|x86.ActiveCfg = Debug|Any CPU
{847B31D5-C253-4766-BF81-032F4670589D}.Debug|x86.Build.0 = Debug|Any CPU
{847B31D5-C253-4766-BF81-032F4670589D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{847B31D5-C253-4766-BF81-032F4670589D}.Release|Any CPU.Build.0 = Release|Any CPU
{847B31D5-C253-4766-BF81-032F4670589D}.Release|x64.ActiveCfg = Release|Any CPU
{847B31D5-C253-4766-BF81-032F4670589D}.Release|x64.Build.0 = Release|Any CPU
{847B31D5-C253-4766-BF81-032F4670589D}.Release|x86.ActiveCfg = Release|Any CPU
{847B31D5-C253-4766-BF81-032F4670589D}.Release|x86.Build.0 = Release|Any CPU
{41510BD0-7F25-470B-A1DC-12E1DB1AB3B7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{41510BD0-7F25-470B-A1DC-12E1DB1AB3B7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{41510BD0-7F25-470B-A1DC-12E1DB1AB3B7}.Debug|x64.ActiveCfg = Debug|Any CPU
{41510BD0-7F25-470B-A1DC-12E1DB1AB3B7}.Debug|x64.Build.0 = Debug|Any CPU
{41510BD0-7F25-470B-A1DC-12E1DB1AB3B7}.Debug|x86.ActiveCfg = Debug|Any CPU
{41510BD0-7F25-470B-A1DC-12E1DB1AB3B7}.Debug|x86.Build.0 = Debug|Any CPU
{41510BD0-7F25-470B-A1DC-12E1DB1AB3B7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{41510BD0-7F25-470B-A1DC-12E1DB1AB3B7}.Release|Any CPU.Build.0 = Release|Any CPU
{41510BD0-7F25-470B-A1DC-12E1DB1AB3B7}.Debug|x64.ActiveCfg = Debug|x64
{41510BD0-7F25-470B-A1DC-12E1DB1AB3B7}.Debug|x64.Build.0 = Debug|x64
{41510BD0-7F25-470B-A1DC-12E1DB1AB3B7}.Debug|x86.ActiveCfg = Debug|x86
{41510BD0-7F25-470B-A1DC-12E1DB1AB3B7}.Debug|x86.Build.0 = Debug|x86
{41510BD0-7F25-470B-A1DC-12E1DB1AB3B7}.Release|x64.ActiveCfg = Release|x64
{41510BD0-7F25-470B-A1DC-12E1DB1AB3B7}.Release|x64.Build.0 = Release|x64
{41510BD0-7F25-470B-A1DC-12E1DB1AB3B7}.Release|x86.ActiveCfg = Release|Any CPU
{41510BD0-7F25-470B-A1DC-12E1DB1AB3B7}.Release|x86.Build.0 = Release|Any CPU
{9C78ECE9-FDCF-4E72-979A-6C93E1201DA9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9C78ECE9-FDCF-4E72-979A-6C93E1201DA9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9C78ECE9-FDCF-4E72-979A-6C93E1201DA9}.Debug|x64.ActiveCfg = Debug|Any CPU
{9C78ECE9-FDCF-4E72-979A-6C93E1201DA9}.Debug|x64.Build.0 = Debug|Any CPU
{9C78ECE9-FDCF-4E72-979A-6C93E1201DA9}.Debug|x86.ActiveCfg = Debug|Any CPU
{9C78ECE9-FDCF-4E72-979A-6C93E1201DA9}.Debug|x86.Build.0 = Debug|Any CPU
{9C78ECE9-FDCF-4E72-979A-6C93E1201DA9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9C78ECE9-FDCF-4E72-979A-6C93E1201DA9}.Release|Any CPU.Build.0 = Release|Any CPU
{9C78ECE9-FDCF-4E72-979A-6C93E1201DA9}.Release|x64.ActiveCfg = Release|Any CPU
{9C78ECE9-FDCF-4E72-979A-6C93E1201DA9}.Release|x64.Build.0 = Release|Any CPU
{9C78ECE9-FDCF-4E72-979A-6C93E1201DA9}.Release|x86.ActiveCfg = Release|Any CPU
{9C78ECE9-FDCF-4E72-979A-6C93E1201DA9}.Release|x86.Build.0 = Release|Any CPU
{FCD1E629-1E96-4BDD-A247-35B50F31137A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FCD1E629-1E96-4BDD-A247-35B50F31137A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{41510BD0-7F25-470B-A1DC-12E1DB1AB3B7}.Release|x86.ActiveCfg = Release|x86
{41510BD0-7F25-470B-A1DC-12E1DB1AB3B7}.Release|x86.Build.0 = Release|x86
{9C78ECE9-FDCF-4E72-979A-6C93E1201DA9}.Debug|x64.ActiveCfg = Debug|x64
{9C78ECE9-FDCF-4E72-979A-6C93E1201DA9}.Debug|x64.Build.0 = Debug|x64
{9C78ECE9-FDCF-4E72-979A-6C93E1201DA9}.Debug|x86.ActiveCfg = Debug|x86
{9C78ECE9-FDCF-4E72-979A-6C93E1201DA9}.Debug|x86.Build.0 = Debug|x86
{9C78ECE9-FDCF-4E72-979A-6C93E1201DA9}.Release|x64.ActiveCfg = Release|x64
{9C78ECE9-FDCF-4E72-979A-6C93E1201DA9}.Release|x64.Build.0 = Release|x64
{9C78ECE9-FDCF-4E72-979A-6C93E1201DA9}.Release|x86.ActiveCfg = Release|x86
{9C78ECE9-FDCF-4E72-979A-6C93E1201DA9}.Release|x86.Build.0 = Release|x86
{FCD1E629-1E96-4BDD-A247-35B50F31137A}.Debug|x64.ActiveCfg = Debug|Any CPU
{FCD1E629-1E96-4BDD-A247-35B50F31137A}.Debug|x64.Build.0 = Debug|Any CPU
{FCD1E629-1E96-4BDD-A247-35B50F31137A}.Debug|x86.ActiveCfg = Debug|Any CPU
{FCD1E629-1E96-4BDD-A247-35B50F31137A}.Debug|x86.Build.0 = Debug|Any CPU
{FCD1E629-1E96-4BDD-A247-35B50F31137A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FCD1E629-1E96-4BDD-A247-35B50F31137A}.Release|Any CPU.Build.0 = Release|Any CPU
{FCD1E629-1E96-4BDD-A247-35B50F31137A}.Release|x64.ActiveCfg = Release|Any CPU
{FCD1E629-1E96-4BDD-A247-35B50F31137A}.Release|x64.Build.0 = Release|Any CPU
{FCD1E629-1E96-4BDD-A247-35B50F31137A}.Release|x86.ActiveCfg = Release|Any CPU
{FCD1E629-1E96-4BDD-A247-35B50F31137A}.Release|x86.Build.0 = Release|Any CPU
{6D4EC05A-3A81-4B92-8881-96F499F5986B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6D4EC05A-3A81-4B92-8881-96F499F5986B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6D4EC05A-3A81-4B92-8881-96F499F5986B}.Debug|x64.ActiveCfg = Debug|Any CPU
{6D4EC05A-3A81-4B92-8881-96F499F5986B}.Debug|x64.Build.0 = Debug|Any CPU
{6D4EC05A-3A81-4B92-8881-96F499F5986B}.Debug|x86.ActiveCfg = Debug|Any CPU
{6D4EC05A-3A81-4B92-8881-96F499F5986B}.Debug|x86.Build.0 = Debug|Any CPU
{6D4EC05A-3A81-4B92-8881-96F499F5986B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6D4EC05A-3A81-4B92-8881-96F499F5986B}.Release|Any CPU.Build.0 = Release|Any CPU
{6D4EC05A-3A81-4B92-8881-96F499F5986B}.Release|x64.ActiveCfg = Release|Any CPU
{6D4EC05A-3A81-4B92-8881-96F499F5986B}.Release|x64.Build.0 = Release|Any CPU
{6D4EC05A-3A81-4B92-8881-96F499F5986B}.Release|x86.ActiveCfg = Release|Any CPU
{6D4EC05A-3A81-4B92-8881-96F499F5986B}.Release|x86.Build.0 = Release|Any CPU
{E1B3CC41-BC1C-47B7-A6A6-AA50E6994C05}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E1B3CC41-BC1C-47B7-A6A6-AA50E6994C05}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E1B3CC41-BC1C-47B7-A6A6-AA50E6994C05}.Debug|x64.ActiveCfg = Debug|Any CPU
{E1B3CC41-BC1C-47B7-A6A6-AA50E6994C05}.Debug|x64.Build.0 = Debug|Any CPU
{E1B3CC41-BC1C-47B7-A6A6-AA50E6994C05}.Debug|x86.ActiveCfg = Debug|Any CPU
{E1B3CC41-BC1C-47B7-A6A6-AA50E6994C05}.Debug|x86.Build.0 = Debug|Any CPU
{E1B3CC41-BC1C-47B7-A6A6-AA50E6994C05}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E1B3CC41-BC1C-47B7-A6A6-AA50E6994C05}.Release|Any CPU.Build.0 = Release|Any CPU
{E1B3CC41-BC1C-47B7-A6A6-AA50E6994C05}.Release|x64.ActiveCfg = Release|Any CPU
{E1B3CC41-BC1C-47B7-A6A6-AA50E6994C05}.Release|x64.Build.0 = Release|Any CPU
{E1B3CC41-BC1C-47B7-A6A6-AA50E6994C05}.Release|x86.ActiveCfg = Release|Any CPU
{E1B3CC41-BC1C-47B7-A6A6-AA50E6994C05}.Release|x86.Build.0 = Release|Any CPU
{4762DD42-3CF3-4742-9AEA-5D39781FD2A6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4762DD42-3CF3-4742-9AEA-5D39781FD2A6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6D4EC05A-3A81-4B92-8881-96F499F5986B}.Debug|x64.ActiveCfg = Debug|x64
{6D4EC05A-3A81-4B92-8881-96F499F5986B}.Debug|x64.Build.0 = Debug|x64
{6D4EC05A-3A81-4B92-8881-96F499F5986B}.Debug|x86.ActiveCfg = Debug|x86
{6D4EC05A-3A81-4B92-8881-96F499F5986B}.Debug|x86.Build.0 = Debug|x86
{6D4EC05A-3A81-4B92-8881-96F499F5986B}.Release|x64.ActiveCfg = Release|x64
{6D4EC05A-3A81-4B92-8881-96F499F5986B}.Release|x64.Build.0 = Release|x64
{6D4EC05A-3A81-4B92-8881-96F499F5986B}.Release|x86.ActiveCfg = Release|x86
{6D4EC05A-3A81-4B92-8881-96F499F5986B}.Release|x86.Build.0 = Release|x86
{E1B3CC41-BC1C-47B7-A6A6-AA50E6994C05}.Debug|x64.ActiveCfg = Debug|x64
{E1B3CC41-BC1C-47B7-A6A6-AA50E6994C05}.Debug|x64.Build.0 = Debug|x64
{E1B3CC41-BC1C-47B7-A6A6-AA50E6994C05}.Debug|x86.ActiveCfg = Debug|x86
{E1B3CC41-BC1C-47B7-A6A6-AA50E6994C05}.Debug|x86.Build.0 = Debug|x86
{E1B3CC41-BC1C-47B7-A6A6-AA50E6994C05}.Release|x64.ActiveCfg = Release|x64
{E1B3CC41-BC1C-47B7-A6A6-AA50E6994C05}.Release|x64.Build.0 = Release|x64
{E1B3CC41-BC1C-47B7-A6A6-AA50E6994C05}.Release|x86.ActiveCfg = Release|x86
{E1B3CC41-BC1C-47B7-A6A6-AA50E6994C05}.Release|x86.Build.0 = Release|x86
{4762DD42-3CF3-4742-9AEA-5D39781FD2A6}.Debug|x64.ActiveCfg = Debug|Any CPU
{4762DD42-3CF3-4742-9AEA-5D39781FD2A6}.Debug|x64.Build.0 = Debug|Any CPU
{4762DD42-3CF3-4742-9AEA-5D39781FD2A6}.Debug|x86.ActiveCfg = Debug|Any CPU
{4762DD42-3CF3-4742-9AEA-5D39781FD2A6}.Debug|x86.Build.0 = Debug|Any CPU
{4762DD42-3CF3-4742-9AEA-5D39781FD2A6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4762DD42-3CF3-4742-9AEA-5D39781FD2A6}.Release|Any CPU.Build.0 = Release|Any CPU
{4762DD42-3CF3-4742-9AEA-5D39781FD2A6}.Release|x64.ActiveCfg = Release|Any CPU
{4762DD42-3CF3-4742-9AEA-5D39781FD2A6}.Release|x64.Build.0 = Release|Any CPU
{4762DD42-3CF3-4742-9AEA-5D39781FD2A6}.Release|x86.ActiveCfg = Release|Any CPU
{4762DD42-3CF3-4742-9AEA-5D39781FD2A6}.Release|x86.Build.0 = Release|Any CPU
{8A14FB66-07CD-4E4C-A533-89DE0AFF4FCB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8A14FB66-07CD-4E4C-A533-89DE0AFF4FCB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8A14FB66-07CD-4E4C-A533-89DE0AFF4FCB}.Debug|x64.ActiveCfg = Debug|Any CPU
{8A14FB66-07CD-4E4C-A533-89DE0AFF4FCB}.Debug|x64.Build.0 = Debug|Any CPU
{8A14FB66-07CD-4E4C-A533-89DE0AFF4FCB}.Debug|x86.ActiveCfg = Debug|Any CPU
{8A14FB66-07CD-4E4C-A533-89DE0AFF4FCB}.Debug|x86.Build.0 = Debug|Any CPU
{8A14FB66-07CD-4E4C-A533-89DE0AFF4FCB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8A14FB66-07CD-4E4C-A533-89DE0AFF4FCB}.Release|Any CPU.Build.0 = Release|Any CPU
{8A14FB66-07CD-4E4C-A533-89DE0AFF4FCB}.Release|x64.ActiveCfg = Release|Any CPU
{8A14FB66-07CD-4E4C-A533-89DE0AFF4FCB}.Release|x64.Build.0 = Release|Any CPU
{8A14FB66-07CD-4E4C-A533-89DE0AFF4FCB}.Release|x86.ActiveCfg = Release|Any CPU
{8A14FB66-07CD-4E4C-A533-89DE0AFF4FCB}.Release|x86.Build.0 = Release|Any CPU
{8A14FB66-07CD-4E4C-A533-89DE0AFF4FCB}.Debug|x64.ActiveCfg = Debug|x64
{8A14FB66-07CD-4E4C-A533-89DE0AFF4FCB}.Debug|x64.Build.0 = Debug|x64
{8A14FB66-07CD-4E4C-A533-89DE0AFF4FCB}.Debug|x86.ActiveCfg = Debug|x86
{8A14FB66-07CD-4E4C-A533-89DE0AFF4FCB}.Debug|x86.Build.0 = Debug|x86
{8A14FB66-07CD-4E4C-A533-89DE0AFF4FCB}.Release|x64.ActiveCfg = Release|x64
{8A14FB66-07CD-4E4C-A533-89DE0AFF4FCB}.Release|x64.Build.0 = Release|x64
{8A14FB66-07CD-4E4C-A533-89DE0AFF4FCB}.Release|x86.ActiveCfg = Release|x86
{8A14FB66-07CD-4E4C-A533-89DE0AFF4FCB}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

Просмотреть файл

@ -1,9 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\k4a.props" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<Platform Condition=" '$(Platform)' == '' ">x64</Platform>
<ProjectGuid>{CCD99E9D-1EE2-41F5-AD3F-4110A466A9A4}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>K4aWpfTestApplication</RootNamespace>
@ -14,23 +15,38 @@
<WarningLevel>4</WarningLevel>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<OutputPath>$(BaseOutputPath)$(AssemblyName)\</OutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<PlatformTarget>x64</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<PlatformTarget>x64</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<PlatformTarget>x86</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
@ -106,15 +122,15 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Content Include="..\..\..\build\bin\k4a.dll">
<Content Include="$(K4aBinaryDirectory)\bin\k4a.dll">
<Link>k4a.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="..\..\..\build\bin\libusb-1.0.dll">
<Content Include="$(K4aBinaryDirectory)\bin\libusb-1.0.dll">
<Link>libusb-1.0.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="C:\Program Files\Azure Kinect SDK\sdk\windows-desktop\amd64\release\bin\depthengine_1_0.dll">
<Content Include="$(K4aBinaryDirectory)\bin\depthengine_1_0.dll">
<Link>depthengine_1_0.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>

Просмотреть файл

@ -1,9 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\k4a.props" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<Platform Condition=" '$(Platform)' == '' ">x64</Platform>
<ProjectGuid>{8A14FB66-07CD-4E4C-A533-89DE0AFF4FCB}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>Microsoft.AzureKinect.Examples.WinForms</RootNamespace>
@ -12,23 +13,38 @@
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<OutputPath>$(BaseOutputPath)$(AssemblyName)\</OutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<PlatformTarget>x64</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<PlatformTarget>x64</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<PlatformTarget>x86</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
@ -87,15 +103,15 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Content Include="..\..\..\build\bin\k4a.dll">
<Content Include="$(K4aBinaryDirectory)\bin\k4a.dll">
<Link>k4a.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="..\..\..\build\bin\libusb-1.0.dll">
<Content Include="$(K4aBinaryDirectory)\bin\libusb-1.0.dll">
<Link>libusb-1.0.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="C:\Program Files\Azure Kinect SDK\sdk\windows-desktop\amd64\release\bin\depthengine_1_0.dll">
<Content Include="$(K4aBinaryDirectory)\bin\depthengine_1_0.dll">
<Link>depthengine_1_0.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>

Просмотреть файл

@ -1,11 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\k4a.props" />
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<IsPackable>false</IsPackable>
<Platforms>x64;x86</Platforms>
<OutputPath>$(BaseOutputPath)$(AssemblyName)\</OutputPath>
</PropertyGroup>
<ItemGroup>
<Content Include="..\StubGenerator.$(Platform).xml">
<Link>appsettings.xml</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<PackageReference Include="nunit" Version="3.10.1" />
<PackageReference Include="NUnit3TestAdapter" Version="3.10.0" />

Просмотреть файл

@ -1,14 +1,14 @@
using System;
using NUnit.Framework;
using System.Runtime.InteropServices;
using System.Diagnostics;
using System.Runtime.InteropServices;
using Microsoft.AzureKinect.Test.StubGenerator;
using NUnit.Framework;
namespace Tests
{
#pragma warning disable IDE1006 // Naming Styles
class TestNativeMethods
internal class TestNativeMethods
{
public enum k4a_result_t
{
@ -45,13 +45,13 @@ namespace Tests
public class Tests
{
readonly StubbedModule k4a;
private readonly StubbedModule k4a;
public Tests()
{
NativeInterface k4ainterface = NativeInterface.Create(
@"d:\git\Azure-Kinect-Sensor-SDK\build\bin\k4a.dll",
@"D:\git\Azure-Kinect-Sensor-SDK\include\k4a\k4a.h");
EnvironmentInfo.CalculateFileLocation(@"%K4A_BINARY_DIR%\bin\k4a.dll"),
EnvironmentInfo.CalculateFileLocation(@"%K4A_SOURCE_DIR%\include\k4a\k4a.h"));
k4a = StubbedModule.Create("k4a", k4ainterface);
}

Просмотреть файл

@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Text;
namespace Microsoft.AzureKinect.Test.StubGenerator
{
@ -22,20 +20,29 @@ namespace Microsoft.AzureKinect.Test.StubGenerator
/// <summary>
/// Create a CodeString with some C code
/// </summary>
/// <param name="code"></param>
/// <param name="code">The C code string to represent.</param>
public CodeString(string code)
{
AssignCode(code, 2);
AssignCode(code);
}
private string code = "";
// Performs the asignment and looks back frameDepth stack frames
// for the origin information
private void AssignCode(string code, int frameDepth)
/// <summary>
/// Performs the assignment of the code block and looks through the stack to find the origin information, filename and line number.
/// </summary>
/// <param name="code">The C code string to represent.</param>
private void AssignCode(string code)
{
int frameDepth = 0;
var trace = new System.Diagnostics.StackTrace(true);
var frame = trace.GetFrame(frameDepth);
while (frame.GetMethod().DeclaringType == typeof(CodeString))
{
frame = trace.GetFrame(++frameDepth);
}
SourceLineNumber = frame.GetFileLineNumber();
SourceFileName = frame.GetFileName();
@ -50,7 +57,7 @@ namespace Microsoft.AzureKinect.Test.StubGenerator
}
set
{
AssignCode(code, 2);
AssignCode(code);
}
}
@ -65,7 +72,7 @@ namespace Microsoft.AzureKinect.Test.StubGenerator
public static implicit operator CodeString(string s)
{
CodeString c = new CodeString();
c.AssignCode(s, 2);
c.AssignCode(s);
return c;
}

Просмотреть файл

@ -1,12 +1,11 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using System.Linq;
using System.IO;
using System.Text;
namespace Microsoft.AzureKinect.Test.StubGenerator
{
class Compiler
internal class Compiler
{
/// <summary>
/// Compiles a DLL
@ -26,7 +25,6 @@ namespace Microsoft.AzureKinect.Test.StubGenerator
options = options ?? CompilerOptions.GetDefault();
string moduleName = outputBinary;
// Set up compiler arguments
StringBuilder compilerArguments = new StringBuilder();
compilerArguments.Append(options.CompilerFlags);
@ -49,17 +47,18 @@ namespace Microsoft.AzureKinect.Test.StubGenerator
compilerArguments.Append($" \"{sourceFilePath}\"");
}
}
foreach (string includePath in options.IncludePaths)
foreach (DirectoryInfo includePath in options.IncludePaths)
{
compilerArguments.Append($" \"/I{includePath}\"");
compilerArguments.Append($" \"/I{includePath.FullName}\"");
}
// Linker options
compilerArguments.Append(" /link");
foreach (string libraryPath in options.LibraryPaths)
foreach (DirectoryInfo libraryPath in options.LibraryPaths)
{
compilerArguments.Append($" \"/LIBPATH:{libraryPath}\"");
compilerArguments.Append($" \"/LIBPATH:{libraryPath.FullName}\"");
}
compilerArguments.Append($" \"/OUT:{moduleName}\"");
if (impLib != null)
{
@ -78,10 +77,10 @@ namespace Microsoft.AzureKinect.Test.StubGenerator
}
// Start the compiler process
ProcessStartInfo startInfo = new ProcessStartInfo(options.CompilerPath)
ProcessStartInfo startInfo = new ProcessStartInfo(options.CompilerPath.FullName)
{
Arguments = compilerArguments.ToString(),
WorkingDirectory = options.TempPath,
WorkingDirectory = options.TempPath.FullName,
RedirectStandardOutput = true
};
@ -99,7 +98,8 @@ namespace Microsoft.AzureKinect.Test.StubGenerator
throw new Exception("Compilation failed: " + output);
}
}
} catch (System.ComponentModel.Win32Exception ex)
}
catch (System.ComponentModel.Win32Exception ex)
{
if ((uint)ex.ErrorCode == 0x80004005)
{

Просмотреть файл

@ -1,30 +1,20 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
namespace Microsoft.AzureKinect.Test.StubGenerator
{
public class CompilerOptions
{
public static CompilerOptions defaultOptions = new CompilerOptions();
public static CompilerOptions GetDefault()
private static CompilerOptions defaultOptions = new CompilerOptions();
public CompilerOptions()
{
return defaultOptions;
}
public static void SetDefault(CompilerOptions options)
this.CompilerPath = EnvironmentInfo.CalculateFileLocation(@"%CMAKE_CXX_COMPILER%");
this.LinkerPath = EnvironmentInfo.CalculateFileLocation(@"%CMAKE_LINKER%");
this.CompilerFlags = "/DWIN32 /D_WINDOWS /W3 /GR /EHa /Od /Zi";
this.Libraries = new string[]
{
defaultOptions = options;
}
//public string CompilerPath { get; set; } = @"C:/Program Files (x86)/Microsoft Visual Studio/Preview/Enterprise/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x64/cl.exe";
public string CompilerPath { get; set; } = @"cl.exe";
//public string LinkerPath { get; set; } = @"C:/Program Files (x86)/Microsoft Visual Studio/Preview/Enterprise/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x64/link.exe";
public string LinkerPath { get; set; } = @"link.exe";
public string CompilerFlags { get; set; } = "/DWIN32 /D_WINDOWS /W3 /GR /EHa /Od /Zi";
public string[] Libraries { get; set; } = new string[] {
"kernel32.lib",
"user32.lib",
"gdi32.lib",
@ -36,86 +26,104 @@ namespace Microsoft.AzureKinect.Test.StubGenerator
"comdlg32.lib",
"advapi32.lib"
};
/*
public string[] IncludePaths { get; set; } = new string[] {
@"D:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.20.27027\include",
@"D:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.20.27027\atlmfc\include",
@"D:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Auxiliary\VS\include",
@"C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\ucrt",
@"C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um",
@"C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\shared",
@"C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\winrt",
@"C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\cppwinrt",
@"C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\Include\um",
@"D:\git\Azure-Kinect-Sensor-SDK\include",
@"D:\git\Azure-Kinect-Sensor-SDK\build\src\sdk\include",
@"D:\git\Azure-Kinect-Sensor-SDK\src\csharp\K4aStub"
};
*/
public string[] IncludePaths { get; set; } = new string[] {
@"D:\git\Azure-Kinect-Sensor-SDK\include",
@"D:\git\Azure-Kinect-Sensor-SDK\build\src\sdk\include",
@"D:\git\Azure-Kinect-Sensor-SDK\src\csharp\K4aStub"
};
/*
public string[] LibraryPaths { get; set; } = new string[]
this.IncludePaths = new DirectoryInfo[]
{
@"D:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.20.27027\lib\x64",
@"D:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.20.27027\atlmfc\lib\x64",
@"D:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Auxiliary\VS\lib\x64",
@"C:\Program Files (x86)\Windows Kits\10\lib\10.0.17763.0\ucrt\x64",
@"C:\Program Files (x86)\Windows Kits\10\lib\10.0.17763.0\um\x64",
@"C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\lib\um\x64",
@"C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\Lib\um\x64",
EnvironmentInfo.CalculateDirectoryLocation(@"%K4A_SOURCE_DIR%\include"),
EnvironmentInfo.CalculateDirectoryLocation(@"%K4A_BINARY_DIR%\src\sdk\include"),
EnvironmentInfo.CalculateDirectoryLocation(@"%K4A_SOURCE_DIR%\src\csharp\K4aStub")
};
*/
public string[] LibraryPaths { get; set; } = new string[] { };
this.LibraryPaths = new DirectoryInfo[] { };
public string BinaryPath { get; set; } = @"C:\temp\binaries";
public string TempPath { get; set; } = @"C:\temp\compilation";
string baseTempPath = Path.Combine(Path.GetTempPath(), "AzureKinect");
this.BinaryPath = new DirectoryInfo(Path.Combine(baseTempPath, @"binaries"));
this.TempPath = new DirectoryInfo(Path.Combine(baseTempPath, @"compilation"));
this.StubFile = new FileInfo("Stub.cpp");
}
private CompilerOptions(CompilerOptions other)
{
this.BinaryPath = other.BinaryPath;
this.CompilerFlags = other.CompilerFlags;
this.CompilerPath = other.CompilerPath;
this.IncludePaths = other.IncludePaths;
this.Libraries = other.Libraries;
this.LibraryPaths = other.LibraryPaths;
this.LinkerPath = other.LinkerPath;
this.StubFile = other.StubFile;
this.TempPath = other.TempPath;
this.CodeHeader = other.CodeHeader;
}
public FileInfo CompilerPath { get; set; }
public FileInfo LinkerPath { get; set; }
public string CompilerFlags { get; set; }
public string[] Libraries { get; set; }
public DirectoryInfo[] IncludePaths { get; set; }
public DirectoryInfo[] LibraryPaths { get; set; }
public DirectoryInfo BinaryPath { get; set; }
public DirectoryInfo TempPath { get; set; }
public FileInfo StubFile { get; set; }
public string StubFile { get; set; } = "Stub.cpp";
public CodeString CodeHeader { get; set; } = @"
#define k4a_EXPORTS
#include ""k4a\k4a.h""
";
public static CompilerOptions GetDefault()
{
return defaultOptions;
}
public static void SetDefault(CompilerOptions options)
{
defaultOptions = options;
}
// Gets the hash of options that may impact the output of the compiled modules
public byte[] GetOptionsHash()
{
StringBuilder summaryString = new StringBuilder();
var md5 = System.Security.Cryptography.MD5.Create();
byte[] hash = md5.ComputeHash(System.Text.Encoding.Unicode.GetBytes(
CompilerPath + ";" +
CompilerFlags + ";" +
Libraries + ";" +
IncludePaths + ";" +
LibraryPaths
));
summaryString.AppendFormat("{0};", this.CompilerPath.FullName);
summaryString.AppendFormat("{0};", this.LinkerPath.FullName);
summaryString.AppendFormat("{0};", this.CompilerFlags);
foreach (string library in this.Libraries)
{
summaryString.AppendFormat("{0};", library);
}
foreach (DirectoryInfo directory in this.IncludePaths)
{
summaryString.AppendFormat("{0};", directory.FullName);
}
foreach (DirectoryInfo directory in this.LibraryPaths)
{
summaryString.AppendFormat("{0};", directory.FullName);
}
byte[] hash = md5.ComputeHash(Encoding.Unicode.GetBytes(summaryString.ToString()));
return hash;
}
public CompilerOptions Copy()
{
return new CompilerOptions()
{
BinaryPath = this.BinaryPath,
CompilerFlags = this.CompilerFlags,
CompilerPath = this.CompilerPath,
IncludePaths = this.IncludePaths,
Libraries = this.Libraries,
LibraryPaths = this.LibraryPaths,
LinkerPath = this.LinkerPath,
StubFile = this.StubFile,
TempPath = this.TempPath,
CodeHeader = this.CodeHeader
};
return new CompilerOptions(this);
}
}
}

Просмотреть файл

@ -0,0 +1,52 @@
using System;
using System.IO;
using System.Xml;
namespace Microsoft.AzureKinect.Test.StubGenerator
{
public static class EnvironmentInfo
{
private static object SyncRoot = new object();
private static bool IsInitialized = false;
public static void LoadEnvironment()
{
if (EnvironmentInfo.IsInitialized)
{
return;
}
lock (EnvironmentInfo.SyncRoot)
{
if (EnvironmentInfo.IsInitialized)
{
return;
}
XmlDocument appSettings = new XmlDocument();
appSettings.Load("appsettings.xml");
Environment.SetEnvironmentVariable("K4A_BINARY_DIR", appSettings.DocumentElement["K4A_BINARY_DIR"].InnerXml);
Environment.SetEnvironmentVariable("K4A_SOURCE_DIR", appSettings.DocumentElement["K4A_SOURCE_DIR"].InnerXml);
Environment.SetEnvironmentVariable("CMAKE_CXX_COMPILER", appSettings.DocumentElement["CMAKE_CXX_COMPILER"].InnerXml);
Environment.SetEnvironmentVariable("CMAKE_LINKER", appSettings.DocumentElement["CMAKE_LINKER"].InnerXml);
Environment.SetEnvironmentVariable("INCLUDE", appSettings.DocumentElement["INCLUDE"].InnerXml);
Environment.SetEnvironmentVariable("LIB", appSettings.DocumentElement["LIB"].InnerXml);
EnvironmentInfo.IsInitialized = true;
}
}
public static FileInfo CalculateFileLocation(string filename)
{
EnvironmentInfo.LoadEnvironment();
return new FileInfo(Environment.ExpandEnvironmentVariables(filename));
}
public static DirectoryInfo CalculateDirectoryLocation(string filename)
{
EnvironmentInfo.LoadEnvironment();
return new DirectoryInfo(Environment.ExpandEnvironmentVariables(filename));
}
}
}

Просмотреть файл

@ -1,18 +1,16 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
namespace Microsoft.AzureKinect.Test.StubGenerator
{
/// <summary>
/// Hashes an arbitrary object
/// Hashes an arbitrary object.
/// </summary>
class Hash
internal class Hash
{
/// <summary>
/// Serialize an object to XML and compute its hash
/// Serialize an object to XML and compute its hash.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="object"></param>
@ -32,6 +30,7 @@ namespace Microsoft.AzureKinect.Test.StubGenerator
var md5 = System.Security.Cryptography.MD5.Create();
return md5.ComputeHash(input);
}
private Hash(byte[] hash)
{
this.hash = hash;
@ -42,6 +41,11 @@ namespace Microsoft.AzureKinect.Test.StubGenerator
return new Hash(HashSerializedObject(@object));
}
public static Hash GetHash(CompilerOptions options)
{
return new Hash(options.GetOptionsHash());
}
public static Hash operator +(Hash left, Hash right)
{
return new Hash(HashBytes(left.hash.Concat(right.hash).ToArray()));

Просмотреть файл

@ -1,4 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\k4a.props" />
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
@ -15,5 +16,4 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

Просмотреть файл

@ -16,13 +16,13 @@ namespace Microsoft.AzureKinect.Test.StubGenerator
public static ModuleImplementation Compile(CodeString code, CompilerOptions options)
{
Hash hashCode = Hash.GetHash(code) + Hash.GetHash(options) + Hash.GetHash("version1");
string moduleName = System.IO.Path.Combine(options.BinaryPath, $"imp{hashCode}.dll");
string moduleName = System.IO.Path.Combine(options.BinaryPath.FullName, $"imp{hashCode}.dll");
if (!System.IO.File.Exists(moduleName))
{
// Produce the source code file
StringBuilder sourceFile = new StringBuilder();
string sourceFilePath = System.IO.Path.Combine(options.TempPath, $"imp{hashCode}.cpp");
string sourceFilePath = System.IO.Path.Combine(options.TempPath.FullName, $"imp{hashCode}.cpp");
CodeString prefix = @"
#include ""StubImplementation.h""
@ -35,7 +35,7 @@ namespace Microsoft.AzureKinect.Test.StubGenerator
filestream.WriteLine(sourceFile.ToString());
}
string stubImportLib = System.IO.Path.Combine(options.TempPath, "stubimport.lib");
string stubImportLib = System.IO.Path.Combine(options.TempPath.FullName, "stubimport.lib");
Compiler.CompileModule(new string[] { sourceFilePath }, moduleName, null, options, additionalLibraries: new string[] { stubImportLib });
}
@ -86,7 +86,7 @@ namespace Microsoft.AzureKinect.Test.StubGenerator
}
}
static void ModuleError(string file, int line, string expression)
private static void ModuleError(string file, int line, string expression)
{
throw new NativeFailureException(expression, file, line);
}
@ -127,7 +127,8 @@ namespace Microsoft.AzureKinect.Test.StubGenerator
}
}
~ModuleImplementation() {
~ModuleImplementation()
{
// Do not change this code. Put cleanup code in Dispose(bool disposing) above.
Dispose(false);
}

Просмотреть файл

@ -1,11 +1,10 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
namespace Microsoft.AzureKinect.Test.StubGenerator
{
class ModuleInfo
internal class ModuleInfo
{
private ModuleInfo(string[] exports)
{
@ -18,12 +17,22 @@ namespace Microsoft.AzureKinect.Test.StubGenerator
List<string> exports = new List<string>();
if (!System.IO.File.Exists(path))
{
throw new System.IO.FileNotFoundException("Failed to analyze module, file not found.", path);
}
if (!options.TempPath.Exists)
{
options.TempPath.Create();
}
var regex = new System.Text.RegularExpressions.Regex(@"^\s+\d+\s+[\dA-Fa-f]+\s+[0-9A-Fa-f]{8}\s+([^\s]*).*?$", System.Text.RegularExpressions.RegexOptions.Multiline);
// Start the compiler process
ProcessStartInfo startInfo = new ProcessStartInfo(options.LinkerPath)
ProcessStartInfo startInfo = new ProcessStartInfo(options.LinkerPath.FullName)
{
Arguments = $"/dump \"{path}\" /exports",
WorkingDirectory = options.TempPath,
WorkingDirectory = options.TempPath.FullName,
RedirectStandardOutput = true,
RedirectStandardError = true,
RedirectStandardInput = true
@ -54,8 +63,8 @@ namespace Microsoft.AzureKinect.Test.StubGenerator
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine("exception info");
System.Diagnostics.Debug.WriteLine(ex, "exception info");
throw new InvalidOperationException("Failed to analyze module", ex);
}
return new ModuleInfo(exports.ToArray());

Просмотреть файл

@ -1,21 +1,21 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Text.RegularExpressions;
namespace Microsoft.AzureKinect.Test.StubGenerator
{
public class NativeInterface
{
public NativeInterface(string modulePath, string headerPath, IReadOnlyList<FunctionInfo> functions)
public NativeInterface(FileInfo modulePath, FileInfo headerPath, IReadOnlyList<FunctionInfo> functions)
{
this.HeaderPath = headerPath;
this.ModulePath = modulePath;
this.Functions = functions;
}
public string HeaderPath { get; }
public string ModulePath { get; }
public FileInfo HeaderPath { get; }
public FileInfo ModulePath { get; }
public IReadOnlyList<FunctionInfo> Functions { get; }
/// <summary>
@ -23,12 +23,12 @@ namespace Microsoft.AzureKinect.Test.StubGenerator
/// </summary>
/// <param name="modulePath"></param>
/// <returns></returns>
public static NativeInterface Create(string modulePath, string headerPath)
public static NativeInterface Create(FileInfo modulePath, FileInfo headerPath)
{
List<FunctionInfo> functions = new List<FunctionInfo>();
// Get the exports from the module
ModuleInfo module = ModuleInfo.Analyze(modulePath);
ModuleInfo module = ModuleInfo.Analyze(modulePath.FullName);
List<string> exports = new List<string>(module.Exports);
//Regex functionRegex = new Regex(@"^\s*K4A_EXPORT\s+(?<return>\S+)\s+(?<function>[a-zA-Z0-9_]+)\s*\((?<arguments>[^\)]*)\)", RegexOptions.Multiline);
@ -49,9 +49,7 @@ namespace Microsoft.AzureKinect.Test.StubGenerator
Regex parameterRegex = new Regex(@"^\s*(?<type>.*?)(?<name>[a-zA-Z0-9_]+)\s*$");
using (var header = System.IO.File.OpenText(headerPath))
using (var header = File.OpenText(headerPath.FullName))
{
string headerData = header.ReadToEnd().Replace("\r\n", "\n");
@ -92,7 +90,7 @@ namespace Microsoft.AzureKinect.Test.StubGenerator
}
else
{
throw new Exception("Header declares a function not found in module exports");
throw new Exception($"Header declares a function not found in module exports. Function \"{info.Declaration}\" was not found in exports.");
}
}
}

Просмотреть файл

@ -1,27 +1,22 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Linq;
using System.Diagnostics;
using System.Text.RegularExpressions;
using System.Text;
namespace Microsoft.AzureKinect.Test.StubGenerator
{
public class StubbedModule
{
public CompilerOptions CompilerOptions { get; }
public string ModuleName { get; }
readonly Dictionary<string, FunctionImplementation> currentFunctionImplementations = new Dictionary<string, FunctionImplementation>();
readonly Dictionary<Hash, ModuleImplementation> implementedModules = new Dictionary<Hash, ModuleImplementation>();
private readonly Dictionary<string, FunctionImplementation> currentFunctionImplementations = new Dictionary<string, FunctionImplementation>();
private readonly Dictionary<Hash, ModuleImplementation> implementedModules = new Dictionary<Hash, ModuleImplementation>();
private void GenerateStub(string modulePath, NativeInterface @interface, CompilerOptions options)
{
// Generate the stub function definitions
CodeString stubCode = new CodeString(options.CodeHeader);
foreach (FunctionInfo def in @interface.Functions)
@ -42,9 +37,9 @@ namespace Microsoft.AzureKinect.Test.StubGenerator
}
string sourceFilePath = System.IO.Path.Combine(options.TempPath, "stubfunctions.cpp");
string sourceFilePath = Path.Combine(options.TempPath.FullName, "stubfunctions.cpp");
using (var filestream = System.IO.File.CreateText(sourceFilePath))
using (var filestream = File.CreateText(sourceFilePath))
{
filestream.WriteLine("#include \"stub.h\"");
filestream.WriteLine($"// Defined at {options.CodeHeader.SourceFileName} line {options.CodeHeader.SourceLineNumber}");
@ -54,11 +49,11 @@ namespace Microsoft.AzureKinect.Test.StubGenerator
}
System.IO.File.Copy("Stub.cpp", System.IO.Path.Combine(options.TempPath, "Stub.cpp"), true);
System.IO.File.Copy("Stub.h", System.IO.Path.Combine(options.TempPath, "Stub.h"), true);
System.IO.File.Copy("StubImplementation.h", System.IO.Path.Combine(options.TempPath, "StubImplementation.h"), true);
System.IO.File.Copy("Stub.cpp", Path.Combine(options.TempPath.FullName, "Stub.cpp"), true);
System.IO.File.Copy("Stub.h", Path.Combine(options.TempPath.FullName, "Stub.h"), true);
System.IO.File.Copy("StubImplementation.h", Path.Combine(options.TempPath.FullName, "StubImplementation.h"), true);
string stubImportLib = System.IO.Path.Combine(options.TempPath, "stubimport.lib");
string stubImportLib = Path.Combine(options.TempPath.FullName, "stubimport.lib");
CompilerOptions modifiedOptions = options.Copy();
modifiedOptions.CompilerFlags += " /DStubExport";
@ -107,29 +102,41 @@ namespace Microsoft.AzureKinect.Test.StubGenerator
this.CompilerOptions = options;
this.NativeInterface = @interface;
if (options.TempPath.Exists)
{
try
{
System.IO.Directory.Delete(options.TempPath);
} catch
{
options.TempPath.Delete(true);
options.TempPath.Refresh();
}
catch (Exception ex)
{
Console.WriteLine("Exception: {0}", ex);
}
}
System.IO.Directory.CreateDirectory(options.TempPath);
if (options.BinaryPath.Exists)
{
try
{
System.IO.Directory.Delete(options.BinaryPath);
options.BinaryPath.Delete(true);
options.BinaryPath.Refresh();
}
catch
catch (Exception ex)
{
Console.WriteLine("Exception: {0}", ex);
}
}
System.IO.Directory.CreateDirectory(options.BinaryPath);
string executingDirectory = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);
string modulePath = System.IO.Path.Combine(executingDirectory, moduleName + ".dll");
options.TempPath.Create();
options.TempPath.Refresh();
options.BinaryPath.Create();
options.BinaryPath.Refresh();
string executingDirectory = Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);
string modulePath = Path.Combine(executingDirectory, moduleName + ".dll");
GenerateStub(modulePath, @interface, options);
}
internal int GetTotalCallCount(string function)

Просмотреть файл

@ -1,13 +1,12 @@
using NUnit.Framework;
using Microsoft.AzureKinect.Test.StubGenerator;
using Microsoft.AzureKinect;
using Microsoft.AzureKinect.Test.StubGenerator;
using NUnit.Framework;
namespace Microsoft.AzureKinect.UnitTests
{
public class CalibrationFunctionTests
{
readonly StubbedModule NativeK4a;
private readonly StubbedModule NativeK4a;
public CalibrationFunctionTests()
{
@ -15,9 +14,8 @@ namespace Microsoft.AzureKinect.UnitTests
if (NativeK4a == null)
{
NativeInterface k4ainterface = NativeInterface.Create(
@"d:\git\Azure-Kinect-Sensor-SDK\build\bin\k4a.dll",
@"D:\git\Azure-Kinect-Sensor-SDK\include\k4a\k4a.h");
EnvironmentInfo.CalculateFileLocation(@"%K4A_BINARY_DIR%\bin\k4a.dll"),
EnvironmentInfo.CalculateFileLocation(@"%K4A_SOURCE_DIR%\include\k4a\k4a.h"));
NativeK4a = StubbedModule.Create("k4a", k4ainterface);
}

Просмотреть файл

@ -1,12 +1,11 @@
using NUnit.Framework;
using Microsoft.AzureKinect.Test.StubGenerator;
using Microsoft.AzureKinect;
using Microsoft.AzureKinect.Test.StubGenerator;
using NUnit.Framework;
namespace Microsoft.AzureKinect.UnitTests
{
public class CaptureFunctionTests
{
readonly StubbedModule NativeK4a;
private readonly StubbedModule NativeK4a;
public CaptureFunctionTests()
{
@ -14,9 +13,8 @@ namespace Microsoft.AzureKinect.UnitTests
if (NativeK4a == null)
{
NativeInterface k4ainterface = NativeInterface.Create(
@"d:\git\Azure-Kinect-Sensor-SDK\build\bin\k4a.dll",
@"D:\git\Azure-Kinect-Sensor-SDK\include\k4a\k4a.h");
EnvironmentInfo.CalculateFileLocation(@"%K4A_BINARY_DIR%\bin\k4a.dll"),
EnvironmentInfo.CalculateFileLocation(@"%K4A_SOURCE_DIR%\include\k4a\k4a.h"));
NativeK4a = StubbedModule.Create("k4a", k4ainterface);
}
@ -29,7 +27,7 @@ namespace Microsoft.AzureKinect.UnitTests
}
// Helper function to implement basic open/close behavior
void SetOpenCloseImplementation()
private void SetOpenCloseImplementation()
{
NativeK4a.SetImplementation(@"
@ -50,7 +48,7 @@ void k4a_device_close(k4a_device_t device_handle)
}}");
}
System.WeakReference CreateWithWeakReference<T>(System.Func<T> factory)
private System.WeakReference CreateWithWeakReference<T>(System.Func<T> factory)
{
return new System.WeakReference(factory());
}

Просмотреть файл

@ -1,11 +1,10 @@
using NUnit.Framework;
using Microsoft.AzureKinect.Test.StubGenerator;
using Microsoft.AzureKinect;
using NUnit.Framework;
namespace Microsoft.AzureKinect.UnitTests
{
/// <summary>
/// These tests vailidate the calling and marshalling behavior of the native functions in the C# wrapper
/// These tests validate the calling and marshaling behavior of the native functions in the C# wrapper
///
/// For any p/invoke function the tests should validate
/// a) Input parameters are appropriately passed through
@ -16,7 +15,7 @@ namespace Microsoft.AzureKinect.UnitTests
/// </summary>
public class DeviceFunctionTests
{
readonly StubbedModule NativeK4a;
private readonly StubbedModule NativeK4a;
public DeviceFunctionTests()
{
@ -24,9 +23,8 @@ namespace Microsoft.AzureKinect.UnitTests
if (NativeK4a == null)
{
NativeInterface k4ainterface = NativeInterface.Create(
@"d:\git\Azure-Kinect-Sensor-SDK\build\bin\k4a.dll",
@"D:\git\Azure-Kinect-Sensor-SDK\include\k4a\k4a.h");
EnvironmentInfo.CalculateFileLocation(@"%K4A_BINARY_DIR%\bin\k4a.dll"),
EnvironmentInfo.CalculateFileLocation(@"%K4A_SOURCE_DIR%\include\k4a\k4a.h"));
NativeK4a = StubbedModule.Create("k4a", k4ainterface);
}
@ -39,7 +37,7 @@ namespace Microsoft.AzureKinect.UnitTests
}
// Helper function to implement basic open/close behavior
void SetOpenCloseImplementation()
private void SetOpenCloseImplementation()
{
NativeK4a.SetImplementation(@"
@ -137,8 +135,7 @@ void k4a_device_close(k4a_device_t device_handle)
});
}
System.WeakReference CreateWithWeakReference<T>(System.Func<T> factory)
private System.WeakReference CreateWithWeakReference<T>(System.Func<T> factory)
{
return new System.WeakReference(factory());
}
@ -227,7 +224,8 @@ k4a_buffer_result_t k4a_device_get_serialnum(k4a_device_t device_handle,
device.Dispose();
Assert.Throws(typeof(System.ObjectDisposedException), () => {
Assert.Throws(typeof(System.ObjectDisposedException), () =>
{
_ = device.SerialNum;
});
@ -484,11 +482,11 @@ k4a_result_t k4a_device_get_calibration(k4a_device_t device_handle, k4a_depth_mo
for (int i = 0; i < 9; i++)
{
Assert.AreEqual((float)i * 1.2f, calibration.depth_camera_calibration.extrinsics.rotation[i]);
Assert.AreEqual(i * 1.2f, calibration.depth_camera_calibration.extrinsics.rotation[i]);
}
for (int i = 0; i < 3; i++)
{
Assert.AreEqual((float)i * 1.3f, calibration.depth_camera_calibration.extrinsics.translation[i]);
Assert.AreEqual(i * 1.3f, calibration.depth_camera_calibration.extrinsics.translation[i]);
}
Assert.AreEqual(81, calibration.depth_camera_calibration.intrinsics.parameter_count);
@ -496,7 +494,7 @@ k4a_result_t k4a_device_get_calibration(k4a_device_t device_handle, k4a_depth_mo
for (int i = 0; i < calibration.depth_camera_calibration.intrinsics.parameters.Length; i++)
{
Assert.AreEqual((float)i * 1.4f, calibration.depth_camera_calibration.intrinsics.parameters[i]);
Assert.AreEqual(i * 1.4f, calibration.depth_camera_calibration.intrinsics.parameters[i]);
}
Assert.AreEqual(91, calibration.depth_camera_calibration.resolution_width);
Assert.AreEqual(92, calibration.depth_camera_calibration.resolution_height);
@ -681,7 +679,8 @@ k4a_wait_result_t k4a_device_get_capture(k4a_device_t device_handle, k4a_capture
Assert.AreEqual(0, count.Calls("k4a_device_get_capture"));
Assert.AreEqual(0, count.Calls("k4a_capture_release"));
Assert.Throws(typeof(System.TimeoutException), () => {
Assert.Throws(typeof(System.TimeoutException), () =>
{
using (Capture capture = device.GetCapture(2345))
{
@ -732,7 +731,8 @@ k4a_wait_result_t k4a_device_get_capture(k4a_device_t device_handle, k4a_capture
Assert.AreEqual(0, count.Calls("k4a_device_get_capture"));
Assert.AreEqual(0, count.Calls("k4a_capture_release"));
Assert.Throws(typeof(Microsoft.AzureKinect.Exception), () => {
Assert.Throws(typeof(Microsoft.AzureKinect.Exception), () =>
{
using (Capture capture = device.GetCapture(2345))
{
@ -808,7 +808,8 @@ k4a_result_t k4a_device_set_color_control(k4a_device_t device_handle, k4a_color_
device.Dispose();
Assert.Throws(typeof(System.ObjectDisposedException), () => {
Assert.Throws(typeof(System.ObjectDisposedException), () =>
{
device.SetColorControl(ColorControlCommand.PowerlineFrequency, ColorControlMode.Manual, 2345);
});
}
@ -837,7 +838,8 @@ k4a_result_t k4a_device_set_color_control(k4a_device_t device_handle, k4a_color_
using (Device device = Device.Open(0))
{
Assert.AreEqual(0, count.Calls("k4a_device_set_color_control"));
Assert.Throws(typeof(Microsoft.AzureKinect.Exception), () => {
Assert.Throws(typeof(Microsoft.AzureKinect.Exception), () =>
{
device.SetColorControl(ColorControlCommand.PowerlineFrequency, ColorControlMode.Manual, 2345);
});
Assert.AreEqual(1, count.Calls("k4a_device_set_color_control"));
@ -918,7 +920,8 @@ k4a_result_t k4a_device_get_color_control(k4a_device_t device_handle, k4a_color_
using (Device device = Device.Open(0))
{
Assert.AreEqual(0, count.Calls("k4a_device_get_color_control"));
Assert.Throws(typeof(Microsoft.AzureKinect.Exception), () => {
Assert.Throws(typeof(Microsoft.AzureKinect.Exception), () =>
{
device.GetColorControl(ColorControlCommand.PowerlineFrequency, out ColorControlMode mode);
});
Assert.AreEqual(1, count.Calls("k4a_device_get_color_control"));
@ -1010,7 +1013,8 @@ k4a_wait_result_t k4a_device_get_imu_sample(k4a_device_t device_handle, k4a_imu_
{
Assert.AreEqual(0, count.Calls("k4a_device_get_imu_sample"));
Assert.Throws(typeof(System.TimeoutException), () => {
Assert.Throws(typeof(System.TimeoutException), () =>
{
ImuSample sample = device.GetImuSample(2345);
});
@ -1040,7 +1044,8 @@ k4a_wait_result_t k4a_device_get_imu_sample(k4a_device_t device_handle, k4a_imu_
{
Assert.AreEqual(0, count.Calls("k4a_device_get_imu_sample"));
Assert.Throws(typeof(Microsoft.AzureKinect.Exception), () => {
Assert.Throws(typeof(Microsoft.AzureKinect.Exception), () =>
{
ImuSample sample = device.GetImuSample(2345);
});
@ -1152,11 +1157,13 @@ k4a_result_t k4a_device_get_sync_jack(
using (Device device = Device.Open(0))
{
Assert.Throws(typeof(Microsoft.AzureKinect.Exception), () => {
Assert.Throws(typeof(Microsoft.AzureKinect.Exception), () =>
{
bool instate = device.SyncInJackConnected;
});
Assert.Throws(typeof(Microsoft.AzureKinect.Exception), () => {
Assert.Throws(typeof(Microsoft.AzureKinect.Exception), () =>
{
bool instate = device.SyncOutJackConnected;
});
}
@ -1255,7 +1262,8 @@ k4a_result_t k4a_device_get_version(
");
{
CallCount count = NativeK4a.CountCalls();
Assert.Throws(typeof(Microsoft.AzureKinect.Exception), () => {
Assert.Throws(typeof(Microsoft.AzureKinect.Exception), () =>
{
using (Device device = Device.Open(0))
{
HardwareVersion version = device.Version;
@ -1437,7 +1445,8 @@ k4a_result_t k4a_device_start_imu(
CallCount count = NativeK4a.CountCalls();
using (Device device = Device.Open(0))
{
Assert.Throws(typeof(Microsoft.AzureKinect.Exception), () => {
Assert.Throws(typeof(Microsoft.AzureKinect.Exception), () =>
{
device.StartImu();
});

Просмотреть файл

@ -1,11 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\k4a.props" />
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<IsPackable>false</IsPackable>
<Platforms>x64;x86</Platforms>
<OutputPath>$(BaseOutputPath)$(AssemblyName)\</OutputPath>
</PropertyGroup>
<ItemGroup>
<Content Include="..\StubGenerator.$(Platform).xml">
<Link>appsettings.xml</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<PackageReference Include="nunit" Version="3.10.1" />
<PackageReference Include="NUnit3TestAdapter" Version="3.10.0" />

Просмотреть файл

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\k4a.props" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@ -17,18 +18,18 @@
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<OutputPath>bin\Debug\</OutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<OutputPath>bin\Release\</OutputPath>
</PropertyGroup>
<ItemGroup>
<Reference Include="PresentationCore" />

Просмотреть файл

@ -1,12 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\k4a.props" />
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<PropertyGroup>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DocumentationFile>D:\git\Azure-Kinect-Sensor-SDK\src\csharp\Microsoft.AzureKinect\Microsoft.AzureKinect.xml</DocumentationFile>
<DocumentationFile>Microsoft.AzureKinect.xml</DocumentationFile>
</PropertyGroup>
</Project>

Просмотреть файл

@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.Text;
using Microsoft.AzureKinect.Native;
namespace Microsoft.AzureKinect
@ -185,7 +184,7 @@ namespace Microsoft.AzureKinect
#region Functions
[DllImport("k4a")]
[DllImport("k4a", CallingConvention = CallingConvention.Cdecl)]
[NativeReference]
public static extern k4a_result_t k4a_calibration_2d_to_2d(
Calibration calibration,
@ -196,7 +195,7 @@ namespace Microsoft.AzureKinect
out Float2 target_point2d,
out bool valid);
[DllImport("k4a")]
[DllImport("k4a", CallingConvention = CallingConvention.Cdecl)]
[NativeReference]
public static extern k4a_result_t k4a_calibration_2d_to_3d(
Calibration calibration,
@ -207,7 +206,7 @@ namespace Microsoft.AzureKinect
out Float3 target_point3d,
out bool valid);
[DllImport("k4a")]
[DllImport("k4a", CallingConvention = CallingConvention.Cdecl)]
[NativeReference]
public static extern k4a_result_t k4a_calibration_3d_to_2d(
Calibration calibration,
@ -217,7 +216,7 @@ namespace Microsoft.AzureKinect
out Float2 target_point2d,
out bool valid);
[DllImport("k4a")]
[DllImport("k4a", CallingConvention = CallingConvention.Cdecl)]
[NativeReference]
public static extern k4a_result_t k4a_calibration_3d_to_3d(
Calibration calibration,
@ -227,7 +226,7 @@ namespace Microsoft.AzureKinect
out Float3 target_point3d,
out bool valid);
[DllImport("k4a")]
[DllImport("k4a", CallingConvention = CallingConvention.Cdecl)]
[NativeReference]
public static extern k4a_result_t k4a_calibration_get_from_raw(
byte[] raw_calibration,
@ -236,23 +235,23 @@ namespace Microsoft.AzureKinect
ColorResolution color_resolution,
out Calibration calibration);
[DllImport("k4a")]
[DllImport("k4a", CallingConvention = CallingConvention.Cdecl)]
[NativeReference]
public static extern k4a_transformation_t k4a_transformation_create(Calibration calibration);
[DllImport("k4a")]
[DllImport("k4a", CallingConvention = CallingConvention.Cdecl)]
[NativeReference]
public static extern k4a_result_t k4a_transformation_destroy(IntPtr transformation_handle);
[DllImport("k4a")]
[DllImport("k4a", CallingConvention = CallingConvention.Cdecl)]
[NativeReference]
public static extern k4a_result_t k4a_transformation_depth_image_to_color_camera(
k4a_transformation_t transformation_handle,
k4a_image_t depth_image,
k4a_image_t transformed_depth_image);
[DllImport("k4a")]
[DllImport("k4a", CallingConvention = CallingConvention.Cdecl)]
[NativeReference]
public static extern k4a_result_t k4a_transformation_color_image_to_depth_camera(
k4a_transformation_t transformation_handle,
@ -260,7 +259,7 @@ namespace Microsoft.AzureKinect
k4a_image_t color_image,
k4a_image_t transformed_color_image);
[DllImport("k4a")]
[DllImport("k4a", CallingConvention = CallingConvention.Cdecl)]
[NativeReference]
public static extern k4a_result_t k4a_transformation_depth_image_to_point_cloud(
k4a_transformation_t transformation_handle,
@ -268,58 +267,58 @@ namespace Microsoft.AzureKinect
Calibration.DeviceType camera,
k4a_image_t xyz_image);
[DllImport("k4a")]
[DllImport("k4a", CallingConvention = CallingConvention.Cdecl)]
[NativeReference]
public static extern void k4a_device_close(IntPtr device_handle);
[DllImport("k4a")]
[DllImport("k4a", CallingConvention = CallingConvention.Cdecl)]
[NativeReference]
public static extern k4a_result_t k4a_capture_create(out k4a_capture_t capture_handle);
[DllImport("k4a")]
[DllImport("k4a", CallingConvention = CallingConvention.Cdecl)]
[NativeReference]
public static extern k4a_image_t k4a_capture_get_color_image(k4a_capture_t capture_handle);
[DllImport("k4a")]
[DllImport("k4a", CallingConvention = CallingConvention.Cdecl)]
[NativeReference]
public static extern k4a_image_t k4a_capture_get_depth_image(k4a_capture_t capture_handle);
[DllImport("k4a")]
[DllImport("k4a", CallingConvention = CallingConvention.Cdecl)]
[NativeReference]
public static extern k4a_image_t k4a_capture_get_ir_image(k4a_capture_t capture_handle);
[DllImport("k4a")]
[DllImport("k4a", CallingConvention = CallingConvention.Cdecl)]
[NativeReference]
public static extern float k4a_capture_get_temperature_c(k4a_capture_t capture_handle);
[DllImport("k4a")]
[DllImport("k4a", CallingConvention = CallingConvention.Cdecl)]
[NativeReference]
public static extern void k4a_capture_set_color_image(k4a_capture_t capture_handle, k4a_image_t image_handle);
[DllImport("k4a")]
[DllImport("k4a", CallingConvention = CallingConvention.Cdecl)]
[NativeReference]
public static extern void k4a_capture_set_depth_image(k4a_capture_t capture_handle, k4a_image_t image_handle);
[DllImport("k4a")]
[DllImport("k4a", CallingConvention = CallingConvention.Cdecl)]
[NativeReference]
public static extern void k4a_capture_set_ir_image(k4a_capture_t capture_handle, k4a_image_t image_handle);
[DllImport("k4a")]
[DllImport("k4a", CallingConvention = CallingConvention.Cdecl)]
[NativeReference]
public static extern void k4a_capture_set_temperature_c(k4a_capture_t capture_handle, float temperature_c);
[DllImport("k4a")]
[DllImport("k4a", CallingConvention = CallingConvention.Cdecl)]
[NativeReference]
public static extern void k4a_capture_reference(IntPtr capture_handle);
[DllImport("k4a")]
[DllImport("k4a", CallingConvention = CallingConvention.Cdecl)]
[NativeReference]
public static extern void k4a_capture_release(IntPtr capture_handle);
[DllImport("k4a")]
[DllImport("k4a", CallingConvention = CallingConvention.Cdecl)]
[NativeReference]
public static extern k4a_result_t k4a_image_create(ImageFormat format,
int width_pixels,
@ -329,7 +328,7 @@ namespace Microsoft.AzureKinect
public delegate void k4a_memory_destroy_cb_t(IntPtr buffer, IntPtr context);
[DllImport("k4a")]
[DllImport("k4a", CallingConvention = CallingConvention.Cdecl)]
[NativeReference]
public static extern k4a_result_t k4a_image_create_from_buffer(
ImageFormat format,
@ -343,19 +342,19 @@ namespace Microsoft.AzureKinect
out k4a_image_t image_handle
);
[DllImport("k4a")]
[DllImport("k4a", CallingConvention = CallingConvention.Cdecl)]
[NativeReference]
public static extern void k4a_image_reference(IntPtr image_handle);
[DllImport("k4a")]
[DllImport("k4a", CallingConvention = CallingConvention.Cdecl)]
[NativeReference]
public static extern void k4a_image_release(IntPtr image_handle);
[DllImport("k4a")]
[DllImport("k4a", CallingConvention = CallingConvention.Cdecl)]
[NativeReference]
public static extern UInt32 k4a_device_get_installed_count();
[DllImport("k4a")]
[DllImport("k4a", CallingConvention = CallingConvention.Cdecl)]
[NativeReference]
public static extern k4a_result_t k4a_device_get_calibration(
k4a_device_t device_handle,
@ -364,128 +363,128 @@ namespace Microsoft.AzureKinect
out Calibration calibration);
[DllImport("k4a")]
[DllImport("k4a", CallingConvention = CallingConvention.Cdecl)]
[NativeReference]
public static extern k4a_wait_result_t k4a_device_get_capture(
k4a_device_t device_handle,
out k4a_capture_t capture_handle,
Int32 timeout_in_ms);
[DllImport("k4a")]
[DllImport("k4a", CallingConvention = CallingConvention.Cdecl)]
[NativeReference]
public static extern k4a_wait_result_t k4a_device_get_imu_sample(
k4a_device_t device_handle,
out ImuSample imu_sample,
Int32 timeout_in_ms);
[DllImport("k4a")]
[DllImport("k4a", CallingConvention = CallingConvention.Cdecl)]
[NativeReference]
public static extern k4a_result_t k4a_device_get_sync_jack(
k4a_device_t device_handle,
out bool sync_in_jack_connected,
out bool sync_out_jack_connected);
[DllImport("k4a")]
[DllImport("k4a", CallingConvention = CallingConvention.Cdecl)]
[NativeReference]
public static extern k4a_result_t k4a_device_get_version(
k4a_device_t device_handle,
out k4a_hardware_version_t version);
[DllImport("k4a")]
[DllImport("k4a", CallingConvention = CallingConvention.Cdecl)]
[NativeReference]
public static extern k4a_buffer_result_t k4a_device_get_raw_calibration(k4a_device_t device_handle, [Out] byte[] data, ref UIntPtr data_size);
[DllImport("k4a")]
[DllImport("k4a", CallingConvention = CallingConvention.Cdecl)]
[NativeReference]
public static extern k4a_result_t k4a_device_set_color_control(k4a_device_t device_handle, ColorControlCommand command, ColorControlMode mode, Int32 value);
[DllImport("k4a")]
[DllImport("k4a", CallingConvention = CallingConvention.Cdecl)]
[NativeReference]
public static extern k4a_result_t k4a_device_get_color_control(k4a_device_t device_handle, ColorControlCommand command, out ColorControlMode mode, out Int32 value);
[DllImport("k4a")]
[DllImport("k4a", CallingConvention = CallingConvention.Cdecl)]
[NativeReference]
public static extern k4a_result_t k4a_device_start_cameras(k4a_device_t device_handle, k4a_device_configuration_t config);
[DllImport("k4a")]
[DllImport("k4a", CallingConvention = CallingConvention.Cdecl)]
[NativeReference]
public static extern void k4a_device_stop_cameras(k4a_device_t device_handle);
[DllImport("k4a")]
[DllImport("k4a", CallingConvention = CallingConvention.Cdecl)]
[NativeReference]
public static extern k4a_result_t k4a_device_start_imu(k4a_device_t device_handle);
[DllImport("k4a")]
[DllImport("k4a", CallingConvention = CallingConvention.Cdecl)]
[NativeReference]
public static extern void k4a_device_stop_imu(k4a_device_t device_handle);
[DllImport("k4a")]
[DllImport("k4a", CallingConvention = CallingConvention.Cdecl)]
[NativeReference]
public static extern k4a_result_t k4a_device_open(UInt32 index, out k4a_device_t device_handle);
[DllImport("k4a")]
[DllImport("k4a", CallingConvention = CallingConvention.Cdecl)]
[NativeReference]
public static extern k4a_buffer_result_t k4a_device_get_serialnum(k4a_device_t device_handle, StringBuilder serial_number, ref UIntPtr data_size);
[DllImport("k4a")]
[DllImport("k4a", CallingConvention = CallingConvention.Cdecl)]
[NativeReference]
public static extern UInt64 k4a_image_get_exposure_usec(k4a_image_t image_handle);
[DllImport("k4a")]
[DllImport("k4a", CallingConvention = CallingConvention.Cdecl)]
[NativeReference]
public static extern void k4a_image_set_exposure_time_usec(k4a_image_t image_handle, UInt64 value);
[DllImport("k4a")]
[DllImport("k4a", CallingConvention = CallingConvention.Cdecl)]
[NativeReference]
public static extern ImageFormat k4a_image_get_format(k4a_image_t image_handle);
[DllImport("k4a")]
[DllImport("k4a", CallingConvention = CallingConvention.Cdecl)]
[NativeReference]
public static extern int k4a_image_get_height_pixels(k4a_image_t image_handle);
[DllImport("k4a")]
[DllImport("k4a", CallingConvention = CallingConvention.Cdecl)]
[NativeReference]
public static extern int k4a_image_get_width_pixels(k4a_image_t image_handle);
[DllImport("k4a")]
[DllImport("k4a", CallingConvention = CallingConvention.Cdecl)]
[NativeReference]
public static extern int k4a_image_get_stride_bytes(k4a_image_t image_handle);
[DllImport("k4a")]
[DllImport("k4a", CallingConvention = CallingConvention.Cdecl)]
[NativeReference]
public static extern UIntPtr k4a_image_get_size(k4a_image_t image_handle);
[DllImport("k4a")]
[DllImport("k4a", CallingConvention = CallingConvention.Cdecl)]
[NativeReference]
public static extern UInt32 k4a_image_get_iso_speed(k4a_image_t image_handle);
[DllImport("k4a")]
[DllImport("k4a", CallingConvention = CallingConvention.Cdecl)]
[NativeReference]
public static extern void k4a_image_set_iso_speed(k4a_image_t image_handle, UInt32 value);
[DllImport("k4a")]
[DllImport("k4a", CallingConvention = CallingConvention.Cdecl)]
[NativeReference]
public static extern UInt32 k4a_image_get_white_balance(k4a_image_t image_handle);
[DllImport("k4a")]
[DllImport("k4a", CallingConvention = CallingConvention.Cdecl)]
[NativeReference]
public static extern void k4a_image_set_white_balance(k4a_image_t image_handle, UInt32 value);
[DllImport("k4a")]
[DllImport("k4a", CallingConvention = CallingConvention.Cdecl)]
[NativeReference]
public static extern UInt64 k4a_image_get_timestamp_usec(k4a_image_t image_handle);
[DllImport("k4a")]
[DllImport("k4a", CallingConvention = CallingConvention.Cdecl)]
[NativeReference]
public static extern void k4a_image_set_timestamp_usec(k4a_image_t image_handle, UInt64 value);
[DllImport("k4a")]
[DllImport("k4a", CallingConvention = CallingConvention.Cdecl)]
[NativeReference]
public static extern IntPtr k4a_image_get_buffer(k4a_image_t image_handle);

Просмотреть файл

@ -1,10 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\k4a.props" />
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
<Platforms>x64;x86</Platforms>
<OutputPath>$(BaseOutputPath)$(AssemblyName)\</OutputPath>
</PropertyGroup>
<ItemGroup>
<Content Include="..\StubGenerator.$(Platform).xml">
<Link>appsettings.xml</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Microsoft.AzureKinect.Test.StubGenerator\Microsoft.AzureKinect.Test.StubGenerator.csproj" />
</ItemGroup>

Просмотреть файл

@ -1,21 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\k4a.props" />
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<IsPackable>false</IsPackable>
<Platforms>AnyCPU;x64</Platforms>
<Platforms>x64;x86</Platforms>
<OutputPath>$(BaseOutputPath)$(AssemblyName)\</OutputPath>
</PropertyGroup>
<ItemGroup>
<None Include="..\..\..\build\bin\k4a.dll" Link="k4a.dll">
<None Include="$(K4aBinaryDirectory)\bin\k4a.dll" Link="k4a.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\..\..\build\bin\k4a.pdb" Link="k4a.pdb">
<None Include="$(K4aBinaryDirectory)\bin\k4a.pdb" Link="k4a.pdb">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\..\..\build\bin\libusb-1.0.dll" Link="libusb-1.0.dll">
<None Include="$(K4aBinaryDirectory)\bin\libusb-1.0.dll" Link="libusb-1.0.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

16
src/csharp/k4a.props Normal file
Просмотреть файл

@ -0,0 +1,16 @@
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildThisFileDirectory)k4a.$(Platform).props" Condition="Exists('$(MSBuildThisFileDirectory)k4a.$(Platform).props')" />
<Target Name="VerifyCMakeDependencies" BeforeTargets="Build" Condition="'$(Platform)' != 'AnyCPU'">
<Error Condition="!Exists('$(MSBuildThisFileDirectory)k4a.$(Platform).props')" Text="$(Platform) version of the Azure Kinect properties file was not found. Please run CMake configure."/>
</Target>
<PropertyGroup Condition="'$(Platform)' != 'AnyCPU'">
<BaseOutputPath Condition="'$(BaseOutputPath)' == ''">$(K4aBinaryDirectory)\bin\$(Configuration)\$(Platform)\</BaseOutputPath>
<!-- According to "EnableBaseIntermediateOutputPathMismatchWarning" there will be a warning if $(BaseIntermediateOutputPath) is not the same as $(MSBuildProjectExtensionsPath).
Not changing the IntermediateOutputPath until we have a better understanding of where we want files.
<BaseIntermediateOutputPath>$(K4aBinaryDirectory)\obj\</BaseIntermediateOutputPath>
<IntermediateOutputPath>$(BaseIntermediateOutputPath)\$(Configuration)\$(Platform)\$(AssemblyName)\</IntermediateOutputPath>-->
</PropertyGroup>
</Project>