xref: /reactos/.github/workflows/build.yml (revision 34d5d1db)
1name: Build
2on: [push, pull_request]
3
4jobs:
5  build-linux:
6    strategy:
7      matrix:
8        compiler: [gcc, clang]
9        arch: [i386, amd64]
10      fail-fast: false
11    runs-on: ubuntu-latest
12    steps:
13    - name: Get RosBE build specifics
14      id: get_rosbe_spec
15      run: |
16        gcc -march=native -Q --help=target | grep "\-march= " | awk '{print $NF}'
17        echo ::set-output name=march-sha::$(gcc -march=native -Q --help=target | sha1sum | awk '{print $1}')
18        echo ::set-output name=git-sha::$(git ls-remote https://github.com/zefklop/RosBE.git | grep unix_amd64 | awk '{print $1}')
19        wget https://gist.githubusercontent.com/zefklop/b2d6a0b470c70183e93d5285a03f5899/raw/build_rosbe_ci.sh
20    - name: Get RosBE
21      id: get_rosbe
22      uses: actions/cache@v2
23      with:
24        path: RosBE-CI
25        key: RosBE-CI-${{runner.os}}-${{steps.get_rosbe_spec.outputs.march-sha}}-${{steps.get_rosbe_spec.outputs.git-sha}}-${{hashfiles('./build_rosbe_ci.sh')}}
26    - name: Compile RosBE
27      if: ${{ steps.get_rosbe.outputs.cache-hit != 'true' }}
28      run: |
29        chmod +x build_rosbe_ci.sh
30        ./build_rosbe_ci.sh ${{github.workspace}}/RosBE-CI
31    - name: Install ccache
32      run: sudo apt install ccache
33    - name: Install LLVM
34      if: ${{ matrix.compiler == 'clang' }}
35      run: |
36        export LLVM_VERSION=12
37        wget https://apt.llvm.org/llvm.sh
38        chmod +x llvm.sh
39        sudo ./llvm.sh $LLVM_VERSION
40        echo "D_CLANG_VERSION=-DCLANG_VERSION=$LLVM_VERSION" >> $GITHUB_ENV
41    - name: Source checkout
42      uses: actions/checkout@v2
43      with:
44        path: src
45    - name: Set up cache for ccache
46      uses: actions/cache@v2
47      with:
48        path: ccache
49        key: ccache-${{matrix.compiler}}-${{matrix.arch}}-${{github.sha}}
50        restore-keys: |
51          ccache-${{matrix.compiler}}-${{matrix.arch}}-
52    - name: Set ccache settings
53      run: |
54        echo "CCACHE_BASEDIR=${{github.workspace}}" >> $GITHUB_ENV
55        echo "CCACHE_DIR=${{github.workspace}}/ccache" >> $GITHUB_ENV
56        echo "CCACHE_MAXSIZE=1G" >> $GITHUB_ENV
57        echo "CCACHE_SLOPPINESS=time_macros" >> $GITHUB_ENV
58    - name: Ease ccache compiler check (GCC)
59      if: ${{ matrix.compiler == 'gcc' }}
60      run: echo "CCACHE_COMPILERCHECK=string:${{steps.get_rosbe_spec.outputs.git-sha}}-${{hashfiles('./build_rosbe_ci.sh')}}" >> $GITHUB_ENV
61    - name: Configure
62      run: echo 'cmake -S ${{github.workspace}}/src -B ${{github.workspace}}/build -G Ninja -DCMAKE_TOOLCHAIN_FILE:FILEPATH=toolchain-${{matrix.compiler}}.cmake -DARCH:STRING=${{matrix.arch}} -DENABLE_CCACHE=1 -DENABLE_ROSTESTS=1 -DENABLE_ROSAPPS=1 ${{env.D_CLANG_VERSION}}' | ${{github.workspace}}/RosBE-CI/RosBE.sh . 0 ${{matrix.arch}}
63    - name: Build
64      run: echo 'cmake --build ${{github.workspace}}/build -- -k0' | ${{github.workspace}}/RosBE-CI/RosBE.sh . 0 ${{matrix.arch}}
65    - name: Generate ISOs
66      run: echo 'cmake --build ${{github.workspace}}/build --target bootcd --target livecd' | ${{github.workspace}}/RosBE-CI/RosBE.sh . 0 ${{matrix.arch}}
67    - name: Print ccache statistics
68      run: ccache -s
69    - name: Upload ISOs
70      uses: actions/upload-artifact@v2
71      with:
72        name: reactos-${{matrix.compiler}}-${{matrix.arch}}-${{github.sha}}
73        path: |
74          build/bootcd.iso
75          build/livecd.iso
76
77  build-msvc:
78    strategy:
79      matrix:
80        arch: [i386, amd64]
81        buildtype: [Debug,Release]
82        toolset: ['14.2', '14.1'] # VS 2019, 2017
83        include:
84        - arch: i386 # Not compiling on amd64 prompt
85          toolset: '14.0' # VS 2015
86      fail-fast: false
87    runs-on: windows-latest
88    steps:
89    - name: Install ninja
90      run: choco install -y ninja
91    - name: Install Flex & Bison
92      run: |
93        curl -O https://svn.reactos.org/storage/vperevertkin/flexbison.7z
94        7z x flexbison.7z -O${{github.workspace}}\bin
95        echo "${{github.workspace}}\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
96        echo "BISON_PKGDATADIR=${{github.workspace}}\bin\share\bison" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
97        echo "M4=${{github.workspace}}\bin\m4.exe" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
98    - name: Activate VS cmd (x86)
99      if: ${{ matrix.arch == 'i386' }}
100      uses: ilammy/msvc-dev-cmd@v1
101      with:
102        arch: amd64_x86
103        toolset: ${{matrix.toolset}}
104    - name: Activate VS cmd (amd64)
105      if: ${{ matrix.arch == 'amd64' }}
106      uses: ilammy/msvc-dev-cmd@v1
107      with:
108        arch: amd64
109        toolset: ${{matrix.toolset}}
110    - name: Source checkout
111      uses: actions/checkout@v2
112      with:
113        path: src
114    - name: Configure
115      run: cmake -S src -B build -G Ninja -DCMAKE_TOOLCHAIN_FILE:FILEPATH=toolchain-msvc.cmake -DARCH:STRING=${{matrix.arch}} -DENABLE_ROSTESTS=1 -DENABLE_ROSAPPS=1 -DCMAKE_BUILD_TYPE=${{matrix.buildtype}}
116    - name: Build
117      run: cmake --build build  -- -k0
118    - name: Generate ISOs
119      run: cmake --build build --target bootcd --target livecd
120    - name: Upload ISOs
121      uses: actions/upload-artifact@v2
122      with:
123        name: reactos-msvc${{matrix.toolset}}-${{matrix.arch}}-${{github.sha}}
124        path: |
125          build/bootcd.iso
126          build/livecd.iso
127    - name: Upload debug symbols
128      uses: actions/upload-artifact@v2
129      with:
130        name: reactos-syms-msvc${{matrix.toolset}}-${{matrix.arch}}-${{github.sha}}
131        path: build/msvc_pdb
132
133  build-msvc-arm:
134    strategy:
135      matrix:
136        arch: [arm]
137        toolset: ['14.2', '14.1'] # VS 2019, 2017
138      fail-fast: false
139    runs-on: windows-latest
140    steps:
141    - name: Install ninja
142      run: choco install -y ninja
143    - name: Install Flex & Bison
144      run: |
145        curl -O https://svn.reactos.org/storage/vperevertkin/flexbison.7z
146        7z x flexbison.7z -O${{github.workspace}}\bin
147        echo "${{github.workspace}}\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
148        echo "BISON_PKGDATADIR=${{github.workspace}}\bin\share\bison" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
149        echo "M4=${{github.workspace}}\bin\m4.exe" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
150    - name: Activate VS cmd (arm)
151      uses: ilammy/msvc-dev-cmd@v1
152      with:
153        arch: x86_arm
154        toolset: ${{matrix.toolset}}
155    - name: Source checkout
156      uses: actions/checkout@v2
157      with:
158        path: src
159    - name: Configure
160      run: cmake -S src -B build -G Ninja -DCMAKE_TOOLCHAIN_FILE:FILEPATH=toolchain-msvc.cmake -DARCH:STRING=${{matrix.arch}} -DENABLE_ROSTESTS=1 -DENABLE_ROSAPPS=1
161    - name: Build rapps
162      run: cmake --build build --target rapps
163
164  build-clang-cl:
165    strategy:
166      matrix:
167        arch: [i386, amd64]
168      fail-fast: false
169    runs-on: windows-latest
170    steps:
171    - name: Install ninja
172      run: choco install -y ninja
173    - name: Install LLVM (x86)
174      if: ${{ matrix.arch == 'i386' }}
175      run: |
176        choco install --x86 -y llvm
177        echo "LLVM_PATH=${env:PROGRAMFILES(X86)}\llvm\bin" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
178    - name: Install LLVM (amd64)
179      if: ${{ matrix.arch == 'amd64' }}
180      run: |
181        choco install -y llvm
182        echo "LLVM_PATH=${env:PROGRAMFILES}\llvm\bin" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
183    - name: Install Flex & Bison
184      run: |
185        curl -O https://svn.reactos.org/storage/vperevertkin/flexbison.7z
186        7z x flexbison.7z -O${{github.workspace}}\bin
187        echo "${{github.workspace}}\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
188        echo "BISON_PKGDATADIR=${{github.workspace}}\bin\share\bison" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
189        echo "M4=${{github.workspace}}\bin\m4.exe" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
190    - name: Activate VS cmd (x86)
191      if: ${{ matrix.arch == 'i386' }}
192      uses: ilammy/msvc-dev-cmd@v1
193      with:
194        arch: amd64_x86
195        toolset: '14.1' # latest masm build known to make bootable builds
196    - name: Activate VS cmd (amd64)
197      if: ${{ matrix.arch == 'amd64' }}
198      uses: ilammy/msvc-dev-cmd@v1
199      with:
200        arch: amd64
201        toolset: '14.1' # latest masm build known to make bootable builds
202    - name: Add LLVM to PATH
203      run: echo "${env:LLVM_PATH}" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
204    - name: Source checkout
205      uses: actions/checkout@v2
206      with:
207        path: src
208    - name: Configure
209      run: cmake -S src -B build -G Ninja -DCMAKE_TOOLCHAIN_FILE:FILEPATH=toolchain-msvc.cmake -DARCH:STRING=${{matrix.arch}} -DENABLE_ROSTESTS=1 -DENABLE_ROSAPPS=1 -DUSE_CLANG_CL:BOOL=TRUE
210    - name: Build
211      run: cmake --build build -- -k0
212    - name: Generate ISOs
213      run: cmake --build build --target bootcd --target livecd
214    - name: Upload ISOs
215      uses: actions/upload-artifact@v2
216      with:
217        name: reactos-clang-cl-${{matrix.arch}}-${{github.sha}}
218        path: |
219          build/bootcd.iso
220          build/livecd.iso
221    - name: Upload debug symbols
222      uses: actions/upload-artifact@v2
223      with:
224        name: reactos-syms-clang-cl-${{matrix.arch}}-${{github.sha}}
225        path: build/msvc_pdb
226
227  build-msbuild-i386:
228    name: MSBuild (i386)
229    runs-on: windows-latest
230    steps:
231    - name: Install Flex and Bison
232      run: |
233        curl -O https://svn.reactos.org/storage/vperevertkin/flexbison.7z
234        7z x flexbison.7z -O${{github.workspace}}\bin
235        echo "${{github.workspace}}\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
236        echo "BISON_PKGDATADIR=${{github.workspace}}\bin\share\bison" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
237        echo "M4=${{github.workspace}}\bin\m4.exe" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
238    - name: Add CL to PATH
239      uses: ilammy/msvc-dev-cmd@v1
240      with:
241        arch: amd64_x86
242    - uses: actions/checkout@v2
243      with:
244        path: src
245    - name: Configure
246      run: |
247        mkdir build
248        cd build
249        cmake -G "Visual Studio 16 2019" -A Win32 -DCMAKE_TOOLCHAIN_FILE:FILEPATH=toolchain-msvc.cmake -DARCH:STRING=i386 -DENABLE_ROSTESTS=1 -DENABLE_ROSAPPS=1 ${{github.workspace}}\src
250    - name: Build
251      run: cmake --build ${{github.workspace}}\build --target bootcd --target livecd
252