Skip to content

Commit

Permalink
CMake: cleanup dependencies
Browse files Browse the repository at this point in the history
Signed-off-by: Axel Heider <[email protected]>
  • Loading branch information
Axel Heider committed Mar 25, 2023
1 parent d0850ae commit fa12533
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 91 deletions.
22 changes: 8 additions & 14 deletions apps/Arm/odroid_vm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,29 +34,23 @@ add_subdirectory(components/timer)

# 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
add_custom_target(set_dtb DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/linux/linux-dtb")

# Create file server with Add Linux VM images
DefineCAmkESVMFileServer(
FILES
"linux:${CAMKES_ARM_LINUX_DIR}/linux"
"linux-dtb:${CMAKE_CURRENT_BINARY_DIR}/linux/linux-dtb"
DEPENDS
set_dtb
)
# Create file server with add Linux VM images
DefineCAmkESVMFileServer(FILES "linux:${CAMKES_ARM_LINUX_DIR}/linux" "linux-dtb:${linux_dtb}")

# Declare odroid root server
DeclareCAmkESRootserver(
Expand Down
7 changes: 3 additions & 4 deletions apps/Arm/vm_cross_connector/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -215,12 +215,11 @@ AddCamkesCPPFlag(
VmVirtioNetVirtqueue
)

# There is an implicit dependency on ' output_overlayed_rootfs_location', so
# there is no need to explicitly depend on 'rootfs_target'.
DefineCAmkESVMFileServer(
FILES
"linux:${CAMKES_VM_IMAGES_DIR}/${KernelARMPlatform}/linux"
FILES "linux:${CAMKES_VM_IMAGES_DIR}/${KernelARMPlatform}/linux"
"linux-initrd:${output_overlayed_rootfs_location}"
DEPENDS
rootfs_target
)

CAmkESAddImportPath(${KernelARMPlatform})
Expand Down
7 changes: 3 additions & 4 deletions apps/Arm/vm_introspect/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,11 @@ AddCamkesCPPFlag(
VmVirtioNetVirtqueue
)

# There is an implicit dependency on ' output_overlayed_rootfs_location', so
# there is no need to explicitly depend on 'rootfs_target'.
DefineCAmkESVMFileServer(
FILES
"linux:${CAMKES_VM_IMAGES_DIR}/${KernelARMPlatform}/linux"
FILES "linux:${CAMKES_VM_IMAGES_DIR}/${KernelARMPlatform}/linux"
"linux-initrd:${output_overlayed_rootfs_location}"
DEPENDS
rootfs_target
)

CAmkESAddImportPath(${KernelARMPlatform})
Expand Down
15 changes: 7 additions & 8 deletions apps/Arm/vm_minimal/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,16 @@ if("${KernelARMPlatform}" STREQUAL "tk1")
VERBATIM
DEPENDS ${device_tree_src}
)
# Create custom target for setting the dtb
add_custom_target(dtb_gen_target DEPENDS "${linux-dtb}")
# There is no need to create an explicit target there, any step that uses
# 'output_dtb_location' 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")

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

# There is no need to generate or modify a DTB, so we just have a dummy
# target here. The target is depends on the (existing) DTB file, so we get a
# nice error here in case it is missing.
set(output_dtb_location "${CAMKES_VM_IMAGES_DIR}/tx1/linux-dtb")
add_custom_target(dtb_gen_target DEPENDS "${output_dtb_location}")

elseif("${KernelARMPlatform}" STREQUAL "exynos5422")
find_package(camkes-vm-linux REQUIRED)
Expand Down Expand Up @@ -131,12 +127,15 @@ endif()

AddCamkesCPPFlag(cpp_flags CONFIG_VARS VmEmmc2NoDMA VmVUSB Tk1DeviceFwd Tk1Insecure)

# Generate the File Server. There is no need to list 'dtb_gen_target' as
# explicit dependency, because we we depend on the file `output_dtb_location`
# anyway.
set(cpio_files "linux:${linux_image}" "linux-dtb:${output_dtb_location}")
if(rootfs_file)
list(APPEND cpio_files "linux-initrd:${rootfs_file}")
endif()

DefineCAmkESVMFileServer(FILES ${cpio_files} DEPENDS dtb_gen_target)
DefineCAmkESVMFileServer(FILES ${cpio_files})

CAmkESAddImportPath(${KernelARMPlatform})

Expand Down
11 changes: 3 additions & 8 deletions apps/x86/cma34cr_centos/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,11 @@ AddLWIPConfiguration(${CMAKE_CURRENT_SOURCE_DIR}/lwip_include)

# Add Linux VM images into file server
# This implicitly depends on all input files. Since ${decompressed_kernel} is
# generated by some recipe set up in DecompressLinuxKernel(), there should be no
# need to add the explicit dependency on 'extract_linux_kernel' here also if
# dependencies are set up properly. But this function might do other things
# also, so we play safe and add the explicit dependency.
# generated by a proper recipe set up in DecompressLinuxKernel(), we don't have
# to list 'extract_linux_kernel' explicitly as dependency.
DefineCAmkESVMFileServer(
FILES
"bzimage:${decompressed_kernel}"
FILES "bzimage:${decompressed_kernel}"
"rootfs.cpio:${CMAKE_CURRENT_SOURCE_DIR}/centos_linux/rootfs.cpio"
DEPENDS
extract_linux_kernel
)

# Declare CAmkES Root Server
Expand Down
11 changes: 3 additions & 8 deletions apps/x86/cma34cr_ubuntu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,11 @@ DecompressLinuxKernel(extract_linux_kernel decompressed_kernel ${kernel_file})

# Add Linux VM images into file server
# This implicitly depends on all input files. Since ${decompressed_kernel} is
# generated by some recipe set up in DecompressLinuxKernel(), there should be no
# need to add the explicit dependency on 'extract_linux_kernel' here also if
# dependencies are set up properly. But this function might do other things
# also, so we play safe and add the explicit dependency.
# generated by a proper recipe set up in DecompressLinuxKernel(), we don't have
# to list 'extract_linux_kernel' explicitly as dependency.
DefineCAmkESVMFileServer(
FILES
"bzimage:${decompressed_kernel}"
FILES "bzimage:${decompressed_kernel}"
"rootfs.cpio:${CMAKE_CURRENT_SOURCE_DIR}/ubuntu_linux/rootfs.cpio"
DEPENDS
extract_linux_kernel
)

# Declare CAmkES Root Server
Expand Down
12 changes: 3 additions & 9 deletions apps/x86/minimal/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,10 @@ DecompressLinuxKernel(extract_linux_kernel decompressed_kernel ${kernel_file})

# Add Linux VM images into file server
# This implicitly depends on all input files. Since ${decompressed_kernel} is
# generated by some recipe set up in DecompressLinuxKernel(), there should be no
# need to add the explicit dependency on 'extract_linux_kernel' here also if
# dependencies are set up properly. But this function might do other things
# also, so we play safe and add the explicit dependency.
# generated by a proper recipe set up in DecompressLinuxKernel(), we don't have
# to list 'extract_linux_kernel' explicitly as dependency.
DefineCAmkESVMFileServer(
FILES
"bzimage:${decompressed_kernel}"
"rootfs.cpio:${rootfs_file}"
DEPENDS
extract_linux_kernel
FILES "bzimage:${decompressed_kernel}" "rootfs.cpio:${rootfs_file}"
)

# Declare CAmkES Root Server
Expand Down
14 changes: 3 additions & 11 deletions apps/x86/optiplex9020/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,9 @@ DecompressLinuxKernel(extract_linux_kernel decompressed_kernel ${kernel_file})

# Add Linux VM images into file server
# This implicitly depends on all input files. Since ${decompressed_kernel} is
# generated by some recipe set up in DecompressLinuxKernel(), there should be no
# need to add the explicit dependency on 'extract_linux_kernel' here also if
# dependencies are set up properly. But this function might do other things
# also, so we play safe and add the explicit dependency.
DefineCAmkESVMFileServer(
FILES
"bzimage:${decompressed_kernel}"
"rootfs.cpio:${rootfs_file}"
DEPENDS
extract_linux_kernel
)
# generated by a proper recipe set up in DecompressLinuxKernel(), we don't have
# to list 'extract_linux_kernel' explicitly as dependency.
DefineCAmkESVMFileServer(FILES "bzimage:${decompressed_kernel}" "rootfs.cpio:${rootfs_file}")

# Declare CAmkES Root Server
DeclareCAmkESRootserver(
Expand Down
11 changes: 3 additions & 8 deletions apps/x86/virtio_blk_sample/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,11 @@ DecompressLinuxKernel(extract_linux_kernel decompressed_kernel ${kernel_file})

# Add Linux VM images into file server
# This implicitly depends on all input files. Since ${decompressed_kernel} is
# generated by some recipe set up in DecompressLinuxKernel(), there should be no
# need to add the explicit dependency on 'extract_linux_kernel' here also if
# dependencies are set up properly. But this function might do other things
# also, so we play safe and add the explicit dependency.
# generated by a proper recipe set up in DecompressLinuxKernel(), we don't have
# to list 'extract_linux_kernel' explicitly as dependency.
DefineCAmkESVMFileServer(
FILES
"bzimage:${decompressed_kernel}"
FILES "bzimage:${decompressed_kernel}"
"rootfs.cpio:${rootfs_file}"
DEPENDS
extract_linux_kernel
)

# Declare CAmkES Root Server
Expand Down
22 changes: 5 additions & 17 deletions apps/x86/zmq_samples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ AddZMQBinary(pub)
AddZMQBinary(sub)

set(rootfs_images "")
set(rootfs_deps "")

foreach(i RANGE ${NumberVMsLess1})
set(overlay_target "overlay_vm${i}")
Expand All @@ -159,29 +158,18 @@ foreach(i RANGE ${NumberVMsLess1})
"${rootfs_target}"
)
list(APPEND rootfs_images "vm${i}_rootfs.cpio:${rootfs_img}")
list(APPEND rootfs_deps "${rootfs_target}")
endforeach()

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

# Add Linux VM images into file server.
# This implicitly depends on all input files. Since ${decompressed_kernel} is
# generated by some recipe set up in DecompressLinuxKernel(), there should be no
# need to add the explicit dependency on 'extract_linux_kernel' here also if
# dependencies are set up properly. But this function might do other things
# also, so we play safe and add the explicit dependency.
# For 'rootfs_deps' it is similar, AddOverlayDirToRootfs() should have created a
# recipe for the output with proper dependencies, so there should not be a need
# that we explicitly depend on everything from 'rootfs_deps' here.
DefineCAmkESVMFileServer(
FILES
"bzimage:${decompressed_kernel}"
"${rootfs_images}"
DEPENDS
extract_linux_kernel
"${rootfs_deps}"
)
# generated by a proper recipe set up in DecompressLinuxKernel(), we don't have
# to list 'extract_linux_kernel' explicitly as dependency. For 'rootfs_images'
# it is the same, AddOverlayDirToRootfs() created a proper recipe for the output
# files, so we don't have to depend on the targets.
DefineCAmkESVMFileServer(FILES "bzimage:${decompressed_kernel}" "${rootfs_images}")

# Initialise CAmkES Root Server with addition CPP includes
DeclareCAmkESRootserver("${zmq_camkes}" CPP_INCLUDES "${VM_PROJECT_DIR}/components/VM")

0 comments on commit fa12533

Please sign in to comment.