|
16 | 16 | include:
|
17 | 17 | - os: windows-latest
|
18 | 18 | cpp_compiler: cl
|
| 19 | + separator: '\\' |
19 | 20 | - os: ubuntu-latest
|
20 | 21 | cpp_compiler: g++
|
| 22 | + separator: "/" |
21 | 23 |
|
22 | 24 | steps:
|
23 | 25 | - uses: actions/checkout@v4
|
@@ -56,34 +58,70 @@ jobs:
|
56 | 58 | shell: bash
|
57 | 59 | run: |
|
58 | 60 | conan profile detect --force
|
| 61 | + echo "[conf]" >> ~/.conan2/profiles/default |
| 62 | + echo "tools.system.package_manager:mode=install" >> ~/.conan2/profiles/default |
| 63 | + echo "tools.system.package_manager:sudo=True" >> ~/.conan2/profiles/default |
59 | 64 |
|
60 |
| - - name: Install Conan Dependencies |
| 65 | + - name: Cache Conan packages |
| 66 | + uses: actions/cache@v3 |
| 67 | + with: |
| 68 | + path: ~/.conan2 |
| 69 | + key: ${{ runner.os }}-conan-${{ hashFiles('**/conanfile.txt') }} |
| 70 | + restore-keys: | |
| 71 | + ${{ runner.os }}-conan- |
| 72 | +
|
| 73 | + - name: Install Conan Dependencies (Linux) |
| 74 | + if: runner.os == 'Linux' |
61 | 75 | run: |
|
62 | 76 | conan install . --build=missing -s build_type=${{ matrix.build_type }}
|
63 | 77 |
|
64 |
| - - name: Configure CMake |
| 78 | + - name: Install Conan Dependencies (Windows) |
| 79 | + if: runner.os == 'Windows' |
| 80 | + shell: pwsh |
65 | 81 | run: |
|
66 |
| - cmake --preset conan-${{ matrix.build_type }} |
67 |
| -
|
68 |
| - - name: Build |
69 |
| - run: cmake --build --preset conan-${{ matrix.build_type }} |
| 82 | + conan install . --build=missing -s build_type=${{ matrix.build_type }} -c tools.cmake.cmake_layout:build_folder_vars=['generators'] -c tools.cmake.cmaketoolchain:generator=Ninja |
70 | 83 |
|
71 |
| - - name: Test |
72 |
| - run: ctest --preset conan-${{ matrix.build_type }} |
| 84 | + - name: Set Build Directory |
| 85 | + id: strings |
| 86 | + shell: bash |
| 87 | + run: | |
| 88 | + if [ "${{ runner.os }}" == "Windows" ]; then |
| 89 | + echo "build-output-dir=${{ github.workspace }}\\build\\${{ matrix.build_type }}" >> "$GITHUB_OUTPUT" |
| 90 | + echo "game-path=src\\game\\stabby.exe" >> "$GITHUB_OUTPUT" |
| 91 | + echo "preset=conan-default" >> "$GITHUB_OUTPUT" |
| 92 | + else |
| 93 | + echo "build-output-dir=${{ github.workspace }}/build/${{ matrix.build_type }}" >> "$GITHUB_OUTPUT" |
| 94 | + echo "game-path=src/game/stabby" >> "$GITHUB_OUTPUT" |
| 95 | + echo "preset=conan-release" >> "$GITHUB_OUTPUT" |
| 96 | + fi |
73 | 97 |
|
74 |
| - - name: Set Artifact Path |
75 |
| - id: artifact |
| 98 | + - name: Configure CMake |
76 | 99 | shell: bash
|
77 | 100 | run: |
|
78 | 101 | if [ "${{ runner.os }}" == "Windows" ]; then
|
79 |
| - echo "game-path=build/${{ matrix.build_type }}/src/game/stabby.exe" >> "$GITHUB_OUTPUT" |
| 102 | + build_dir="${{ github.workspace }}\\build\\${{ matrix.build_type }}" |
| 103 | + toolchain_path="${{ github.workspace }}\\build\\${{ matrix.build_type }}\\generators\\conan_toolchain.cmake" |
80 | 104 | else
|
81 |
| - echo "game-path=build/${{ matrix.build_type }}/src/game/stabby" >> "$GITHUB_OUTPUT" |
| 105 | + build_dir="${{ github.workspace }}/build/${{ matrix.build_type }}" |
| 106 | + toolchain_path="${{ github.workspace }}/build/${{ matrix.build_type }}/generators/conan_toolchain.cmake" |
82 | 107 | fi
|
83 | 108 |
|
| 109 | + cmake -S . \ |
| 110 | + -B "$build_dir" \ |
| 111 | + -G Ninja \ |
| 112 | + -DCMAKE_TOOLCHAIN_FILE="$toolchain_path" \ |
| 113 | + -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} |
| 114 | +
|
| 115 | + - name: Build |
| 116 | + run: cmake --build ${{ steps.strings.outputs.build-output-dir }} |
| 117 | + |
| 118 | + - name: Test |
| 119 | + working-directory: ${{ steps.strings.outputs.build-output-dir }} |
| 120 | + run: ctest --build-config ${{ matrix.build_type }} |
| 121 | + |
84 | 122 | - name: Upload Build Artifacts
|
85 | 123 | uses: actions/upload-artifact@v3
|
86 | 124 | with:
|
87 | 125 | name: ${{ runner.os }}-${{ matrix.build_type }}-build
|
88 |
| - path: ${{ steps.artifact.outputs.game-path }} |
| 126 | + path: ${{ steps.strings.outputs.build-output-dir }}/${{ steps.strings.outputs.game-path }} |
89 | 127 | if-no-files-found: ignore
|
0 commit comments