!yamlscript/v0:

:use common: :all
:: workflow-setup()

jobs:
  xcompile:
    :: setup-job('rarearchs' 'xcompile')
    name: ${{matrix.arch}}
    runs-on: ubuntu-24.04
    strategy:
      fail-fast: false
      matrix:
        include:
          - {arch: aarch64    , tc: aarch64-linux-gnu} # this is armv8
          - {arch: armv7      , tc: arm-linux-gnueabihf, flags: -march=armv7+fp}
          - {arch: armv6      , tc: arm-linux-gnueabi, flags: -march=armv6+fp}
          - {arch: armv5      , tc: arm-linux-gnueabi, flags: -march=armv5te+fp}
          - {arch: armv4      , tc: arm-linux-gnueabi, flags: -march=armv4}
          - {arch: loongarch64, tc: loongarch64-linux-gnu, version: -14}
          - {arch: mips       , tc: mips-linux-gnu}
          - {arch: mipsel     , tc: mipsel-linux-gnu}
          - {arch: mips64     , tc: mips64-linux-gnuabi64}
          - {arch: mips64el   , tc: mips64el-linux-gnuabi64}
          - {arch: riscv64    , tc: riscv64-linux-gnu}
          - {arch: s390x      , tc: s390x-linux-gnu}
          - {arch: ppc        , tc: powerpc-linux-gnu}
          - {arch: ppc64      , tc: powerpc64-linux-gnu}
          - {arch: ppc64le    , tc: powerpc64le-linux-gnu}
          - {arch: sparc64    , tc: sparc64-linux-gnu}
          # TODO xtensa!
    steps:
    - :: checkout-action
    - name: install
      run: |
        sudo apt-get update
        sudo apt-get install -y \
            gcc${{matrix.version}}-${{matrix.tc}} \
            g++${{matrix.version}}-${{matrix.tc}} \
            qemu-user-static
    - name: info
      run: |
        ${{matrix.tc}}-g++${{matrix.version}} --version
        ${{matrix.tc}}-g++${{matrix.version}} -dM -E - </dev/null | sort
        ${{matrix.tc}}-g++${{matrix.version}} ${{matrix.flags}} -dM -E - </dev/null | sort
    - :: xcompile-steps("${{matrix.arch}}" "Debug"   "11" "${{matrix.flags}}")
    - :: xcompile-steps("${{matrix.arch}}" "Release" "11" "${{matrix.flags}}")
    - :: xcompile-steps("${{matrix.arch}}" "Debug"   "20" "${{matrix.flags}}")
    - :: xcompile-steps("${{matrix.arch}}" "Release" "20" "${{matrix.flags}}")
