aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/build.yml
blob: a033ceb1fee53649a9ce337010edf168ccb720db (plain) (blame)
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
name: eden-build

on:
  push:
    branches: [ "*" ]
    tags: [ "*" ]
  pull_request:
    branches: [ master ]

jobs:
  source:
    if: ${{ !github.head_ref }}
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          submodules: recursive
      - name: Pack
        run: ./.ci/source.sh
      - name: Upload
        uses: actions/upload-artifact@v4
        with:
          name: source
          path: artifacts/
  windows:
    runs-on: windows-latest
    strategy:
      matrix:
        target: ["msvc"] # TODO: Add msys2
    defaults:
      run:
        shell: ${{ (matrix.target == 'msys2' && 'msys2') || 'bash' }} {0}
    env:
      CCACHE_DIR: ${{ github.workspace }}/.ccache
      CCACHE_COMPILERCHECK: content
      CCACHE_SLOPPINESS: time_macros
      OS: windows
      TARGET: ${{ matrix.target }}
    steps:
      - uses: actions/checkout@v4
        with:
          submodules: recursive
          fetch-depth: 0
      - name: Set up ccache
        uses: actions/cache@v4
        with:
          path: ${{ env.CCACHE_DIR }}
          key: ${{ runner.os }}-${{ matrix.target }}-ccache-${{ github.sha }}
          restore-keys: |
            ${{ runner.os }}-${{ matrix.target }}-ccache-
      - name: Set up vcpkg cache
        uses: actions/cache@v4
        with:
          path: |
            ${{ github.workspace }}/build/vcpkg_installed
            ${{ github.workspace }}/build/externals
            ${{ github.workspace }}/.vcpkg
          key: ${{ runner.os }}-${{ matrix.target }}-vcpkg-${{ hashFiles('**/CMakeLists.txt', '**/vcpkg.json') }}-${{ github.run_id }}
          restore-keys: |
            ${{ runner.os }}-${{ matrix.target }}-vcpkg-
      - name: Set up MSVC
        uses: ilammy/msvc-dev-cmd@v1
        if: ${{ matrix.target == 'msvc' }}
      - name: Install extra tools
        run: choco install ccache ninja wget cygwin
        if: ${{ matrix.target == 'msvc' }}
      - name: Install vulkan-SDK
        run: ./.ci/install-vulkan-sdk.ps1
        shell: pwsh
      - name: Cygwin with autoconf # NEEDED FOR LIBUSB
        shell: cmd
        run: |
          C:\tools\cygwin\cygwinsetup.exe -q -P autoconf,automake,libtool,make,pkg-config
          
          REM Create wrapper batch files for Cygwin tools in a directory that will be in PATH
          mkdir C:\cygwin-wrappers
          
          REM Create autoconf.bat wrapper
          echo @echo off > C:\cygwin-wrappers\autoconf.bat
          echo C:\tools\cygwin\bin\bash.exe -l -c "autoconf %%*" >> C:\cygwin-wrappers\autoconf.bat
          
          REM Add other wrappers if needed for other Cygwin tools
          echo @echo off > C:\cygwin-wrappers\automake.bat
          echo C:\tools\cygwin\bin\bash.exe -l -c "automake %%*" >> C:\cygwin-wrappers\automake.bat
          
          REM Add the wrappers directory to PATH
          echo C:\cygwin-wrappers>>"%GITHUB_PATH%"
          echo C:\tools\cygwin\bin>>"%GITHUB_PATH%"
      - name: CMake Configure
        id: cmake
        shell: cmd
        run: |
          mkdir build
          cd build
          cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_TOOLCHAIN_FILE="%CD%\..\CMakeModules\MSVCCache.cmake" -DYUZU_USE_BUNDLED_QT=ON -DENABLE_QT_TRANSLATION=ON -DUSE_DISCORD_PRESENCE=ON -DYUZU_USE_BUNDLED_VCPKG=ON -DYUZU_USE_BUNDLED_SDL2=ON -DUSE_CCACHE=ON
      - name: Build
        id: build
        shell: cmd
        run: |
          cd build
          ninja yuzu yuzu-cmd yuzu-room tests
          ccache -s -v        
      - name: Package artifacts
        if: steps.build.outcome == 'success'
        shell: pwsh
        run: |
          $GITDATE = $(git show -s --date=short --format='%ad') -replace "-", ""
          $GITREV = $(git show -s --format='%h')
          $RELEASE_DIST = "eden-windows-msvc"
          $ARTIFACTS_DIR = "${{ github.workspace }}/artifacts"
          
          mkdir -p $ARTIFACTS_DIR
          mkdir -p $RELEASE_DIST
          mkdir -p pdb
          
          Copy-Item "build/bin/Release/*" -Destination "$RELEASE_DIST" -Recurse -ErrorAction SilentlyContinue
          if (-not $?) {
            # Try without Release subfolder if that doesn't exist
            Copy-Item "build/bin/*" -Destination "$RELEASE_DIST" -Recurse -ErrorAction SilentlyContinue
          }
          
          Get-ChildItem "build/bin/" -Recurse -Filter "*.pdb" | Copy-Item -destination .\pdb -ErrorAction SilentlyContinue
          
          $BUILD_ZIP = "eden-windows-msvc-$GITDATE-$GITREV.zip"
          $BUILD_PDB = "eden-windows-msvc-$GITDATE-$GITREV-debugsymbols.zip"
          $BUILD_7Z = "eden-windows-msvc-$GITDATE-$GITREV.7z"
          
          7z a -tzip $BUILD_ZIP $RELEASE_DIST\*
          
          if (Test-Path -Path ".\pdb\*.pdb") {
            7z a -tzip $BUILD_PDB .\pdb\*.pdb
            Move-Item $BUILD_PDB $ARTIFACTS_DIR/ -ErrorAction SilentlyContinue
          }
          
          7z a $BUILD_7Z $RELEASE_DIST
          
          Move-Item $BUILD_ZIP $ARTIFACTS_DIR/ -ErrorAction SilentlyContinue
          Move-Item $BUILD_7Z $ARTIFACTS_DIR/ -ErrorAction SilentlyContinue
          
          Copy-Item "LICENSE*" -Destination "$RELEASE_DIST" -ErrorAction SilentlyContinue
          Copy-Item "README*" -Destination "$RELEASE_DIST" -ErrorAction SilentlyContinue
      - name: Upload Windows artifacts
        if: steps.build.outcome == 'success'
        uses: actions/upload-artifact@v4
        with:
          name: ${{ matrix.target }}
          path: artifacts/*
  linux:
    runs-on: ubuntu-latest
    env:
      CCACHE_DIR: ${{ github.workspace }}/.ccache
      CCACHE_COMPILERCHECK: content
      CCACHE_SLOPPINESS: time_macros
      OS: linux
      TARGET: fresh 
    container:
      image: icybriar/eden-build-environment:latest
      options: -u 1001
    steps:
      - uses: actions/checkout@v4
        with:
          submodules: recursive
          fetch-depth: 0
      - name: Set up cache
        uses: actions/cache@v4
        with:
          path: ${{ env.CCACHE_DIR }}
          key: ${{ runner.os }}-fresh-${{ github.sha }}
          restore-keys: |
            ${{ runner.os }}-fresh-

      - name: Set up vcpkg cache
        uses: actions/cache@v4
        with:
          path: |
            ${{ github.workspace }}/build/vcpkg_installed
            ${{ github.workspace }}/build/externals
            ${{ github.workspace }}/.vcpkg
          key: ${{ runner.os }}-fresh-vcpkg-${{ hashFiles('**/CMakeLists.txt', '**/vcpkg.json') }}-${{ github.run_id }}
          restore-keys: |
            ${{ runner.os }}-fresh-vcpkg-

      - name: Build
        run: ./.ci/linux.sh
        
      - name: Package AppImages
        run: |
          ./.ci/package-appimage.sh "${{ github.ref_name }}"
      
      - name: Upload Linux artifacts
        uses: actions/upload-artifact@v4
        with:
          name: linux
          path: artifacts/*
  android:
    runs-on: ubuntu-latest
    env:
      CCACHE_DIR: ${{ github.workspace }}/.ccache
      CCACHE_COMPILERCHECK: content
      CCACHE_SLOPPINESS: time_macros
      OS: android
      TARGET: universal
    steps:
      - uses: actions/checkout@v4
        with:
          submodules: recursive
          fetch-depth: 0
      - name: Set up cache
        uses: actions/cache@v4
        with:
          path: |
            ~/.gradle/caches
            ~/.gradle/wrapper
            ${{ env.CCACHE_DIR }}
          key: ${{ runner.os }}-android-${{ github.sha }}
          restore-keys: |
            ${{ runner.os }}-android-
      - name: Set tag name
        run: |
          if [[ "$GITHUB_REF_TYPE" == "tag" ]]; then
              echo "GIT_TAG_NAME=$GITHUB_REF_NAME" >> $GITHUB_ENV
          fi
          echo $GIT_TAG_NAME
      - name: Deps
        run: |
          sudo apt-get update -y
          sudo apt-get install ccache glslang-dev glslang-tools apksigner -y
      - name: Build
        run: JAVA_HOME=$JAVA_HOME_21_X64 ./.ci/android.sh
        env:
          ANDROID_KEYSTORE_B64: ${{ secrets.ANDROID_KEYSTORE_B64 }}
          ANDROID_KEY_ALIAS: ${{ secrets.ANDROID_KEY_ALIAS }}
          ANDROID_KEYSTORE_PASS: ${{ secrets.ANDROID_KEYSTORE_PASS }}
      - name: Package Android artifacts
        run: |
          GITDATE="$(git show -s --date=short --format='%ad' | sed 's/-//g')"
          GITREV="$(git show -s --format='%h')"
          ARTIFACTS_DIR="$PWD/artifacts"
          mkdir -p "${ARTIFACTS_DIR}/"
          
          REV_NAME="eden-android-${GITDATE}-${GITREV}"
          BUILD_FLAVOR="mainline"
          BUILD_TYPE_LOWER="release"
          BUILD_TYPE_UPPER="Release"
          
          if [ "${GITHUB_REPOSITORY}" == "eden-emulator/eden" ]; then
            BUILD_TYPE_LOWER="relWithDebInfo"
            BUILD_TYPE_UPPER="RelWithDebInfo"
          fi
          
          cp src/android/app/build/outputs/apk/"${BUILD_FLAVOR}/${BUILD_TYPE_LOWER}/app-${BUILD_FLAVOR}-${BUILD_TYPE_LOWER}.apk" \
             "${ARTIFACTS_DIR}/${REV_NAME}.apk" || echo "APK not found"
          
          cp src/android/app/build/outputs/bundle/"${BUILD_FLAVOR}${BUILD_TYPE_UPPER}"/"app-${BUILD_FLAVOR}-${BUILD_TYPE_LOWER}.aab" \
             "${ARTIFACTS_DIR}/${REV_NAME}.aab" || echo "AAB not found"
             
          ls -la "${ARTIFACTS_DIR}/"
          
      - name: Upload Android artifacts
        uses: actions/upload-artifact@v4
        with:
          name: android
          path: artifacts/*