Skip to content

Commit

Permalink
CMake: use params for DefineCAmkESVMFileServer()
Browse files Browse the repository at this point in the history
- avoid calling AddToFileServer(), build the file list as CMake variable
  instead.
- clean up the CMake target dependencies, avoid explicit references
  to (helper) targets, when this is not necessary.

Signed-off-by: Axel Heider <[email protected]>
  • Loading branch information
Axel Heider committed Mar 16, 2024
1 parent a114a67 commit 6dfdae4
Show file tree
Hide file tree
Showing 14 changed files with 231 additions and 158 deletions.
12 changes: 4 additions & 8 deletions apps/Arm/odroid_vm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ add_subdirectory(components/spi)
add_subdirectory(components/clk)
add_subdirectory(components/timer)

set(linux_binary_name "${CAMKES_ARM_LINUX_DIR}/linux")

# Different device tree if compiling with VmVUSB
if(VmVUSB)
set(device_tree_src "${CAMKES_ARM_LINUX_DIR}/linux-secure-vusb-dtb")
Expand All @@ -49,14 +47,12 @@ add_custom_command(
bash -c
"sed \"s/root=\\/dev\\/mmcblk1p2/root=\\/dev\\/${VmRootfs}/g\" ${device_tree_src} > ${linux_dtb}"
VERBATIM
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 Linux VM images into file server
AddToFileServer("linux" "${linux_binary_name}")
AddToFileServer("linux-dtb" "${CMAKE_CURRENT_BINARY_DIR}/linux/linux-dtb" DEPENDS set_dtb)
DefineCAmkESVMFileServer()
# Create file server with VM images. There is an implicit dependency on the
# input files, so the rules above will be invoked to generate/update the files.
DefineCAmkESVMFileServer(FILES "linux:${CAMKES_ARM_LINUX_DIR}/linux" "linux-dtb:${linux_dtb}")

# Declare odroid root server
DeclareCAmkESRootserver(
Expand Down
16 changes: 10 additions & 6 deletions apps/Arm/vm_cross_connector/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ elseif("${KernelARMPlatform}" STREQUAL "qemu-arm-virt")
endif()
endif()

AddToFileServer("linux" "${CAMKES_VM_IMAGES_DIR}/${KernelARMPlatform}/linux")

if(BUILD_CROSSVM)
set(rootfs_file "${CAMKES_VM_IMAGES_DIR}/${KernelARMPlatform}/rootfs.cpio.gz")
# Checkout and configure linux to build crossvm module
Expand Down Expand Up @@ -195,17 +193,16 @@ AddFileToOverlayDir(
overlay
)

# Construct new rootfs
# Construct new rootfs.
AddOverlayDirToRootfs(
overlay
${rootfs_file}
"buildroot"
"rootfs_install"
output_overlayed_rootfs_location
rootfs_target
rootfs_target # helper CMake target to be created, not used
GZIP
)
AddToFileServer("linux-initrd" ${output_overlayed_rootfs_location} DEPENDS rootfs_target)

AddCamkesCPPFlag(
cpp_flags
Expand All @@ -218,7 +215,14 @@ AddCamkesCPPFlag(
VmVirtioNetVirtqueue
)

DefineCAmkESVMFileServer()
# Create file server with VM images. There is an implicit dependency on the
# input files, so the rules above will be invoked to generate/update the files.
# There is no need to specify an explicit dependency on the helper target
# 'rootfs_target'.
DefineCAmkESVMFileServer(
FILES "linux:${CAMKES_VM_IMAGES_DIR}/${KernelARMPlatform}/linux"
"linux-initrd:${output_overlayed_rootfs_location}"
)

CAmkESAddImportPath(${KernelARMPlatform})

Expand Down
15 changes: 9 additions & 6 deletions apps/Arm/vm_introspect/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ elseif("${KernelARMPlatform}" STREQUAL "qemu-arm-virt")

endif()

AddToFileServer("linux" "${CAMKES_VM_IMAGES_DIR}/${KernelARMPlatform}/linux")

set(rootfs_file "${CAMKES_VM_IMAGES_DIR}/${KernelARMPlatform}/rootfs_crossvm.cpio.gz")

ExternalProject_Add(
Expand Down Expand Up @@ -104,11 +102,18 @@ AddOverlayDirToRootfs(
"buildroot"
"rootfs_install"
output_overlayed_rootfs_location
rootfs_target
rootfs_target # helper CMake target to be created, not used
GZIP
)

AddToFileServer("linux-initrd" ${output_overlayed_rootfs_location} DEPENDS rootfs_target)
# Create file server with VM images. There is an implicit dependency on the
# input files, so the rules above will be invoked to generate/update the files.
# There is no need to specify an explicit dependency on the helper target
# 'rootfs_target'.
DefineCAmkESVMFileServer(
FILES "linux:${CAMKES_VM_IMAGES_DIR}/${KernelARMPlatform}/linux"
"linux-initrd:${output_overlayed_rootfs_location}"
)

AddCamkesCPPFlag(
cpp_flags
Expand All @@ -121,8 +126,6 @@ AddCamkesCPPFlag(
VmVirtioNetVirtqueue
)

DefineCAmkESVMFileServer()

CAmkESAddImportPath(${KernelARMPlatform})

# Define our VM Component with out cross vm dataports glue code
Expand Down
85 changes: 46 additions & 39 deletions apps/Arm/vm_minimal/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ include(${CAMKES_ARM_VM_HELPERS_PATH})

set(cpp_includes "${CAMKES_VM_DIR}/components/VM_Arm")

# On some platforms, there is no dedicated rootfs, because it's part of the
# Linux kernel image.
set(rootfs_file "")

# Create our CPP Flags based on ARM VM config variables
if("${KernelARMPlatform}" STREQUAL "tk1")
set(cpp_flags "-DKERNELARMPLATFORM_TK1")
Expand All @@ -23,10 +27,11 @@ if("${KernelARMPlatform}" STREQUAL "tk1")
set(device_tree_src "${CAMKES_ARM_LINUX_DIR}/linux-tk1-secure.dts")
endif()

# kernel image contains rootfs
if(VmTk1InitrdRootfs)
set(linux_binary_name "${CAMKES_ARM_LINUX_DIR}/linux-tk1-initrd")
set(linux_image "${CAMKES_ARM_LINUX_DIR}/linux-tk1-initrd")
else()
set(linux_binary_name "${CAMKES_ARM_LINUX_DIR}/linux-tk1-debian")
set(linux_image "${CAMKES_ARM_LINUX_DIR}/linux-tk1-debian")
endif()

set(dtb_file "${CMAKE_CURRENT_BINARY_DIR}/linux/linux-dtb")
Expand All @@ -37,55 +42,50 @@ if("${KernelARMPlatform}" STREQUAL "tk1")
VERBATIM
DEPENDS ${device_tree_src}
)
# Create custom target for setting the dtb
add_custom_target(set_dtb DEPENDS "${dtb_file}")

# Add Linux VM images into file server
AddToFileServer("linux" "${linux_binary_name}")
AddToFileServer("linux-dtb" "${dtb_file}" DEPENDS set_dtb)
# There is no need to create an explicit target there, any step that uses
# 'dtb_file' and lists it properly as dependency will make CMake run the
# command above to create (or update) it.

elseif("${KernelARMPlatform}" STREQUAL "tx1")
set(cpp_flags "-DKERNELARMPLATFORM_TX1")

AddToFileServer("linux" "${CAMKES_VM_IMAGES_DIR}/tx1/linux")
AddToFileServer("linux-dtb" "${CAMKES_VM_IMAGES_DIR}/tx1/linux-dtb")
# kernel image contains rootfs
set(linux_image "${CAMKES_VM_IMAGES_DIR}/tx1/linux")
set(dtb_file "${CAMKES_VM_IMAGES_DIR}/tx1/linux-dtb")

elseif("${KernelARMPlatform}" STREQUAL "exynos5422")
find_package(camkes-vm-linux REQUIRED)
include(${CAMKES_VM_LINUX_HELPERS_PATH})
set(cpp_flags "-DKERNELARMPLATFORM_EXYNOS5422")

AddToFileServer("linux" "${CAMKES_VM_IMAGES_DIR}/exynos5422/linux")
# Generate overlayed rootfs
set(linux_image "${CAMKES_VM_IMAGES_DIR}/exynos5422/linux")
set(rootfs_file "${CAMKES_VM_IMAGES_DIR}/exynos5422/rootfs.cpio.gz")
AddToFileServer("linux-initrd" ${rootfs_file})

# Updated dtb based on initrd
UpdateDtbFromInitrd(
"${CAMKES_VM_IMAGES_DIR}/exynos5422/linux-dtb"
${rootfs_file}
"0x4d700000"
dtb_gen_target
output_dtb_location
target_gen_dtb # helper CMake target to be created, not used
dtb_file
)
AddToFileServer("linux-dtb" "${output_dtb_location}" DEPENDS dtb_gen_target)

elseif("${KernelARMPlatform}" STREQUAL "tx2")
find_package(camkes-vm-linux REQUIRED)
include(${CAMKES_VM_LINUX_HELPERS_PATH})
set(cpp_flags "-DKERNELARMPLATFORM_TX2")

AddToFileServer("linux" "${CAMKES_VM_IMAGES_DIR}/tx2/linux")
set(linux_image "${CAMKES_VM_IMAGES_DIR}/tx2/linux")
set(rootfs_file "${CAMKES_VM_IMAGES_DIR}/tx2/rootfs.cpio.gz")
AddToFileServer("linux-initrd" ${rootfs_file})

# Updated dtb based on initrd
UpdateDtbFromInitrd(
"${CAMKES_VM_IMAGES_DIR}/tx2/linux-dtb"
${rootfs_file}
"0xf7000000"
dtb_gen_target
output_dtb_location
target_gen_dtb # helper CMake target to be created, not used
dtb_file
)
AddToFileServer("linux-dtb" "${output_dtb_location}" DEPENDS dtb_gen_target)

elseif("${KernelARMPlatform}" STREQUAL "qemu-arm-virt")

Expand All @@ -100,18 +100,18 @@ elseif("${KernelARMPlatform}" STREQUAL "qemu-arm-virt")
include(${CAMKES_VM_LINUX_HELPERS_PATH})
set(cpp_flags "-DKERNELARMPLATFORM_QEMU-ARM-VIRT")

AddToFileServer("linux" "${CAMKES_VM_IMAGES_DIR}/qemu-arm-virt/linux")
set(linux_image "${CAMKES_VM_IMAGES_DIR}/qemu-arm-virt/linux")
set(rootfs_file "${CAMKES_VM_IMAGES_DIR}/qemu-arm-virt/rootfs.cpio.gz")
AddToFileServer("linux-initrd" ${rootfs_file})

# Updated dtb based on initrd
UpdateDtbFromInitrd(
"${CAMKES_VM_IMAGES_DIR}/qemu-arm-virt/linux-dtb"
${rootfs_file}
"0x4d700000"
dtb_gen_target
output_dtb_location
target_gen_dtb # helper CMake target to be created, not used
dtb_file
)
AddToFileServer("linux-dtb" "${output_dtb_location}" DEPENDS dtb_gen_target)

include(simulation)
set(SIMULATION ON CACHE BOOL "Generate simulation script to run qemu with the proper arguments")
if(SIMULATION)
Expand All @@ -127,18 +127,17 @@ elseif("${KernelARMPlatform}" STREQUAL "odroidc2")
CAMKES_ROOT_DTB_FILE_PATH "${CAMKES_VM_IMAGES_DIR}/odroidc2/camkes-linux-dtb"
CACHE STRING ""
)
AddToFileServer("linux" "${CAMKES_VM_IMAGES_DIR}/odroidc2/linux")
set(linux_image "${CAMKES_VM_IMAGES_DIR}/odroidc2/linux")
set(rootfs_file "${CAMKES_VM_IMAGES_DIR}/odroidc2/rootfs.cpio.gz")
AddToFileServer("linux-initrd" ${rootfs_file})

# Updated dtb based on initrd
UpdateDtbFromInitrd(
"${CAMKES_VM_IMAGES_DIR}/odroidc2/linux-dtb"
${rootfs_file}
"0x2d700000"
dtb_gen_target
output_dtb_location
target_gen_dtb # helper CMake target to be created, not used
dtb_file
)
AddToFileServer("linux-dtb" "${output_dtb_location}" DEPENDS dtb_gen_target)

elseif("${KernelARMPlatform}" STREQUAL "zcu102")

Expand All @@ -149,9 +148,9 @@ elseif("${KernelARMPlatform}" STREQUAL "zcu102")
)
endif()

AddToFileServer("linux" "${CAMKES_VM_IMAGES_DIR}/zynqmp/${VmZynqmpPetalinuxVersion}/linux")
AddToFileServer(
"linux-initrd"
set(linux_image "${CAMKES_VM_IMAGES_DIR}/zynqmp/${VmZynqmpPetalinuxVersion}/linux")
set(
rootfs_file
"${CAMKES_VM_IMAGES_DIR}/zynqmp/${VmZynqmpPetalinuxVersion}/rootfs-minimal.cpio.gz"
)

Expand All @@ -164,10 +163,9 @@ elseif("${KernelARMPlatform}" STREQUAL "zcu102")
VERBATIM
DEPENDS ${dts_file}
)

# Create custom target for setting the dtb
add_custom_target(set_dtb DEPENDS "${dtb_file}")
AddToFileServer("linux-dtb" "${dtb_file}" DEPENDS set_dtb)
# There is no need to create an explicit target there, any step that uses
# 'dtb_file' and lists it properly as dependency will make CMake run the
# command above to create (or update) it.

list(APPEND cpp_includes "${CAMKES_VM_DIR}/components/VM_Arm/plat_include/zynqmp")

Expand All @@ -176,7 +174,16 @@ endif()

AddCamkesCPPFlag(cpp_flags CONFIG_VARS VmEmmc2NoDMA VmVUSB Tk1DeviceFwd Tk1Insecure)

DefineCAmkESVMFileServer()
# Create file server with VM images. There is an implicit dependency on the
# input files, so the rules above will be invoked to generate/update the files.
# There is no need to specify an explicit dependency on the helper target
# 'target_gen_dtb'
set(cpio_files "linux:${linux_image}" "linux-dtb:${dtb_file}")
if(rootfs_file)
list(APPEND cpio_files "linux-initrd:${rootfs_file}")
endif()

DefineCAmkESVMFileServer(FILES ${cpio_files})

CAmkESAddImportPath(${KernelARMPlatform})

Expand Down
30 changes: 12 additions & 18 deletions apps/Arm/vm_multi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ AddOverlayDirToRootfs(
"buildroot"
"rootfs_install"
vm0_output_overlayed_rootfs_location
rootfs_target_vm0
rootfs_target_vm0 # helper CMake target to be created, not used
GZIP
)

Expand All @@ -69,28 +69,22 @@ AddOverlayDirToRootfs(
"buildroot"
"rootfs_install"
client_output_overlayed_rootfs_location
rootfs_target_client_vm
rootfs_target_client_vm # helper CMake target to be created, not used
GZIP
)

AddToFileServer(
"linux-initrd-vm0"
"${vm0_output_overlayed_rootfs_location}"
DEPENDS
rootfs_target_vm0
)
AddToFileServer(
"linux-initrd-vm-client"
"${client_output_overlayed_rootfs_location}"
DEPENDS
rootfs_target_client_vm
)

AddToFileServer("linux" "${CAMKES_VM_IMAGES_DIR}/${KernelARMPlatform}/linux")

AddCamkesCPPFlag(cpp_flags CONFIG_VARS VmEmmc2NoDMA VmVUSB VmVchan Tk1DeviceFwd Tk1Insecure)

DefineCAmkESVMFileServer()
# Create file server with VM images. There is an implicit dependency on the
# input files, so the rules above will be invoked to generate/update the files.
# There is no need to specify an explicit dependency on the helper targets
# 'rootfs_target_vm0' and 'rootfs_target_client_vm'
DefineCAmkESVMFileServer(
FILES
"linux-initrd-vm0:${vm0_output_overlayed_rootfs_location}"
"linux-initrd-vm-client:${client_output_overlayed_rootfs_location}"
"linux:${CAMKES_VM_IMAGES_DIR}/${KernelARMPlatform}/linux"
)

CAmkESAddImportPath(${KernelARMPlatform})

Expand Down
21 changes: 13 additions & 8 deletions apps/Arm/vm_serial_server/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ include(${CAMKES_VM_LINUX_HELPERS_PATH})
# Create our CPP Flags based on ARM VM config variables
set(cpp_flags "-DKERNELARMPLATFORM_EXYNOS5422")

AddToFileServer("linux" "${CAMKES_VM_IMAGES_DIR}/exynos5422/linux")
# Generate overlayed rootfs
set(rootfs_file "${CAMKES_VM_IMAGES_DIR}/exynos5422/rootfs.cpio.gz")
AddFileToOverlayDir(
Expand All @@ -32,25 +31,31 @@ AddOverlayDirToRootfs(
"buildroot"
"rootfs_install"
output_overlayed_rootfs_location
rootfs_target
rootfs_target # helper CMake target to be created, not used
GZIP
)
AddToFileServer("linux-initrd" ${output_overlayed_rootfs_location} DEPENDS rootfs_target)

# Updated dtb based on generated initrd
UpdateDtbFromInitrd(
"${CAMKES_VM_IMAGES_DIR}/exynos5422/linux-dtb-virtcon"
${output_overlayed_rootfs_location}
"0x4d700000"
dtb_gen_target
dtb_gen_target # helper CMake target to be created, not used
output_dtb_location
DEPENDS
rootfs_target
)
AddToFileServer("linux-dtb" "${output_dtb_location}" DEPENDS dtb_gen_target)

AddCamkesCPPFlag(cpp_flags CONFIG_VARS VmEmmc2NoDMA VmVUSB Tk1DeviceFwd Tk1Insecure)

DefineCAmkESVMFileServer()
# Create file server with VM images. There is an implicit dependency on the
# input files, so the rules above will be invoked to generate/update the files.
# There is no need to specify an explicit dependency on the helper targets
# 'rootfs_target' and 'dtb_gen_target'
DefineCAmkESVMFileServer(
FILES
"linux:${CAMKES_VM_IMAGES_DIR}/exynos5422/linux"
"linux-initrd:${output_overlayed_rootfs_location}"
"linux-dtb:${output_dtb_location}"
)

CAmkESAddImportPath(exynos5422)

Expand Down
Loading

0 comments on commit 6dfdae4

Please sign in to comment.