-
Notifications
You must be signed in to change notification settings - Fork 19
159 lines (135 loc) Β· 5.92 KB
/
build-windows.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
name: Windows
on:
push:
pull_request:
branches: [ master ]
env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
INSTALL_PREFIX: _install
PROJECT_NAME: tcp_pubsub
VS_TOOLSET: v140
VS_NAME: vs2015
jobs:
build-windows:
strategy:
fail-fast: false
matrix:
library_type: [static, shared, object]
build_arch: [x64, win32]
# The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
# You can convert this to a matrix build if you need cross-platform coverage.
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
runs-on: windows-2019
steps:
- name: Set Variables
run: |
if ( '${{ matrix.library_type }}' -eq 'static' )
{
echo "tcp_pubsub_library_type=STATIC" >> "$Env:GITHUB_ENV"
echo "package_postfix=static" >> "$Env:GITHUB_ENV"
}
elseif( '${{ matrix.library_type }}' -eq 'shared' )
{
echo "tcp_pubsub_library_type=SHARED" >> "$Env:GITHUB_ENV"
echo "package_postfix=shared" >> "$Env:GITHUB_ENV"
}
elseif( '${{ matrix.library_type }}' -eq 'object' )
{
echo "tcp_pubsub_library_type=OBJECT" >> "$Env:GITHUB_ENV"
echo "package_postfix=object" >> "$Env:GITHUB_ENV"
}
- name: Checkout
uses: actions/checkout@v4
with:
submodules: 'true'
fetch-depth: 0
############################################
# Test-compile the project
############################################
- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
shell: cmd
run: |
cmake -B ${{github.workspace}}/_build ^
-G "Visual Studio 16 2019" ^
-A ${{ matrix.build_arch }} ^
-T ${{ env.VS_TOOLSET }} ^
-DTCP_PUBSUB_BUILD_SAMPLES=ON ^
-DTCP_PUBSUB_BUILD_TESTS=ON ^
-DTCP_PUBSUB_USE_BUILTIN_ASIO=ON ^
-DTCP_PUBSUB_USE_BUILTIN_RECYCLE=ON ^
-DTCP_PUBSUB_USE_BUILTIN_GTEST=ON ^
-DTCP_PUBSUB_LIBRARY_TYPE=${{env.tcp_pubsub_library_type}} ^
-DCMAKE_INSTALL_PREFIX=${{env.INSTALL_PREFIX}}
- name: Build (Release)
shell: cmd
run: |
cmake --build ${{github.workspace}}/_build --config Release --parallel
- name: Install (Release)
shell: cmd
run: |
cmake --build ${{github.workspace}}/_build --config Release --target INSTALL
if: ${{ matrix.library_type != 'object' }}
- name: Build (Debug)
shell: cmd
run: |
cmake --build ${{github.workspace}}/_build --config Debug --parallel
- name: Install (Debug)
shell: cmd
run: |
cmake --build ${{github.workspace}}/_build --config Debug --target INSTALL
if: ${{ matrix.library_type != 'object' }}
- name: Run Tests
run: ctest -C Release -V
working-directory: ${{ github.workspace }}/_build
- name: Read Project Version from CMakeCache
run: |
$cmake_project_version_line = cat ${{github.workspace}}/_build/CMakeCache.txt | Select-String -Pattern ^CMAKE_PROJECT_VERSION:
$cmake_project_version = $cmake_project_version_line.Line.split("=")[1]
echo "CMAKE_PROJECT_VERSION=$cmake_project_version" >> "$Env:GITHUB_ENV"
- name: Upload binaries
uses: actions/upload-artifact@v4
with:
name: ${{ env.PROJECT_NAME }}-${{ env.CMAKE_PROJECT_VERSION }}-windows-${{ matrix.build_arch }}-${{ env.VS_NAME }}-${{ matrix.library_type }}
path: ${{github.workspace}}/${{env.INSTALL_PREFIX}}
if: ${{ matrix.library_type != 'object' }}
############################################
# Test if our binary can be linked against
############################################
- name: CMake integration test
shell: powershell
run: |
cmake -B "${{github.workspace}}/samples/integration_test/_build" `
-A ${{ matrix.build_arch }} `
-DCMAKE_PREFIX_PATH="${{github.workspace}}/${{env.INSTALL_PREFIX}}"
working-directory: ${{ github.workspace }}/samples/integration_test
if: ${{ matrix.library_type != 'object' }}
- name: Compile integration test (Release)
shell: cmd
run: cmake --build ${{github.workspace}}/samples/integration_test/_build --config Release
working-directory: ${{ github.workspace }}/samples/integration_test
if: ${{ matrix.library_type != 'object' }}
- name: Run integration test (Release)
run: |
if ( '${{ matrix.library_type }}' -eq 'shared' )
{
$Env:Path = '${{github.workspace}}/${{env.INSTALL_PREFIX}}/bin;' + $Env:Path
}
.\integration_test.exe
working-directory: ${{ github.workspace }}/samples/integration_test/_build/Release
if: ${{ matrix.library_type != 'object' }}
- name: Compile integration test (Debug)
shell: cmd
run: cmake --build ${{github.workspace}}/samples/integration_test/_build --config Debug
working-directory: ${{ github.workspace }}/samples/integration_test
if: ${{ matrix.library_type != 'object' }}
- name: Run integration test (Debug)
run: |
if ( '${{ matrix.library_type }}' -eq 'shared' )
{
$Env:Path = '${{github.workspace}}/${{env.INSTALL_PREFIX}}/bin;' + $Env:Path
}
.\integration_test.exe
working-directory: ${{ github.workspace }}/samples/integration_test/_build/Debug
if: ${{ matrix.library_type != 'object' }}