|
| 1 | +# ThreadX RISC-V32 GNU port: QEMU virt demo build. |
| 2 | +# |
| 3 | +# This subdirectory is opted-in by ports/risc-v32/gnu/CMakeLists.txt when |
| 4 | +# the consumer is building the threadx library for the risc-v32/gnu port. |
| 5 | +# |
| 6 | +# kernel.elf is marked EXCLUDE_FROM_ALL so that: |
| 7 | +# - The default `cmake --build .` (which builds the threadx library |
| 8 | +# and any tests the consumer wires up) is unaffected by the demo. |
| 9 | +# - Users who explicitly want the demo can `cmake --build . |
| 10 | +# --target kernel.elf` or `cmake --build . --target |
| 11 | +# check-functional-riscv32` to also drive the QEMU/GDB test runner. |
| 12 | +# |
| 13 | +# This avoids touching the root CMakeLists.txt while still keeping the |
| 14 | +# build-system entry point for the demo discoverable next to the demo |
| 15 | +# sources themselves. |
| 16 | + |
| 17 | +set(QEMU_DEMO_DIR ${CMAKE_CURRENT_LIST_DIR}) |
| 18 | + |
| 19 | +add_executable(kernel.elf EXCLUDE_FROM_ALL |
| 20 | + ${QEMU_DEMO_DIR}/demo_threadx.c |
| 21 | + ${QEMU_DEMO_DIR}/entry.s |
| 22 | + ${QEMU_DEMO_DIR}/uart.c |
| 23 | + ${QEMU_DEMO_DIR}/plic.c |
| 24 | + ${QEMU_DEMO_DIR}/hwtimer.c |
| 25 | + ${QEMU_DEMO_DIR}/trap.c |
| 26 | + ${QEMU_DEMO_DIR}/board.c |
| 27 | + ${QEMU_DEMO_DIR}/tx_initialize_low_level.S |
| 28 | +) |
| 29 | + |
| 30 | +target_link_libraries(kernel.elf PRIVATE threadx) |
| 31 | + |
| 32 | +target_include_directories(kernel.elf PRIVATE |
| 33 | + ${CMAKE_SOURCE_DIR}/common/inc |
| 34 | + ${CMAKE_SOURCE_DIR}/ports/${THREADX_ARCH}/${THREADX_TOOLCHAIN}/inc |
| 35 | + ${QEMU_DEMO_DIR} |
| 36 | +) |
| 37 | + |
| 38 | +target_link_options(kernel.elf PRIVATE |
| 39 | + -T${QEMU_DEMO_DIR}/link.lds |
| 40 | + -nostartfiles |
| 41 | + -Wl,-Map=kernel.map |
| 42 | +) |
| 43 | + |
| 44 | +# QEMU/GDB functional test runner. Optional: skipped silently if the |
| 45 | +# host has no Python 3 interpreter on PATH. |
| 46 | +find_package(Python3 COMPONENTS Interpreter) |
| 47 | +if(Python3_FOUND) |
| 48 | + add_custom_target(check-functional-riscv32 |
| 49 | + COMMAND ${Python3_EXECUTABLE} |
| 50 | + ${QEMU_DEMO_DIR}/test/azrtos_test_tx_gnu_riscv32_qemu.py |
| 51 | + --elf $<TARGET_FILE:kernel.elf> |
| 52 | + --qemu qemu-system-riscv32 |
| 53 | + --gdb gdb |
| 54 | + DEPENDS kernel.elf |
| 55 | + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} |
| 56 | + COMMENT "Running RISC-V32 QEMU/GDB functional test runner..." |
| 57 | + ) |
| 58 | +else() |
| 59 | + message(STATUS |
| 60 | + "Python3 not found; check-functional-riscv32 target unavailable.") |
| 61 | +endif() |
0 commit comments