Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom autocoders #1558

Merged
merged 3 commits into from
Jul 20, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions cmake/API.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
####
set(FPRIME_TARGET_LIST "" CACHE INTERNAL "FPRIME_TARGET_LIST: custom fprime targets" FORCE)
set(FPRIME_UT_TARGET_LIST "" CACHE INTERNAL "FPRIME_UT_TARGET_LIST: custom fprime targets" FORCE)
set(FPRIME_AUTOCODER_TARGET_LIST "" CACHE INTERNAL "FPRIME_AUTOCODER_TARGET_LIST: custom fprime targets" FORCE)
####
# Function `add_fprime_subdirectory`:
#
Expand Down Expand Up @@ -467,6 +468,45 @@ macro(register_fprime_target_helper TARGET_FILE_PATH TARGET_LIST)
endmacro(register_fprime_target_helper)


####
# Macro `register_fprime_autocoder`:
#
# Identical to the above `register_fprime_target` function
LeStarch marked this conversation as resolved.
Show resolved Hide resolved
#
###
macro(register_fprime_autocoder TARGET_FILE_PATH)
# Normal registered targets don't run in prescan
message(STATUS "Registering custom autocoder: ${TARGET_FILE_PATH}")
if (NOT DEFINED FPRIME_PRESCAN)
register_fprime_autocoder_helper("${TARGET_FILE_PATH}" FPRIME_AUTOCODER_TARGET_LIST)
endif()
endmacro(register_fprime_autocoder)


####
# Macro `register_fprime_autocoder_helper`:
#
# Helper function to do the actual registration.
#
####
macro(register_fprime_autocoder_helper TARGET_FILE_PATH TARGET_LIST)
LeStarch marked this conversation as resolved.
Show resolved Hide resolved
include("${TARGET_FILE_PATH}")
# Prevent out-of-order setups
get_property(MODULE_DETECTION_STARTED GLOBAL PROPERTY MODULE_DETECTION SET)
if (MODULE_DETECTION_STARTED)
message(FATAL_ERROR "Cannot register fprime autocoder after including subdirectories or FPrime-Code.cmake'")
endif()
# Get the target list to add this target to or use default
set(LIST_NAME FPRIME_AUTOCODER_TARGET_LIST)
if (${ARGC} GREATER 1)
set(LIST_NAME "${ARGV1}")
endif()
get_property(TARGETS GLOBAL PROPERTY "${TARGET_LIST}")
if (NOT TARGET_FILE_PATH IN_LIST TARGETS)
set_property(GLOBAL APPEND PROPERTY "${LIST_NAME}" "${TARGET_FILE_PATH}")
endif()
endmacro(register_fprime_autocoder_helper)

#### Documentation links
# Next Topics:
# - Setting Options: [Options](Options.md) are used to vary a CMake build.
Expand Down
3 changes: 2 additions & 1 deletion cmake/target/build.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ endfunction()
function(build_add_module_target MODULE TARGET SOURCES DEPENDENCIES)
get_target_property(MODULE_TYPE "${MODULE}" FP_TYPE)
message(STATUS "Adding ${MODULE_TYPE}: ${MODULE}")
run_ac_set("${SOURCES}" autocoder/fpp autocoder/ai_xml)
get_property(CUSTOM_AUTOCODERS GLOBAL PROPERTY FPRIME_AUTOCODER_TARGET_LIST)
run_ac_set("${SOURCES}" autocoder/fpp autocoder/ai_xml ${CUSTOM_AUTOCODERS})
LeStarch marked this conversation as resolved.
Show resolved Hide resolved
resolve_dependencies(RESOLVED ${DEPENDENCIES} ${AC_DEPENDENCIES} )
build_setup_build_module("${MODULE}" "${SOURCES}" "${AC_GENERATED}" "${AC_SOURCES}" "${RESOLVED}")
# Special flags applied to modules when compiling with testing enabled
Expand Down
2 changes: 1 addition & 1 deletion docs/UsersGuide/dev/target-integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ globally. Module targets run on every module defining the `<target>_register_fpr
targets run on deployments defined with the `<target>_register_fprime_deployment` calls, and global targets run once.

Targets are CMake files that define three functions, one for each level, and are described below. The filename of this
CMake without the `.cmake` extension is determines the`<target>` name. e.g. `utility.cmake` will define the `utility`
CMake without the `.cmake` extension determines the`<target>` name. e.g. `utility.cmake` will define the `utility`
target.

Targets stages are defined in the following order:
Expand Down