]> git.sesse.net Git - stockfish/blob - .github/workflows/stockfish_arm_binaries.yml
GitHub Action: upload ARM artifacts
[stockfish] / .github / workflows / stockfish_arm_binaries.yml
1 name: Stockfish
2 on:
3   workflow_call:
4 jobs:
5   Stockfish:
6     name: ${{ matrix.config.name }} ${{ matrix.binaries }}
7     runs-on: ${{ matrix.config.os }}
8     env:
9       COMPILER: ${{ matrix.config.compiler }}
10       COMP: ${{ matrix.config.comp }}
11       EMU: ${{ matrix.config.emu }}
12       EXT: ${{ matrix.config.ext }}
13       OS: ${{ matrix.config.os }}
14       BINARY: ${{ matrix.binaries }}
15     strategy:
16       matrix:
17         config:
18           - {
19               name: "Android NDK aarch64",
20               os: ubuntu-20.04,
21               compiler: aarch64-linux-android21-clang++,
22               emu: qemu-aarch64,
23               comp: ndk,
24               shell: 'bash {0}'
25             }
26           - {
27               name: "Android NDK arm",
28               os: ubuntu-20.04,
29               compiler: armv7a-linux-androideabi21-clang++,
30               emu: qemu-arm,
31               comp: ndk,
32               shell: 'bash {0}'
33             }
34         binaries:
35           - armv8
36           - armv7
37           - armv7-neon
38         exclude:
39           - binaries: armv8
40             config: {compiler: armv7a-linux-androideabi21-clang++}
41           - binaries: armv7
42             config: {compiler: aarch64-linux-android21-clang++}
43           - binaries: armv7-neon
44             config: {compiler: aarch64-linux-android21-clang++}
45     defaults:
46       run:
47         working-directory: src
48         shell: ${{ matrix.config.shell }}
49     steps:
50       - uses: actions/checkout@v3
51         with:
52           fetch-depth: 0
53
54       - name: Download required linux packages
55         if: runner.os == 'Linux'
56         run: |
57           sudo apt update
58           sudo apt install qemu-user
59
60       - name: Download the used network from the fishtest framework
61         run: |
62           make net
63
64       - name: Check compiler
65         run: |
66           if [ $COMP == ndk ]; then
67             ANDROID_ROOT=/usr/local/lib/android
68             ANDROID_SDK_ROOT=$ANDROID_ROOT/sdk
69             SDKMANAGER=$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager
70             echo "y" | $SDKMANAGER "ndk;21.4.7075529"
71             ANDROID_NDK_ROOT=$ANDROID_SDK_ROOT/ndk/21.4.7075529
72             export PATH=$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH
73           fi
74           $COMPILER -v
75
76       - name: Test help target
77         run: |
78           make help
79
80       # Compile profile guided builds
81
82       - name: Compile ${{ matrix.binaries }} build
83         run: |
84           if [ $COMP == ndk ]; then
85             ANDROID_ROOT=/usr/local/lib/android
86             ANDROID_SDK_ROOT=$ANDROID_ROOT/sdk
87             SDKMANAGER=$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager
88             echo "y" | $SDKMANAGER "ndk;21.4.7075529"
89             ANDROID_NDK_ROOT=$ANDROID_SDK_ROOT/ndk/21.4.7075529
90             export PATH=$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH
91             export LDFLAGS="-static -Wno-unused-command-line-argument"
92           fi
93           make clean
94           make -j2 profile-build ARCH=$BINARY COMP=$COMP WINE_PATH=$EMU
95           make strip ARCH=$BINARY COMP=$COMP
96           mv ./stockfish$EXT ../stockfish-android-$BINARY$EXT
97
98       - name: Remove non src files
99         run: rm -f *.o .depend *.nnue
100
101       - name: Create tar archive.
102         run: |
103           cd ..
104           mkdir stockfish
105           cp -r src stockfish/
106           cp stockfish-android-$BINARY$EXT stockfish/
107           cp "Top CPU Contributors.txt" stockfish/
108           cp Copying.txt stockfish/
109           cp AUTHORS stockfish/
110           tar -cvf stockfish-android-$BINARY.tar stockfish
111
112       - name: Upload binaries
113         uses: actions/upload-artifact@v3
114         with:
115           name: stockfish-android-${{ matrix.binaries }}
116           path: |
117             stockfish-android-${{ matrix.binaries }}.tar