@@ -110,27 +110,20 @@ function(DefineCAmkESVMFileServer)
110110 set (PARAM_TYPE "FileServer" )
111111 endif ()
112112
113- if (PARAM_INSTANCE)
114- set (FSRV_TARGET "${PARAM_INSTANCE} _config" )
115- else ()
113+ if (NOT PARAM_INSTANCE)
116114 set (PARAM_INSTANCE "fserv" )
117- set (FSRV_TARGET "vm_fserver_config" )
118- endif ()
119-
120- # The target might exist already when AddToFileServer() was called.
121- if (NOT TARGET ${FSRV_TARGET} )
122- add_custom_target (${FSRV_TARGET} )
123115 endif ()
124116
125117 # For dependencies and files, both lists and lists of list are supported for
126118 # convenience reasons. Furthermore, empty entries are also allowed. This
127119 # can happen when the caller uses variables for the lists, when in some
128120 # configurations the lists remain empty.
129121
122+ set (DEPS "" )
130123 foreach (element IN LISTS PARAM_DEPENDS)
131124 foreach (item IN LISTS element)
132125 if (item)
133- set_property ( TARGET ${FSRV_TARGET} APPEND PROPERTY DEPS ${item} )
126+ list ( APPEND DEPS " ${item} " )
134127 endif ()
135128 endforeach ()
136129 endforeach ()
@@ -155,54 +148,24 @@ function(DefineCAmkESVMFileServer)
155148 set (FILE_NAME "${CMAKE_MATCH_1} " )
156149 get_filename_component (CPIO_NAME "${FILE_NAME} " NAME )
157150 endif ()
158- set_property (
159- TARGET ${FSRV_TARGET}
160- APPEND
161- PROPERTY FILES "${CPIO_NAME} :${FILE_NAME} "
151+ set (CPIO_FILE "${PARAM_INSTANCE} /files/${CPIO_NAME} " )
152+ add_custom_command (
153+ OUTPUT "${CPIO_FILE} "
154+ COMMENT "copy: ${FILE_NAME} -> ${CPIO_FILE} "
155+ COMMAND
156+ ${CMAKE_COMMAND} -E copy "${FILE_NAME} " "${CPIO_FILE} "
157+ VERBATIM
158+ DEPENDS ${FILE_NAME} ${DEPS}
162159 )
160+ # There is no need to create an explicit target for the command
161+ # above, because the archive creation depends on all files
162+ # listed in CPIO_FILES. The command above is the creation rule
163+ # for each one.
164+ list (APPEND CPIO_FILES "${CPIO_FILE} " )
163165 endif ()
164166 endforeach ()
165167 endforeach ()
166168
167- # now process the file/deps list
168- get_target_property (files ${FSRV_TARGET} FILES )
169- if (NOT files) # this also catches "files-NOTFOUND" if property is not set
170- set (files "" )
171- endif ()
172- get_target_property (deps ${FSRV_TARGET} DEPS )
173- if (NOT deps) # this also catches "deps-NOTFOUND" if property is not set
174- set (deps "" )
175- endif ()
176-
177- set (CPIO_FILES "" )
178- foreach (item IN LISTS files) # <CPIO_NAME>:<FILENAME>
179- string (
180- REGEX
181- MATCH
182- "^([^:]+):([^:]+)$"
183- cpio_item
184- "${item} "
185- )
186- if (NOT cpio_item)
187- message (FATAL_ERROR "invalid CPIO file format: '${item} '" )
188- endif ()
189- set (CPIO_NAME "${CMAKE_MATCH_1} " )
190- set (FILE_NAME "${CMAKE_MATCH_2} " )
191- set (CPIO_FILE "${PARAM_INSTANCE} /files/${CPIO_NAME} " )
192- add_custom_command (
193- OUTPUT "${CPIO_FILE} "
194- COMMENT "copy: ${FILE_NAME} -> ${CPIO_FILE} "
195- COMMAND
196- ${CMAKE_COMMAND} -E copy "${FILE_NAME} " "${CPIO_FILE} "
197- VERBATIM
198- DEPENDS ${FILE_NAME} ${deps}
199- )
200- # There is no need to create an explicit target for the command above,
201- # the archive creation depends on all files in CPIO_FILES, where the
202- # command above is the creation rule for each one.
203- list (APPEND CPIO_FILES "${CPIO_FILE} " )
204- endforeach ()
205-
206169 # Build CPIO archive. It implicitly depends on all files in CPIO_FILES,
207170 # which have their own dependencies each from above. So we don't have any
208171 # additional explicit dependencies here.
@@ -254,59 +217,6 @@ function(DeclareCAmkESVMRootServer camkes_config)
254217 )
255218endfunction (DeclareCAmkESVMRootServer )
256219
257- # Function for adding a file/image to the vm file server.
258- #
259- # Parameters:
260- #
261- # <filename_pref>
262- # The name the caller wishes to use to reference the file in the CPIO archive.
263- # This corresponds with the name set in the 'kernel_image' camkes variable for
264- # a given instance vm.
265- #
266- # <file_dest>
267- # The location of the file/image the caller is adding to the file server
268- #
269- # INSTANCE <name>
270- # Instance name of the file server CAmkES component.
271- # Optional, defaults to "fserv"
272- #
273- # DEPENDS <dep>[ <dep>[...]]
274- # Any additional dependencies for the file/image the caller is adding to the
275- # file server
276- #
277- function (AddToFileServer filename_pref file_dest )
278-
279- cmake_parse_arguments (
280- PARSE_ARGV
281- 2
282- PARAM # variable prefix
283- "" # option arguments
284- "INSTANCE" # optional single value arguments
285- "DEPENDS" # optional multi value arguments
286- )
287-
288- if (PARAM_UNPARSED_ARGUMENTS)
289- message (FATAL_ERROR "Unknown arguments: ${PARAM_UNPARSED_ARGUMENTS} " )
290- endif ()
291-
292- if (PARAM_INSTANCE)
293- set (FSRV_TARGET "${PARAM_INSTANCE} _config" )
294- else ()
295- set (FSRV_TARGET "vm_fserver_config" )
296- endif ()
297-
298- if (NOT TARGET ${FSRV_TARGET} )
299- add_custom_target (${FSRV_TARGET} )
300- endif ()
301-
302- set_property (TARGET ${FSRV_TARGET} APPEND PROPERTY FILES "${filename_pref} :${file_dest} " )
303-
304- if (PARAM_DEPENDS)
305- set_property (TARGET ${FSRV_TARGET} APPEND PROPERTY DEPS ${PARAM_DEPENDS} )
306- endif ()
307-
308- endfunction (AddToFileServer )
309-
310220# Function for decompressing/extracting a vmlinux file from a given kernel image
311221# decompress_target: The target name the caller wishes to use to generate the decompressed kernel
312222# image
0 commit comments