Skip to content

Commit

Permalink
Merge pull request #824 from Daft-Freak/pipx
Browse files Browse the repository at this point in the history
Search for the 32blit executable if the module fails
  • Loading branch information
Gadgetoid committed Jul 1, 2023
2 parents d9a39c3 + ee4d458 commit 12ec9e4
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 12 deletions.
15 changes: 13 additions & 2 deletions 32blit-config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@ if (NOT DEFINED BLIT_ONCE)
# make sure that the tools are installed
execute_process(COMMAND ${PYTHON_EXECUTABLE} -m ttblit version RESULT_VARIABLE VERSION_STATUS OUTPUT_VARIABLE TOOLS_VERSION ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)

if(${VERSION_STATUS})
# check for the executable if the module isn't found
find_program(32BLIT_TOOLS_EXECUTABLE 32blit)
if(32BLIT_TOOLS_EXECUTABLE)
# get the version
execute_process(COMMAND ${32BLIT_TOOLS_EXECUTABLE} version RESULT_VARIABLE VERSION_STATUS OUTPUT_VARIABLE TOOLS_VERSION ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()
else()
set(32BLIT_TOOLS_EXECUTABLE ${PYTHON_EXECUTABLE} -m ttblit)
endif()

# get just the python command to output to the user
get_filename_component(PYTHON_USER_EXECUTABLE "${PYTHON_EXECUTABLE}" NAME)

Expand Down Expand Up @@ -37,7 +48,7 @@ if (NOT DEFINED BLIT_ONCE)

# get the inputs/outputs for the asset tool (at configure time)
execute_process(
COMMAND ${PYTHON_EXECUTABLE} -m ttblit --debug cmake --config ${CMAKE_CURRENT_SOURCE_DIR}/${FILE} --output ${CMAKE_CURRENT_BINARY_DIR} --cmake ${CMAKE_CURRENT_BINARY_DIR}/assets.cmake
COMMAND ${32BLIT_TOOLS_EXECUTABLE} --debug cmake --config ${CMAKE_CURRENT_SOURCE_DIR}/${FILE} --output ${CMAKE_CURRENT_BINARY_DIR} --cmake ${CMAKE_CURRENT_BINARY_DIR}/assets.cmake
RESULT_VARIABLE TOOL_RESULT
)
if(${TOOL_RESULT})
Expand All @@ -49,7 +60,7 @@ if (NOT DEFINED BLIT_ONCE)
# do asset packing (at build time)
add_custom_command(
OUTPUT ${ASSET_OUTPUTS}
COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && ${PYTHON_EXECUTABLE} -m ttblit --debug pack --force --config ${CMAKE_CURRENT_SOURCE_DIR}/${FILE} --output ${CMAKE_CURRENT_BINARY_DIR}
COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && ${32BLIT_TOOLS_EXECUTABLE} --debug pack --force --config ${CMAKE_CURRENT_SOURCE_DIR}/${FILE} --output ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS ${ASSET_DEPENDS} ${CMAKE_CURRENT_SOURCE_DIR}/${FILE}
)

Expand Down
4 changes: 2 additions & 2 deletions 32blit-pico/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ function(blit_metadata TARGET FILE)

# get the inputs/outputs for the asset tool (at configure time)
execute_process(
COMMAND ${PYTHON_EXECUTABLE} -m ttblit cmake --config ${FILE} --cmake ${CMAKE_CURRENT_BINARY_DIR}/metadata.cmake
COMMAND ${32BLIT_TOOLS_EXECUTABLE} cmake --config ${FILE} --cmake ${CMAKE_CURRENT_BINARY_DIR}/metadata.cmake
RESULT_VARIABLE TOOL_RESULT
)
if(${TOOL_RESULT})
Expand All @@ -193,7 +193,7 @@ function(blit_metadata TARGET FILE)

add_custom_command(
OUTPUT ${METADATA_SOURCE}
COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && ${PYTHON_EXECUTABLE} -m ttblit metadata --force --config ${FILE} --pico-bi ${METADATA_SOURCE}
COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && ${32BLIT_TOOLS_EXECUTABLE} metadata --force --config ${FILE} --pico-bi ${METADATA_SOURCE}
DEPENDS ${FILE}
)

Expand Down
4 changes: 2 additions & 2 deletions 32blit-sdl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ function(blit_metadata TARGET FILE)

# parse the metadata to variables
execute_process(
COMMAND ${PYTHON_EXECUTABLE} -m ttblit cmake --config ${FILE} --cmake ${CMAKE_CURRENT_BINARY_DIR}/metadata.cmake
COMMAND ${32BLIT_TOOLS_EXECUTABLE} cmake --config ${FILE} --cmake ${CMAKE_CURRENT_BINARY_DIR}/metadata.cmake
RESULT_VARIABLE TOOL_RESULT
)
if(${TOOL_RESULT})
Expand All @@ -244,7 +244,7 @@ function(blit_metadata TARGET FILE)

add_custom_command(
OUTPUT ${ICON}
COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && ${PYTHON_EXECUTABLE} -m ttblit metadata --force --config ${FILE} --icns ${ICON}
COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && ${32BLIT_TOOLS_EXECUTABLE} metadata --force --config ${FILE} --icns ${ICON}
DEPENDS ${METADATA_DEPENDS} ${FILE}
)

Expand Down
2 changes: 1 addition & 1 deletion 32blit-stm32/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,6 @@ function(blit_executable_int_flash NAME SOURCES)

add_custom_command(TARGET ${NAME} POST_BUILD
COMMENT "Building ${NAME}.dfu"
COMMAND ${PYTHON_EXECUTABLE} -m ttblit dfu build --force --output-file ${NAME}.dfu --input-file ${NAME}.bin
COMMAND ${32BLIT_TOOLS_EXECUTABLE} dfu build --force --output-file ${NAME}.dfu --input-file ${NAME}.bin
)
endfunction()
8 changes: 4 additions & 4 deletions 32blit-stm32/executable.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ function(blit_executable NAME)

add_custom_command(TARGET ${NAME} POST_BUILD
COMMENT "Building ${NAME}.blit"
COMMAND ${PYTHON_EXECUTABLE} -m ttblit relocs --elf-file $<TARGET_FILE:${NAME}> --bin-file ${NAME}.bin --output ${BLIT_FILENAME}
COMMAND ${32BLIT_TOOLS_EXECUTABLE} relocs --elf-file $<TARGET_FILE:${NAME}> --bin-file ${NAME}.bin --output ${BLIT_FILENAME}
)

add_custom_target(${NAME}.flash DEPENDS ${NAME} COMMAND ${PYTHON_EXECUTABLE} -m ttblit install --port=${FLASH_PORT} --launch ${CMAKE_CURRENT_BINARY_DIR}/${BLIT_FILENAME})
add_custom_target(${NAME}.flash DEPENDS ${NAME} COMMAND ${32BLIT_TOOLS_EXECUTABLE} install --port=${FLASH_PORT} --launch ${CMAKE_CURRENT_BINARY_DIR}/${BLIT_FILENAME})
endfunction()

function(blit_metadata TARGET FILE)
Expand All @@ -68,7 +68,7 @@ function(blit_metadata TARGET FILE)

# get the inputs/outputs for the asset tool (at configure time)
execute_process(
COMMAND ${PYTHON_EXECUTABLE} -m ttblit cmake --config ${FILE} --cmake ${CMAKE_CURRENT_BINARY_DIR}/metadata.cmake
COMMAND ${32BLIT_TOOLS_EXECUTABLE} cmake --config ${FILE} --cmake ${CMAKE_CURRENT_BINARY_DIR}/metadata.cmake
RESULT_VARIABLE TOOL_RESULT
)
if(${TOOL_RESULT})
Expand All @@ -85,7 +85,7 @@ function(blit_metadata TARGET FILE)

add_custom_command(
TARGET ${TARGET} POST_BUILD
COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && ${PYTHON_EXECUTABLE} -m ttblit metadata --config ${FILE} --file ${CMAKE_CURRENT_BINARY_DIR}/${BLIT_FILENAME}
COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && ${32BLIT_TOOLS_EXECUTABLE} metadata --config ${FILE} --file ${CMAKE_CURRENT_BINARY_DIR}/${BLIT_FILENAME}
)

# force relink on change so that the post-build commands are rerun
Expand Down
2 changes: 1 addition & 1 deletion firmware-update/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# embed the built firmware
add_custom_command(
COMMAND ${PYTHON_EXECUTABLE} -m ttblit raw --force --input_file $<TARGET_FILE_DIR:firmware>/firmware.bin --symbol_name firmware_data --output_file firmware.hpp
COMMAND ${32BLIT_TOOLS_EXECUTABLE} raw --force --input_file $<TARGET_FILE_DIR:firmware>/firmware.bin --symbol_name firmware_data --output_file firmware.hpp
OUTPUT firmware.hpp
DEPENDS firmware
)
Expand Down

0 comments on commit 12ec9e4

Please sign in to comment.