Ensure execute_process is error checked

Check the return value from execute_process calls and fail
with an appropriate message.

This makes debugging of cmake failures much easier.

Signed-off-by: Ben Leslie <benno@brkawy.com>
This commit is contained in:
Ben Leslie
2021-01-19 01:12:48 +00:00
committed by Kent McLeod
parent 502dec1cd3
commit e11ef82663
2 changed files with 24 additions and 1 deletions

View File

@@ -135,14 +135,22 @@ if(DEFINED KernelDTSList AND (NOT "${KernelDTSList}" STREQUAL ""))
execute_process(
COMMAND
${DTC_TOOL} -q -I dts -O dtb -o ${KernelDTBPath} ${KernelDTSIntermediate}
RESULT_VARIABLE error
)
if(error)
message(FATAL_ERROR "Failed to compile DTS to DTB: ${KernelDTBPath}")
endif()
# Track the size of the DTB for downstream tools
execute_process(
COMMAND
${STAT_TOOL} -c '%s' ${KernelDTBPath}
OUTPUT_VARIABLE KernelDTBSize
OUTPUT_STRIP_TRAILING_WHITESPACE
RESULT_VARIABLE error
)
if(error)
message(FATAL_ERROR "Failed to determine KernelDTBSize: ${KernelDTBPath}")
endif()
string(
REPLACE
"\'"

View File

@@ -34,7 +34,14 @@ if(KernelPlatformQEMUArmVirt)
set(KernelArmCortexA53 ON)
set(KernelArchArmV8a ON)
endif()
execute_process(COMMAND qemu-system-${QEMU_ARCH} -version OUTPUT_VARIABLE QEMU_VERSION_STR)
execute_process(
COMMAND qemu-system-${QEMU_ARCH} -version
OUTPUT_VARIABLE QEMU_VERSION_STR
RESULT_VARIABLE error
)
if(error)
message(FATAL_ERROR "Failed to determine qemu version (qemu-system-${QEMU_ARCH})")
endif()
string(
REGEX
MATCH
@@ -69,14 +76,22 @@ if(KernelPlatformQEMUArmVirt)
${QEMU_BINARY} -machine virt,dumpdtb=${DTBPath},${QEMU_VIRT_OPTION} -m ${QEMU_MEMORY}
-cpu ${ARM_CPU} -smp ${QEMU_SMP_OPTION} -nographic
ERROR_VARIABLE QEMU_OUTPUT_MESSAGE
RESULT_VARIABLE error
)
string(STRIP ${QEMU_OUTPUT_MESSAGE} QEMU_OUTPUT_MESSAGE)
message(STATUS ${QEMU_OUTPUT_MESSAGE})
if(error)
message(FATAL_ERROR "Failed to dump DTB using ${QEMU_BINARY})")
endif()
execute_process(
COMMAND
dtc -q -I dtb -O dts ${DTBPath}
OUTPUT_FILE ${DTSPath}
RESULT_VARIABLE error
)
if(error)
message(FATAL_ERROR "Failed to convert DTB to DTS (${DTBPath})")
endif()
list(APPEND KernelDTSList "${DTSPath}")
list(APPEND KernelDTSList "src/plat/qemu-arm-virt/overlay-qemu-arm-virt.dts")
if(KernelArmHypervisorSupport)