|
8 | 8 |
|
9 | 9 | jobs: |
10 | 10 | build: |
11 | | - runs-on: windows-latest |
| 11 | + strategy: |
| 12 | + matrix: |
| 13 | + os: [windows-latest, ubuntu-latest, macos-latest] |
| 14 | + fail-fast: false # Don't cancel other jobs if one fails |
| 15 | + runs-on: ${{ matrix.os }} |
| 16 | + continue-on-error: ${{ matrix.os != 'windows-latest' }} # Allow Linux/macOS to fail |
12 | 17 |
|
13 | 18 | steps: |
14 | 19 | - uses: actions/checkout@v4 |
15 | 20 |
|
16 | | - - name: Install Rust 1.88.0 |
17 | | - uses: dtolnay/rust-toolchain@stable |
18 | | - with: |
19 | | - toolchain: "1.88.0" |
20 | | - |
21 | 21 | - name: Build project |
22 | 22 | run: cargo build --verbose |
23 | 23 |
|
24 | 24 | test: |
25 | | - runs-on: windows-latest |
| 25 | + strategy: |
| 26 | + matrix: |
| 27 | + os: [windows-latest, ubuntu-latest, macos-latest] |
| 28 | + fail-fast: false # Don't cancel other jobs if one fails |
| 29 | + runs-on: ${{ matrix.os }} |
| 30 | + continue-on-error: ${{ matrix.os != 'windows-latest' }} # Allow Linux/macOS to fail |
26 | 31 | needs: build |
27 | 32 |
|
28 | 33 | steps: |
29 | 34 | - uses: actions/checkout@v4 |
30 | 35 |
|
31 | | - - name: Install Rust 1.88.0 |
32 | | - uses: dtolnay/rust-toolchain@stable |
33 | | - with: |
34 | | - toolchain: "1.88.0" |
35 | | - |
36 | 36 | - name: Run tests |
37 | 37 | run: cargo test --verbose |
38 | 38 |
|
39 | 39 | run-and-execute: |
40 | | - runs-on: windows-latest |
41 | | - |
| 40 | + strategy: |
| 41 | + matrix: |
| 42 | + include: |
| 43 | + - os: windows-latest |
| 44 | + target: windows-x64 |
| 45 | + nasm_format: win64 |
| 46 | + executable_ext: .exe |
| 47 | + continue_on_error: false |
| 48 | + - os: ubuntu-latest |
| 49 | + target: linux-x64 |
| 50 | + nasm_format: elf64 |
| 51 | + executable_ext: "" |
| 52 | + continue_on_error: true |
| 53 | + - os: macos-latest |
| 54 | + target: macos-x64 |
| 55 | + nasm_format: macho64 |
| 56 | + executable_ext: "" |
| 57 | + continue_on_error: true |
| 58 | + fail-fast: false # Don't cancel other jobs if one fails |
| 59 | + runs-on: ${{ matrix.os }} |
| 60 | + continue-on-error: ${{ matrix.continue_on_error }} # Allow Linux/macOS to fail |
| 61 | + needs: test |
| 62 | + |
42 | 63 | steps: |
43 | 64 | - uses: actions/checkout@v4 |
44 | | - |
45 | | - - name: Install Rust 1.88.0 |
46 | | - uses: dtolnay/rust-toolchain@stable |
47 | | - with: |
48 | | - toolchain: "1.88.0" |
49 | | - |
50 | | - - name: Install NASM |
| 65 | + |
| 66 | + # Windows-specific dependencies |
| 67 | + - name: Install NASM (Windows) |
| 68 | + if: matrix.os == 'windows-latest' |
51 | 69 | run: | |
52 | 70 | choco install nasm |
53 | 71 | & "C:\Program Files\NASM\nasm.exe" -v |
54 | 72 | |
55 | | - - name: Install GCC (MinGW) |
| 73 | + # Linux-specific dependencies |
| 74 | + - name: Install NASM and GCC (Linux) |
| 75 | + if: matrix.os == 'ubuntu-latest' |
56 | 76 | run: | |
57 | | - choco install mingw |
| 77 | + sudo apt-get update |
| 78 | + sudo apt-get install -y nasm gcc |
| 79 | + nasm -v |
58 | 80 | gcc --version |
59 | 81 | |
60 | | - - name: Run compiler to generate ASM |
61 | | - run: cargo run |
| 82 | + # macOS-specific dependencies |
| 83 | + - name: Install NASM and GCC (macOS) |
| 84 | + if: matrix.os == 'macos-latest' |
| 85 | + run: | |
| 86 | + brew install nasm gcc |
| 87 | + nasm -v |
| 88 | + gcc --version |
| 89 | + |
| 90 | + - name: Run compiler to generate ASM for target |
| 91 | + run: cargo run -- --target ${{ matrix.target }} |
| 92 | + |
| 93 | + # Windows assembly and linking |
| 94 | + - name: Compile ASM to object file (Windows) |
| 95 | + if: matrix.os == 'windows-latest' |
| 96 | + run: '& "C:\Program Files\NASM\nasm.exe" -f ${{ matrix.nasm_format }} build/output.asm -o build/output.obj' |
| 97 | + |
| 98 | + - name: Link and create executable (Windows) |
| 99 | + if: matrix.os == 'windows-latest' |
| 100 | + run: gcc -o build/output${{ matrix.executable_ext }} build/output.obj -lmsvcrt |
| 101 | + |
| 102 | + # Linux assembly and linking |
| 103 | + - name: Compile ASM to object file (Linux) |
| 104 | + if: matrix.os == 'ubuntu-latest' |
| 105 | + run: nasm -f ${{ matrix.nasm_format }} build/output.asm -o build/output.o |
| 106 | + |
| 107 | + - name: Link and create executable (Linux) |
| 108 | + if: matrix.os == 'ubuntu-latest' |
| 109 | + run: gcc -o build/output${{ matrix.executable_ext }} build/output.o -no-pie |
| 110 | + |
| 111 | + # macOS assembly and linking |
| 112 | + - name: Compile ASM to object file (macOS) |
| 113 | + if: matrix.os == 'macos-latest' |
| 114 | + run: nasm -f ${{ matrix.nasm_format }} build/output.asm -o build/output.o |
62 | 115 |
|
63 | | - - name: Compile ASM to object file |
64 | | - run: '& "C:\Program Files\NASM\nasm.exe" -f win64 build/output.asm -o output.obj' |
| 116 | + - name: Link and create executable (macOS) |
| 117 | + if: matrix.os == 'macos-latest' |
| 118 | + run: gcc -o build/output${{ matrix.executable_ext }} build/output.o |
65 | 119 |
|
66 | | - - name: Link and create executable |
67 | | - run: gcc -o build/output.exe build/output.obj -lmsvcrt |
| 120 | + # Execute the binary (all platforms) |
| 121 | + - name: Execute the binary (Windows) |
| 122 | + if: matrix.os == 'windows-latest' |
| 123 | + run: .\build\output${{ matrix.executable_ext }} |
68 | 124 |
|
69 | | - - name: Execute the binary |
70 | | - run: .\build\output.exe |
| 125 | + - name: Execute the binary (Linux/macOS) |
| 126 | + if: matrix.os != 'windows-latest' |
| 127 | + run: ./build/output${{ matrix.executable_ext }} |
0 commit comments