-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lestarch: fpp tools installation checks version
- Loading branch information
Showing
5 changed files
with
99 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,86 @@ | ||
message(STATUS "Searching/installing for fpp-tools") | ||
find_program(FPP_DEPEND fpp-depend) | ||
find_program(FPP_TO_XML fpp-to-xml) | ||
find_program(FPP_TO_CPP fpp-to-cpp) | ||
find_program(FPP_LOCATE_DEFS fpp-locate-defs) | ||
#### | ||
# fpp.cmake: | ||
# | ||
# A setup to install fpp tool suite automatically as part of the CMake run. If the user wants to avoid this, the user | ||
# should install FPP on the system path and that will be used. | ||
#### | ||
set(FPP_VERSION 0d7c587898ddb7a672775dbd2efe55d4e42051da) | ||
set(FPP_TOOLS_PATH "${CMAKE_BINARY_DIR}/fpp-tools-install" CACHE PATH "Installation path for fpp tools") | ||
|
||
#### | ||
# locate_fpp_tools: | ||
# | ||
# Locates the fpp tool suite and sets FPP_FOUND if the right version of the tools is found. It will look first to the | ||
# above install location and then to the system path as a fallback. | ||
#### | ||
function(locate_fpp_tools NO_DEFAULTS) | ||
set(FPP_RE_MATCH "(v[0-9].[0-9].[0-9]) commit ([a-f0-9]+)") | ||
# Loop through each tool, looking if it was found and check the version | ||
foreach(TOOL FPP_DEPEND FPP_TO_XML FPP_TO_CPP FPP_LOCATE_DEFS) | ||
string(TOLOWER ${TOOL} PROGRAM) | ||
string(REPLACE "_" "-" PROGRAM "${PROGRAM}") | ||
|
||
# Clear any previous version of this find and search in this order: install dir, system path | ||
unset(${TOOL} CACHE) | ||
find_program(${TOOL} ${PROGRAM} PATHS ${FPP_TOOLS_PATH} NO_DEFAULT_PATH) | ||
find_program(${TOOL} ${PROGRAM} PATHS ${FPP_TOOLS_PATH}) | ||
|
||
# If the tool exists, check the version | ||
if (${TOOL}) | ||
execute_process(COMMAND ${${TOOL}} --help OUTPUT_VARIABLE OUTPUT_TEXT) | ||
if (OUTPUT_TEXT MATCHES "${FPP_RE_MATCH}") | ||
if ("${CMAKE_MATCH_1}" STREQUAL "${FPP_VERSION}" OR "${CMAKE_MATCH_2}" STREQUAL "${FPP_VERSION}") | ||
continue() | ||
endif() | ||
message(STATUS "[fpp-tools] ${${TOOL}} version ${CMAKE_MATCH_0} not expected version ${FPP_VERSION}") | ||
endif() | ||
endif() | ||
set(FPP_FOUND False PARENT_SCOPE) | ||
return() | ||
endforeach() | ||
set(FPP_FOUND True PARENT_SCOPE) | ||
message(STATUS "[fpp-tools] fpp-depend found at: ${FPP_DEPEND}") | ||
message(STATUS "[fpp-tools] fpp-to-xml found at: ${FPP_TO_XML}") | ||
message(STATUS "[fpp-tools] fpp-to-cpp found at: ${FPP_TO_CPP}") | ||
message(STATUS "[fpp-tools] fpp-locate-defs found at: ${FPP_LOCATE_DEFS}") | ||
endfunction(locate_fpp_tools) | ||
|
||
|
||
message(STATUS "[fpp-tools] Searching for fpp-tools") | ||
locate_fpp_tools(False) | ||
# Download and unpack googletest at configure time if it doesn't exit already | ||
if (NOT FPP_DEPEND OR NOT FPP_TO_XML OR NOT FPP_TO_CPP OR NOT FPP_LOCATE_DEFS) | ||
if (NOT FPP_FOUND) | ||
make_directory(${FPP_TOOLS_PATH}) | ||
include("${CMAKE_CURRENT_LIST_DIR}/sbt.cmake") | ||
message(STATUS "[fpp-tools] Installing new tools to ${FPP_TOOLS_PATH}, this will take a few minutes") | ||
configure_file("${CMAKE_CURRENT_LIST_DIR}/CMakeLists.fpp.txt.in" fpp-download/CMakeLists.txt) | ||
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . | ||
RESULT_VARIABLE result | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/fpp-download ) | ||
execute_process( | ||
COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . | ||
RESULT_VARIABLE result | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/fpp-download | ||
OUTPUT_QUIET | ||
ERROR_VARIABLE ERROR_OUT | ||
) | ||
if(result) | ||
message(FATAL_ERROR "CMake step for fpp failed: ${result}") | ||
message(FATAL_ERROR "Download step for fpp failed: ${result}\n${ERROR_OUT}") | ||
endif() | ||
# Cached JAVA and sbt items | ||
find_program(JAVA java) | ||
find_program(SBT sbt) | ||
get_filename_component(JAVA_PATH "${JAVA}" DIRECTORY) | ||
get_filename_component(SBT_PATH "${SBT}" DIRECTORY) | ||
|
||
execute_process(COMMAND ${CMAKE_COMMAND} -E env PATH="${JAVA_PATH}:${SBT_PATH}:$ENV{PATH}" | ||
${CMAKE_COMMAND} --build . | ||
RESULT_VARIABLE result | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/fpp-download ) | ||
execute_process( | ||
COMMAND ${CMAKE_COMMAND} -E env PATH="${JAVA_PATH}:${SBT_PATH}:$ENV{PATH}" ${CMAKE_COMMAND} --build . | ||
RESULT_VARIABLE result | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/fpp-download | ||
OUTPUT_QUIET | ||
ERROR_VARIABLE ERROR_OUT | ||
) | ||
if(result) | ||
message(FATAL_ERROR "Build step for fpp failed: ${result}") | ||
message(FATAL_ERROR "Build step for fpp failed: ${result}\n${ERROR_OUT}") | ||
endif() | ||
locate_fpp_tools(True) | ||
if (NOT FPP_FOUND) | ||
message(FATAL_ERROR "[fpp-tools] Failed to install fpp-tools version ${FPP_VERSION}") | ||
endif() | ||
find_program(FPP_DEPEND fpp-depend PATH ${CMAKE_BINARY_DIR}/fpp-tools/src/compiler/bin/) | ||
find_program(FPP_TO_XML fpp-to-xml PATH ${CMAKE_BINARY_DIR}/fpp-tools/src/compiler/bin/) | ||
find_program(FPP_TO_CPP fpp-to-cpp PATH ${CMAKE_BINARY_DIR}/fpp-tools/src/compiler/bin/) | ||
find_program(FPP_LOCATE_DEFS fpp-locate-defs PATH ${CMAKE_BINARY_DIR}/fpp-tools/src/compiler/bin/) | ||
endif() | ||
message(STATUS "fpp-depend found at: ${FPP_DEPEND}") | ||
message(STATUS "fpp-to-xml found at: ${FPP_TO_XML}") | ||
message(STATUS "fpp-to-cpp found at: ${FPP_TO_CPP}") | ||
message(STATUS "fpp-locate-defs found at: ${FPP_LOCATE_DEFS}") | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,29 @@ | ||
message(STATUS "Searching/installing for sbt") | ||
message(STATUS "[fpp-tools] Searching for sbt") | ||
find_program(SBT sbt) | ||
# Download and unpack googletest at configure time if it doesn't exit already | ||
if (SBT STREQUAL "SBT-NOTFOUND" ) | ||
if (NOT SBT) | ||
message(STATUS "[fpp-tools] Installing sbt, this will take a few minutes") | ||
configure_file("${CMAKE_CURRENT_LIST_DIR}/CMakeLists.sbt.txt.in" sbt-download/CMakeLists.txt) | ||
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . | ||
RESULT_VARIABLE result | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/sbt-download ) | ||
execute_process( | ||
COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . | ||
RESULT_VARIABLE result | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/sbt-download | ||
OUTPUT_QUIET | ||
ERROR_VARIABLE ERROR_OUT | ||
) | ||
if(result) | ||
message(FATAL_ERROR "CMake step for sbt failed: ${result}") | ||
message(FATAL_ERROR "CMake step for sbt failed: ${result}\n${ERROR_OUT}") | ||
endif() | ||
execute_process(COMMAND ${CMAKE_COMMAND} --build . | ||
RESULT_VARIABLE result | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/sbt-download ) | ||
execute_process( | ||
COMMAND ${CMAKE_COMMAND} --build . | ||
RESULT_VARIABLE result | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/sbt-download | ||
OUTPUT_QUIET | ||
ERROR_VARIABLE ERROR_OUT | ||
) | ||
if(result) | ||
message(FATAL_ERROR "Build step for sbt failed: ${result}") | ||
message(FATAL_ERROR "Build step for sbt failed: ${result}\n${ERROR_OUT}") | ||
endif() | ||
find_program(SBT sbt PATH ${CMAKE_BINARY_DIR}/sbt/bin) | ||
|
||
find_program(SBT sbt PATH ${FPP_TOOLS_PATH}/sbt/bin) | ||
endif() | ||
message(STATUS "sbt found at: ${SBT}") | ||
|
||
message(STATUS "[fpp-tools] sbt found at: ${SBT}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters