Skip to content

Commit

Permalink
C# Build Integration (microsoft#316)
Browse files Browse the repository at this point in the history
* Adding the C# build to the Azure Pipeline.
* Standardizing names of projects and aligning project and folder names.
* Removing the C# unit test's runtime dependency on the Binary folder.
  • Loading branch information
Derek M authored May 3, 2019
1 parent a4b7f05 commit 5f56c1e
Show file tree
Hide file tree
Showing 30 changed files with 258 additions and 124 deletions.
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,14 @@ set(TARGET_ARCH ${CMAKE_SYSTEM_PROCESSOR})

# CMake doesn't set the target processor correctly for MSVC
if ("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC")
if ("${CMAKE_CONFIGURATION_TYPES}" STREQUAL "")
set(K4A_BINARY_DIR_DEBUG ${PROJECT_BINARY_DIR}/bin)
set(K4A_BINARY_DIR_RELEASE ${PROJECT_BINARY_DIR}/bin)
else()
set(K4A_BINARY_DIR_DEBUG ${PROJECT_BINARY_DIR}/bin/Debug)
set(K4A_BINARY_DIR_RELEASE ${PROJECT_BINARY_DIR}/bin/RelWithDebInfo)
endif()

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)
Expand Down
2 changes: 0 additions & 2 deletions StubGenerator.xml.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<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>
Expand Down
110 changes: 108 additions & 2 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,83 +30,115 @@ jobs:
CMakeArch: 'amd64'
BuildGenerator: 'Ninja'
CMakeConfiguration: 'debug'
MSBuildPlatform: 'x64'
MSBuildConfiguration: 'Debug'
vmImage: 'vs2017-win2016'
VS2017_x64-msvc_rel_ninja:
CMakeArch: 'amd64'
BuildGenerator: 'Ninja'
CMakeConfiguration: 'relwithdebinfo'
MSBuildPlatform: 'x64'
MSBuildConfiguration: 'Release'
vmImage: 'vs2017-win2016'
VS2017_x64-msvc_debug_msbuild:
CMakeArch: 'amd64'
BuildGenerator: 'Visual Studio 15 2017 Win64'
CMakeConfiguration: 'debug'
MSBuildPlatform: 'x64'
MSBuildConfiguration: 'Debug'
vmImage: 'vs2017-win2016'
VS2017_x64-msvc_rel_msbuild:
CMakeArch: 'amd64'
BuildGenerator: 'Visual Studio 15 2017 Win64'
CMakeConfiguration: 'relwithdebinfo'
MSBuildPlatform: 'x64'
MSBuildConfiguration: 'Release'
vmImage: 'vs2017-win2016'
VS2017_x86-msvc_debug_ninja:
CMakeArch: 'x86'
BuildGenerator: 'Ninja'
CMakeConfiguration: 'debug'
MSBuildPlatform: 'x86'
MSBuildConfiguration: 'Debug'
vmImage: 'vs2017-win2016'
VS2017_x86-msvc_rel_ninja:
CMakeArch: 'x86'
BuildGenerator: 'Ninja'
CMakeConfiguration: 'relwithdebinfo'
MSBuildPlatform: 'x86'
MSBuildConfiguration: 'Release'
vmImage: 'vs2017-win2016'
VS2017_x86-msvc_debug_msbuild:
CMakeArch: 'x86'
BuildGenerator: 'Visual Studio 15 2017'
CMakeConfiguration: 'debug'
MSBuildPlatform: 'x86'
MSBuildConfiguration: 'Debug'
vmImage: 'vs2017-win2016'
VS2017_x86-msvc_rel_msbuild:
CMakeArch: 'x86'
BuildGenerator: 'Visual Studio 15 2017'
CMakeConfiguration: 'relwithdebinfo'
MSBuildPlatform: 'x86'
MSBuildConfiguration: 'Release'
vmImage: 'vs2017-win2016'
VS2019_x64-msvc_debug_ninja:
CMakeArch: 'amd64'
BuildGenerator: 'Ninja'
CMakeConfiguration: 'debug'
MSBuildPlatform: 'x64'
MSBuildConfiguration: 'Debug'
vmImage: 'windows-2019'
VS2019_x64-msvc_rel_ninja:
CMakeArch: 'amd64'
BuildGenerator: 'Ninja'
CMakeConfiguration: 'relwithdebinfo'
MSBuildPlatform: 'x64'
MSBuildConfiguration: 'Release'
vmImage: 'windows-2019'
# VS2019 msbuild generators blocked by issue Microsoft/azure-pipelines-image-generation#754
# VS2019_x86_64-pc-windows-msvc_debug_msbuild:
# CMakeArch: 'amd64'
# BuildGenerator: 'Visual Studio 16 2019'
# CMakeConfiguration: 'debug'
# MSBuildPlatform: 'x64'
# MSBuildConfiguration: 'Debug'
# vmImage: 'windows-2019'
# VS2019_x86_64-pc-windows-msvc_relwithdebinfo_msbuild:
# CMakeArch: 'amd64'
# BuildGenerator: 'Visual Studio 16 2019'
# CMakeConfiguration: 'relwithdebinfo'
# MSBuildPlatform: 'x64'
# MSBuildConfiguration: 'Release'
# vmImage: 'windows-2019'
VS2019_x86-msvc_debug_ninja:
CMakeArch: 'x86'
BuildGenerator: 'Ninja'
CMakeConfiguration: 'debug'
MSBuildPlatform: 'x86'
MSBuildConfiguration: 'Debug'
vmImage: 'windows-2019'
VS2019_x86-msvc_rel_ninja:
CMakeArch: 'x86'
BuildGenerator: 'Ninja'
CMakeConfiguration: 'relwithdebinfo'
MSBuildPlatform: 'x86'
MSBuildConfiguration: 'Release'
vmImage: 'windows-2019'
# VS2019 msbuild generators blocked by issue Microsoft/azure-pipelines-image-generation#754
# VS2019_x86-pc-windows-msvc_debug_msbuild:
# CMakeArch: 'x86'
# BuildGenerator: 'Visual Studio 16 2019'
# CMakeConfiguration: 'debug'
# MSBuildPlatform: 'x86'
# MSBuildConfiguration: 'Debug'
# vmImage: 'windows-2019'
# VS2019_x86-pc-windows-msvc_relwithdebinfo_msbuild:
# CMakeArch: 'x86'
# BuildGenerator: 'Visual Studio 16 2019'
# CMakeConfiguration: 'relwithdebinfo'
# MSBuildPlatform: 'x86'
# MSBuildConfiguration: 'Release'
# vmImage: 'windows-2019'
pool:
vmImage: $(vmImage)
Expand Down Expand Up @@ -233,6 +265,68 @@ jobs:
testRunTitle: 'Unit Tests'
condition: succeededOrFailed()

# Create a placeholder version of the depth engine to satisfy MSBuild copy rules.
# This version is not needed for actual execution.
# In the future we should fetch the real version from a valid source.
- powershell: |
if ("$(BuildGenerator)" -eq "Ninja")
{
IF(-Not (Test-Path "$(Build.BinariesDirectory)\bin\depthengine_1_0.dll")) { Add-Content "$(Build.BinariesDirectory)\bin\depthengine_1_0.dll" "Placeholder file, please download real depth engine." }
}
elseif ("$(BuildGenerator)" -like "Visual Studio *")
{
IF(-Not (Test-Path "$(Build.BinariesDirectory)\bin\$(CMakeConfiguration)\depthengine_1_0.dll")) { Add-Content "$(Build.BinariesDirectory)\bin\$(CMakeConfiguration)\depthengine_1_0.dll" "Placeholder file, please download real depth engine." }
}
else
{
Write-Error "Unknown Generator <<$(BuildGenerator)>>"
}
displayName: 'Create placeholder depth engine'
- task: NuGetToolInstaller@0
inputs:
versionSpec: '>=4.3.1'

- task: 333b11bd-d341-40d9-afcf-b32d5ce6f23b@2 # NuGetCommand@2
inputs:
command: 'restore'
solution: '$(Build.SourcesDirectory)\src\csharp\K4a.sln'

- task: VSBuild@1
displayName: 'Build C# Wrappers'
inputs:
solution: '$(Build.SourcesDirectory)\src\csharp\K4a.sln'
msbuildArgs: '/p:BaseOutputPath="$(Build.BinariesDirectory)\$(MSBuildConfiguration)\\"'
platform: '$(MSBuildPlatform)'
configuration: '$(MSBuildConfiguration)'

- task: VSTest@2
displayName: 'Run C# Unit Tests'
inputs:
testSelector: 'testAssemblies'
searchFolder: '$(Build.BinariesDirectory)'
platform: '$(MSBuildPlatform)'
configuration: '$(MSBuildConfiguration)'
testAssemblyVer2: |
**/*UnitTests.dll
!**/obj/**
# Clean up any placeholder version of the depth engine that were created.
- powershell: |
if ("$(BuildGenerator)" -eq "Ninja")
{
IF(Test-Path "$(Build.BinariesDirectory)\bin\depthengine_1_0.dll") { Remove-Item "$(Build.BinariesDirectory)\bin\depthengine_1_0.dll" }
}
elseif ("$(BuildGenerator)" -like "Visual Studio *")
{
IF(Test-Path "$(Build.BinariesDirectory)\bin\$(CMakeConfiguration)\depthengine_1_0.dll") { Remove-Item "$(Build.BinariesDirectory)\bin\$(CMakeConfiguration)\depthengine_1_0.dll" }
}
else
{
Write-Error "Unknown Generator <<$(BuildGenerator)>>"
}
displayName: 'Clean up temp depth engine'
- task: CopyFiles@2
displayName: 'Copy build folder to Staging'
inputs:
Expand Down Expand Up @@ -472,6 +566,8 @@ jobs:
- Agent.OS -equals Windows_NT

steps:
- task: VisualStudioTestPlatformInstaller@1

- checkout: self
clean: true
lfs: false
Expand All @@ -497,7 +593,6 @@ jobs:
Invoke-WebRequest -uri "$(ResourceBaseUrl)/firmware/AzureKinectDK_Fw_$(firmware_version).bin$(ResourceToken)" -OutFile "$(System.ArtifactsDirectory)\firmware\AzureKinectDK_Fw_$(firmware_version).bin"
displayName: 'Download Resources'
- task: CopyFiles@2
displayName: "Copy DepthEnginePlugin into bin folder"
inputs:
Expand Down Expand Up @@ -531,13 +626,24 @@ jobs:
timeoutInMinutes: 15
continueOnError: true

# Issue #322, figure out the dependencies to be able to run the functional tests.
# - task: VSTest@2
# displayName: 'Run C# Functional Tests'
# inputs:
# testSelector: 'testAssemblies'
# searchFolder: '$(Build.BinariesDirectory)'
# platform: '$(MSBuildPlatform)'
# configuration: '$(MSBuildConfiguration)'
# testAssemblyVer2: |
# **/*FunctionalTests.dll
# !**/obj/**

- task: PowerShell@2
inputs:
targetType: 'filePath'
filePath: './scripts/Reset-Device.ps1'
displayName: 'Reset K4A Device'


- ${{ if eq(variables['System.CollectionId'], 'cb55739e-4afe-46a3-970f-1b49d8ee7564') }}:
- job: LinuxFunctionalTests
displayName: Linux Functional Test
Expand Down
10 changes: 8 additions & 2 deletions k4a.props.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
<Project>
<PropertyGroup>
<K4aBinaryDirectory>@PROJECT_BINARY_DIR@</K4aBinaryDirectory>
</PropertyGroup>
<K4aGeneratorSourcesDirectory>@PROJECT_BINARY_DIR@/src</K4aGeneratorSourcesDirectory>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
<K4aBinaryDirectory>@K4A_BINARY_DIR_DEBUG@</K4aBinaryDirectory>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
<K4aBinaryDirectory>@K4A_BINARY_DIR_RELEASE@</K4aBinaryDirectory>
</PropertyGroup>
</Project>
Loading

0 comments on commit 5f56c1e

Please sign in to comment.