scripts: Add include-what-you-use (iwyu) related scripts and configs

This commit is contained in:
Rylie Pavlik 2023-11-15 12:16:55 -06:00
parent afb34f3c9e
commit 0ac6fdae94
13 changed files with 594 additions and 2 deletions

7
scripts/cppwinrt.imp Normal file
View file

@ -0,0 +1,7 @@
# Copyright 2022-2023, Collabora, Ltd.
#
# SPDX-License-Identifier: BSL-1.0
#
# GENERATED - edit generate_iwyu_mapping_cppwinrt.py instead of this file
[
]

20
scripts/eigen.imp Normal file
View file

@ -0,0 +1,20 @@
# Copyright 2022-2023, Collabora, Ltd.
#
# SPDX-License-Identifier: BSL-1.0
#
# GENERATED - edit generate_iwyu_mapping.py instead of this file
[
{ include: ["@[<\"]src/Core/ArrayBase.h[>\"]", "private", "<Eigen/Core>", "public"] },
{ include: ["@[<\"]src/Core/MatrixBase.h[>\"]", "private", "<Eigen/Core>", "public"] },
{ include: ["@[<\"]src/Core/DenseBase.h[>\"]", "private", "<Eigen/Core>", "public"] },
{ include: ["@[<\"]Eigen/src/Core/.*", "private", "<Eigen/Core>", "public"] },
{ include: ["@[<\"]src/Core/.*", "private", "<Eigen/Core>", "public"] },
{ include: ["@[<\"]Eigen/src/Geometry/.*", "private", "<Eigen/Geometry>", "public"] },
{ include: ["@[<\"]src/Geometry/.*", "private", "<Eigen/Geometry>", "public"] },
{ include: ["@[<\"]Eigen/src/LU/.*", "private", "<Eigen/LU>", "public"] },
{ include: ["@[<\"]src/LU/.*", "private", "<Eigen/LU>", "public"] },
{ include: ["@[<\"]Eigen/src/SparseCore/.*", "private", "<Eigen/SparseCore>", "public"] },
{ include: ["@[<\"]src/SparseCore/.*", "private", "<Eigen/SparseCore>", "public"] },
{ include: ["@[<\"]Eigen/src/Sparse/.*", "private", "<Eigen/Sparse>", "public"] },
{ include: ["@[<\"]src/Sparse/.*", "private", "<Eigen/Sparse>", "public"] },
]

153
scripts/generate_iwyu_mapping.py Executable file
View file

@ -0,0 +1,153 @@
#!/usr/bin/env python3
# Copyright 2022-2023, Collabora, Ltd.
#
# SPDX-License-Identifier: BSL-1.0
#
# Original author: Rylie Pavlik <rylie.pavlik@collabora.com
"""Script to set up mapping.imp, etc for include-what-you-use."""
from pathlib import Path
from typing import List
_REPO = Path(__file__).parent.parent.resolve()
_SCRIPT_DIR = Path(__file__).parent.resolve()
_OUTPUT_FILENAME = _SCRIPT_DIR / "mapping.imp"
_FILE = Path(__file__).resolve()
_WRAPPERS = [
"""{ include: ["@[<\\"]vulkan/.+", "private", "\\"xrt/xrt_vulkan_includes.h\\"", "public"] },""",
"""{ include: ["\\"EGL/eglplatform.h\\"", "private", "\\"ogl/ogl_api.h\\"", "public"] },""",
"""{ include: ["<math.h>", "public", "\\"math/m_mathinclude.h\\"", "public"] },""",
"""{ include: ["<cmath>", "public", "\\"math/m_mathinclude.h\\"", "public"] },""",
"""{ symbol: ["M_PI", "public", "\\"math/m_mathinclude.h\\"", "public"] },""",
"""{ symbol: ["M_PIl", "public", "\\"math/m_mathinclude.h\\"", "public"] },""",
"""{ symbol: ["M_1_PI", "public", "\\"math/m_mathinclude.h\\"", "public"] },""",
"""{ symbol: ["ssize_t", "public", "\\"xrt/xrt_compiler.h\\"", "public"] },""",
]
_MISC_ERRORS = [
"""{ include: ["@[<\\"]bits/exception.h[>\\"]", "private", "<exception>", "public"] },""",
"""{ include: ["@[<\\"]ext/alloc_traits.h[>\\"]", "private", "<vector>", "public"] },""",
"""{ include: ["@[<\\"]bits/types/struct_iovec.h.", "private", "<sys/uio.h>", "public"] },""",
]
_MISC_DEPS = [
"""{ include: ["@[<\\"]jmoreconfig.h>\\"]", "private", "\\"jpeglib.h\\"", "public"] },""",
]
_OPENCV_ENTRIES = [
"""{ include: ["@<opencv2/core/.*.inl.hpp>", "private", "<opencv2/core.hpp>", "public"] },""",
"""{ include: ["@<opencv2/core/hal/.*", "private", "<opencv2/core.hpp>", "public"] },""",
]
def _generate_openxr_entries():
for header in ("openxr_platform.h", "openxr_platform_defines.h"):
yield """{ include: ["@[<\\"]openxr/%s.*", "private", "\\"xrt/xrt_openxr_includes.h\\"", "public"] },""" % header
def _generate_eigen_entries():
for stubborn_header in ("ArrayBase", "MatrixBase", "DenseBase"):
yield """{ include: ["@[<\\"]src/Core/%s.h[>\\"]", "private", "<Eigen/Core>", "public"] },""" % (
stubborn_header,
)
for module in ("Core", "Geometry", "LU", "SparseCore", "Sparse"):
yield """{ include: ["@[<\\"]Eigen/src/%s/.*", "private", "<Eigen/%s>", "public"] },""" % (
module,
module,
)
yield """{ include: ["@[<\\"]src/%s/.*", "private", "<Eigen/%s>", "public"] },""" % (
module,
module,
)
_CONFIG_HEADERS = (
"xrt_config_android.h",
"xrt_config_build.h",
"xrt_config_drivers.h",
"xrt_config_have.h",
"xrt_config_vulkan.h",
)
def _generate_config_header_defines():
for header in _CONFIG_HEADERS:
input_filename = header + ".cmake_in"
input_file = _REPO / "src" / "xrt" / "include" / "xrt" / input_filename
with open(str(input_file), "r", encoding="utf-8") as fp:
for line in fp:
if line.startswith("#cmakedefine"):
parts = line.split(" ")
symbol = parts[1].strip()
yield """{ symbol: ["%s", "public", "\\"xrt/%s\\"", "public"] },""" % (
symbol,
header,
)
def get_all_entries():
entries = []
entries.extend(_WRAPPERS)
entries.extend(_MISC_ERRORS)
entries.extend(_MISC_DEPS)
# entries.extend(_OPENCV_ENTRIES)
# entries.extend(_generate_eigen_entries())
entries.extend(_generate_openxr_entries())
entries.extend(_generate_config_header_defines())
return entries
# REUSE-IgnoreStart
def _find_copyright_lines(fn: Path, *args):
with open(fn, encoding="utf-8") as f:
copyright_lines = [line.strip() for line in f if line.startswith("# Copyright")]
known_lines = set(copyright_lines)
for alt_fn in args:
with open(_SCRIPT_DIR / alt_fn, encoding="utf-8") as f:
new_lines = [line.strip() for line in f if line.startswith("# Copyright")]
copyright_lines.extend(line for line in new_lines if line not in known_lines)
known_lines.update(new_lines)
return copyright_lines
def write_mapping_file(entries: List[str], output_filename: Path, script_name: str):
"""Write an IWYU mapping file with the given entries."""
# Grab all lines from this and our other script.
lines = _find_copyright_lines(_FILE, script_name)
lines += [
"""#""",
"# SPDX-License" + "-Identifier: BSL-1.0", # split to avoid breaking REUSE tool
"""#""",
"""# GENERATED - edit %s instead of this file""" % script_name,
"[",
]
lines.extend(entries)
lines += "]"
content = "".join(line + "\n" for line in lines)
with open(output_filename, "w", encoding="utf-8") as fp:
fp.write(content)
# REUSE-IgnoreEnd
def write_file():
my_script_fn = Path(__file__).resolve().name
eigen_path = _SCRIPT_DIR / "eigen.imp"
write_mapping_file(list(_generate_eigen_entries()), eigen_path, my_script_fn)
opencv_path = _SCRIPT_DIR / "opencv.imp"
write_mapping_file(_OPENCV_ENTRIES, opencv_path, my_script_fn)
entries = get_all_entries()
for ref_path in (eigen_path, opencv_path):
entries.append("""{ ref: "%s" },""" % ref_path.name)
write_mapping_file(entries, _OUTPUT_FILENAME, my_script_fn)
if __name__ == "__main__":
write_file()

View file

@ -0,0 +1,65 @@
#!/usr/bin/env python3
# Copyright 2022-2023, Collabora, Ltd.
#
# SPDX-License-Identifier: BSL-1.0
#
# Original author: Rylie Pavlik <rylie.pavlik@collabora.com
"""Script to set up cppwinrt.imp for include-what-you-use."""
from pathlib import Path
import sys
import re
from generate_iwyu_mapping import write_mapping_file
_SCRIPT_DIR = Path(__file__).parent.resolve()
_OUTPUT_FILENAME = _SCRIPT_DIR / "cppwinrt.imp"
header_guard = re.compile(r"#ifndef WINRT_([a-zA-Z0-9_]+)_H\s*")
def find_namespace_name(header: Path) -> str:
with open(header, "r", encoding="utf-8") as fp:
for line in fp:
result = header_guard.match(line)
if not result:
continue
define_insides = result.group(1)
return define_insides.replace("_", ".")
raise RuntimeError("Could not figure out namespace name for " + str(header))
def make_canonical_include(namespace_name: str) -> str:
return "<winrt/%s.h>" % namespace_name
def make_private_include_pattern(namespace_name: str) -> str:
def munge_character(c: str):
if c == ".":
return "[.]"
if c.isupper():
return "[%s%s]" % (c, c.lower())
return c
munged_namespace = "".join(munge_character(c) for c in namespace_name)
return "@<winrt/impl/%s[.][0-9][.]h>" % munged_namespace
def get_all_cppwinrt_entries(cppwinrt_root: str):
root = Path(cppwinrt_root)
for header in root.glob("*.h"):
namespace_name = find_namespace_name(header)
pattern = make_private_include_pattern(namespace_name)
canonical = make_canonical_include(namespace_name)
yield """{ include: ["%s", "private", "%s", "public"] },""" % (
pattern,
canonical,
)
def write_file(cppwinrt_root: str):
entries = list(get_all_cppwinrt_entries(cppwinrt_root))
write_mapping_file(entries, _OUTPUT_FILENAME, Path(__file__).resolve().name)
if __name__ == "__main__":
write_file(sys.argv[1])

View file

@ -0,0 +1,57 @@
#!/usr/bin/env python3
# Copyright 2022-2023, Collabora, Ltd.
#
# SPDX-License-Identifier: BSL-1.0
#
# Original author: Rylie Pavlik <rylie.pavlik@collabora.com
"""Script to set up msvc.imp for include-what-you-use."""
from pathlib import Path
from generate_iwyu_mapping import write_mapping_file
_SCRIPT_DIR = Path(__file__).parent.resolve()
_OUTPUT_FILENAME = _SCRIPT_DIR / "msvc.imp"
_STL_EQUIVS = {
"<xutility>": ["<utility>"],
"<xstring>": ["<string>"],
"<xatomic.h>": ["<atomic>"],
"<xtr1common>": ["<type_traits>"],
"<corecrt_math.h>": ["<math.h>", "<cmath>"],
"<vcruntime_exceptions.h>": ["<exception>"],
# This header contains common functionality used by a ton of containers
"<xmemory>": [
"<deque>",
"<filesystem>",
"<forward_list>",
"<functional>",
"<future>",
"<hash_map>",
"<hash_set>",
"<list>",
"<map>",
"<memory>",
"<set>",
"<string>",
"<unordered_map>",
"<unordered_set>",
"<vector>",
],
}
def get_all_stl_entries():
for src, dests in _STL_EQUIVS.items():
for dest in dests:
yield """{ include: ["%s", "private", "%s", "public"] },""" % (
src,
dest,
)
def write_file():
entries = list(get_all_stl_entries())
write_mapping_file(entries, _OUTPUT_FILENAME, Path(__file__).resolve().name)
if __name__ == "__main__":
write_file()

View file

@ -0,0 +1,32 @@
#!/usr/bin/env python3
# Copyright 2022-2023, Collabora, Ltd.
#
# SPDX-License-Identifier: BSL-1.0
#
# Original author: Rylie Pavlik <rylie.pavlik@collabora.com
"""Script to set up windows.imp for include-what-you-use."""
from pathlib import Path
from generate_iwyu_mapping import write_mapping_file
_SCRIPT_DIR = Path(__file__).parent.resolve()
_OUTPUT_FILENAME = _SCRIPT_DIR / "windows.imp"
_SYMBOLS = {"IUnknown": "<Unknwn.h>"}
def get_all_entries():
for sym, header in _SYMBOLS.items():
yield """{ symbol: ["%s", "public", "%s", "public"] },""" % (
sym,
header,
)
def write_file():
entries = list(get_all_entries())
write_mapping_file(entries, _OUTPUT_FILENAME, Path(__file__).resolve().name)
if __name__ == "__main__":
write_file()

103
scripts/mapping.imp Normal file
View file

@ -0,0 +1,103 @@
# Copyright 2022-2023, Collabora, Ltd.
#
# SPDX-License-Identifier: BSL-1.0
#
# GENERATED - edit generate_iwyu_mapping.py instead of this file
[
{ include: ["@[<\"]vulkan/.+", "private", "\"xrt/xrt_vulkan_includes.h\"", "public"] },
{ include: ["\"EGL/eglplatform.h\"", "private", "\"ogl/ogl_api.h\"", "public"] },
{ include: ["<math.h>", "public", "\"math/m_mathinclude.h\"", "public"] },
{ include: ["<cmath>", "public", "\"math/m_mathinclude.h\"", "public"] },
{ symbol: ["M_PI", "public", "\"math/m_mathinclude.h\"", "public"] },
{ symbol: ["M_PIl", "public", "\"math/m_mathinclude.h\"", "public"] },
{ symbol: ["M_1_PI", "public", "\"math/m_mathinclude.h\"", "public"] },
{ symbol: ["ssize_t", "public", "\"xrt/xrt_compiler.h\"", "public"] },
{ include: ["@[<\"]bits/exception.h[>\"]", "private", "<exception>", "public"] },
{ include: ["@[<\"]ext/alloc_traits.h[>\"]", "private", "<vector>", "public"] },
{ include: ["@[<\"]bits/types/struct_iovec.h.", "private", "<sys/uio.h>", "public"] },
{ include: ["@[<\"]jmoreconfig.h>\"]", "private", "\"jpeglib.h\"", "public"] },
{ include: ["@[<\"]openxr/openxr_platform.h.*", "private", "\"xrt/xrt_openxr_includes.h\"", "public"] },
{ include: ["@[<\"]openxr/openxr_platform_defines.h.*", "private", "\"xrt/xrt_openxr_includes.h\"", "public"] },
{ symbol: ["XRT_ANDROID_PACKAGE", "public", "\"xrt/xrt_config_android.h\"", "public"] },
{ symbol: ["XRT_MODULE_AUX_VIVE", "public", "\"xrt/xrt_config_build.h\"", "public"] },
{ symbol: ["XRT_MODULE_COMPOSITOR", "public", "\"xrt/xrt_config_build.h\"", "public"] },
{ symbol: ["XRT_MODULE_COMPOSITOR_MAIN", "public", "\"xrt/xrt_config_build.h\"", "public"] },
{ symbol: ["XRT_MODULE_COMPOSITOR_NULL", "public", "\"xrt/xrt_config_build.h\"", "public"] },
{ symbol: ["XRT_MODULE_MERCURY_HANDTRACKING", "public", "\"xrt/xrt_config_build.h\"", "public"] },
{ symbol: ["XRT_MODULE_IPC", "public", "\"xrt/xrt_config_build.h\"", "public"] },
{ symbol: ["XRT_MODULE_MONADO_GUI", "public", "\"xrt/xrt_config_build.h\"", "public"] },
{ symbol: ["XRT_MODULE_MONADO_CLI", "public", "\"xrt/xrt_config_build.h\"", "public"] },
{ symbol: ["XRT_FEATURE_CLIENT_DEBUG_GUI", "public", "\"xrt/xrt_config_build.h\"", "public"] },
{ symbol: ["XRT_FEATURE_COLOR_LOG", "public", "\"xrt/xrt_config_build.h\"", "public"] },
{ symbol: ["XRT_FEATURE_DEBUG_GUI", "public", "\"xrt/xrt_config_build.h\"", "public"] },
{ symbol: ["XRT_FEATURE_OPENXR", "public", "\"xrt/xrt_config_build.h\"", "public"] },
{ symbol: ["XRT_FEATURE_OPENXR_DEBUG_UTILS", "public", "\"xrt/xrt_config_build.h\"", "public"] },
{ symbol: ["XRT_FEATURE_OPENXR_DISPLAY_REFRESH_RATE", "public", "\"xrt/xrt_config_build.h\"", "public"] },
{ symbol: ["XRT_FEATURE_OPENXR_FORCE_FEEDBACK_CURL", "public", "\"xrt/xrt_config_build.h\"", "public"] },
{ symbol: ["XRT_FEATURE_OPENXR_HEADLESS", "public", "\"xrt/xrt_config_build.h\"", "public"] },
{ symbol: ["XRT_FEATURE_OPENXR_INTERACTION_EXT_EYE_GAZE", "public", "\"xrt/xrt_config_build.h\"", "public"] },
{ symbol: ["XRT_FEATURE_OPENXR_INTERACTION_EXT_HAND", "public", "\"xrt/xrt_config_build.h\"", "public"] },
{ symbol: ["XRT_FEATURE_OPENXR_INTERACTION_EXT_PALM_POSE", "public", "\"xrt/xrt_config_build.h\"", "public"] },
{ symbol: ["XRT_FEATURE_OPENXR_INTERACTION_ML2", "public", "\"xrt/xrt_config_build.h\"", "public"] },
{ symbol: ["XRT_FEATURE_OPENXR_INTERACTION_MNDX", "public", "\"xrt/xrt_config_build.h\"", "public"] },
{ symbol: ["XRT_FEATURE_OPENXR_INTERACTION_MSFT_HAND", "public", "\"xrt/xrt_config_build.h\"", "public"] },
{ symbol: ["XRT_FEATURE_OPENXR_INTERACTION_OPPO", "public", "\"xrt/xrt_config_build.h\"", "public"] },
{ symbol: ["XRT_FEATURE_OPENXR_INTERACTION_WINMR", "public", "\"xrt/xrt_config_build.h\"", "public"] },
{ symbol: ["XRT_FEATURE_OPENXR_LAYER_CUBE", "public", "\"xrt/xrt_config_build.h\"", "public"] },
{ symbol: ["XRT_FEATURE_OPENXR_LAYER_CYLINDER", "public", "\"xrt/xrt_config_build.h\"", "public"] },
{ symbol: ["XRT_FEATURE_OPENXR_LAYER_DEPTH", "public", "\"xrt/xrt_config_build.h\"", "public"] },
{ symbol: ["XRT_FEATURE_OPENXR_LAYER_EQUIRECT1", "public", "\"xrt/xrt_config_build.h\"", "public"] },
{ symbol: ["XRT_FEATURE_OPENXR_LAYER_EQUIRECT2", "public", "\"xrt/xrt_config_build.h\"", "public"] },
{ symbol: ["XRT_FEATURE_OPENXR_OVERLAY", "public", "\"xrt/xrt_config_build.h\"", "public"] },
{ symbol: ["XRT_FEATURE_OPENXR_SPACE_LOCAL_FLOOR", "public", "\"xrt/xrt_config_build.h\"", "public"] },
{ symbol: ["XRT_FEATURE_OPENXR_SPACE_UNBOUNDED", "public", "\"xrt/xrt_config_build.h\"", "public"] },
{ symbol: ["XRT_FEATURE_OPENXR_VISIBILITY_MASK", "public", "\"xrt/xrt_config_build.h\"", "public"] },
{ symbol: ["XRT_FEATURE_RENDERDOC", "public", "\"xrt/xrt_config_build.h\"", "public"] },
{ symbol: ["XRT_FEATURE_SERVICE", "public", "\"xrt/xrt_config_build.h\"", "public"] },
{ symbol: ["XRT_FEATURE_SERVICE_SYSTEMD", "public", "\"xrt/xrt_config_build.h\"", "public"] },
{ symbol: ["XRT_FEATURE_SLAM", "public", "\"xrt/xrt_config_build.h\"", "public"] },
{ symbol: ["XRT_FEATURE_SSE2", "public", "\"xrt/xrt_config_build.h\"", "public"] },
{ symbol: ["XRT_FEATURE_STEAMVR_PLUGIN", "public", "\"xrt/xrt_config_build.h\"", "public"] },
{ symbol: ["XRT_FEATURE_TRACING", "public", "\"xrt/xrt_config_build.h\"", "public"] },
{ symbol: ["XRT_FEATURE_WINDOW_PEEK", "public", "\"xrt/xrt_config_build.h\"", "public"] },
{ symbol: ["XRT_IPC_MSG_SOCK_FILENAME", "public", "\"xrt/xrt_config_build.h\"", "public"] },
{ symbol: ["XRT_IPC_SERVICE_PID_FILENAME", "public", "\"xrt/xrt_config_build.h\"", "public"] },
{ symbol: ["XRT_HAVE_BASALT", "public", "\"xrt/xrt_config_have.h\"", "public"] },
{ symbol: ["XRT_HAVE_BLUETOOTH", "public", "\"xrt/xrt_config_have.h\"", "public"] },
{ symbol: ["XRT_HAVE_D3D11", "public", "\"xrt/xrt_config_have.h\"", "public"] },
{ symbol: ["XRT_HAVE_D3D12", "public", "\"xrt/xrt_config_have.h\"", "public"] },
{ symbol: ["XRT_HAVE_DBUS", "public", "\"xrt/xrt_config_have.h\"", "public"] },
{ symbol: ["XRT_HAVE_DXGI", "public", "\"xrt/xrt_config_have.h\"", "public"] },
{ symbol: ["XRT_HAVE_EGL", "public", "\"xrt/xrt_config_have.h\"", "public"] },
{ symbol: ["XRT_HAVE_FFMPEG", "public", "\"xrt/xrt_config_have.h\"", "public"] },
{ symbol: ["XRT_HAVE_GST", "public", "\"xrt/xrt_config_have.h\"", "public"] },
{ symbol: ["XRT_HAVE_HIDAPI", "public", "\"xrt/xrt_config_have.h\"", "public"] },
{ symbol: ["XRT_HAVE_JPEG", "public", "\"xrt/xrt_config_have.h\"", "public"] },
{ symbol: ["XRT_HAVE_KIMERA", "public", "\"xrt/xrt_config_have.h\"", "public"] },
{ symbol: ["XRT_HAVE_LIBBSD", "public", "\"xrt/xrt_config_have.h\"", "public"] },
{ symbol: ["XRT_HAVE_LIBUDEV", "public", "\"xrt/xrt_config_have.h\"", "public"] },
{ symbol: ["XRT_HAVE_LIBUSB", "public", "\"xrt/xrt_config_have.h\"", "public"] },
{ symbol: ["XRT_HAVE_LIBUVC", "public", "\"xrt/xrt_config_have.h\"", "public"] },
{ symbol: ["XRT_HAVE_OPENCV", "public", "\"xrt/xrt_config_have.h\"", "public"] },
{ symbol: ["XRT_HAVE_OPENGL", "public", "\"xrt/xrt_config_have.h\"", "public"] },
{ symbol: ["XRT_HAVE_OPENGLES", "public", "\"xrt/xrt_config_have.h\"", "public"] },
{ symbol: ["XRT_HAVE_OPENVR", "public", "\"xrt/xrt_config_have.h\"", "public"] },
{ symbol: ["XRT_HAVE_PERCETTO", "public", "\"xrt/xrt_config_have.h\"", "public"] },
{ symbol: ["XRT_HAVE_SDL2", "public", "\"xrt/xrt_config_have.h\"", "public"] },
{ symbol: ["XRT_HAVE_SYSTEMD", "public", "\"xrt/xrt_config_have.h\"", "public"] },
{ symbol: ["XRT_HAVE_TRACY", "public", "\"xrt/xrt_config_have.h\"", "public"] },
{ symbol: ["XRT_HAVE_V4L2", "public", "\"xrt/xrt_config_have.h\"", "public"] },
{ symbol: ["XRT_HAVE_VULKAN", "public", "\"xrt/xrt_config_have.h\"", "public"] },
{ symbol: ["XRT_HAVE_WAYLAND", "public", "\"xrt/xrt_config_have.h\"", "public"] },
{ symbol: ["XRT_HAVE_WAYLAND_DIRECT", "public", "\"xrt/xrt_config_have.h\"", "public"] },
{ symbol: ["XRT_HAVE_WIL", "public", "\"xrt/xrt_config_have.h\"", "public"] },
{ symbol: ["XRT_HAVE_WINRT", "public", "\"xrt/xrt_config_have.h\"", "public"] },
{ symbol: ["VK_USE_PLATFORM_ANDROID_KHR", "public", "\"xrt/xrt_config_vulkan.h\"", "public"] },
{ symbol: ["VK_USE_PLATFORM_WAYLAND_KHR", "public", "\"xrt/xrt_config_vulkan.h\"", "public"] },
{ symbol: ["VK_USE_PLATFORM_XCB_KHR", "public", "\"xrt/xrt_config_vulkan.h\"", "public"] },
{ symbol: ["VK_USE_PLATFORM_XLIB_XRANDR_EXT", "public", "\"xrt/xrt_config_vulkan.h\"", "public"] },
{ symbol: ["VK_USE_PLATFORM_WIN32_KHR", "public", "\"xrt/xrt_config_vulkan.h\"", "public"] },
{ symbol: ["VK_USE_PLATFORM_DISPLAY_KHR", "public", "\"xrt/xrt_config_vulkan.h\"", "public"] },
{ ref: "eigen.imp" },
{ ref: "opencv.imp" },
]

28
scripts/msvc.imp Normal file
View file

@ -0,0 +1,28 @@
# Copyright 2022, Collabora, Ltd.
# SPDX-License-Identifier: BSL-1.0
#
# GENERATED - edit generate_iwyu_mapping_msvc.py instead of this file
[
{ include: ["<xutility>", "private", "<utility>", "public"] },
{ include: ["<xstring>", "private", "<string>", "public"] },
{ include: ["<xatomic.h>", "private", "<atomic>", "public"] },
{ include: ["<xtr1common>", "private", "<type_traits>", "public"] },
{ include: ["<corecrt_math.h>", "private", "<math.h>", "public"] },
{ include: ["<corecrt_math.h>", "private", "<cmath>", "public"] },
{ include: ["<vcruntime_exceptions.h>", "private", "<exception>", "public"] },
{ include: ["<xmemory>", "private", "<deque>", "public"] },
{ include: ["<xmemory>", "private", "<filesystem>", "public"] },
{ include: ["<xmemory>", "private", "<forward_list>", "public"] },
{ include: ["<xmemory>", "private", "<functional>", "public"] },
{ include: ["<xmemory>", "private", "<future>", "public"] },
{ include: ["<xmemory>", "private", "<hash_map>", "public"] },
{ include: ["<xmemory>", "private", "<hash_set>", "public"] },
{ include: ["<xmemory>", "private", "<list>", "public"] },
{ include: ["<xmemory>", "private", "<map>", "public"] },
{ include: ["<xmemory>", "private", "<memory>", "public"] },
{ include: ["<xmemory>", "private", "<set>", "public"] },
{ include: ["<xmemory>", "private", "<string>", "public"] },
{ include: ["<xmemory>", "private", "<unordered_map>", "public"] },
{ include: ["<xmemory>", "private", "<unordered_set>", "public"] },
{ include: ["<xmemory>", "private", "<vector>", "public"] },
]

9
scripts/opencv.imp Normal file
View file

@ -0,0 +1,9 @@
# Copyright 2022-2023, Collabora, Ltd.
#
# SPDX-License-Identifier: BSL-1.0
#
# GENERATED - edit generate_iwyu_mapping.py instead of this file
[
{ include: ["@<opencv2/core/.*.inl.hpp>", "private", "<opencv2/core.hpp>", "public"] },
{ include: ["@<opencv2/core/hal/.*", "private", "<opencv2/core.hpp>", "public"] },
]

82
scripts/run_iwyu.ps1 Normal file
View file

@ -0,0 +1,82 @@
# Copyright 2022, Collabora, Ltd.
# SPDX-License-Identifier: BSL-1.0
[CmdletBinding()]
param (
[Parameter()]
[string]
$IwyuBinDir,
[Parameter()]
[string]
$Python
)
$ErrorActionPreference = 'Stop'
Push-Location $PSScriptRoot/..
if (!$IwyuBinDir) {
$cmd = Get-Command "iwyu" -ErrorAction SilentlyContinue
if ($cmd) {
$IwyuBinDir = $cmd.Source
}
}
if (!$IwyuBinDir) {
Write-Error "Please specify IwyuBinDir - could not find on path"
return -1
}
if (!$Python) {
$cmd = Get-Command "python3" -ErrorAction SilentlyContinue
if ($cmd) {
$Python = $cmd.Source
}
}
if (!$Python) {
$cmd = Get-Command "python" -ErrorAction SilentlyContinue
if ($cmd) {
$Python = $cmd.Source
}
}
if (!$Python) {
Write-Error "Please specify Python - could not find on path"
return -1
}
$iwyuShareDir = Get-Item -Path $IwyuBinDir/../share/include-what-you-use
function Create-Args {
[CmdletBinding()]
Param(
[Parameter(ValueFromPipeline)]
$FullName
)
process {
$item = Get-Item $FullName
Write-Output '-Xiwyu'
Write-Output ("--mapping_file=" + $item.FullName)
}
}
$python_args = @(
(Join-Path $IwyuBinDir "iwyu_tool.py")
"-p"
"build"
"src/xrt"
"--"
)
$python_args = $python_args + (Join-Path $iwyuShareDir 'iwyu.gcc.imp' | Create-Args)
$python_args = $python_args + (Get-ChildItem -Path $iwyuShareDir -Filter "*intrinsics.imp" | Create-Args)
$python_args = $python_args + (Get-ChildItem -Path $iwyuShareDir -Filter "libcxx.imp" | Create-Args)
Write-Host $python_args
$our_mapping_file = Join-Path (Get-Location) scripts/mapping.imp
$python_args = $python_args + @("-Xiwyu", "--mapping_file=$our_mapping_file")
# & $Python (Join-Path $IwyuBinDir "iwyu_tool.py") -p build src/xrt -- -Xiwyu "--mapping_file=$our_mapping_file" @python_args | Tee-Object -FilePath iwyu.txt -Encoding utf8
Start-Process -FilePath $Python -ArgumentList $python_args -PassThru -Wait -NoNewWindow
Pop-Location

13
scripts/run_iwyu.sh Executable file
View file

@ -0,0 +1,13 @@
#!/bin/sh
# Copyright 2022, Collabora, Ltd.
# SPDX-License-Identifier: BSL-1.0
(
set -e
cd "$(dirname $0)" && cd ..
extra_args=""
for fn in /usr/share/include-what-you-use/iwyu.gcc.imp /usr/share/include-what-you-use/*intrinsics.imp /usr/share/include-what-you-use/libcxx*.imp; do
extra_args="${extra_args} -Xiwyu --mapping_file=$fn"
done
iwyu_tool -p build src/xrt/ "$@" -- -Xiwyu "--mapping_file=$(pwd)/scripts/mapping.imp" ${extra_args} | tee iwyu.txt
)

7
scripts/windows.imp Normal file
View file

@ -0,0 +1,7 @@
# Copyright 2022, Collabora, Ltd.
# SPDX-License-Identifier: BSL-1.0
#
# GENERATED - edit generate_iwyu_mapping_windows.py instead of this file
[
{ symbol: ["IUnknown", "public", "<Unknwn.h>", "public"] },
]

View file

@ -1,12 +1,28 @@
---
# SPDX-License-Identifier: CC0-1.0
# SPDX-FileCopyrightText: 2020, Collabora, Ltd.
# SPDX-FileCopyrightText: 2020-2022, Collabora, Ltd.
Language: Cpp
BasedOnStyle: LLVM
Standard: Auto
# Includes
SortIncludes: false
SortIncludes: false
# SortIncludes: true
# IncludeBlocks: Regroup
# # IncludeBlocks: Preserve
# IncludeCategories:
# # xrt includes first, they set up defines, clean up after messy headers, etc.
# - Regex: "^[<\"](xrt)/"
# Priority: 2
# # Then, any other internal library
# - Regex: "^[<\"](util|vk|os|math|render|multi)/"
# Priority: 3
# # system includes
# - Regex: "<([[:alnum:].]+|type_traits)>"
# Priority: 5
# # Everything else (local includes)
# - Regex: ".*"
# Priority: 2
# Spacing and Blank Lines
DerivePointerAlignment: false