diff --git a/CMakeLists.txt b/CMakeLists.txt index 79e54a8..732a07c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD-2-Clause # -cmake_minimum_required(VERSION 3.8.2) +cmake_minimum_required(VERSION 3.16.0) project(camkes-vm-linux C) @@ -32,13 +32,13 @@ if(CAmkESVMDefaultBuildrootOverlay) set(binary_dir ${CMAKE_BINARY_DIR}/camkes-linux-artifacts) if(KernelSel4ArchX86_64) - # Get Custom toolchain for 64-bit Linux - FindCustomPollyToolchain(LINUX_TOOLCHAIN "linux-gcc-64bit-pic") - set(arch_size_dir "64") + # Get Custom toolchain for 64-bit Linux + FindCustomPollyToolchain(LINUX_TOOLCHAIN "linux-gcc-64bit-pic") + set(arch_size_dir "64") else() - # Get Custom toolchain for 32-bit Linux - FindCustomPollyToolchain(LINUX_TOOLCHAIN "linux-gcc-32bit-pic") - set(arch_size_dir "32") + # Get Custom toolchain for 32-bit Linux + FindCustomPollyToolchain(LINUX_TOOLCHAIN "linux-gcc-32bit-pic") + set(arch_size_dir "32") endif() # Setup Linux Sources @@ -47,21 +47,15 @@ if(CAmkESVMDefaultBuildrootOverlay) GetDefaultLinuxMd5(linux_md5) DownloadLinux(${linux_major} ${linux_minor} ${linux_md5} vm_linux_extract_dir download_vm_linux) # Linux config and symvers are to be copied to unpacked archive - set( - linux_config + set(linux_config "${CMAKE_CURRENT_SOURCE_DIR}/linux_configs/${linux_major}.${linux_minor}/${arch_size_dir}/config" ) - set( - linux_symvers + set(linux_symvers "${CMAKE_CURRENT_SOURCE_DIR}/linux_configs/${linux_major}.${linux_minor}/${arch_size_dir}/Module.symvers" ) # Configure unpacked archive with config and symvers ConfigureLinux( - ${vm_linux_extract_dir} - ${linux_config} - ${linux_symvers} - configure_vm_linux - DEPENDS + ${vm_linux_extract_dir} ${linux_config} ${linux_symvers} configure_vm_linux DEPENDS download_vm_linux ) @@ -70,20 +64,14 @@ if(CAmkESVMDefaultBuildrootOverlay) set(connector_apps_binary_dir ${binary_dir}/connector-apps) ExternalProject_Add( camkes-connector-apps - URL - file:///${CMAKE_CURRENT_SOURCE_DIR}/camkes-linux-artifacts/camkes-linux-apps/camkes-connector-apps - BINARY_DIR - ${connector_apps_binary_dir} - BUILD_ALWAYS - ON - STAMP_DIR - ${connector_apps_stamp_dir} - EXCLUDE_FROM_ALL - INSTALL_COMMAND + URL file:///${CMAKE_CURRENT_SOURCE_DIR}/camkes-linux-artifacts/camkes-linux-apps/camkes-connector-apps + BINARY_DIR ${connector_apps_binary_dir} + BUILD_ALWAYS ON + STAMP_DIR ${connector_apps_stamp_dir} + EXCLUDE_FROM_ALL INSTALL_COMMAND "" - CMAKE_ARGS - -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} - -DCMAKE_TOOLCHAIN_FILE=${LINUX_32BIT_TOOLCHAIN} + CMAKE_ARGS -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + -DCMAKE_TOOLCHAIN_FILE=${LINUX_32BIT_TOOLCHAIN} ) # Build camkes connector modules @@ -91,25 +79,17 @@ if(CAmkESVMDefaultBuildrootOverlay) set(connector_modules_binary_dir ${binary_dir}/connector-modules) ExternalProject_Add( camkes-connector-modules - URL - file:///${CMAKE_CURRENT_SOURCE_DIR}/camkes-linux-artifacts/camkes-linux-modules/camkes-connector-modules - BINARY_DIR - ${connector_modules_binary_dir} - BUILD_ALWAYS - ON - STAMP_DIR - ${connector_modules_stamp_dir} - EXCLUDE_FROM_ALL - INSTALL_COMMAND + URL file:///${CMAKE_CURRENT_SOURCE_DIR}/camkes-linux-artifacts/camkes-linux-modules/camkes-connector-modules + BINARY_DIR ${connector_modules_binary_dir} + BUILD_ALWAYS ON + STAMP_DIR ${connector_modules_stamp_dir} + EXCLUDE_FROM_ALL INSTALL_COMMAND "" - DEPENDS - download_vm_linux - configure_vm_linux - CMAKE_ARGS - -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} - -DCMAKE_TOOLCHAIN_FILE=${LINUX_32BIT_TOOLCHAIN} - -DLINUX_KERNEL_DIR=${vm_linux_extract_dir} - -DMODULE_HELPERS_FILE=${CMAKE_CURRENT_SOURCE_DIR}/linux-module-helpers.cmake + DEPENDS download_vm_linux configure_vm_linux + CMAKE_ARGS -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + -DCMAKE_TOOLCHAIN_FILE=${LINUX_32BIT_TOOLCHAIN} + -DLINUX_KERNEL_DIR=${vm_linux_extract_dir} + -DMODULE_HELPERS_FILE=${CMAKE_CURRENT_SOURCE_DIR}/linux-module-helpers.cmake ) # Declare camkes connector apps @@ -128,12 +108,8 @@ if(CAmkESVMDefaultBuildrootOverlay) # Declare camkes connector modules AddExternalProjFilesToOverlay( - camkes-connector-modules - ${connector_modules_binary_dir} - default_buildroot_overlay - "lib/modules/4.8.16/kernel/drivers/vmm" - FILES - connection.ko + camkes-connector-modules ${connector_modules_binary_dir} default_buildroot_overlay + "lib/modules/4.8.16/kernel/drivers/vmm" FILES connection.ko ) # Add additional init scripts to the default buildroot overlay diff --git a/Findcamkes-vm-linux.cmake b/Findcamkes-vm-linux.cmake index 3bc031c..2358168 100644 --- a/Findcamkes-vm-linux.cmake +++ b/Findcamkes-vm-linux.cmake @@ -4,20 +4,24 @@ # SPDX-License-Identifier: BSD-2-Clause # -set(CAMKES_VM_LINUX_DIR "${CMAKE_CURRENT_LIST_DIR}" CACHE STRING "") -set(CAMKES_VM_LINUX_HELPERS_PATH "${CMAKE_CURRENT_LIST_DIR}/vm-linux-helpers.cmake" CACHE STRING "") -set( - CAMKES_VM_LINUX_MODULE_HELPERS_PATH "${CMAKE_CURRENT_LIST_DIR}/linux-module-helpers.cmake" +set(CAMKES_VM_LINUX_DIR + "${CMAKE_CURRENT_LIST_DIR}" CACHE STRING "" ) -set( - CAMKES_VM_LINUX_SOURCE_HELPERS_PATH "${CMAKE_CURRENT_LIST_DIR}/linux-source-helpers.cmake" +set(CAMKES_VM_LINUX_HELPERS_PATH + "${CMAKE_CURRENT_LIST_DIR}/vm-linux-helpers.cmake" + CACHE STRING "" +) +set(CAMKES_VM_LINUX_MODULE_HELPERS_PATH + "${CMAKE_CURRENT_LIST_DIR}/linux-module-helpers.cmake" + CACHE STRING "" +) +set(CAMKES_VM_LINUX_SOURCE_HELPERS_PATH + "${CMAKE_CURRENT_LIST_DIR}/linux-source-helpers.cmake" CACHE STRING "" ) mark_as_advanced( - CAMKES_VM_LINUX_DIR - CAMKES_VM_LINUX_HELPERS_PATH - CAMKES_VM_LINUX_MODULE_HELPERS_PATH + CAMKES_VM_LINUX_DIR CAMKES_VM_LINUX_HELPERS_PATH CAMKES_VM_LINUX_MODULE_HELPERS_PATH CAMKES_VM_LINUX_SOURCE_HELPERS_PATH ) @@ -27,10 +31,6 @@ endmacro() include(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS( - camkes-vm-linux - DEFAULT_MSG - CAMKES_VM_LINUX_DIR - CAMKES_VM_LINUX_HELPERS_PATH - CAMKES_VM_LINUX_MODULE_HELPERS_PATH - CAMKES_VM_LINUX_SOURCE_HELPERS_PATH + camkes-vm-linux DEFAULT_MSG CAMKES_VM_LINUX_DIR CAMKES_VM_LINUX_HELPERS_PATH + CAMKES_VM_LINUX_MODULE_HELPERS_PATH CAMKES_VM_LINUX_SOURCE_HELPERS_PATH ) diff --git a/camkes-linux-artifacts/camkes-linux-apps/camkes-connector-apps/CMakeLists.txt b/camkes-linux-artifacts/camkes-linux-apps/camkes-connector-apps/CMakeLists.txt index f3b7f61..10ee8dc 100644 --- a/camkes-linux-artifacts/camkes-linux-apps/camkes-connector-apps/CMakeLists.txt +++ b/camkes-linux-artifacts/camkes-linux-apps/camkes-connector-apps/CMakeLists.txt @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD-2-Clause # -cmake_minimum_required(VERSION 3.8.2) +cmake_minimum_required(VERSION 3.16.0) add_subdirectory(pkgs/consumes_event) add_subdirectory(pkgs/dataport) diff --git a/camkes-linux-artifacts/camkes-linux-apps/camkes-connector-apps/pkgs/consumes_event/CMakeLists.txt b/camkes-linux-artifacts/camkes-linux-apps/camkes-connector-apps/pkgs/consumes_event/CMakeLists.txt index ddb09ce..86901ce 100644 --- a/camkes-linux-artifacts/camkes-linux-apps/camkes-connector-apps/pkgs/consumes_event/CMakeLists.txt +++ b/camkes-linux-artifacts/camkes-linux-apps/camkes-connector-apps/pkgs/consumes_event/CMakeLists.txt @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD-2-Clause # -cmake_minimum_required(VERSION 3.8.2) +cmake_minimum_required(VERSION 3.16.0) project(consumes-event C) diff --git a/camkes-linux-artifacts/camkes-linux-apps/camkes-connector-apps/pkgs/dataport/CMakeLists.txt b/camkes-linux-artifacts/camkes-linux-apps/camkes-connector-apps/pkgs/dataport/CMakeLists.txt index bca09f0..ad299bb 100644 --- a/camkes-linux-artifacts/camkes-linux-apps/camkes-connector-apps/pkgs/dataport/CMakeLists.txt +++ b/camkes-linux-artifacts/camkes-linux-apps/camkes-connector-apps/pkgs/dataport/CMakeLists.txt @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD-2-Clause # -cmake_minimum_required(VERSION 3.8.2) +cmake_minimum_required(VERSION 3.16.0) project(dataport C) diff --git a/camkes-linux-artifacts/camkes-linux-apps/camkes-connector-apps/pkgs/emits_event/CMakeLists.txt b/camkes-linux-artifacts/camkes-linux-apps/camkes-connector-apps/pkgs/emits_event/CMakeLists.txt index c28d8c1..ba0a019 100644 --- a/camkes-linux-artifacts/camkes-linux-apps/camkes-connector-apps/pkgs/emits_event/CMakeLists.txt +++ b/camkes-linux-artifacts/camkes-linux-apps/camkes-connector-apps/pkgs/emits_event/CMakeLists.txt @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD-2-Clause # -cmake_minimum_required(VERSION 3.8.2) +cmake_minimum_required(VERSION 3.16.0) project(emits-event C) diff --git a/camkes-linux-artifacts/camkes-linux-apps/camkes-connector-apps/pkgs/string_reverse/CMakeLists.txt b/camkes-linux-artifacts/camkes-linux-apps/camkes-connector-apps/pkgs/string_reverse/CMakeLists.txt index b4a27cc..46ec0d9 100644 --- a/camkes-linux-artifacts/camkes-linux-apps/camkes-connector-apps/pkgs/string_reverse/CMakeLists.txt +++ b/camkes-linux-artifacts/camkes-linux-apps/camkes-connector-apps/pkgs/string_reverse/CMakeLists.txt @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD-2-Clause # -cmake_minimum_required(VERSION 3.8.2) +cmake_minimum_required(VERSION 3.16.0) project(string_reverse C) diff --git a/camkes-linux-artifacts/camkes-linux-apps/camkes-introspect-app/CMakeLists.txt b/camkes-linux-artifacts/camkes-linux-apps/camkes-introspect-app/CMakeLists.txt index 1f53a34..2f162cd 100644 --- a/camkes-linux-artifacts/camkes-linux-apps/camkes-introspect-app/CMakeLists.txt +++ b/camkes-linux-artifacts/camkes-linux-apps/camkes-introspect-app/CMakeLists.txt @@ -4,6 +4,6 @@ # SPDX-License-Identifier: BSD-2-Clause # -cmake_minimum_required(VERSION 3.8.2) +cmake_minimum_required(VERSION 3.16.0) add_subdirectory(pkgs/introspect) diff --git a/camkes-linux-artifacts/camkes-linux-apps/camkes-introspect-app/pkgs/introspect/CMakeLists.txt b/camkes-linux-artifacts/camkes-linux-apps/camkes-introspect-app/pkgs/introspect/CMakeLists.txt index 8e6e389..ac080c7 100644 --- a/camkes-linux-artifacts/camkes-linux-apps/camkes-introspect-app/pkgs/introspect/CMakeLists.txt +++ b/camkes-linux-artifacts/camkes-linux-apps/camkes-introspect-app/pkgs/introspect/CMakeLists.txt @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD-2-Clause # -cmake_minimum_required(VERSION 3.8.2) +cmake_minimum_required(VERSION 3.16.0) project(introspect C) diff --git a/camkes-linux-artifacts/camkes-linux-apps/demo-apps/helloworld/CMakeLists.txt b/camkes-linux-artifacts/camkes-linux-apps/demo-apps/helloworld/CMakeLists.txt index df02a44..aa76cbd 100644 --- a/camkes-linux-artifacts/camkes-linux-apps/demo-apps/helloworld/CMakeLists.txt +++ b/camkes-linux-artifacts/camkes-linux-apps/demo-apps/helloworld/CMakeLists.txt @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD-2-Clause # -cmake_minimum_required(VERSION 3.8.2) +cmake_minimum_required(VERSION 3.16.0) project(helloworld C) diff --git a/camkes-linux-artifacts/camkes-linux-modules/camkes-connector-modules/CMakeLists.txt b/camkes-linux-artifacts/camkes-linux-modules/camkes-connector-modules/CMakeLists.txt index 4740de8..b3305fb 100644 --- a/camkes-linux-artifacts/camkes-linux-modules/camkes-connector-modules/CMakeLists.txt +++ b/camkes-linux-artifacts/camkes-linux-modules/camkes-connector-modules/CMakeLists.txt @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD-2-Clause # -cmake_minimum_required(VERSION 3.8.2) +cmake_minimum_required(VERSION 3.16.0) if(NOT MODULE_HELPERS_FILE) message(FATAL_ERROR "MODULE_HELPERS_FILE is not defined") @@ -17,10 +17,6 @@ if(NOT LINUX_KERNEL_DIR) endif() DefineLinuxModule( - ${CMAKE_CURRENT_SOURCE_DIR}/connection - connection_output - connection_target - INCLUDES - KERNEL_DIR + ${CMAKE_CURRENT_SOURCE_DIR}/connection connection_output connection_target INCLUDES KERNEL_DIR ${LINUX_KERNEL_DIR} ) diff --git a/linux-module-helpers.cmake b/linux-module-helpers.cmake index f723e0f..b0fc576 100644 --- a/linux-module-helpers.cmake +++ b/linux-module-helpers.cmake @@ -4,7 +4,7 @@ # SPDX-License-Identifier: BSD-2-Clause # -cmake_minimum_required(VERSION 3.8.2) +cmake_minimum_required(VERSION 3.16.0) # Function to define a linux kernel module. Given the directory to the # kernel module @@ -13,12 +13,7 @@ cmake_minimum_required(VERSION 3.8.2) # output_module_target: Target name to be used for compiled linux kernel module function(DefineLinuxModule module_dir output_module_location output_module_target) cmake_parse_arguments( - PARSE_ARGV - 1 - DEFINE_LINUX_MODULE - "" - "KERNEL_DIR;ARCH;CROSS_COMPILE" - "DEPENDS;INCLUDES" + PARSE_ARGV 1 DEFINE_LINUX_MODULE "" "KERNEL_DIR;ARCH;CROSS_COMPILE" "DEPENDS;INCLUDES" ) # Check that the linux kerenl directory has been passed if(NOT DEFINE_LINUX_MODULE_KERNEL_DIR) @@ -64,8 +59,10 @@ function(DefineLinuxModule module_dir output_module_location output_module_targe ) # Add target for linux module add_custom_target( - ${output_module_target} ALL - DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${module_name}.ko" + ${output_module_target} ALL DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${module_name}.ko" + ) + set(${output_module_location} + "${CMAKE_CURRENT_BINARY_DIR}/${module_name}.ko" + PARENT_SCOPE ) - set(${output_module_location} "${CMAKE_CURRENT_BINARY_DIR}/${module_name}.ko" PARENT_SCOPE) endfunction(DefineLinuxModule) diff --git a/linux-source-helpers.cmake b/linux-source-helpers.cmake index 634fe5b..99157c0 100644 --- a/linux-source-helpers.cmake +++ b/linux-source-helpers.cmake @@ -4,27 +4,36 @@ # SPDX-License-Identifier: BSD-2-Clause # -cmake_minimum_required(VERSION 3.8.2) +cmake_minimum_required(VERSION 3.16.0) # Function for getting the major version for the default Linux guest kernel provided # by the project # version: caller variable which is set to the kernel major version function(GetDefaultLinuxMajor version) - set(${version} "4" PARENT_SCOPE) + set(${version} + "4" + PARENT_SCOPE + ) endfunction(GetDefaultLinuxMajor) # Function for getting the minor version for the default Linux guest kernel provided # by the project # version: caller variable which is set to the kernel minor version function(GetDefaultLinuxMinor version) - set(${version} "8.16" PARENT_SCOPE) + set(${version} + "8.16" + PARENT_SCOPE + ) endfunction(GetDefaultLinuxMinor) # Function for getting the md5 hash for the default Linux guest kernel provided # by the project # md5: caller variable which is set to the kernel md5 function(GetDefaultLinuxMd5 md5) - set(${md5} "5230b0185b5f4916feab86c450207606" PARENT_SCOPE) + set(${md5} + "5230b0185b5f4916feab86c450207606" + PARENT_SCOPE + ) endfunction(GetDefaultLinuxMd5) # Function for getting the version for the default Linux guest kernel provided @@ -33,7 +42,10 @@ endfunction(GetDefaultLinuxMd5) function(GetDefaultLinuxVersion version) GetDefaultLinuxMinor(minor) GetDefaultLinuxMajor(major) - set(${version} "${major}.${minor}" PARENT_SCOPE) + set(${version} + "${major}.${minor}" + PARENT_SCOPE + ) endfunction(GetDefaultLinuxVersion) # Function for downloading the Linux source inorder to build kernel modules @@ -46,9 +58,8 @@ function(DownloadLinux linux_major linux_minor linux_md5 linux_out_dir linux_out # Create a cmake file to download the linux source. We do this so we don't download the # the linux source until build time file( - WRITE - ${CMAKE_CURRENT_BINARY_DIR}/download_linux.cmake - "file(DOWNLOAD ${linux_url} ${CMAKE_CURRENT_BINARY_DIR}/out/${linux_archive} \ + WRITE ${CMAKE_CURRENT_BINARY_DIR}/download_linux.cmake + "file(DOWNLOAD ${linux_url} ${CMAKE_CURRENT_BINARY_DIR}/out/${linux_archive} \ SHOW_PROGRESS \ EXPECTED_MD5 ${linux_md5})" ) @@ -59,16 +70,14 @@ function(DownloadLinux linux_major linux_minor linux_md5 linux_out_dir linux_out VERBATIM ) add_custom_target( - download_${linux_out_target} - DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/out/${linux_archive}" + download_${linux_out_target} DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/out/${linux_archive}" ) # Unpack linux tar archive # We track the .cmake_extracted file instead of the directory to avoid 'ninja clean' trying to delete # the extracted directory add_custom_command( OUTPUT out/${linux_dir}/.cmake_extracted - COMMAND - ${CMAKE_COMMAND} -E tar xf ${linux_archive} + COMMAND ${CMAKE_COMMAND} -E tar xf ${linux_archive} COMMAND touch ${linux_dir}/.cmake_extracted WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/out VERBATIM @@ -81,27 +90,26 @@ function(DownloadLinux linux_major linux_minor linux_md5 linux_out_dir linux_out ) # Add clean target for extracted linux directory. add_custom_target( - clean-${linux_out_target} - COMMAND bash -c "rm -r ${CMAKE_CURRENT_BINARY_DIR}/out/${linux_dir}" + clean-${linux_out_target} COMMAND bash -c + "rm -r ${CMAKE_CURRENT_BINARY_DIR}/out/${linux_dir}" ) # Add linux out target add_custom_target(${linux_out_target} DEPENDS extract_${linux_out_target}) set_property( - TARGET ${linux_out_target} - PROPERTY EXTRACT_DIR "${CMAKE_CURRENT_BINARY_DIR}/out/${linux_dir}" + TARGET ${linux_out_target} PROPERTY EXTRACT_DIR + "${CMAKE_CURRENT_BINARY_DIR}/out/${linux_dir}" ) # Pass out directory back to parent - set(${linux_out_dir} "${CMAKE_CURRENT_BINARY_DIR}/out/${linux_dir}" PARENT_SCOPE) + set(${linux_out_dir} + "${CMAKE_CURRENT_BINARY_DIR}/out/${linux_dir}" + PARENT_SCOPE + ) endfunction(DownloadLinux) # Function for configuring the Linux source located at 'linux_dir' with given # config (linux_config_location) and symvers (linux_symvers_location) -function( - ConfigureLinux - linux_dir - linux_config_location - linux_symvers_location - configure_linux_target +function(ConfigureLinux linux_dir linux_config_location linux_symvers_location + configure_linux_target ) # Get any existing dependencies for configuring linux cmake_parse_arguments(PARSE_ARGV 4 CONFIGURE_LINUX "" "ARCH;CROSS_COMPILE" "DEPENDS") @@ -121,17 +129,15 @@ function( # Copy linux config & symvers add_custom_command( OUTPUT ${linux_dir}/.config ${linux_dir}/Module.symvers - COMMAND - ${CMAKE_COMMAND} -E copy "${linux_config_location}" "${linux_dir}/.config" - COMMAND - ${CMAKE_COMMAND} -E copy "${linux_symvers_location}" "${linux_dir}/Module.symvers" + COMMAND ${CMAKE_COMMAND} -E copy "${linux_config_location}" "${linux_dir}/.config" + COMMAND ${CMAKE_COMMAND} -E copy "${linux_symvers_location}" "${linux_dir}/Module.symvers" VERBATIM DEPENDS ${CONFIGURE_LINUX_DEPENDS} ) # Create copy config target add_custom_target( - ${configure_linux_target}_copy_configs - DEPENDS "${linux_dir}/.config" "${linux_dir}/Module.symvers" + ${configure_linux_target}_copy_configs DEPENDS "${linux_dir}/.config" + "${linux_dir}/Module.symvers" ) # Prepare/Configure Linux Build Directory add_custom_command( diff --git a/vm-linux-helpers.cmake b/vm-linux-helpers.cmake index 790e8a4..30d4d40 100644 --- a/vm-linux-helpers.cmake +++ b/vm-linux-helpers.cmake @@ -4,9 +4,12 @@ # SPDX-License-Identifier: BSD-2-Clause # -cmake_minimum_required(VERSION 3.8.2) +cmake_minimum_required(VERSION 3.16.0) RequireFile(UPDATE_INITRD_ROOTFS_PATH update_dtb_initrd.py PATHS "${CMAKE_CURRENT_LIST_DIR}/tools") -set(VM_LINUX_PROJECT_DIR "${CMAKE_CURRENT_LIST_DIR}" CACHE INTERNAL "") +set(VM_LINUX_PROJECT_DIR + "${CMAKE_CURRENT_LIST_DIR}" + CACHE INTERNAL "" +) if(KernelX86_64VTX64BitGuests) set(arch_size_dir "64") else() @@ -38,9 +41,8 @@ function(AddFileToOverlayDir filename file_location root_location overlay_name) # Copy the file into the rootfs output directory at 'root_location' add_custom_command( OUTPUT ${rootfs_output_dir}/${root_location}/${filename} - COMMAND - ${CMAKE_COMMAND} -E copy "${file_location}" - "${rootfs_output_dir}/${root_location}/${filename}" + COMMAND ${CMAKE_COMMAND} -E copy "${file_location}" + "${rootfs_output_dir}/${root_location}/${filename}" VERBATIM DEPENDS ${file_location} ${ROOTFS_FILE_OVERLAY_DEPENDS} ) @@ -83,8 +85,7 @@ function(AddLinkToOverlayDir filename file_location root_location overlay_name) # Create the symbolic link add_custom_command( OUTPUT ${rootfs_output_dir}/${root_location}/${filename} - COMMAND - cd ${rootfs_output_dir}/${root_location} && ln -s ${file_location} ${filename} + COMMAND cd ${rootfs_output_dir}/${root_location} && ln -s ${file_location} ${filename} VERBATIM DEPENDS ${ROOTFS_FILE_OVERLAY_DEPENDS} ) @@ -130,8 +131,7 @@ function( set(additional_install_flags "--splitgz") endif() if(NOT ${ROOTFS_OVERLAY_CUSTOM_INIT} STREQUAL "") - set( - additional_install_flags + set(additional_install_flags "${additional_install_flags} --custom-init=${ROOTFS_OVERLAY_CUSTOM_INIT}" ) endif() @@ -156,8 +156,7 @@ function( DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/out_${target_name}/output_overlay_rootfs.cpio${gzip_ext}" ) - set( - ${output_rootfs_location} + set(${output_rootfs_location} "${CMAKE_CURRENT_BINARY_DIR}/out_${target_name}/output_overlay_rootfs.cpio${gzip_ext}" PARENT_SCOPE ) @@ -185,7 +184,10 @@ function( "$" ${ARGN} ) - set(${output_rootfs_location} "${return_location}" PARENT_SCOPE) + set(${output_rootfs_location} + "${return_location}" + PARENT_SCOPE + ) endfunction(AddOverlayDirToRootfs) # Wrapper function to declare object files in an external project and add them to the targeted overlay @@ -195,12 +197,8 @@ endfunction(AddOverlayDirToRootfs) # overlay_root_location: The location in the overlay the file is to be installed. Note all files passed in a given # call of this helper will install in the same root location. # FILES: A list of files to declare from an external project and add to the given overlay -function( - AddExternalProjFilesToOverlay - external_target - external_install_dir - overlay_target - overlay_root_location +function(AddExternalProjFilesToOverlay external_target external_install_dir overlay_target + overlay_root_location ) # Get the external project files to add the the overlay cmake_parse_arguments(PARSE_ARGV 4 EXTERNAL_PROJ_OVERLAY "" "" "FILES") @@ -215,21 +213,14 @@ function( # Declare the project files include(external-project-helpers) DeclareExternalProjObjectFiles( - ${external_target} - ${external_install_dir} - FILES - ${EXTERNAL_PROJ_OVERLAY_FILES} + ${external_target} ${external_install_dir} FILES ${EXTERNAL_PROJ_OVERLAY_FILES} ) # Iterate adding each file to the overlay foreach(file IN LISTS EXTERNAL_PROJ_OVERLAY_FILES) get_filename_component(file_name ${file} NAME) AddFileToOverlayDir( - "${file_name}" - ${external_install_dir}/${file} - "${overlay_root_location}" - ${overlay_target} - DEPENDS - ${external_target} + "${file_name}" ${external_install_dir}/${file} "${overlay_root_location}" + ${overlay_target} DEPENDS ${external_target} ) endforeach() endfunction() @@ -237,13 +228,8 @@ endfunction() # Function takes an input dtb file and input rootfs file and creates a new dtb with # updated initrd-start and initrd-end fields. These fields reflect the size of the # input rootfs file. -function( - UpdateDtbFromInitrd - input_dtb_file - input_rootfs_file - initrd_start_location - output_dtb_target - output_dtb_file +function(UpdateDtbFromInitrd input_dtb_file input_rootfs_file initrd_start_location + output_dtb_target output_dtb_file ) get_filename_component(dtb_basename ${input_dtb_file} NAME) cmake_parse_arguments(PARSE_ARGV 5 INITRD_DTB "" "" "DEPENDS") @@ -251,27 +237,27 @@ function( add_custom_command( OUTPUT ${output_dtb_filename} COMMAND - python3 "${UPDATE_INITRD_ROOTFS_PATH}" - --dtb "${input_dtb_file}" - --output_dtb "${CMAKE_CURRENT_BINARY_DIR}/${output_dtb_filename}" - --initrd "${input_rootfs_file}" + python3 "${UPDATE_INITRD_ROOTFS_PATH}" --dtb "${input_dtb_file}" --output_dtb + "${CMAKE_CURRENT_BINARY_DIR}/${output_dtb_filename}" --initrd "${input_rootfs_file}" --initrd_start "${initrd_start_location}" VERBATIM DEPENDS ${input_dtb_file} ${input_rootfs_file} ${INITRD_DTB_DEPENDS} ) add_custom_target( - ${output_dtb_target} - DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${output_dtb_filename}" + ${output_dtb_target} DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${output_dtb_filename}" + ) + set(${output_dtb_file} + "${CMAKE_CURRENT_BINARY_DIR}/${output_dtb_filename}" + PARENT_SCOPE ) - set(${output_dtb_file} "${CMAKE_CURRENT_BINARY_DIR}/${output_dtb_filename}" PARENT_SCOPE) endfunction(UpdateDtbFromInitrd) # Function for getting the default location of the Linux guest kernel provided # by the vm project # dest_file: caller variable which is set with the kernel location function(GetDefaultLinuxKernelFile dest_file) - set( - ${dest_file} ${VM_LINUX_PROJECT_DIR}/images/kernel/${arch_size_dir}/default_bzimage_4.8.16 + set(${dest_file} + ${VM_LINUX_PROJECT_DIR}/images/kernel/${arch_size_dir}/default_bzimage_4.8.16 PARENT_SCOPE ) endfunction(GetDefaultLinuxKernelFile) @@ -284,8 +270,8 @@ function(GetArchDefaultLinuxKernelFile arch_size dest_file) if(NOT (arch_size STREQUAL "32" OR arch_size STREQUAL "64")) message(FATAL_ERROR "arch_size for GetArchDefaultLinuxKernelFile should be either 32 or 64") endif() - set( - ${dest_file} ${VM_LINUX_PROJECT_DIR}/images/kernel/${arch_size}/default_bzimage_4.8.16 + set(${dest_file} + ${VM_LINUX_PROJECT_DIR}/images/kernel/${arch_size}/default_bzimage_4.8.16 PARENT_SCOPE ) endfunction(GetArchDefaultLinuxKernelFile) @@ -294,8 +280,7 @@ endfunction(GetArchDefaultLinuxKernelFile) # by the vm project # dest_file: caller variable which is set with the rootfs location function(GetDefaultLinuxRootfsFile dest_file) - set( - ${dest_file} + set(${dest_file} ${VM_LINUX_PROJECT_DIR}/images/rootfs/${arch_size_dir}/default_buildroot_rootfs-bare.cpio PARENT_SCOPE ) @@ -309,8 +294,7 @@ function(GetArchDefaultLinuxRootfsFile arch_size dest_file) if(NOT (arch_size STREQUAL "32" OR arch_size STREQUAL "64")) message(FATAL_ERROR "arch_size for GetArchDefaultLinuxRootfsFile should be either 32 or 64") endif() - set( - ${dest_file} + set(${dest_file} ${VM_LINUX_PROJECT_DIR}/images/rootfs/${arch_size}/default_buildroot_rootfs-bare.cpio PARENT_SCOPE )