diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-08-11 20:25:31 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-08-11 20:25:31 +0400 |
commit | ca7c07cda942976d805fcf2bbfe168b4b7b3fe18 (patch) | |
tree | 54e9c2d82261a0e88da03006400ff3b82cb4715c /build_files | |
parent | 35ef09372a8d78f57f93b3cb4744d2d38b45c5b0 (diff) |
add back datatoc, use this instead of cmake script which was too slow.
Diffstat (limited to 'build_files')
-rw-r--r-- | build_files/cmake/data_to_c.cmake | 25 | ||||
-rw-r--r-- | build_files/cmake/macros.cmake | 40 |
2 files changed, 19 insertions, 46 deletions
diff --git a/build_files/cmake/data_to_c.cmake b/build_files/cmake/data_to_c.cmake deleted file mode 100644 index b8b18269dc8..00000000000 --- a/build_files/cmake/data_to_c.cmake +++ /dev/null @@ -1,25 +0,0 @@ -# cmake script, to be called on its own with 3 defined args -# -# - FILE_FROM -# - FILE_TO -# - VAR_NAME - -# not highly optimal, may replace with generated C program like makesdna -file(READ ${FILE_FROM} file_from_string HEX) -string(LENGTH ${file_from_string} _max_index) -math(EXPR size_on_disk ${_max_index}/2) - -file(REMOVE ${FILE_TO}) - -file(APPEND ${FILE_TO} "int ${VAR_NAME}_size = ${size_on_disk};\n") -file(APPEND ${FILE_TO} "char ${VAR_NAME}[] = {") - -set(_index 0) - -while(NOT _index EQUAL _max_index) - string(SUBSTRING "${file_from_string}" ${_index} 2 _pair) - file(APPEND ${FILE_TO} "0x${_pair},") - math(EXPR _index ${_index}+2) -endwhile() -# null terminator not essential but good if we want plane strings encoded -file(APPEND ${FILE_TO} "0x00};\n") diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake index af122541ae5..3d2d19c7685 100644 --- a/build_files/cmake/macros.cmake +++ b/build_files/cmake/macros.cmake @@ -729,19 +729,21 @@ endmacro() # TODO, create a C binary and call it instead!, doing this in cmake its slow macro(data_to_c - file_from file_to var_name + file_from file_to list_to_add) list(APPEND ${list_to_add} ${file_to}) + get_filename_component(_file_to_path ${file_to} PATH) + add_custom_command( OUTPUT ${file_to} - COMMAND ${CMAKE_COMMAND} - -DFILE_FROM=${file_from} - -DFILE_TO=${file_to} - -DVAR_NAME=${var_name} - -P ${CMAKE_SOURCE_DIR}/build_files/cmake/data_to_c.cmake + COMMAND ${CMAKE_COMMAND} -E make_directory ${_file_to_path} + COMMAND ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/datatoc + ${file_from} + ${file_to} DEPENDS ${file_from}) + unset(_file_to_path) endmacro() # same as above but generates the var name and output automatic. @@ -749,26 +751,22 @@ macro(data_to_c_simple file_from list_to_add) - # get var name automatic from name - get_filename_component(_file_from_only ${file_from} NAME) - string(REPLACE "." "_" _file_from_only ${_file_from_only}) - set(_var_name "datatoc_${_file_from_only}") - - # only to avoid confusion - set(_file_to ${file_from}.c) + # only to avoid confusion + set(_file_to ${file_from}.c) list(APPEND ${list_to_add} ${CMAKE_CURRENT_BINARY_DIR}/${_file_to}) + get_filename_component(_file_to_path ${_file_to} PATH) + add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_file_to} - COMMAND ${CMAKE_COMMAND} - -DFILE_FROM=${CMAKE_CURRENT_SOURCE_DIR}/${file_from} - -DFILE_TO=${CMAKE_CURRENT_BINARY_DIR}/${_file_to} - -DVAR_NAME=${_var_name} - -P ${CMAKE_SOURCE_DIR}/build_files/cmake/data_to_c.cmake + COMMAND ${CMAKE_COMMAND} -E make_directory ${_file_to_path} + COMMAND ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/datatoc + ${CMAKE_CURRENT_SOURCE_DIR}/${file_from} + ${CMAKE_CURRENT_BINARY_DIR}/${_file_to} DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${file_from}) - unset(_file_from_only) - unset(_var_name) - unset(_file_to) + unset(_var_name) + unset(_file_to) + unset(_file_to_path) endmacro() |