name: Stockfish on: workflow_call: jobs: Stockfish: name: ${{ matrix.config.name }} ${{ matrix.binaries }} runs-on: ${{ matrix.config.os }} env: COMPILER: ${{ matrix.config.compiler }} COMP: ${{ matrix.config.comp }} EMU: ${{ matrix.config.emu }} EXT: ${{ matrix.config.ext }} OS: ${{ matrix.config.os }} BINARY: ${{ matrix.binaries }} strategy: matrix: config: - name: Android NDK aarch64 os: ubuntu-22.04 compiler: aarch64-linux-android21-clang++ emu: qemu-aarch64 comp: ndk shell: bash {0} - name: Android NDK arm os: ubuntu-22.04 compiler: armv7a-linux-androideabi21-clang++ emu: qemu-arm comp: ndk shell: bash {0} binaries: - armv8 - armv7 - armv7-neon exclude: - binaries: armv8 config: {compiler: armv7a-linux-androideabi21-clang++} - binaries: armv7 config: {compiler: aarch64-linux-android21-clang++} - binaries: armv7-neon config: {compiler: aarch64-linux-android21-clang++} defaults: run: working-directory: src shell: ${{ matrix.config.shell }} steps: - uses: actions/checkout@v3 with: fetch-depth: 0 - name: Download required linux packages if: runner.os == 'Linux' run: | sudo apt update sudo apt install qemu-user - name: Install NDK if: runner.os == 'Linux' run: | if [ $COMP == ndk ]; then NDKV="21.4.7075529" ANDROID_ROOT=/usr/local/lib/android ANDROID_SDK_ROOT=$ANDROID_ROOT/sdk SDKMANAGER=$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager echo "y" | $SDKMANAGER "ndk;$NDKV" ANDROID_NDK_ROOT=$ANDROID_SDK_ROOT/ndk/$NDKV ANDROID_NDK_BIN=$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin echo "ANDROID_NDK_BIN=$ANDROID_NDK_BIN" >> $GITHUB_ENV fi - name: Download the used network from the fishtest framework run: make net - name: Check compiler run: | if [ $COMP == ndk ]; then export PATH=${{ env.ANDROID_NDK_BIN }}:$PATH fi $COMPILER -v - name: Test help target run: make help - name: Check git run: git --version # Compile profile guided builds - name: Compile ${{ matrix.binaries }} build run: | if [ $COMP == ndk ]; then export PATH=${{ env.ANDROID_NDK_BIN }}:$PATH export LDFLAGS="-static -Wno-unused-command-line-argument" fi make clean make -j2 profile-build ARCH=$BINARY COMP=$COMP WINE_PATH=$EMU make strip ARCH=$BINARY COMP=$COMP mv ./stockfish$EXT ../stockfish-android-$BINARY$EXT - name: Remove non src files run: rm -f *.o .depend *.nnue - name: Download wiki run: | git clone https://github.com/official-stockfish/Stockfish.wiki.git ../wiki cd ../wiki rm -rf .git - name: Create tar archive. run: | cd .. mkdir stockfish cp -r wiki stockfish/ cp -r src stockfish/ cp stockfish-android-$BINARY$EXT stockfish/ cp "Top CPU Contributors.txt" stockfish/ cp Copying.txt stockfish/ cp AUTHORS stockfish/ tar -cvf stockfish-android-$BINARY.tar stockfish - name: Upload binaries uses: actions/upload-artifact@v3 with: name: stockfish-android-${{ matrix.binaries }} path: stockfish-android-${{ matrix.binaries }}.tar