%global toolchain clang Summary: A tool for use with clang to analyze #includes in C and C++ source files Name: include-what-you-use License: NCSA Version: 0.19 Release: 1%{?dist} URL: https://include-what-you-use.org/ Source0: https://github.com/%{name}/%{name}/archive/refs/tags/%{version}.tar.gz BuildRequires: boost-devel BuildRequires: cmake BuildRequires: clang-analyzer BuildRequires: clang-libs BuildRequires: clang-devel BuildRequires: clang-tools-extra-devel BuildRequires: libcxx-devel BuildRequires: libcxxabi-devel BuildRequires: libffi-devel BuildRequires: llvm-devel BuildRequires: ncurses-compat-libs BuildRequires: python-devel BuildRequires: zlib-devel %global _description %{expand: "Include what you use" means this: for every symbol (type, function, variable, or macro) that you use in foo.cc (or foo.cpp), either foo.cc or foo.h should include a .h file that exports the declaration of that symbol. (Similarly, for foo_test.cc, either foo_test.cc or foo.h should do the including.) Obviously symbols defined in foo.cc itself are excluded from this requirement. This puts us in a state where every file includes the headers it needs to declare the symbols that it uses. When every file includes what it uses, then it is possible to edit any file and remove unused headers, without fear of accidentally breaking the upwards dependencies of that file. It also becomes easy to automatically track and update dependencies in the source code.} %description %_description %prep %autosetup %build # Fix shebangs %py3_shebang_fix fix_includes.py %py3_shebang_fix iwyu_tool.py %cmake -G "Unix Makefiles" \ -DCMAKE_PREFIX_PATH=%{_libdir} \ -DCMAKE_C_COMPILER=clang \ -DCMAKE_CXX_COMPILER=clang++ %cmake_build %install %cmake_install %check # Enable finding of headers in tests failed_tests_add_include_argument=( "iterator.cc" "no_char_traits.cc" "scope_crash.cc" "std_size_t.cc" "stl_container_provides_allocator.cc") failed_tests_additional_include_argument=( "associated_h_file_heuristic.cc" "badinc.cc" "catch.cc" "check_also.cc" "computed_include.cc" "libbuiltins.cc" "macro_defined_by_includer.cc" "pch_in_code.cc" "precomputed_tpl_args.cc" "quoted_includes_first.cc" "sizeof_reference.cc" "uses_printf.cc") clang_major_ver=$(clang --version | grep version | cut -f3 -d" " | cut -f1 -d".") for test in ${failed_tests_add_include_argument[@]};do sed -i "/===\/\//a\/\/ IWYU_ARGS: -I %{_libdir}/clang/${clang_major_ver}/include/" tests/cxx/$test done for test in ${failed_tests_additional_include_argument[@]};do sed -i "s|-I .|-I . -I %{_libdir}/clang/${clang_major_ver}/include|g" tests/cxx/$test done # Disble failing test sed -i "/cxx.test_badinc /d" %__cmake_builddir/CTestTestfile.cmake %ctest %files %doc README.md %license LICENSE.TXT %{_bindir}/fix_includes.py %{_bindir}/include-what-you-use %{_bindir}/iwyu_tool.py %{_mandir}/man1/include-what-you-use.* %dir %{_datadir}/include-what-you-use %{_datadir}/include-what-you-use/*.imp %changelog * Thu Mar 02 2023 Benson Muite - 0.19-1 - Initial packaging