about summary refs log tree commit diff stats
path: root/.github/workflows/release.yml
blob: a5d82aebabd2dcc1b31461d3336ddc336989c89a (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
### Auto build Box64 and release its binary with Github Action
name: Build and Release Box64

on:
  workflow_dispatch:
  release:
  push:
    paths:
      - "**/*.c"
      - "**/*.h"
      - "**/*.S"
      - "**/*.py"
      - "CMakeLists.txt"
      - "**/*.yml"
  pull_request:
    types: [assigned, opened, synchronize, reopened]
    paths:
      - "**/*.c"
      - "**/*.h"
      - "**/*.S"
      - "**/*.py"
      - "CMakeLists.txt"
      - "**/*.yml"

jobs:
  build:
    strategy:
      fail-fast: false
      matrix:
        platform: [X64, OTHER_ARM, RISCV, RPI4ARM64, RK3326, RK3399, RK3588, PHYTIUM, SD845, SD888, ADLINK, ARM64, ANDROID]
        type: [Release, Trace]
        os: [ubuntu-latest]
        include:
          - platform: TEGRAX1
            type: Release
            os: ubuntu-20.04
          - platform: TEGRAX1
            type: Trace
            os: ubuntu-20.04

    runs-on: ${{ matrix.os }}
    steps:
      - name: "Checkout Box64 Repository"
        uses: actions/checkout@v3

      - name: "Environment preparation"
        run: |
          sudo apt-get update
          if [[ ${{ matrix.platform }} != 'X64' && ${{ matrix.platform }} != 'OTHER_ARM' && ${{ matrix.platform }} != 'RISCV' ]]; then
            sudo apt-get -y install git cmake make python3
            if [[ ${{ matrix.platform }} == 'ANDROID' ]]; then
              wget https://dl.google.com/android/repository/android-ndk-r23b-linux.zip
              unzip android-ndk-r23b-linux.zip
              echo "BOX64_COMPILER=$PWD/android-ndk-r23b/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android31-clang" >> $GITHUB_ENV
              echo "BOX64_PLATFORM_MARCRO=-DANDROID=1 -DARM_DYNAREC=1 -DNOLOADADDR=1" >> $GITHUB_ENV
            else
              sudo apt-get -y install git gcc-aarch64-linux-gnu
              echo "BOX64_PLATFORM_MARCRO=-D${{ matrix.platform }}=1" >> $GITHUB_ENV
              echo "BOX64_COMPILER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
            fi
          else
            if [[ ${{ matrix.platform }} == 'X64' ]]; then
              echo "BOX64_PLATFORM_MARCRO=-DLD80BITS=1 -DNOALIGN=1" >> $GITHUB_ENV
              echo "BOX64_COMPILER=gcc" >> $GITHUB_ENV
              sudo apt-get -y install git cmake make python3
            elif [[ ${{ matrix.platform }} == 'RISCV' ]]; then
              echo BOX64_PLATFORM_MARCRO="-DRV64=ON" >> $GITHUB_ENV
              echo "BOX64_COMPILER=riscv64-linux-gnu-gcc" >> $GITHUB_ENV
              sudo apt-get -y install git gcc-riscv64-linux-gnu cmake make python3
            else
              echo BOX64_PLATFORM_MARCRO="-DARM_DYNAREC=ON" >> $GITHUB_ENV
              echo "BOX64_COMPILER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
              sudo apt-get -y install git gcc-aarch64-linux-gnu cmake make python3
            fi
          fi
          if [[ ${{ matrix.type }} == 'Release' ]]; then
            echo BOX64_BUILD_TYPE=Release >> $GITHUB_ENV
            echo BOX64_HAVE_TRACE=0 >> $GITHUB_ENV
          else
            echo BOX64_BUILD_TYPE=RelWithDebInfo >> $GITHUB_ENV
            echo BOX64_HAVE_TRACE=1 >> $GITHUB_ENV
          fi

      - name: "Display Build info"
        run: |
          echo "CMake Platform Macro: ${{ env.BOX64_PLATFORM_MARCRO }}"
          echo "CMake C Compiler: ${{ env.BOX64_COMPILER }}"
          echo "Build type: ${{ env.BOX64_BUILD_TYPE }}"
          echo "Trace Enabled: ${{ env.BOX64_HAVE_TRACE }}"

      - name: "Build Box64"
        run: |
          mkdir build
          cd build
          cmake .. -DCMAKE_C_COMPILER=${{ env.BOX64_COMPILER }}\
                   ${{ env.BOX64_PLATFORM_MARCRO }}\
                   -DCMAKE_BUILD_TYPE=${{ env.BOX64_BUILD_TYPE }}\
                   -DHAVE_TRACE=${{ env.BOX64_HAVE_TRACE }}\
                   -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON\
                   -DCI=${{ matrix.platform != 'ANDROID' }}
          make -j$(nproc) VERBOSE=1

      - name: "Test Box64"
        if: ${{ matrix.platform != 'TEGRAX1' }}
        run: |
          if [[ ${{ matrix.platform }} != 'X64' && ${{ matrix.platform }} != 'ANDROID' ]]; then
            mkdir qemu8.1.0
            wget -O- -q https://archive.archlinux.org/packages/q/qemu-user-static/qemu-user-static-8.1.0-2-x86_64.pkg.tar.zst | tar -I zstd -C qemu8.1.0 -xf -
            sudo cp qemu8.1.0/usr/bin/* /usr/bin/
          fi

          cd build
          if [[ ${{ matrix.platform }} == 'RISCV' ]]; then
            INTERPRETER=qemu-riscv64-static QEMU_LD_PREFIX=/usr/riscv64-linux-gnu/ ctest -j$(nproc) --rerun-failed --output-on-failure
            INTERPRETER=qemu-riscv64-static QEMU_LD_PREFIX=/usr/riscv64-linux-gnu/ BOX64_DYNAREC=0 ctest -j$(nproc) --rerun-failed --output-on-failure
            INTERPRETER=qemu-riscv64-static QEMU_LD_PREFIX=/usr/riscv64-linux-gnu/ QEMU_CPU=rv64,zba=true,zbb=true,zbc=true,zbs=true ctest -j$(nproc) --rerun-failed --output-on-failure
            INTERPRETER=qemu-riscv64-static QEMU_LD_PREFIX=/usr/riscv64-linux-gnu/ QEMU_CPU=rv64,xtheadba=true,xtheadba=true,xtheadbb=true,xtheadbs=true,xtheadcondmov=true,xtheadmemidx=true,xtheadmempair=true,xtheadfmemidx=true,xtheadmac=true,xtheadfmv=true ctest -j$(nproc) --rerun-failed --output-on-failure
          elif [[ ${{ matrix.platform }} != 'X64' && ${{ matrix.platform }} != 'ANDROID' ]]; then # AArch64
            INTERPRETER=qemu-aarch64-static QEMU_LD_PREFIX=/usr/aarch64-linux-gnu/ BOX64_DYNAREC=0 ctest -j$(nproc) --rerun-failed --output-on-failure
            INTERPRETER=qemu-aarch64-static QEMU_LD_PREFIX=/usr/aarch64-linux-gnu/ ctest -j$(nproc) --rerun-failed --output-on-failure
          elif [[ ${{ matrix.platform }} == 'ANDROID' ]]; then
            true
          else
            BOX64_DYNAREC=0 ctest -j$(nproc) --rerun-failed --output-on-failure
            ctest -j$(nproc) --rerun-failed --output-on-failure
          fi

      - name: "Upload Artifact"
        uses: actions/upload-artifact@v3
        with:
          name: box64-${{ matrix.platform }}-${{ matrix.type }}
          path: build/box64