12
12
matrix :
13
13
mode : [debug, release]
14
14
module : [builtin, loadable]
15
+ outputdir : [src, build]
16
+
17
+ env :
18
+ BUILD_DIR : build
19
+ MAKE_FLAGS : CC=clang-10 LLVM_CONFIG_PATH=llvm-config-10 -j3
20
+ QEMU_INITRAM_DESC : .github/workflows/qemu-initramfs.desc
21
+ QEMU_INITRAM_IMG : qemu-initramfs.img
22
+ QEMU_STDOUT_LOG : qemu-stdout.log
15
23
16
24
steps :
17
25
# Setup
@@ -26,16 +34,25 @@ jobs:
26
34
- run : cp .github/workflows/kernel-${{ matrix.mode }}.config .config
27
35
- if : matrix.module == 'loadable'
28
36
run : sed -i -E 's/^(CONFIG_RUST_EXAMPLE=)(y)$/\1m/g' .config
29
- - run : make CC=clang-10 LLVM_CONFIG_PATH=llvm-config-10 -j3
37
+ - if : matrix.outputdir == 'src'
38
+ run : make ${MAKE_FLAGS}
39
+ - if : matrix.outputdir == 'build'
40
+ run : |
41
+ mkdir ${BUILD_DIR}
42
+ mv .config ${BUILD_DIR}/.config
43
+ make ${MAKE_FLAGS} O=${BUILD_DIR}
30
44
31
45
# Run
32
46
- if : matrix.module == 'builtin'
33
- run : sed -i '/rust_example/d' .github/workflows/qemu-initramfs.desc
34
- - run : usr/gen_init_cpio .github/workflows/qemu-initramfs.desc > qemu-initramfs.img
35
- - run : qemu-system-x86_64 -kernel arch/x86/boot/bzImage -initrd qemu-initramfs.img -cpu Cascadelake-Server -smp 2 -append "console=ttyS0 ${{ matrix.module == 'builtin' && 'rust_example.my_i32=123321' || '' }}" -nographic -no-reboot | tee qemu-stdout.log
47
+ run : sed -i '/rust_example/d' ${QEMU_INITRAM_DESC}
48
+ - if : matrix.outputdir == 'src'
49
+ run : usr/gen_init_cpio ${QEMU_INITRAM_DESC} > ${QEMU_INITRAM_IMG}
50
+ - if : matrix.outputdir == 'build'
51
+ run : ${BUILD_DIR}/usr/gen_init_cpio ${QEMU_INITRAM_DESC} > ${QEMU_INITRAM_IMG}
52
+ - run : qemu-system-x86_64 -kernel arch/x86/boot/bzImage -initrd ${QEMU_INITRAM_IMG} -cpu Cascadelake-Server -smp 2 -append "console=ttyS0 ${{ matrix.module == 'builtin' && 'rust_example.my_i32=123321' || '' }}" -nographic -no-reboot | tee ${QEMU_STDOUT_LOG}
36
53
37
54
# Check
38
- - run : grep -F 'Rust Example (init)' qemu-stdout.log
39
- - run : " grep 'my_i32: \\ +123321' qemu-stdout.log "
55
+ - run : grep -F 'Rust Example (init)' ${QEMU_STDOUT_LOG}
56
+ - run : " grep 'my_i32: \\ +123321' ${QEMU_STDOUT_LOG}
40
57
- if: matrix.module == 'loadable'
41
- run : grep -F 'Rust Example (exit)' qemu-stdout.log
58
+ run: grep -F 'Rust Example (exit)' ${QEMU_STDOUT_LOG}
0 commit comments