mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-01-23 21:30:41 +00:00
cmake: convert bmp images to c headers using python script
A pure CMake script was too slow
This commit is contained in:
committed by
Anonymous Maarten
parent
74612701bb
commit
80da0cf06d
@@ -208,8 +208,46 @@ if(SDL3_TESTS_SUBPROJECT)
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
set(gamepad_images
|
||||
gamepad_axis_arrow.bmp
|
||||
gamepad_axis.bmp
|
||||
gamepad_back.bmp
|
||||
gamepad_battery_empty.bmp
|
||||
gamepad_battery_full.bmp
|
||||
gamepad_battery_low.bmp
|
||||
gamepad_battery_medium.bmp
|
||||
gamepad_battery_unknown.bmp
|
||||
gamepad_battery_wired.bmp
|
||||
gamepad_button_background.bmp
|
||||
gamepad_button.bmp
|
||||
gamepad_button_small.bmp
|
||||
gamepad_face_abxy.bmp
|
||||
gamepad_face_bayx.bmp
|
||||
gamepad_face_sony.bmp
|
||||
gamepad_front.bmp
|
||||
gamepad_touchpad.bmp
|
||||
)
|
||||
set(gamepad_image_headers)
|
||||
find_package(PythonInterp)
|
||||
if(PYTHONINTERP_FOUND AND NOT PYTHON_VERSION_STRING VERSION_LESS "3.2")
|
||||
set(xxd "${CMAKE_CURRENT_SOURCE_DIR}/../cmake/xxd.py")
|
||||
foreach(bmp ${gamepad_images})
|
||||
get_filename_component(bmp_we "${bmp}" NAME_WE)
|
||||
set(intermediate "${CMAKE_CURRENT_BINARY_DIR}/${bmp_we}.h")
|
||||
set(final "${CMAKE_CURRENT_SOURCE_DIR}/${bmp_we}.h")
|
||||
# Don't add the 'final' headers to the output, to avoid marking them as GENERATED
|
||||
# (generated files are removed when running the CLEAN target)
|
||||
add_custom_command(OUTPUT "${intermediate}"
|
||||
COMMAND "${PYTHON_EXECUTABLE}" "${xxd}" -i "${CMAKE_CURRENT_SOURCE_DIR}/${bmp}" "-o" "${intermediate}"
|
||||
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${intermediate}" "${final}"
|
||||
DEPENDS "${xxd}" "${bmp}"
|
||||
)
|
||||
list(APPEND gamepad_image_headers "${intermediate}" "${final}")
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
add_sdl_test_executable(testfile NONINTERACTIVE SOURCES testfile.c)
|
||||
add_sdl_test_executable(testcontroller TESTUTILS SOURCES testcontroller.c gamepadutils.c)
|
||||
add_sdl_test_executable(testcontroller TESTUTILS SOURCES testcontroller.c gamepadutils.c ${gamepad_image_headers})
|
||||
add_sdl_test_executable(testgeometry TESTUTILS SOURCES testgeometry.c)
|
||||
add_sdl_test_executable(testgl SOURCES testgl.c)
|
||||
add_sdl_test_executable(testgles SOURCES testgles.c)
|
||||
|
||||
Reference in New Issue
Block a user