File gcovr.spec of Package gcovr

#
# spec file for package gcovr
#
# Copyright (c) 2023 SUSE LLC
# Copyright (c) 2019 Neal Gompa <ngompa13@gmail.com>.
#
# 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 https://bugs.opensuse.org/
#

%if 0%{?suse_version} > 1600
%define pythons python3
%else
%define pythons python311
%endif

Name:           gcovr
Version:        6.0
Release:        0
Summary:        A code coverage report generator using GNU gcov
License:        BSD-3-Clause
Group:          Development/Tools/Other
URL:            https://gcovr.com/
Source0:        https://github.com/gcovr/%{name}/archive/%{version}/%{name}-%{version}.tar.gz
BuildRequires:  fdupes
BuildRequires:  python-rpm-macros
BuildRequires:  %{pythons}
BuildRequires:  %{python_module devel}
BuildRequires:  %{python_module lxml}
BuildRequires:  %{python_module setuptools}
# for %%{_bindir}/gcov
Requires:       gcc
Requires:       %{python_module Jinja2}
Requires:       %{python_module lxml}
BuildArch:      noarch
# Only build the documentation on Tumbleweed, as
# python3-sphinxcontrib-autoprogram has not yet landed in anything
# else
%if 0%{?suse_version} > 1500
BuildRequires:  %{python_module Jinja2}
BuildRequires:  %{python_module Sphinx}
BuildRequires:  %{python_module sphinx_rtd_theme}
BuildRequires:  %{python_module sphinxcontrib-autoprogram}
%endif

%description
Gcovr provides a utility for managing the use of the GNU gcov utility
and generating summarized code coverage results.

This command is inspired by the Python coverage.py package, which provides
a similar utility in Python. The gcovr command produces either compact
human-readable summary reports, machine readable XML reports
(in Cobertura format) or simple HTML reports. Thus, gcovr can be viewed
as a command-line alternative to the lcov utility, which runs gcov and
generates an HTML-formatted report.

%if 0%{?suse_version} > 1500
%package        doc
Summary:        Documentation of gcovr
Group:          Documentation/HTML
BuildRequires:  %{python_module Jinja2}
BuildRequires:  %{python_module Sphinx}
BuildRequires:  %{python_module sphinx_rtd_theme}
BuildRequires:  %{python_module sphinxcontrib-autoprogram}

%description    doc
Gcovr provides a utility for managing the use of the GNU gcov utility
and generating summarized code coverage results.

This package contains the documentation of gcovr.
%endif

%python_subpackages

%prep
%autosetup

%build
%python_build

%install
%python_install

%if 0%{?suse_version} > 1500
# the documentation can only be build **after** gcovr is installed
# => need to set PATH, PYTHONPATH so that the installed binary & package are
# found
# also set PYTHON so that the sphinx Makefile picks up python3 instead of
# python2
export PATH=%{buildroot}%{_bindir}:$PATH

pushd doc

%python_expand PYTHONPATH=%{buildroot}/%{$python_sitelib} PYTHON=%{$python} make man
install -D -p -m 0644 build/man/%{name}.1 %{buildroot}%{_mandir}/man1/%{name}.1

# html doc
%python_expand PYTHONPATH=%{buildroot}/%{$python_sitelib} PYTHON=%{$python} make html
rm build/html/.buildinfo
%fdupes -s build/html

popd
%endif

%python_expand %fdupes -s %{buildroot}%{$python_sitelib}

%files %{python_files}
%license LICENSE.txt
%doc README.rst CHANGELOG.rst

%{_bindir}/%{name}
%{python_sitelib}/%{name}*

%if 0%{?suse_version} > 1500
%{_mandir}/man1/%{name}.1%{?ext_man}

%files doc
%doc doc/build/html/*
%endif

%changelog
openSUSE Build Service is sponsored by