diff options
author | Paul Berry <stereotype441@gmail.com> | 2012-03-01 16:38:26 -0800 |
---|---|---|
committer | Paul Berry <stereotype441@gmail.com> | 2012-03-23 13:36:35 -0700 |
commit | 6fe17bb7ce5eab80334249aa8a57f7b948fad318 (patch) | |
tree | d19bf5d0407a8cfaaf5663d6d0201f64d73cf50b /cmake | |
parent | 6409a675112a31e26cae70d86989f7d098629576 (diff) |
piglit-dispatch: Code generation scripts.
This patch contains the code generation scripts that convert the files
gl.spec, gl.tm, and enumext.spec into C code, as well as the CMake
directives to run the scripts.
Code generation occurs in two phases: first the script
glapi/parse_glspec.py converts the .spec and .tm files into an
intermediate JSON format, which is stored in glapi/glapi.json. Then,
the script tests/util/gen_dispatch.py converts the JSON file into two
files, tests/util/generated_dispatch.c and
tests/util/generated_dispatch.h.
There are two motivations for breaking code generation into two phases:
(1) there are other code generation tasks we may add in the future
(e.g. generating the tests/util/piglit-util-enum.c file), and it would
be nice not to have to rewrite any parsing code when we do so. (2) if
the GL consortium ever decides to change the format of gl.spec, gl.tm,
and enumext.spec, then we only have to change parse_glspec.py.
These code generation scripts can be run by invoking "make
piglit_dispatch_gen" from the toplevel source directory.
v2: Add clarifying comments, remove a bogus "print" statement, and
raise an exception if an unrecognized multiplicity is encountered.
Also, handle "reference" multiplicity.
v3: Add APIENTRY to stub functions. Rename "near" and "far" to avoid
problems on MSVC. Get rid of "__" in function names. Rename
initialize_dispatch_pointers => reset_dispatch_pointers. Add
gl_10x_version parameter to get_core_proc(). Output generated code
relative to CMAKE_BINARY_DIR so that it won't pollute source
directories when building out of tree. Add .gitignore so that
generated files are ignored when building in tree. Add GL_VERSION_*
defines.
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/piglit_dispatch.cmake | 44 | ||||
-rw-r--r-- | cmake/piglit_glapi.cmake | 42 |
2 files changed, 86 insertions, 0 deletions
diff --git a/cmake/piglit_dispatch.cmake b/cmake/piglit_dispatch.cmake new file mode 100644 index 000000000..0b0a2eb76 --- /dev/null +++ b/cmake/piglit_dispatch.cmake @@ -0,0 +1,44 @@ +# Copyright 2012 Intel Corporation +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice (including the next +# paragraph) shall be included in all copies or substantial portions of the +# Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. + +set(piglit_dispatch_gen_output_dir ${CMAKE_BINARY_DIR}/tests/util) + +file(MAKE_DIRECTORY ${piglit_dispatch_gen_output_dir}) + +set(piglit_dispatch_gen_outputs + ${piglit_dispatch_gen_output_dir}/generated_dispatch.c + ${piglit_dispatch_gen_output_dir}/generated_dispatch.h + ) + +set(piglit_dispatch_gen_inputs + ${CMAKE_SOURCE_DIR}/tests/util/gen_dispatch.py + ${CMAKE_BINARY_DIR}/glapi/glapi.json + ) + +add_custom_command( + OUTPUT ${piglit_dispatch_gen_outputs} + DEPENDS ${piglit_dispatch_gen_inputs} + COMMAND ${python} ${piglit_dispatch_gen_inputs} ${piglit_dispatch_gen_outputs} + ) + +add_custom_target(piglit_dispatch_gen + DEPENDS ${piglit_dispatch_gen_outputs} + ) diff --git a/cmake/piglit_glapi.cmake b/cmake/piglit_glapi.cmake new file mode 100644 index 000000000..bdc0390e0 --- /dev/null +++ b/cmake/piglit_glapi.cmake @@ -0,0 +1,42 @@ +# Copyright 2012 Intel Corporation +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice (including the next +# paragraph) shall be included in all copies or substantial portions of the +# Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. + +# Note: we're outputting the generated file to a subdirectory of +# ${CMAKE_SOURCE_DIR} so that we can check it back in to source +# control. +set(piglit_glapi_src_dir ${CMAKE_SOURCE_DIR}/glapi) + +file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/glapi) + +set(piglit_glapi_output ${CMAKE_BINARY_DIR}/glapi/glapi.json) + +set(piglit_glapi_inputs + ${piglit_glapi_src_dir}/parse_glspec.py + ${piglit_glapi_src_dir}/gl.tm + ${piglit_glapi_src_dir}/gl.spec + ${piglit_glapi_src_dir}/enumext.spec + ) + +add_custom_command( + OUTPUT ${piglit_glapi_output} + DEPENDS ${piglit_glapi_inputs} + COMMAND ${python} ${piglit_glapi_inputs} ${piglit_glapi_output} + ) |