forked from PortAudio/portaudio
-
Notifications
You must be signed in to change notification settings - Fork 1
96 lines (88 loc) · 4.66 KB
/
MSBuild.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
name: MSBuild MSVC Project File CI
on: [push, pull_request]
env:
# Path to the solution file relative to the root of the project.
SOLUTION_FILE_PATH: ./msvc/portaudio.sln
VCPROJ_FILE_PATH: ./msvc/portaudio.vcproj
VCXPROJ_FILE_PATH: ./msvc/portaudio.vcxproj
VCXPROJ_FILTERS_FILE_PATH: ./msvc/portaudio.vcxproj.filters
VCXPROJ_USER_FILE_PATH: ./msvc/portaudio.vcxproj.user
DEF_FILE_PATH: ./msvc/portaudio.def
jobs:
build:
runs-on: windows-latest
strategy:
matrix:
BUILD_CONFIGURATION: [Release]
BUILD_PLATFORM: [Win32, x64]
steps:
- name: Add MSBuild to PATH
uses: microsoft/setup-msbuild@v1
- uses: actions/checkout@v2
- name: Upgrade VC Project File
# We maintain our vcproj file in an old format to maintain backwards compatibility
# This step upgrades the project to the latest version of MSVC
# see https://docs.microsoft.com/en-us/visualstudio/ide/reference/upgrade-devenv-exe?view=vs-2019
# pipe to file to ensure that it terminates https://stackoverflow.com/questions/48896010/occasionally-occurring-msbuild-error-msb3428/48918105#48918105
# discussion of using vswhere.exe here: https://stackoverflow.com/questions/65287456/how-to-upgrade-a-visual-studio-project-from-within-a-github-action/65311868#65311868
run: |
$devenv = & vswhere.exe '-property' productPath
Write-Output "$devenv"
& $devenv "${{env.VCPROJ_FILE_PATH}}" /Upgrade /NoSplash | Out-Null
Write-Output "devenv launched"
while (!(Test-Path "${{env.VCXPROJ_FILE_PATH}}")) { Start-Sleep -Seconds 10 }
Write-Output "vcxproj found"
while (!(Test-Path "${{env.VCXPROJ_FILTERS_FILE_PATH}}")) { Start-Sleep -Seconds 10 }
Write-Output "vcxproj.filters found"
Start-Sleep -Seconds 10
Write-Output "done."
- name: Remove ASIO Files and Enable PA_USE_DS=1
# Process the project files to remove ASIO-related sources and includes (since we can not access the ASIO SDK in a public build)
run: |
# Process .vcxproj file: remove source files
$xdoc = new-object System.Xml.XmlDocument
$vcxprojFile = resolve-path("${{env.VCXPROJ_FILE_PATH}}")
$xdoc.load($vcxprojFile)
$namespace = New-Object -TypeName "Xml.XmlNamespaceManager" -ArgumentList $xdoc.NameTable
$namespace.AddNamespace("vs", $xdoc.DocumentElement.NamespaceURI)
$nodes = $xdoc.SelectNodes("//vs:ClCompile[contains(@Include, '..\src\hostapi\asio')]", $namespace)
Write-Output "deleting ASIO related compilation nodes from .vcxproj:"
Write-Output $nodes
ForEach($node in $nodes) {
$parent = $node.ParentNode
$parent.RemoveChild($node)
}
# Enable DirectSound host API
$nodes = $xdoc.SelectNodes("//vs:PreprocessorDefinitions[contains(., 'PA_USE_DS=0')]", $namespace)
ForEach($node in $nodes) {
$text = $node.InnerText
$node.InnerText = $text -replace 'PA_USE_DS=0', 'PA_USE_DS=1'
}
$xdoc.save($vcxprojFile)
# Process .vcxproj.filters file: remove source files and includes
$vcxprojFiltersFile = resolve-path("${{env.VCXPROJ_FILTERS_FILE_PATH}}")
$xdoc.load($vcxprojFiltersFile)
$namespace = New-Object -TypeName "Xml.XmlNamespaceManager" -ArgumentList $xdoc.NameTable
$namespace.AddNamespace("vs", $xdoc.DocumentElement.NamespaceURI)
$nodes = $xdoc.SelectNodes("//vs:ClCompile[contains(@Include, '..\src\hostapi\asio')]", $namespace)
Write-Output "deleting ASIO related compilation nodes from .vcxproj.filters:"
Write-Output $nodes
ForEach($node in $nodes) {
$parent = $node.ParentNode
$parent.RemoveChild($node)
}
$nodes = $xdoc.SelectNodes("//vs:ClInclude[contains(@Include, 'pa_asio.h')]", $namespace)
Write-Output "deleting ASIO related include nodes from .vcxproj.filters:"
Write-Output $nodes
ForEach($node in $nodes) {
$parent = $node.ParentNode
$parent.RemoveChild($node)
}
$xdoc.save($vcxprojFiltersFile)
# Process .def file: remove PaAsio_ symbols
Set-Content -Path "${{env.DEF_FILE_PATH}}" -Value (Get-Content -Path "${{env.DEF_FILE_PATH}}" | Select-String -Pattern 'PaAsio_' -NotMatch)
- name: Build
working-directory: ${{env.GITHUB_WORKSPACE}}
# Add additional options to the MSBuild command line here (like platform or verbosity level).
# See https://docs.microsoft.com/visualstudio/msbuild/msbuild-command-line-reference
run: msbuild /m /p:Configuration=${{matrix.BUILD_CONFIGURATION}} /p:Platform=${{matrix.BUILD_PLATFORM}} ${{env.VCXPROJ_FILE_PATH}}