Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-08-09 23:59:36 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-08-09 23:59:36 +0400
commit7a760b4804ab4574e01d7f6d75fc52f93aa2a3b3 (patch)
treeae5d20f881beb00420dd31bd79d9eba033b0ee48 /build_files
parent9f30c7147cdb726e503ff37ba585f5e35b090d8c (diff)
generate COM_OpenCLKernels.cl.h automatically at build time, this allows editing COM_OpenCLKernels.cl and rebuilding and means we dont have to have both files in svn.
updates made to cmake and scons.
Diffstat (limited to 'build_files')
-rw-r--r--build_files/cmake/data_to_c.cmake25
1 files changed, 25 insertions, 0 deletions
diff --git a/build_files/cmake/data_to_c.cmake b/build_files/cmake/data_to_c.cmake
new file mode 100644
index 00000000000..b8b18269dc8
--- /dev/null
+++ b/build_files/cmake/data_to_c.cmake
@@ -0,0 +1,25 @@
+# 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")