cmake: cleanup qemu runner configuration

All runner logic was implemented in qemu.cmake, remove the generic stuff
and make qemu.cmake qemu specific.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit is contained in:
Anas Nashif 2017-12-21 16:45:45 -05:00 committed by Anas Nashif
commit fd276aeb42
2 changed files with 174 additions and 178 deletions

View file

@ -811,6 +811,14 @@ endif()
if(EMU_PLATFORM) if(EMU_PLATFORM)
include($ENV{ZEPHYR_BASE}/cmake/emu/${EMU_PLATFORM}.cmake) include($ENV{ZEPHYR_BASE}/cmake/emu/${EMU_PLATFORM}.cmake)
else()
add_custom_target(run
COMMAND
${CMAKE_COMMAND} -E echo
"==================================================="
"Emulation/Simulation not supported with this board."
"==================================================="
)
endif() endif()
add_subdirectory(cmake/flash) add_subdirectory(cmake/flash)

View file

@ -1,57 +1,54 @@
if(EMU_PLATFORM) if("${ARCH}" STREQUAL "x86")
# TODO: Support more emulators
if("${ARCH}" STREQUAL "x86")
set_ifndef(QEMU_binary_suffix i386) set_ifndef(QEMU_binary_suffix i386)
else() else()
set_ifndef(QEMU_binary_suffix ${ARCH}) set_ifndef(QEMU_binary_suffix ${ARCH})
endif() endif()
find_program( find_program(
QEMU QEMU
qemu-system-${QEMU_binary_suffix} qemu-system-${QEMU_binary_suffix}
) )
set(qemu_targets set(qemu_targets
run run
debugserver debugserver
) )
# We can set "default" value for QEMU_PTY & QEMU_PIPE on cmake invocation. # We can set "default" value for QEMU_PTY & QEMU_PIPE on cmake invocation.
if(QEMU_PTY) if(QEMU_PTY)
# Send console output to a pseudo-tty, used for running automated tests # Send console output to a pseudo-tty, used for running automated tests
set(CMAKE_QEMU_SERIAL0 pty) set(CMAKE_QEMU_SERIAL0 pty)
else() else()
if(QEMU_PIPE) if(QEMU_PIPE)
# Send console output to a pipe, used for running automated tests # Send console output to a pipe, used for running automated tests
set(CMAKE_QEMU_SERIAL0 pipe:${QEMU_PIPE}) set(CMAKE_QEMU_SERIAL0 pipe:${QEMU_PIPE})
else() else()
set(CMAKE_QEMU_SERIAL0 mon:stdio) set(CMAKE_QEMU_SERIAL0 mon:stdio)
endif() endif()
endif() endif()
# But also can set QEMU_PTY & QEMU_PIPE on *make* (not cmake) invocation, # But also can set QEMU_PTY & QEMU_PIPE on *make* (not cmake) invocation,
# like it was before cmake. # like it was before cmake.
set(QEMU_FLAGS -serial \${if \${QEMU_PTY}, pty, \${if \${QEMU_PIPE}, pipe:\${QEMU_PIPE}, ${CMAKE_QEMU_SERIAL0}}}) set(QEMU_FLAGS -serial \${if \${QEMU_PTY}, pty, \${if \${QEMU_PIPE}, pipe:\${QEMU_PIPE}, ${CMAKE_QEMU_SERIAL0}}})
# Add a BT serial device when building for bluetooth, unless the # Add a BT serial device when building for bluetooth, unless the
# application explicitly opts out with NO_QEMU_SERIAL_BT_SERVER. # application explicitly opts out with NO_QEMU_SERIAL_BT_SERVER.
if(CONFIG_BT) if(CONFIG_BT)
if(NOT NO_QEMU_SERIAL_BT_SERVER) if(NOT NO_QEMU_SERIAL_BT_SERVER)
list(APPEND QEMU_FLAGS -serial unix:/tmp/bt-server-bredr) list(APPEND QEMU_FLAGS -serial unix:/tmp/bt-server-bredr)
endif() endif()
endif() endif()
# If we are running a networking application in QEMU, then set proper # If we are running a networking application in QEMU, then set proper
# QEMU variables. This also allows two QEMUs to be hooked together and # QEMU variables. This also allows two QEMUs to be hooked together and
# pass data between them. The QEMU flags are not set for standalone # pass data between them. The QEMU flags are not set for standalone
# tests defined by CONFIG_NET_TEST. # tests defined by CONFIG_NET_TEST.
if(CONFIG_NETWORKING) if(CONFIG_NETWORKING)
if(CONFIG_NET_SLIP_TAP) if(CONFIG_NET_SLIP_TAP)
set(QEMU_NET_STACK 1) set(QEMU_NET_STACK 1)
endif() endif()
endif() endif()
if(QEMU_NET_STACK) if(QEMU_NET_STACK)
list(APPEND qemu_targets list(APPEND qemu_targets
client client
server server
@ -135,33 +132,33 @@ if(EMU_PLATFORM)
# TODO: Support cleanup of the monitor_15_4 process # TODO: Support cleanup of the monitor_15_4 process
) )
endif() endif()
endif(QEMU_NET_STACK) endif(QEMU_NET_STACK)
if(CONFIG_X86_IAMCU) if(CONFIG_X86_IAMCU)
list(APPEND PRE_QEMU_COMMANDS list(APPEND PRE_QEMU_COMMANDS
COMMAND COMMAND
${PYTHON_EXECUTABLE} ${PYTHON_EXECUTABLE}
$ENV{ZEPHYR_BASE}/scripts/qemu-machine-hack.py $ENV{ZEPHYR_BASE}/scripts/qemu-machine-hack.py
$<TARGET_FILE:${logical_target_for_zephyr_elf}> $<TARGET_FILE:${logical_target_for_zephyr_elf}>
) )
endif() endif()
if(NOT QEMU_PIPE) if(NOT QEMU_PIPE)
set(QEMU_PIPE_COMMENT "\nTo exit from QEMU enter: 'CTRL+a, x'\n") set(QEMU_PIPE_COMMENT "\nTo exit from QEMU enter: 'CTRL+a, x'\n")
endif() endif()
# Use flags passed in from the environment # Use flags passed in from the environment
set(env_qemu $ENV{QEMU_EXTRA_FLAGS}) set(env_qemu $ENV{QEMU_EXTRA_FLAGS})
separate_arguments(env_qemu) separate_arguments(env_qemu)
list(APPEND QEMU_EXTRA_FLAGS ${env_qemu}) list(APPEND QEMU_EXTRA_FLAGS ${env_qemu})
list(APPEND MORE_FLAGS_FOR_debugserver -s -S) list(APPEND MORE_FLAGS_FOR_debugserver -s -S)
set_ifndef(QEMU_KERNEL_OPTION set_ifndef(QEMU_KERNEL_OPTION
"-kernel;$<TARGET_FILE:${logical_target_for_zephyr_elf}>" "-kernel;$<TARGET_FILE:${logical_target_for_zephyr_elf}>"
) )
foreach(target ${qemu_targets}) foreach(target ${qemu_targets})
add_custom_target(${target} add_custom_target(${target}
${PRE_QEMU_COMMANDS} ${PRE_QEMU_COMMANDS}
${PRE_QEMU_COMMANDS_FOR_${target}} ${PRE_QEMU_COMMANDS_FOR_${target}}
@ -178,13 +175,4 @@ if(EMU_PLATFORM)
COMMENT "${QEMU_PIPE_COMMENT}[QEMU] CPU: ${QEMU_CPU_TYPE_${ARCH}}" COMMENT "${QEMU_PIPE_COMMENT}[QEMU] CPU: ${QEMU_CPU_TYPE_${ARCH}}"
USES_TERMINAL USES_TERMINAL
) )
endforeach() endforeach()
else()
add_custom_target(run
COMMAND
${CMAKE_COMMAND} -E echo
"==================================================="
"Emulation/Simulation not supported with this board."
"==================================================="
)
endif()