Skip to content

Commit 9dfa583

Browse files
bashbaugEwanC
andauthored
add code generation README (#228)
* add README, update required Mako version * minor grammar fix Co-authored-by: Ewan Crawford <ewan.cr@gmail.com> --------- Co-authored-by: Ewan Crawford <ewan.cr@gmail.com>
1 parent 7bcc0f1 commit 9dfa583

2 files changed

Lines changed: 39 additions & 1 deletion

File tree

scripts/README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# OpenCL Header Code Generation
2+
3+
## Introduction
4+
5+
In order to ease maintenance and enable faster development in the OpenCL headers, the OpenCL headers for extensions are generated from the OpenCL XML machine readable grammar.
6+
Currently, header generation is only enabled for the OpenCL headers for extensions, and the OpenCL headers for core APIs are still authored manually.
7+
8+
## Dependencies
9+
10+
The OpenCL headers are generated using Python [Mako Templates](https://www.makotemplates.org/).
11+
12+
In most cases, after installing Python for your platform, Mako may be installed using:
13+
14+
```sh
15+
$ pip install Mako
16+
```
17+
18+
## Making Changes
19+
20+
Most changes only require modifications to the Mako templates.
21+
Small changes modifying syntax or layout are simple and straightforward.
22+
Occasionally, more complicated changes will be required, say when a new API is added that is unlike any previous API or when a new extension header file is needed, but this should be rare.
23+
24+
The Python script should only need to be modified if additional information needs to be propagated from the XML file into the Mako template itself.
25+
26+
## Generating Headers
27+
28+
The script to generate headers requires the `cl.xml` machine readable grammar.
29+
The latest version of `cl.xml` may be found in the Khronos OpenCL-Docs repo [here](https://github.com/KhronosGroup/OpenCL-Docs/blob/main/xml/cl.xml).
30+
31+
The easiest way to generate new headers is by using the `headers_generate` target.
32+
For example, from a directory used to build the headers, simply execute:
33+
34+
```sh
35+
$ cmake --build . --target headers_generate
36+
```
37+
38+
The `cl.xml` file used to generate headers with the header generation target may be provided by setting the CMake variable `OPENCL_HEADERS_XML_PATH` to the full path to `cl.xml`.

scripts/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Mako==1.1.0
1+
Mako>=1.2.2

0 commit comments

Comments
 (0)