From 60eab85a7526608bb6d1aca920b18d58ec8bb2c5 Mon Sep 17 00:00:00 2001 From: Axel Heider Date: Sat, 20 May 2023 02:06:55 +0200 Subject: [PATCH 1/3] mention DefineCAmkESVMFileServer() in readme Signed-off-by: Axel Heider --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index f0035094..aa6e72dd 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ To build an application with this project we use CMake. This repo provides a ser - `DeclareCAmkESVM(init_component [SOURCES INCLUDES LIBS LD_FLAGS C_FLAGS])`: Function for declaring a CAmkESVM. This is called for each Init component in the defined in the applications `.camkes` file. The user can also pass in extra compilation sources, includes, libs and flags to be compiled with the component through additional arguments (`SOURCES`, `INCLUDES`, `LIBS`, `LD_FLAGS` and `C_FLAGS`) - `DeclareCAmkESVMRootServer(camkes_config)`: Declares the CAmkESVM root server. This function takes the applications `.camkes` file as an argument (`camkes_config`). - `AddToFileServer(filename_pref file_dest [DEPENDS])`: Function for adding a file/image to the vm file server. The caller specifies the name of they wish to refer to the image in the FileServer through the `filename_pref` parameter. `file_dest` is the file system location of the image the caller is adding. Additional dependencies to the image can be passed through the optional `DEPENDS` parameter. +- `DefineCAmkESVMFileServer([TYPE ] [INSTANCE ] [FILES [ [...]] [DEPENDS [ [...]])`: Function for explicitly creating a file server with the given files. This takes into account any files that have been added before via calls to `AddToFileServer()`. This is called internally from `DeclareCAmkESVMRootServer()`. - `DecompressLinuxKernel(decompress_target decompressed_kernel_image compressed_kernel_image [DEPENDS])`: Function for decompressing/extracting a vmlinux file from a given kernel image. The caller specifies a target name (`decompress_target`) for decompressing the kernel, the kernel image to decompress (`compressed_kernel_image`) and additional dependencies to the compressed image through the optional `DEPENDS` parameter. The location of the decompressed image is populated in the `decompressed_kernel_image` parameter passed by the caller. ## Items From b2072b984b3798b788149470719bf30fb9d9955b Mon Sep 17 00:00:00 2001 From: Axel Heider Date: Fri, 5 May 2023 18:28:12 +0200 Subject: [PATCH 2/3] CMake: remove AddToFileServer() With the new interface of DefineCAmkESVMFileServer() there is not need to have AddToFileServer(). CMake lists with files can be built instead and then passed to DefineCAmkESVMFileServer(). Signed-off-by: Axel Heider --- README.md | 1 - camkes_vm_helpers.cmake | 123 ++++++---------------------------------- 2 files changed, 16 insertions(+), 108 deletions(-) diff --git a/README.md b/README.md index aa6e72dd..f8bef5b8 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,6 @@ To build an application with this project we use CMake. This repo provides a ser - `DeclareCAmkESVM(init_component [SOURCES INCLUDES LIBS LD_FLAGS C_FLAGS])`: Function for declaring a CAmkESVM. This is called for each Init component in the defined in the applications `.camkes` file. The user can also pass in extra compilation sources, includes, libs and flags to be compiled with the component through additional arguments (`SOURCES`, `INCLUDES`, `LIBS`, `LD_FLAGS` and `C_FLAGS`) - `DeclareCAmkESVMRootServer(camkes_config)`: Declares the CAmkESVM root server. This function takes the applications `.camkes` file as an argument (`camkes_config`). -- `AddToFileServer(filename_pref file_dest [DEPENDS])`: Function for adding a file/image to the vm file server. The caller specifies the name of they wish to refer to the image in the FileServer through the `filename_pref` parameter. `file_dest` is the file system location of the image the caller is adding. Additional dependencies to the image can be passed through the optional `DEPENDS` parameter. - `DefineCAmkESVMFileServer([TYPE ] [INSTANCE ] [FILES [ [...]] [DEPENDS [ [...]])`: Function for explicitly creating a file server with the given files. This takes into account any files that have been added before via calls to `AddToFileServer()`. This is called internally from `DeclareCAmkESVMRootServer()`. - `DecompressLinuxKernel(decompress_target decompressed_kernel_image compressed_kernel_image [DEPENDS])`: Function for decompressing/extracting a vmlinux file from a given kernel image. The caller specifies a target name (`decompress_target`) for decompressing the kernel, the kernel image to decompress (`compressed_kernel_image`) and additional dependencies to the compressed image through the optional `DEPENDS` parameter. The location of the decompressed image is populated in the `decompressed_kernel_image` parameter passed by the caller. diff --git a/camkes_vm_helpers.cmake b/camkes_vm_helpers.cmake index 9f742fa6..20b49ea7 100644 --- a/camkes_vm_helpers.cmake +++ b/camkes_vm_helpers.cmake @@ -119,25 +119,21 @@ function(DefineCAmkESVMFileServer) set(PARAM_INSTANCE "fserv") endif() - # The target might exist already when AddToFileServer() was called. - set(FSRV_TARGET "vm_fileserver_config_${PARAM_INSTANCE}") - if(NOT TARGET ${FSRV_TARGET}) - add_custom_target(${FSRV_TARGET}) - endif() - # For dependencies and files, both lists and lists of list are supported for # convenience reasons. Furthermore, empty entries are also allowed. This # can happen when the caller uses variables for the lists, when in some # configurations the lists remain empty. + set(DEPS "") foreach(element IN LISTS PARAM_DEPENDS) foreach(item IN LISTS element) if(item) - set_property(TARGET ${FSRV_TARGET} APPEND PROPERTY DEPS ${item}) + list(APPEND DEPS "${item}") endif() endforeach() endforeach() + set(CPIO_FILES "") foreach(element IN LISTS PARAM_FILES) foreach(item IN LISTS element) # [:] if(item) @@ -158,54 +154,24 @@ function(DefineCAmkESVMFileServer) set(FILE_NAME "${CMAKE_MATCH_1}") get_filename_component(CPIO_NAME "${FILE_NAME}" NAME) endif() - set_property( - TARGET ${FSRV_TARGET} - APPEND - PROPERTY FILES "${CPIO_NAME}:${FILE_NAME}" + set(CPIO_FILE "${PARAM_INSTANCE}/files/${CPIO_NAME}") + add_custom_command( + OUTPUT "${CPIO_FILE}" + COMMENT "copy: ${FILE_NAME} -> ${CPIO_FILE}" + COMMAND + ${CMAKE_COMMAND} -E copy "${FILE_NAME}" "${CPIO_FILE}" + VERBATIM + DEPENDS ${FILE_NAME} ${DEPS} ) + # There is no need to create an explicit target for the command + # above, because the archive creation depends on all files + # listed in CPIO_FILES. The command above is the creation rule + # for each one. + list(APPEND CPIO_FILES "${CPIO_FILE}") endif() endforeach() endforeach() - # now process the file/deps list - get_target_property(files ${FSRV_TARGET} FILES) - if(NOT files) # this also catches "files-NOTFOUND" if property is not set - set(files "") - endif() - get_target_property(deps ${FSRV_TARGET} DEPS) - if(NOT deps) # this also catches "deps-NOTFOUND" if property is not set - set(deps "") - endif() - - set(CPIO_FILES "") - foreach(item IN LISTS files) # : - string( - REGEX - MATCH - "^([^:]+):([^:]+)$" - cpio_item - "${item}" - ) - if(NOT cpio_item) - message(FATAL_ERROR "invalid CPIO file format: '${item}'") - endif() - set(CPIO_NAME "${CMAKE_MATCH_1}") - set(FILE_NAME "${CMAKE_MATCH_2}") - set(CPIO_FILE "${PARAM_INSTANCE}/files/${CPIO_NAME}") - add_custom_command( - OUTPUT "${CPIO_FILE}" - COMMENT "copy: ${FILE_NAME} -> ${CPIO_FILE}" - COMMAND - ${CMAKE_COMMAND} -E copy "${FILE_NAME}" "${CPIO_FILE}" - VERBATIM - DEPENDS ${FILE_NAME} ${deps} - ) - # There is no need to create an explicit target for the command above, - # the archive creation depends on all files in CPIO_FILES, where the - # command above is the creation rule for each one. - list(APPEND CPIO_FILES "${CPIO_FILE}") - endforeach() - # Build CPIO archive. It implicitly depends on all files in CPIO_FILES, # which have their own dependencies each from above. So we don't have any # additional explicit dependencies here. @@ -257,63 +223,6 @@ function(DeclareCAmkESVMRootServer camkes_config) ) endfunction(DeclareCAmkESVMRootServer) -# Function for adding a file/image to the vm file server. -# -# Parameters: -# -# -# The name to use for the file in the file server. Components using a file -# server could expect certain files to have a specific name, which could -# differer from the file name on the disk, so this provides a convenient way -# to handle the renaming. -# -# -# The location of the file on the disk. -# -# INSTANCE -# The File server instance to add the file to. -# Optional, defaults to "fserv". -# -# DEPENDS [ [...]] -# Additional dependencies of the file added to the file server. This is an -# optional parameter for non-trivial dependencies of the input file. Each file -# server instance depends on all input files anyway, thus a re-build happens -# automatically on any changes. If an input file is created dynamically by -# another regular CMake target, any dependencies should have been specified -# there already, so there is no need to repeat them here. -# -function(AddToFileServer filename_pref file_dest) - - cmake_parse_arguments( - PARSE_ARGV - 2 - PARAM # variable prefix - "" # option arguments - "INSTANCE" # optional single value arguments - "DEPENDS" # optional multi value arguments - ) - - if(PARAM_UNPARSED_ARGUMENTS) - message(FATAL_ERROR "Unknown arguments: ${PARAM_UNPARSED_ARGUMENTS}") - endif() - - if(NOT PARAM_INSTANCE) - set(PARAM_INSTANCE "fserv") - endif() - - set(FSRV_TARGET "vm_fileserver_config_${PARAM_INSTANCE}") - if(NOT TARGET ${FSRV_TARGET}) - add_custom_target(${FSRV_TARGET}) - endif() - - set_property(TARGET ${FSRV_TARGET} APPEND PROPERTY FILES "${filename_pref}:${file_dest}") - - if(PARAM_DEPENDS) - set_property(TARGET ${FSRV_TARGET} APPEND PROPERTY DEPS ${PARAM_DEPENDS}) - endif() - -endfunction(AddToFileServer) - # Function for decompressing/extracting a vmlinux file from a given kernel image # decompress_target: The target name the caller wishes to use to generate the decompressed kernel # image From 65d4f91eba04131bcb190607f0b9104f684085ae Mon Sep 17 00:00:00 2001 From: Axel Heider Date: Fri, 5 May 2023 18:51:21 +0200 Subject: [PATCH 3/3] CMake: remove DeclareCAmkESVMRootServer() Remove convenience wrapper, as it is no longer useful. Signed-off-by: Axel Heider --- README.md | 2 +- camkes_vm_helpers.cmake | 23 ----------------------- 2 files changed, 1 insertion(+), 24 deletions(-) diff --git a/README.md b/README.md index f8bef5b8..7365460f 100644 --- a/README.md +++ b/README.md @@ -18,9 +18,9 @@ To ensure you have the necessary dependencies for building the CAmkES VM project To build an application with this project we use CMake. This repo provides a series of CMake helper functions (found in `camkes_vm_helpers.cmake`) to assit you with defining your CAmkES VM application. Importing this file into your applications CMake configuration gives you access to the following helper functions: - `DeclareCAmkESVM(init_component [SOURCES INCLUDES LIBS LD_FLAGS C_FLAGS])`: Function for declaring a CAmkESVM. This is called for each Init component in the defined in the applications `.camkes` file. The user can also pass in extra compilation sources, includes, libs and flags to be compiled with the component through additional arguments (`SOURCES`, `INCLUDES`, `LIBS`, `LD_FLAGS` and `C_FLAGS`) -- `DeclareCAmkESVMRootServer(camkes_config)`: Declares the CAmkESVM root server. This function takes the applications `.camkes` file as an argument (`camkes_config`). - `DefineCAmkESVMFileServer([TYPE ] [INSTANCE ] [FILES [ [...]] [DEPENDS [ [...]])`: Function for explicitly creating a file server with the given files. This takes into account any files that have been added before via calls to `AddToFileServer()`. This is called internally from `DeclareCAmkESVMRootServer()`. - `DecompressLinuxKernel(decompress_target decompressed_kernel_image compressed_kernel_image [DEPENDS])`: Function for decompressing/extracting a vmlinux file from a given kernel image. The caller specifies a target name (`decompress_target`) for decompressing the kernel, the kernel image to decompress (`compressed_kernel_image`) and additional dependencies to the compressed image through the optional `DEPENDS` parameter. The location of the decompressed image is populated in the `decompressed_kernel_image` parameter passed by the caller. +- `DeclareCAmkESRootserver()`. Declare the the CAmkES Root Server that sets up the system. ## Items diff --git a/camkes_vm_helpers.cmake b/camkes_vm_helpers.cmake index 20b49ea7..afa3dc14 100644 --- a/camkes_vm_helpers.cmake +++ b/camkes_vm_helpers.cmake @@ -200,29 +200,6 @@ function(DefineCAmkESVMFileServer) endfunction(DefineCAmkESVMFileServer) -# Function for declaring the CAmkESVM root server. Taking the camkes application -# config file we declare a CAmkES Root server and the VM File Server. It is -# expected the caller has declared the file server images before using this -# function. -# camkes_config: The applications .camkes file -# In addition the user can pass in extra CPP compilation includes and flags through -# the CPP_INCLUDES and CPP_FLAGS arguments. -function(DeclareCAmkESVMRootServer camkes_config) - cmake_parse_arguments(PARSE_ARGV 1 CAMKES_ROOT_VM "" "" "CPP_INCLUDES;CPP_FLAGS") - # Initialise the CAmKES VM fileserver - DefineCAmkESVMFileServer() - get_absolute_source_or_binary(config_file "${camkes_config}") - # Declare CAmkES root server - DeclareCAmkESRootserver( - ${config_file} - CPP_FLAGS - ${CAMKES_ROOT_VM_CPP_FLAGS} - CPP_INCLUDES - "${VM_PROJECT_DIR}/components/VM" - ${CAMKES_ROOT_VM_CPP_INCLUDES} - ) -endfunction(DeclareCAmkESVMRootServer) - # Function for decompressing/extracting a vmlinux file from a given kernel image # decompress_target: The target name the caller wishes to use to generate the decompressed kernel # image