File coverage-tools.spec of Package coverage-tools
#
# spec file for package coverage-tools
#
# Copyright (c) 2025 SUSE LLC
#
# 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/
%define dname BinaryCoverage-%{version}
%define pinversion pin-external-4.0-99633-g5ca9893f2-gcc-linux
Name: coverage-tools
Version: 0.5.6
Release: 0
Summary: Tools necessary to test binary coverage of different packages
# nonfree is ISSL - Intel Simplified Software License see intel-simplified-software-license.txt
License: MIT AND NonFree
URL: https://github.com/ilmanzo/CodeCoverage
Source0: %{dname}.tar.gz
Source1: %{pinversion}.tar.gz
Source2: vendor.tar.gz
Source3: https://software.intel.com/sites/landingpage/pintool/intel-simplified-software-license.txt
BuildRequires: go
BuildRequires: unzip
ExclusiveArch: x86_64
# Use older gcc on older product versions
%if 0%{?suse_version} >= 1560
BuildRequires: gcc15-c++
%else
BuildRequires: gcc12-c++
%endif
# If building on SLE
%if 0%{?sle_version} == 0
BuildRequires: openSUSE-release
%endif
%description
This is a function-level code coverage tool using Intel Pin as a dynamic binary instrumentation engine.
It works by firstly prepending and later logging function entry points during execution of target binaries.
The output is a simple text log showing which functions were called, suitable for post-processing or coverage analysis.
%prep
%autosetup -n %{dname} -a1 -b2
%build
export PIN_ROOT=%{_builddir}/%{dname}/%{pinversion}
make
export GOFLAGS="-buildmode=pie -trimpath -mod=vendor"
mv %{_builddir}/vendor .
go build -ldflags="-s -w" -o funkoverage ./cmd
%check
pushd cmd
go test -v ./...
popd
%post
/sbin/ldconfig
%postun
/sbin/ldconfig
%install
mkdir -p %{buildroot}%{_libdir}/coverage-tools
mkdir -p %{buildroot}%{_bindir}
mkdir -p %{buildroot}%{_licensedir}/%{name}/
# Install binaries and scripts
install -m 0755 obj-intel64/FuncTracer.so %{buildroot}%{_libdir}/coverage-tools/
install -m 0755 funkoverage %{buildroot}%{_bindir}/funkoverage
# remove unneeded/development directories
for d in doc source ia32 bindings extras/xed-ia32 intel64/pinrt/include \
extras/libdwarf/libdwarf-2.1.0/test \
extras/libdwarf/libdwarf-2.1.0/src \
extras/libdwarf/libdwarf-2.1.0/fuzz \
extras/libdwarf/libdwarf-2.1.0/.github \
extras/libdwarf/libdwarf-2.1.0/.travis.yml \
extras/libdwarf/libdwarf-2.1.0/autogen.sh \
extras/libdwarf/libdwarf-2.1.0/scripts \
extras/libdwarf/libdwarf-2.1.0/tools \
extras/libunwind/include \
extras/xed-intel64/include \
extras/components/include \
extras/components/lib/ia32 \
extras/components/lib/intel64/libdebugger-protocol.a \
extras/libdwarf/libdwarf-2.1.0/doc \
intel64/lib/libpin.a intel64/lib/libsapin.a \
intel64/pinrt/lib/libpincrt.a intel64/pinrt/lib/libc.a \
intel64/pinrt/lib/libpinos.a \
intel64/pinrt/lib/libpinrt-adaptor-static.a \
intel64/pinrt/lib/librscproto.a
do rm -rf "%{pinversion}/$d" ; done
for lib in extras/xed-intel64/lib/libxed.so intel64/lib/libdwarf.so \
intel64/lib/libpindwarf.so intel64/lib/libpinjitprofiling.so \
intel64/pinrt/lib/libc++.so intel64/pinrt/lib/libc++abi.so \
intel64/pinrt/lib/libpinos.so intel64/pinrt/lib/libunwind-dynamic.so
do chmod 755 "%{pinversion}/$lib" ; done
mv %{pinversion} %{buildroot}/%{_libdir}/coverage-tools/pin
# Copy ISSL license file
install -m 0644 %{_sourcedir}/intel-simplified-software-license.txt %{buildroot}%{_licensedir}/%{name}/intel-simplified-software-license.txt
%files
%license LICENSE
%license %{_licensedir}/%{name}/intel-simplified-software-license.txt
%doc README.md
%{_libdir}/coverage-tools/
%{_bindir}/funkoverage
%changelog