summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Berry <stereotype441@gmail.com>2011-07-29 13:01:36 -0700
committerPaul Berry <stereotype441@gmail.com>2011-08-11 13:13:02 -0700
commit3599bede47a9bcd36e0be596c7e19e6232e22cd0 (patch)
tree3d4a2d50b852a3b623fea92f3f621e7be4c87008
parent978488e96f3cb31e525518857bd93c33930a5b16 (diff)
Refactor cmake script to generate tests for later reuse.
This patch creates a function, piglit_make_generated_tests (in generated_tests/CMakeLists.txt), to encapsulate the logic that builds a custom command. The new function can be reused to generate tests using other python scripts.
-rw-r--r--generated_tests/CMakeLists.txt36
1 files changed, 27 insertions, 9 deletions
diff --git a/generated_tests/CMakeLists.txt b/generated_tests/CMakeLists.txt
index 75b3d8ee..2145d871 100644
--- a/generated_tests/CMakeLists.txt
+++ b/generated_tests/CMakeLists.txt
@@ -1,12 +1,30 @@
-# Add a custom command which executes gen_builtin_uniform_tests.py
-# during the build.
-add_custom_command(
- OUTPUT builtin_uniform_tests.list
- COMMAND ${python} ${CMAKE_CURRENT_SOURCE_DIR}/gen_builtin_uniform_tests.py > builtin_uniform_tests.list
- DEPENDS gen_builtin_uniform_tests.py builtin_function.py
- VERBATIM)
+# Create a custom command that runs the Python script
+# ${generator_script} to generate tests.
+#
+# A list of the files generated will be output to the file
+# ${file_list}. This can be used to run the custom command by itself,
+# and is also used by the build system to tell when the files need to
+# be rebuilt.
+#
+# The custom command will automatically depend on ${generator_script}.
+# Additional dependencies can be supplied using additional arguments.
+function(piglit_make_generated_tests file_list generator_script)
+ # Add a custom command which executes ${generator_script}
+ # during the build.
+ add_custom_command(
+ OUTPUT ${file_list}
+ COMMAND ${python} ${CMAKE_CURRENT_SOURCE_DIR}/${generator_script} > ${file_list}
+ DEPENDS ${generator_script} ${ARGN}
+ VERBATIM)
+endfunction(piglit_make_generated_tests custom_target generator_script)
-# Add a "gen-tests" target that can be used to generate all the tests
-# without doing any other compilation.
+# Create custom commands and targets to build generated tests.
+piglit_make_generated_tests(
+ builtin_uniform_tests.list
+ gen_builtin_uniform_tests.py
+ builtin_function.py)
+
+# Add a "gen-tests" target that can be used to generate all the
+# tests without doing any other compilation.
add_custom_target(gen-tests ALL
DEPENDS builtin_uniform_tests.list)