Skip to content

Commit

Permalink
media/samples: keep pre-generated headers in subdirectory media/sampl…
Browse files Browse the repository at this point in the history
…es/cache
  • Loading branch information
dpocock committed Dec 29, 2022
1 parent 109d9b9 commit 216bb81
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions media/samples/CMakeLists.txt
Expand Up @@ -10,14 +10,13 @@ function(wav_to_header)
endif()
add_custom_command(
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${ARGV0}.wav
OUTPUT ${ARGV0}.h
COMMAND ${SOX_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/${ARGV0}.wav -r 8k -e signed -b 16 -c 1 ${ARGV0}.raw
COMMAND xxd -i -u ${ARGV0}.raw ${ARGV0}.h.0
COMMAND sed -e 's/_raw//g' ${ARGV0}.h.0 > ${ARGV0}.h
COMMAND ${CMAKE_COMMAND} -E rm ${ARGV0}.raw ${ARGV0}.h.0
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${ARGV0}.h
COMMAND ${SOX_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/${ARGV0}.wav -r 8k -e signed -b 16 -c 1 ${CMAKE_CURRENT_BINARY_DIR}/${ARGV0}.raw
COMMAND xxd -i -u ${CMAKE_CURRENT_BINARY_DIR}/${ARGV0}.raw ${CMAKE_CURRENT_BINARY_DIR}/${ARGV0}.h.0
COMMAND sed -e "s/^unsigned char .*_raw/unsigned char ${ARGV0}/g" -e "s/^unsigned int .*_raw_len/unsigned int ${ARGV0}_len/g" ${CMAKE_CURRENT_BINARY_DIR}/${ARGV0}.h.0 > ${CMAKE_CURRENT_BINARY_DIR}/${ARGV0}.h
)
else()
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/${ARGV0}.h DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/cache/${ARGV0}.h DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
endif()
endfunction()

Expand All @@ -31,12 +30,19 @@ set(INCLUDES
music.h
)

set_source_files_properties(
playback_prompt.h
record_prompt.h
music.h
PROPERTIES GENERATED TRUE
)

add_executable(prompt2wav
prompt2wav.cxx
${INCLUDES}
)

target_include_directories(prompt2wav PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
#target_include_directories(prompt2wav PRIVATE ${CMAKE_BINARY_DIR})

# don't need to install this, it is only used during development
#install(TARGETS prompt2wav DESTINATION ${CMAKE_INSTALL_BINDIR})
Expand Down

0 comments on commit 216bb81

Please sign in to comment.