Skip to content

Commit

Permalink
CMake: remove redundancy
Browse files Browse the repository at this point in the history
Signed-off-by: Axel Heider <[email protected]>
  • Loading branch information
Axel Heider committed Jan 29, 2024
1 parent 2c2aaa4 commit d6f53f9
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 35 deletions.
10 changes: 6 additions & 4 deletions apps/Arm/odroid_vm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,18 @@ set(linux_binary_name "${CAMKES_ARM_LINUX_DIR}/linux")

# Different device tree if compiling with VmVUSB
if(VmVUSB)
set(device_tree_src "linux-secure-vusb-dtb")
set(device_tree_src "${CAMKES_ARM_LINUX_DIR}/linux-secure-vusb-dtb")
else()
set(device_tree_src "linux-secure-dtb")
set(device_tree_src "${CAMKES_ARM_LINUX_DIR}/linux-secure-dtb")
endif()

# Sed the device tree updating the rootfs name
set(linux_dtb "${CMAKE_CURRENT_BINARY_DIR}/linux/linux-dtb")
add_custom_command(
OUTPUT linux/linux-dtb
OUTPUT "${linux_dtb}"
COMMAND
bash -c
"sed \"s/root=\\/dev\\/mmcblk1p2/root=\\/dev\\/${VmRootfs}/g\" ${CAMKES_ARM_LINUX_DIR}/${device_tree_src} > linux/linux-dtb"
"sed \"s/root=\\/dev\\/mmcblk1p2/root=\\/dev\\/${VmRootfs}/g\" ${device_tree_src} > ${linux_dtb}"
VERBATIM
)
# Create custom target for setting the dtb
Expand Down
32 changes: 17 additions & 15 deletions apps/Arm/vm_minimal/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,31 @@ if("${KernelARMPlatform}" STREQUAL "tk1")

# Different device tree if compiling with Tk1Insecure
if(Tk1Insecure)
set(device_tree_src "linux-tk1-nonsecured.dts")
set(device_tree_src "${CAMKES_ARM_LINUX_DIR}/linux-tk1-nonsecured.dts")
else()
set(device_tree_src "linux-tk1-secure.dts")
set(device_tree_src "${CAMKES_ARM_LINUX_DIR}/linux-tk1-secure.dts")
endif()

if(VmTk1InitrdRootfs)
set(linux_binary_name "linux-tk1-initrd")
set(linux_binary_name "${CAMKES_ARM_LINUX_DIR}/linux-tk1-initrd")
else()
set(linux_binary_name "linux-tk1-debian")
set(linux_binary_name "${CAMKES_ARM_LINUX_DIR}/linux-tk1-debian")
endif()

set(dtb_file "${CMAKE_CURRENT_BINARY_DIR}/linux/linux-dtb")
add_custom_command(
OUTPUT linux/linux-dtb
OUTPUT "${dtb_file}"
COMMAND
dtc -I dts -O dtb -o linux/linux-dtb ${CAMKES_ARM_LINUX_DIR}/${device_tree_src}
dtc -I dts -O dtb -o ${dtb_file} ${device_tree_src}
VERBATIM
DEPENDS ${CAMKES_ARM_LINUX_DIR}/${device_tree_src}
DEPENDS ${device_tree_src}
)
# Create custom target for setting the dtb
add_custom_target(set_dtb DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/linux/linux-dtb")
add_custom_target(set_dtb DEPENDS "${dtb_file}")

# Add Linux VM images into file server
AddToFileServer("linux" "${CAMKES_ARM_LINUX_DIR}/${linux_binary_name}")
AddToFileServer("linux-dtb" "${CMAKE_CURRENT_BINARY_DIR}/linux/linux-dtb" DEPENDS set_dtb)
AddToFileServer("linux" "${linux_binary_name}")
AddToFileServer("linux-dtb" "${dtb_file}" DEPENDS set_dtb)

elseif("${KernelARMPlatform}" STREQUAL "tx1")
set(cpp_flags "-DKERNELARMPLATFORM_TX1")
Expand Down Expand Up @@ -146,18 +148,18 @@ elseif("${KernelARMPlatform}" STREQUAL "zcu102")
)

set(dts_file "${CAMKES_VM_IMAGES_DIR}/zynqmp/${VmZynqmpPetalinuxVersion}/linux.dts")

set(dtb_file "${CMAKE_CURRENT_BINARY_DIR}/linux/linux-dtb")
add_custom_command(
OUTPUT linux/linux-dtb
OUTPUT ${dtb_file}
COMMAND
dtc -q -I dts -O dtb -o linux/linux-dtb ${dts_file}
dtc -q -I dts -O dtb -o ${dtb_file} ${dts_file}
VERBATIM
DEPENDS ${dts_file}
)

# Create custom target for setting the dtb
add_custom_target(set_dtb DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/linux/linux-dtb")
AddToFileServer("linux-dtb" "${CMAKE_CURRENT_BINARY_DIR}/linux/linux-dtb" DEPENDS set_dtb)
add_custom_target(set_dtb DEPENDS "${dtb_file}")
AddToFileServer("linux-dtb" "${dtb_file}" DEPENDS set_dtb)

list(APPEND cpp_includes "${CAMKES_VM_DIR}/components/VM_Arm/plat_include/zynqmp")
endif()
Expand Down
27 changes: 11 additions & 16 deletions apps/x86/zmq_samples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ find_package(camkes-vm-linux REQUIRED)
include(${CAMKES_VM_LINUX_HELPERS_PATH})

if(CAKEML_FILTER)
set(zmq_camkes "zmq_cakeml.camkes")
include("libs/cakeml_helpers.cmake")

# Number of vms.
Expand All @@ -37,6 +38,7 @@ if(CAKEML_FILTER)
50
)
else()
set(zmq_camkes "zmq_samples.camkes")
# Number of vms.
set(NumberVMs 3)
endif()
Expand Down Expand Up @@ -134,38 +136,31 @@ AddZMQBinary(pub)
AddZMQBinary(sub)

foreach(i RANGE ${NumberVMsLess1})
set(overlay_target "overlay_vm${i}")
set(rootfs_target "rootfs_target_vm${i}")
if(NOT CAKEML_FILTER)
AddFileToOverlayDir(
"S91zmq_bench"
${CMAKE_CURRENT_SOURCE_DIR}/src/user/zmq_bench_${i}.sh
"etc/init.d"
overlay_vm${i}
"${overlay_target}"
)
endif()
# Add the buildroot overlay to our bare rootfs image
AddOverlayDirToRootfs(
overlay_vm${i}
${rootfs_file}
"${overlay_target}"
"${rootfs_file}"
"buildroot"
"rootfs_install"
output_rootfs_location_vm${i}
rootfs_target_vm${i}
)
AddToFileServer(
"vm${i}_rootfs.cpio"
"${output_rootfs_location_vm${i}}"
DEPENDS
rootfs_target_vm${i}
rootfs_img
"${rootfs_target}"
)
AddToFileServer("vm${i}_rootfs.cpio" "${rootfs_img}" DEPENDS "${rootfs_target}")
endforeach()

# Decompress Linux Kernel image and add to file server
DecompressLinuxKernel(extract_linux_kernel decompressed_kernel ${kernel_file})
AddToFileServer("bzimage" ${decompressed_kernel} DEPENDS extract_linux_kernel)

# Initialise CAmkES Root Server with addition CPP includes
if(CAKEML_FILTER)
DeclareCAmkESVMRootServer(zmq_cakeml.camkes)
else()
DeclareCAmkESVMRootServer(zmq_samples.camkes)
endif()
DeclareCAmkESVMRootServer("${zmq_camkes}")

0 comments on commit d6f53f9

Please sign in to comment.