-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathgen_docs.py
More file actions
177 lines (148 loc) · 4.34 KB
/
gen_docs.py
File metadata and controls
177 lines (148 loc) · 4.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
# Data Parallel Control (dpctl)
#
# Copyright 2020-2025 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import argparse
import os
import subprocess
import sys
from _build_helper import (
build_extension,
capture_cmd_output,
clean_build_dir,
err,
install_editable,
log_cmake_args,
make_cmake_args,
resolve_compilers,
run,
)
def parse_args():
p = argparse.ArgumentParser(description="Build dpctl and generate coverage")
p.add_argument(
"--c-compiler", default=None, help="Path or name of C compiler"
)
p.add_argument(
"--cxx-compiler", default=None, help="Path or name of C++ compiler"
)
p.add_argument(
"--compiler-root",
type=str,
default=None,
help="Path to compiler installation root",
)
p.add_argument(
"--oneapi",
dest="oneapi",
action="store_true",
help="Use default oneAPI compiler layout",
)
p.add_argument(
"--verbose",
dest="verbose",
action="store_true",
help="Enable verbose makefile output",
)
p.add_argument(
"--no-level-zero",
dest="no_level_zero",
action="store_true",
default=False,
help="Disable Level Zero backend",
)
p.add_argument(
"--generator", type=str, default="Ninja", help="CMake generator"
)
p.add_argument(
"--cmake-executable",
type=str,
default=None,
help="Path to CMake executable used by build",
)
p.add_argument(
"--cmake-opts",
type=str,
default="",
help="Additional options to pass directly to CMake",
)
p.add_argument(
"--doxyrest-root",
type=str,
help=(
"Path to Doxyrest installation to use to generate Sphinx docs"
+ "for libsyclinterface"
),
)
p.add_argument(
"--clean",
action="store_true",
help="Remove build dir before rebuild (default: False)",
)
return p.parse_args()
def main():
is_linux = "linux" in sys.platform
if not is_linux:
err(f"{sys.platform} not supported", "gen_docs")
args = parse_args()
setup_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
c_compiler, cxx_compiler = resolve_compilers(
args.oneapi,
args.c_compiler,
args.cxx_compiler,
args.compiler_root,
)
if args.clean:
clean_build_dir(setup_dir)
# Level Zero state (on unless explicitly disabled)
level_zero_enabled = False if args.no_level_zero else True
cmake_args = make_cmake_args(
c_compiler=c_compiler,
cxx_compiler=cxx_compiler,
level_zero=level_zero_enabled,
verbose=args.verbose,
)
cmake_args += ["-DDPCTL_GENERATE_DOCS=ON"]
if args.doxyrest_root:
cmake_args += ["-DDPCTL_ENABLE_DOXYREST=ON"]
cmake_args += [f"-DDoxyrest_DIR={args.doxyrest_root}"]
log_cmake_args(cmake_args, "gen_docs")
env = os.environ.copy()
build_extension(
setup_dir,
env,
cmake_args,
cmake_executable=args.cmake_executable,
generator=args.generator,
build_type="Release",
)
install_editable(setup_dir, env)
cmake_build_dir = capture_cmd_output(
["find", "_skbuild", "-name", "cmake-build"], cwd=setup_dir
)
print(f"[gen_docs] Found CMake build dir: {cmake_build_dir}")
run(
["cmake", "--build", ".", "--target", "Sphinx"],
cwd=cmake_build_dir,
)
generated_doc_dir = (
subprocess.check_output(
["find", "_skbuild", "-name", "index.html"], cwd=setup_dir
)
.decode("utf-8")
.strip("\n")
)
print("Generated documentation placed under ", generated_doc_dir)
print("[gen_docs] Done")
if __name__ == "__main__":
main()