Skip to content

Commit 15586fb

Browse files
author
Aliaksandr Adziareika
committed
Add cmake-preset-name option
1 parent 34741dc commit 15586fb

File tree

4 files changed

+65
-31
lines changed

4 files changed

+65
-31
lines changed

.github/actions/build-sdk/action.yml

Lines changed: 42 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,12 @@ inputs:
1010
description: 'Path for build directory (defaults to "{source-path}/build")'
1111
required: false
1212
default: ''
13-
cmake-generator:
14-
description: 'CMake generator to use'
13+
cmake-generator-name:
14+
description: 'CMake generator name (e.g., "Ninja", "Visual Studio 17 2022")'
15+
required: false
16+
default: ''
17+
cmake-preset-name:
18+
description: 'CMake preset name (e.g., "package", "ci")'
1519
required: false
1620
default: ''
1721
cmake-config:
@@ -42,8 +46,8 @@ inputs:
4246
description: 'Run tests after build'
4347
required: false
4448
default: 'false'
45-
cpack-generator:
46-
description: 'CPack package generator (e.g., "DEB", "RPM", "NSIS", "TGZ", "ZIP")'
49+
cpack-generator-name:
50+
description: 'CPack generator name (e.g., "DEB", "RPM", "NSIS", "TGZ", "ZIP")'
4751
required: false
4852
default: ''
4953

@@ -77,10 +81,11 @@ runs:
7781
echo "build-path=$BUILD_PATH" >> "$GITHUB_OUTPUT"
7882
7983
# Set default cmake-generator
80-
CMAKE_GENERATOR="${{ inputs.cmake-generator }}"
81-
if [ -z "$CMAKE_GENERATOR" ]; then
82-
CMAKE_GENERATOR="Ninja"
84+
CMAKE_GENERATOR_NAME="${{ inputs.cmake-generator-name }}"
85+
if [ -z "$CMAKE_GENERATOR_NAME" ]; then
86+
CMAKE_GENERATOR_NAME="Ninja"
8387
fi
88+
CMAKE_GENERATOR="-G \"$CMAKE_GENERATOR_NAME\""
8489
echo "cmake-generator=$CMAKE_GENERATOR" >> "$GITHUB_OUTPUT"
8590
8691
# Set default cmake-config
@@ -97,6 +102,15 @@ runs:
97102
fi
98103
echo "ccache-path=$CCACHE_PATH" >> "$GITHUB_OUTPUT"
99104
105+
# Set cmake-preset (as --preset flag or empty string)
106+
CMAKE_PRESET_NAME="${{ inputs.cmake-preset-name }}"
107+
if [ -z "$CMAKE_PRESET_NAME" ]; then
108+
CMAKE_PRESET=""
109+
else
110+
CMAKE_PRESET="--preset $CMAKE_PRESET_NAME"
111+
fi
112+
echo "cmake-preset=$CMAKE_PRESET" >> "$GITHUB_OUTPUT"
113+
100114
- name: Normalize paths
101115
id: normalize
102116
shell: bash
@@ -113,6 +127,10 @@ runs:
113127
if command -v cygpath &> /dev/null; then
114128
BUILD_PATH=$(cygpath -u "$BUILD_PATH")
115129
fi
130+
131+
# Create build directory if it doesn't exist
132+
mkdir -p "$BUILD_PATH"
133+
116134
echo "build-path=$BUILD_PATH" >> "$GITHUB_OUTPUT"
117135
118136
- name: Read version and commit hash
@@ -175,16 +193,25 @@ runs:
175193
- name: Configure CMake
176194
shell: bash
177195
run: |
196+
# Get absolute paths
197+
SOURCE_DIR="$(cd "${{ steps.normalize.outputs.source-path }}" && pwd)"
198+
BUILD_DIR="$(cd "${{ steps.normalize.outputs.build-path }}" && pwd)"
199+
178200
echo "CMake Configuration:"
179-
echo " Source: ${{ steps.normalize.outputs.source-path }}"
180-
echo " Build: ${{ steps.normalize.outputs.build-path }}"
201+
echo " Source: $SOURCE_DIR"
202+
echo " Build: $BUILD_DIR"
181203
echo " Generator: ${{ steps.defaults.outputs.cmake-generator }}"
204+
echo " Preset: ${{ steps.defaults.outputs.cmake-preset }}"
182205
echo " Config: ${{ steps.defaults.outputs.cmake-config }}"
183206
echo ""
207+
208+
# Run cmake from inside build directory
209+
cd "$BUILD_DIR"
210+
184211
echo "::group::CMake Configuration Output"
185-
cmake -S "${{ steps.normalize.outputs.source-path }}" \
186-
-B "${{ steps.normalize.outputs.build-path }}" \
187-
-G "${{ steps.defaults.outputs.cmake-generator }}" \
212+
cmake "$SOURCE_DIR" \
213+
${{ steps.defaults.outputs.cmake-generator }} \
214+
${{ steps.defaults.outputs.cmake-preset }} \
188215
-DCMAKE_BUILD_TYPE=${{ steps.defaults.outputs.cmake-config }} \
189216
${{ inputs.cmake-compiler }} \
190217
${{ inputs.cmake-defines }}
@@ -216,14 +243,14 @@ runs:
216243
echo "✓ Tests passed successfully"
217244
218245
- name: Package
219-
if: inputs.cpack-generator != ''
246+
if: inputs.cpack-generator-name != ''
220247
shell: bash
221248
run: |
222249
echo "CPack Packaging:"
223-
echo " Generator: ${{ inputs.cpack-generator }}"
250+
echo " Generator: ${{ inputs.cpack-generator-name }}"
224251
echo ""
225252
echo "::group::CPack Output"
226-
cpack --config "${{ steps.normalize.outputs.build-path }}/CPackConfig.cmake" -G ${{ inputs.cpack-generator }}
253+
cpack --config "${{ steps.normalize.outputs.build-path }}/CPackConfig.cmake" -G ${{ inputs.cpack-generator-name }}
227254
echo "::endgroup::"
228255
echo "✓ Package created successfully"
229256

.github/actions/setup-dependencies/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ runs:
3232
shell: pwsh
3333
run: |
3434
Write-Host "::group::Installing Windows dependencies"
35-
choco install ccache ninja nsis vswhere -y
35+
choco install ccache ninja nsis vswhere dotnet-sdk -y
3636
Write-Host "::endgroup::"
3737
Write-Host "✓ Windows dependencies installed"
3838

.github/workflows/reusable-build-sdk.yml

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,16 @@ on:
1818
required: false
1919
type: string
2020
default: 'windows-latest'
21-
cmake-generator:
22-
description: 'CMake generator to use'
21+
cmake-generator-name:
22+
description: 'CMake generator name (e.g., "Ninja", "Visual Studio 17 2022")'
2323
required: false
2424
type: string
2525
default: 'Ninja'
26+
cmake-preset-name:
27+
description: 'CMake preset name (e.g., "package", "ci")'
28+
required: false
29+
type: string
30+
default: ''
2631
cmake-compiler:
2732
description: 'CMake compiler configuration'
2833
required: false
@@ -38,8 +43,8 @@ on:
3843
required: false
3944
type: boolean
4045
default: false
41-
cpack-generator:
42-
description: 'CPack generator'
46+
cpack-generator-name:
47+
description: 'CPack generator name (e.g., "DEB", "RPM", "NSIS", "TGZ", "ZIP")'
4348
required: false
4449
type: string
4550
default: ''
@@ -101,22 +106,23 @@ jobs:
101106
uses: ./.github/actions/build-sdk
102107
with:
103108
source-path: ${{ steps.defaults.outputs.path }}
104-
cmake-generator: ${{ inputs.cmake-generator }}
109+
cmake-generator-name: ${{ inputs.cmake-generator-name }}
110+
cmake-preset-name: ${{ inputs.cmake-preset-name }}
105111
cmake-compiler: ${{ inputs.cmake-compiler }}
106112
cmake-defines: ${{ steps.defaults.outputs.cmake-defines }}
107113
ccache-enable: ${{ inputs.ccache-enable }}
108-
cpack-generator: ${{ inputs.cpack-generator }}
114+
cpack-generator-name: ${{ inputs.cpack-generator-name }}
109115

110116
- name: Compose openDAQ framework filename
111-
if: inputs.cpack-generator != ''
117+
if: inputs.cpack-generator-name != ''
112118
id: opendaq-filename
113-
uses: openDAQ/actions/framework-compose-filename@jira/TBBAS-2680-opendaq-gh-actions-github-api-wrapper-unit-tests
119+
uses: openDAQ/actions/framework-compose-filename@jira/TBBAS-2672-opendaq-gh-actions-architecture
114120
with:
115121
version: ${{ steps.build.outputs.version }}-${{ steps.build.outputs.commit-hash }}
116-
packaging: ${{ inputs.cpack-generator }}
122+
packaging: ${{ inputs.cpack-generator-name }}
117123

118124
- name: Prepare artifact
119-
if: inputs.cpack-generator != ''
125+
if: inputs.cpack-generator-name != ''
120126
shell: bash
121127
env:
122128
ARTIFACT_FILENAME: ${{ steps.opendaq-filename.outputs.filename }}
@@ -152,7 +158,7 @@ jobs:
152158
fi
153159
154160
- name: Upload artifact
155-
if: inputs.cpack-generator != ''
161+
if: inputs.cpack-generator-name != ''
156162
uses: actions/upload-artifact@v4
157163
with:
158164
name: ${{ steps.opendaq-filename.outputs.filename }}

.github/workflows/test-reusable-build-sdk.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,20 @@ jobs:
1111
matrix:
1212
include:
1313
- runner: windows-latest
14-
cmake-generator: Ninja
14+
cmake-generator-name: Ninja
1515
cmake-compiler: >-
1616
-DCMAKE_C_COMPILER=cl
1717
-DCMAKE_CXX_COMPILER=cl
1818
-DCMAKE_C_COMPILER_LAUNCHER=ccache
1919
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
20-
cpack-generator: NSIS
20+
cpack-generator-name: NSIS
2121

2222
uses: ./.github/workflows/reusable-build-sdk.yml
2323
with:
2424
runner: ${{ matrix.runner }}
2525
path: openDAQ
26-
cmake-generator: ${{ matrix.cmake-generator }}
26+
cmake-generator-name: ${{ matrix.cmake-generator-name }}
27+
cmake-preset-name: package
2728
cmake-compiler: ${{ matrix.cmake-compiler }}
2829
ccache-enable: true
29-
cpack-generator: ${{ matrix.cpack-generator }}
30+
cpack-generator-name: ${{ matrix.cpack-generator-name }}

0 commit comments

Comments
 (0)