@@ -233,6 +233,53 @@ function(setup_global_topicids)
233
233
234
234
endfunction (setup_global_topicids)
235
235
236
+ ##################################################################
237
+ #
238
+ # FUNCTION: export_variable_cache
239
+ #
240
+ # Export variables to a "mission_vars.cache" file so they can be
241
+ # referenced by the target-specific builds. This list is ingested
242
+ # during the startup phase of all the subordinate cmake invocations.
243
+ #
244
+ # The passed-in USER_VARLIST should be the names of additional variables
245
+ # to export. These can be cache vars or normal vars.
246
+ #
247
+ function (export_variable_cache USER_VARLIST)
248
+
249
+ # The set of variables that should always be exported
250
+ set (FIXED_VARLIST
251
+ "MISSION_NAME"
252
+ "SIMULATION"
253
+ "MISSION_DEFS"
254
+ "MISSION_SOURCE_DIR"
255
+ "MISSION_BINARY_DIR"
256
+ "MISSIONCONFIG"
257
+ "MISSION_APPS"
258
+ "MISSION_PSPMODULES"
259
+ "MISSION_DEPS"
260
+ "MISSION_EDS_FILELIST"
261
+ "MISSION_EDS_SCRIPTLIST"
262
+ "ENABLE_UNIT_TESTS"
263
+ )
264
+
265
+ set (MISSION_VARCACHE)
266
+ foreach (VARL ${FIXED_VARLIST} ${USER_VARLIST} ${ARGN} )
267
+ # It is important to avoid putting any blank lines in the output,
268
+ # This will cause the reader to misinterpret the data
269
+ if (NOT "${${VARL} }" STREQUAL "" )
270
+ string (APPEND MISSION_VARCACHE "${VARL} \n ${${VARL} }\n " )
271
+ endif (NOT "${${VARL} }" STREQUAL "" )
272
+ endforeach ()
273
+
274
+ # Write the file -- the subprocess will read this file and re-create
275
+ # variables out of them. The alternative to this is to specify many "-D"
276
+ # parameters to the subordinate build but that would not scale well to many vars,
277
+ # and it would go through the shell meaning quoting/escaping for safety becomes
278
+ # very difficult. Using the file method avoids shell interpretation.
279
+ file (WRITE "${CMAKE_BINARY_DIR} /mission_vars.cache" "${MISSION_VARCACHE} " )
280
+
281
+ endfunction (export_variable_cache)
282
+
236
283
##################################################################
237
284
#
238
285
# FUNCTION: prepare
@@ -246,15 +293,16 @@ function(prepare)
246
293
add_definitions (-DSIMULATION=${SIMULATION} )
247
294
endif (SIMULATION)
248
295
249
- # Prepare the table makefile - Ensure the list of tables is initially empty
250
- file (MAKE_DIRECTORY "${MISSION_BINARY_DIR} /tables" )
251
- file (WRITE "${MISSION_BINARY_DIR} /tables/Makefile"
252
- "MISSION_BINARY_DIR := ${MISSION_BINARY_DIR} \n "
253
- "TABLE_BINARY_DIR := ${MISSION_BINARY_DIR} /tables\n "
254
- "MISSION_SOURCE_DIR := ${MISSION_SOURCE_DIR} \n "
255
- "MISSION_DEFS := ${MISSION_DEFS} \n\n "
256
- "include \$ (wildcard ${CFE_SOURCE_DIR} /cmake/tables/*.mk) \$ (wildcard *.d)\n "
257
- )
296
+ # Create directories to hold generated files/wrappers
297
+ file (MAKE_DIRECTORY "${MISSION_BINARY_DIR} /eds" )
298
+ file (MAKE_DIRECTORY "${MISSION_BINARY_DIR} /obj" )
299
+ file (MAKE_DIRECTORY "${MISSION_BINARY_DIR} /inc" )
300
+ file (MAKE_DIRECTORY "${MISSION_BINARY_DIR} /src" )
301
+
302
+ # Certain runtime variables need to be "exported" to the subordinate build, such as
303
+ # the specific arch settings and the location of all the apps. This list is collected
304
+ # during this function execution and exported at the end.
305
+ set (EXPORT_VARLIST)
258
306
259
307
# Create custom targets for building and cleaning all architectures
260
308
# This is required particularly for doing extra stuff in the clean step
@@ -428,76 +476,46 @@ function(prepare)
428
476
# msgid definitions, or any other configuration/preparation that needs to
429
477
# happen at mission/global scope.
430
478
foreach (DEP_NAME ${MISSION_DEPS} )
479
+ list (APPEND EXPORT_VARLIST "${DEP_NAME} _MISSION_DIR" )
431
480
include ("${${DEP_NAME} _MISSION_DIR}/mission_build.cmake" OPTIONAL )
432
481
endforeach (DEP_NAME ${MISSION_DEPS} )
433
482
434
- # Certain runtime variables need to be "exported" to the subordinate build, such as
435
- # the specific arch settings and the location of all the apps. This is done by creating
436
- # a temporary file within the dir and then the subprocess will read that file and re-create
437
- # variables out of them. The alternative to this is to specify many "-D" parameters to the
438
- # subordinate build but that would not scale well to many vars.
439
- set (VARLIST
440
- "MISSION_NAME"
441
- "SIMULATION"
442
- "MISSION_DEFS"
443
- "MISSION_SOURCE_DIR"
444
- "MISSION_BINARY_DIR"
445
- "MISSIONCONFIG"
446
- "MISSION_APPS"
447
- "MISSION_PSPMODULES"
448
- "MISSION_DEPS"
449
- "ENABLE_UNIT_TESTS"
450
- )
451
- foreach (APP ${MISSION_DEPS} )
452
- list (APPEND VARLIST "${APP} _MISSION_DIR" )
453
- endforeach ()
454
-
455
483
foreach (SYSVAR ${TGTSYS_LIST} )
456
- list (APPEND VARLIST "BUILD_CONFIG_${SYSVAR} " )
484
+ list (APPEND EXPORT_VARLIST "BUILD_CONFIG_${SYSVAR} " )
457
485
endforeach (SYSVAR ${TGTSYS_LIST} )
458
486
459
- set (MISSION_VARCACHE)
460
- foreach (VARL ${VARLIST} )
461
- # It is important to avoid putting any blank lines in the output,
462
- # This will cause the reader to misinterpret the data
463
- if (NOT "${${VARL} }" STREQUAL "" )
464
- set (MISSION_VARCACHE "${MISSION_VARCACHE}${VARL} \n ${${VARL} }\n " )
465
- endif (NOT "${${VARL} }" STREQUAL "" )
466
- endforeach (VARL ${VARLIST} )
467
- file (WRITE "${CMAKE_BINARY_DIR} /mission_vars.cache" "${MISSION_VARCACHE} " )
468
-
469
487
generate_build_version_templates()
470
488
471
489
# Generate the tools for the native (host) arch
472
490
# Add all public include dirs for core components to include path for tools
473
491
include_directories (
492
+ ${MISSION_BINARY_DIR} /inc
474
493
${core_api_MISSION_DIR} /fsw/inc
475
494
${osal_MISSION_DIR} /src/os/inc
476
495
${psp_MISSION_DIR} /fsw/inc
477
496
)
478
497
add_subdirectory (${MISSION_SOURCE_DIR} /tools tools)
479
498
480
499
# Add a dependency on the table generator tool as this is required for table builds
481
- # The "elf2cfetbl" target should have been added by the "tools" above
482
- add_dependencies (mission-prebuild elf2cfetbl)
483
- set (TABLETOOL_EXEC $<TARGET_FILE:elf2cfetbl>)
484
-
485
- add_custom_target (tabletool-execute
486
- COMMAND $(MAKE)
487
- CC="${CMAKE_C_COMPILER} "
488
- CFLAGS="${CMAKE_C_FLAGS} "
489
- AR="${CMAKE_AR} "
490
- TBLTOOL="${TABLETOOL_EXEC} "
491
- cfetables
492
- WORKING_DIRECTORY
493
- "${CMAKE_BINARY_DIR} /tables"
494
- DEPENDS
495
- mission-cfetables
500
+ # The table tool target should have been added by the "tools" above
501
+ if (NOT DEFINED CFS_TABLETOOL_SCRIPT_DIR)
502
+ message (FATAL_ERROR "Table Tool missing: CFS_TABLETOOL_SCRIPT_DIR must be defined by the tools" )
503
+ endif ()
504
+ list (APPEND EXPORT_VARLIST CFS_TABLETOOL_SCRIPT_DIR)
505
+
506
+ # Prepare the table makefile - Ensure the list of tables is initially empty
507
+ file (REMOVE_RECURSE "${MISSION_BINARY_DIR} /tables" )
508
+ file (MAKE_DIRECTORY "${MISSION_BINARY_DIR} /tables" )
509
+ file (WRITE "${MISSION_BINARY_DIR} /tables/Makefile"
510
+ "MISSION_BINARY_DIR := ${MISSION_BINARY_DIR} \n "
511
+ "TABLE_BINARY_DIR := ${MISSION_BINARY_DIR} /tables\n "
512
+ "TABLETOOL_SCRIPT_DIR := ${CFS_TABLETOOL_SCRIPT_DIR} \n "
513
+ "MISSION_SOURCE_DIR := ${MISSION_SOURCE_DIR} \n "
514
+ "MISSION_DEFS := ${MISSION_DEFS} \n\n "
515
+ "include \$ (wildcard $(TABLETOOL_SCRIPT_DIR)/*.mk) \$ (wildcard *.d)\n "
496
516
)
497
- add_dependencies (mission-all tabletool-execute)
498
- add_dependencies (mission-install tabletool-execute)
517
+
499
518
add_dependencies (mission-cfetables mission-prebuild)
500
- install (DIRECTORY ${CMAKE_BINARY_DIR} /tables/staging/ DESTINATION .)
501
519
502
520
# Build version information should be generated as part of the pre-build process
503
521
add_dependencies (mission-prebuild mission-version )
@@ -507,6 +525,10 @@ function(prepare)
507
525
install (DIRECTORY ${MISSION_DEFS} /functional-test / DESTINATION ${FT_INSTALL_SUBDIR} )
508
526
endif ()
509
527
528
+ # Export the important state variables collected during this function.
529
+ # This is done last such that everything should have its correct value
530
+ export_variable_cache(${EXPORT_VARLIST} )
531
+
510
532
endfunction (prepare)
511
533
512
534
##################################################################
0 commit comments