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

FPP CMake integration #1629

Merged
merged 3 commits into from
Sep 19, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
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
13 changes: 12 additions & 1 deletion cmake/autocoder/ai_xml.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,20 @@ autocoder_setup_for_individual_sources()
#
# Required function, processes ComponentAi.xml files.
# `AC_INPUT_FILE` potential input to the autocoder
# ...: any number of arguments representing a list of previously generated files
####
function(ai_xml_is_supported AC_INPUT_FILE)
autocoder_support_by_suffix("Ai.xml" "${AC_INPUT_FILE}")
ends_with(IS_SUPPORTED "${AC_INPUT_FILE}" "Ai.xml")
# Don't generate cpp/hpp files that have already been generated
if (IS_SUPPORTED)
string(REPLACE "Ai.xml" "Ac.cpp" CPP_FILE "${AC_INPUT_FILE}")
string(REPLACE "Ai.xml" "Ac.hpp" HPP_FILE "${AC_INPUT_FILE}")
if(("${CPP_FILE}" IN_LIST ARGN) AND ("${HPP_FILE}" IN_LIST ARGN))
set(IS_SUPPORTED FALSE)
endif()
endif()
# Note: set in PARENT_SCOPE in macro is intended. Caller **wants** to set IS_SUPPORTED in their parent's scope.
set(IS_SUPPORTED "${IS_SUPPORTED}" PARENT_SCOPE)
endfunction (ai_xml_is_supported)

####
Expand Down
7 changes: 4 additions & 3 deletions cmake/autocoder/autocoder.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function(run_ac AUTOCODER_CMAKE SOURCES GENERATED_SOURCES)
plugin_include_helper(AUTOCODER_NAME "${AUTOCODER_CMAKE}" is_supported setup_autocode get_generated_files get_dependencies)
# Normalize and filter source paths so that what we intend to run is in a standard form
normalize_paths(AC_INPUT_SOURCES "${SOURCES}" "${GENERATED_SOURCES}")
_filter_sources(AC_INPUT_SOURCES "${AC_INPUT_SOURCES}")
_filter_sources(AC_INPUT_SOURCES "${GENERATED_SOURCES}" "${AC_INPUT_SOURCES}")

# Break early if there are no sources, no need to autocode nothing
if (NOT AC_INPUT_SOURCES)
Expand Down Expand Up @@ -184,14 +184,15 @@ endfunction()
# including an autocoder's CMake file and thus setting the active autocoder. Helper function.
#
# OUTPUT_NAME: name of output variable to set in parent scope
# GENERATED_SOURCES: sources created by other autocoders
# ...: any number of arguments containing lists of sources
####
function(_filter_sources OUTPUT_NAME)
function(_filter_sources OUTPUT_NAME GENERATED_SOURCES)
set(OUTPUT_LIST)
# Loop over the list and check
foreach (SOURCE_LIST IN LISTS ARGN)
foreach(SOURCE IN LISTS SOURCE_LIST)
cmake_language(CALL "${AUTOCODER_NAME}_is_supported" "${SOURCE}")
cmake_language(CALL "${AUTOCODER_NAME}_is_supported" "${SOURCE}" ${GENERATED_SOURCES})
if (IS_SUPPORTED)
list(APPEND OUTPUT_LIST "${SOURCE}")
endif()
Expand Down