Skip to content

Commit e822514

Browse files
authored
Merge pull request #1560 from kbenzie/benie/fast-spec-mode
Add option to enable spec generation fast-mode
2 parents 4a7bf7b + d5e3ded commit e822514

File tree

5 files changed

+18
-7
lines changed

5 files changed

+18
-7
lines changed

CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ option(UR_BUILD_TESTS "Build unit tests." ON)
2929
option(UR_BUILD_TOOLS "build ur tools" ON)
3030
option(UR_FORMAT_CPP_STYLE "format code style of C++ sources" OFF)
3131
option(UR_DEVELOPER_MODE "enable developer checks, treats warnings as errors" OFF)
32+
option(UR_ENABLE_FAST_SPEC_MODE "enable fast specification generation mode" OFF)
3233
option(UR_USE_ASAN "enable AddressSanitizer" OFF)
3334
option(UR_USE_UBSAN "enable UndefinedBehaviorSanitizer" OFF)
3435
option(UR_USE_MSAN "enable MemorySanitizer" OFF)
@@ -292,7 +293,10 @@ if(UR_FORMAT_CPP_STYLE)
292293
# Generate source from the specification
293294
add_custom_target(generate-code USES_TERMINAL
294295
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/scripts
295-
COMMAND ${Python3_EXECUTABLE} run.py --api-json ${API_JSON_FILE} --clang-format=${CLANG_FORMAT}
296+
COMMAND ${Python3_EXECUTABLE} run.py
297+
--api-json ${API_JSON_FILE}
298+
--clang-format=${CLANG_FORMAT}
299+
$<$<BOOL:${UR_ENABLE_FAST_SPEC_MODE}>:--fast-mode>
296300
COMMAND ${Python3_EXECUTABLE} json2src.py --api-json ${API_JSON_FILE} ${PROJECT_SOURCE_DIR}
297301
)
298302

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ List of options provided by CMake:
122122
| UR_BUILD_TOOLS | Build tools | ON/OFF | ON |
123123
| UR_FORMAT_CPP_STYLE | Format code style | ON/OFF | OFF |
124124
| UR_DEVELOPER_MODE | Treat warnings as errors and enables additional checks | ON/OFF | OFF |
125+
| UR_ENABLE_FAST_SPEC_MODE | Enable fast specification generation mode | ON/OFF | OFF |
125126
| UR_USE_ASAN | Enable AddressSanitizer | ON/OFF | OFF |
126127
| UR_USE_TSAN | Enable ThreadSanitizer | ON/OFF | OFF |
127128
| UR_USE_UBSAN | Enable UndefinedBehavior Sanitizer | ON/OFF | OFF |

scripts/generate_docs.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def _make_ref(symbol, symbol_type, meta):
8686
"""
8787
generate a valid reStructuredText file
8888
"""
89-
def _generate_valid_rst(fin, fout, namespace, tags, ver, rev, meta):
89+
def _generate_valid_rst(fin, fout, namespace, tags, ver, rev, meta, fast_mode):
9090
ver=float(ver)
9191
enable = True
9292
code_block = False
@@ -185,13 +185,14 @@ def _generate_valid_rst(fin, fout, namespace, tags, ver, rev, meta):
185185
ver=ver,
186186
namespace=namespace,
187187
tags=tags,
188-
meta=meta)
188+
meta=meta,
189+
fast_mode=fast_mode)
189190

190191
"""
191192
Entry-point:
192193
generate restructuredtext documents from templates
193194
"""
194-
def generate_rst(docpath, section, namespace, tags, ver, rev, specs, meta):
195+
def generate_rst(docpath, section, namespace, tags, ver, rev, specs, meta, fast_mode):
195196
srcpath = os.path.join("./", section)
196197
dstpath = os.path.join(docpath, "source", section)
197198

@@ -200,7 +201,7 @@ def generate_rst(docpath, section, namespace, tags, ver, rev, specs, meta):
200201
util.removeFiles(dstpath, "*.rst")
201202
for fin in util.findFiles(srcpath, "*.rst"):
202203
fout = os.path.join(dstpath, os.path.basename(fin))
203-
loc += _generate_valid_rst(os.path.abspath(fin), fout, namespace, tags, ver, rev, meta)
204+
loc += _generate_valid_rst(os.path.abspath(fin), fout, namespace, tags, ver, rev, meta, fast_mode)
204205

205206
print("Generated %s lines of reStructuredText (rst).\n"%loc)
206207

@@ -215,7 +216,8 @@ def generate_rst(docpath, section, namespace, tags, ver, rev, specs, meta):
215216
rev=rev,
216217
tags=tags,
217218
meta=meta,
218-
specs=specs)
219+
specs=specs,
220+
fast_mode=fast_mode)
219221

220222
"""
221223
Entry-point:

scripts/run.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#!/usr/bin/env python3
12
"""
23
Copyright (C) 2022 Intel Corporation
34
@@ -120,6 +121,7 @@ def main():
120121
required=False, help="specification version to generate.")
121122
parser.add_argument("--api-json", type=str, default="unified_runtime.json", required=False, help="json output file for the spec")
122123
parser.add_argument("--clang-format", type=str, default="clang-format", required=False, help="path to clang-format executable")
124+
parser.add_argument('--fast-mode', action='store_true', help='Disable sections which are slow to render')
123125
args = vars(parser.parse_args())
124126
args['rev'] = revision()
125127

@@ -175,7 +177,7 @@ def main():
175177
raise Exception("Failed to format ur_api.h")
176178

177179
if args['rst']:
178-
generate_docs.generate_rst(docpath, config['name'], config['namespace'], config['tags'], args['ver'], args['rev'], specs, input['meta'])
180+
generate_docs.generate_rst(docpath, config['name'], config['namespace'], config['tags'], args['ver'], args['rev'], specs, input['meta'], args['fast_mode'])
179181

180182
if util.makeErrorCount():
181183
print("\n%s Errors found during generation, stopping execution!"%util.makeErrorCount())

scripts/templates/api_listing.mako

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ ${th.make_type_name(n, tags, obj)}
265265
266266
%endfor # s in specs
267267
268+
%if not fast_mode:
268269
#################################################################
269270
## Print API not part of the spec, needs to be generated separately
270271
#################################################################
@@ -359,3 +360,4 @@ Print Operators
359360
:project: UnifiedRuntime
360361
:outline:
361362
%endfor
363+
%endif

0 commit comments

Comments
 (0)