File include-what-you-use.spec of Package include-what-you-use

# spec file for package include-what-you-use
# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
# Copyright (c) 2018 Aaron Puchert.
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via

Name:           include-what-you-use
Version:        0.9
Release:        0
Summary:        A tool to analyze #includes in C and C++ source files
License:        NCSA
Group:          Development/Languages/C and C++
Source1:        %{name}.1.gz
Patch0:         llvm-link.patch
Patch1:         fix-shebang.patch
Patch2:         iwyu_include_picker.patch
Patch3:         remove-x86-specific-code.patch
BuildRequires:  clang5
BuildRequires:  clang5-devel
BuildRequires:  cmake
%if 0%{?sle_version} && 0%{?sle_version} <= 130000 && !0%{?is_opensuse}
BuildRequires:  gcc6
BuildRequires:  gcc6-c++
BuildRequires:  llvm5-devel
# We need the compiler-specific headers in /usr/lib64/clang/.
Requires:       clang5
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

"Include what you use" means this: for every symbol (type, function,
variable, or macro) that you use in (or foo.cpp), either
or foo.h should include a .h file that exports the declaration of that
symbol. The include-what-you-use program is a tool to analyze includes
of source files to find include-what-you-use violations, and suggest
fixes for them.

The main goal of include-what-you-use is to remove superfluous includes.
It does this both by figuring out what includes are not actually needed
for this file (for both .cc and .h files), and replacing includes with
forward declarations when possible.

%package tools
Summary:        Additional tools to use %{name} effectively
Group:          Development/Languages/C and C++
Requires:       %{name} = %{version}-%{release}
BuildArch:      noarch

%description tools
This package contains additional scripts for using %{name} as automated
refactoring tool.

%setup -q -n %{name}
%patch0 -p1
%patch1 -p1
%patch2 -p1
%patch3 -p1

# Remove obsolete files - this is now hardcoded into
rm gcc.libc.imp gcc.symbols.imp gcc.stl.headers.imp stl.c.headers.imp
# The includes from third_party.imp probably only make sense in some code bases.
rm third_party.imp
# This also obsoletes iwyu.gcc.imp.
rm iwyu.gcc.imp

# Since Clang is built using Clang, use it here too. Except for SLES, where we
# need to use GCC 6 for some reason. (Otherwise there are segfaults.)
%if 0%{?sle_version} && 0%{?sle_version} <= 130000 && !0%{?is_opensuse}
export CC=gcc-6 CXX=g++-6
export CC=clang CXX=clang++
%cmake -DIWYU_LLVM_ROOT_PATH=%{_libdir} ..


install -Dm0644 %{SOURCE1} %{buildroot}%{_mandir}/man1/%{name}.1.gz

%defattr(-, root, root, -)

%files tools
%defattr(-, root, root, -)

openSUSE Build Service is sponsored by