Skip to content

Commit

Permalink
Add option to enable code coverage support when building RPMs
Browse files Browse the repository at this point in the history
To enable building RPMs with code coverage support `-Dwith_coverage=1`
parameter can be passed to rpmbuild. Code coverage support is turned
off by default when building RPMs.

Related: #397
Signed-off-by: Artiom Divak <adivak@redhat.com>
  • Loading branch information
ArtiomDivak committed Sep 14, 2023
1 parent 7749d31 commit ba51bfe
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.developer.md
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,8 @@ The package build process can be adjusted using following environment variables:
- To skip installation of build dependencies this option should contain `yes` value.
- `WITH_PYTHON`
- To skip building python bluechi modules this option should contain `0`.
- `WITH_COVERAGE`
- To start collecting coverage this option should contain `1`.

So for example following command will skip build dependencies installation and store create RPM packages into `output`
subdirectory:
Expand Down
6 changes: 5 additions & 1 deletion bluechi.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
%global with_python 1
%endif

# coverage collection is disabled by default , it can be enabled passing `--define "with_coverage 1"` option to rpmbuild
%if 0%{?with_coverage}
%global coverage_flags -Dwith_coverage=true
%endif

Name: bluechi
Version: @VERSION@
Expand Down Expand Up @@ -203,7 +207,7 @@ API description and manually written code to simplify recurring tasks.
%autosetup

%build
%meson -Dapi_bus=system
%meson -Dapi_bus=system %{?coverage_flags}
%meson_build

%if %{with_python}
Expand Down
1 change: 1 addition & 0 deletions build-scripts/build-rpm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ fi
rpmbuild \
--define "_topmdir rpmbuild" \
--define "_rpmdir rpmbuild" \
--define "with_coverage ${WITH_COVERAGE:=0}"\
--define "with_python ${WITH_PYTHON:=1}" \
--rebuild rpmbuild/SRPMS/*src.rpm

Expand Down
42 changes: 42 additions & 0 deletions test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
Directory already configured.

Just run your build command (e.g. ninja) and Meson will regenerate as necessary.
If ninja fails, run "ninja reconfigure" or "meson setup --reconfigure"
to force Meson to regenerate.

If build failures persist, run "meson setup --wipe" to rebuild from scratch
using the same options as passed when configuring the build.
To change option values, run "meson configure" instead.
Entering 'subprojects/hashmap.c'
Entering 'subprojects/inih'
setting SOURCE_DATE_EPOCH=1693785600
Wrote: rpmbuild/SRPMS/bluechi-0.6.0-0.202309141037.git68fd4bd.fc37.src.rpm
RHEL8 CSB packages 0.0 B/s | 0 B 00:00
Last metadata expiration check: 0:26:18 ago on Thu 14 Sep 2023 10:10:52 AM IDT.
Package checkpolicy-3.5-1.fc37.x86_64 is already installed.
Package gcc-12.3.1-1.fc37.x86_64 is already installed.
Package gcc-c++-12.3.1-1.fc37.x86_64 is already installed.
Package golang-github-cpuguy83-md2man-2.0.2-4.fc37.x86_64 is already installed.
Package meson-1.0.1-1.fc37.noarch is already installed.
Package python3-devel-3.11.4-1.fc37.x86_64 is already installed.
Package python3-setuptools-62.6.0-3.fc37.noarch is already installed.
Package selinux-policy-devel-37.22-1.fc37.noarch is already installed.
Package systemd-devel-251.14-2.fc37.x86_64 is already installed.
Package systemd-rpm-macros-251.14-2.fc37.noarch is already installed.
Package checkpolicy-3.5-1.fc37.x86_64 is already installed.
Package gcc-12.3.1-1.fc37.x86_64 is already installed.
Package gcc-c++-12.3.1-1.fc37.x86_64 is already installed.
Package golang-github-cpuguy83-md2man-2.0.2-4.fc37.x86_64 is already installed.
Package meson-1.0.1-1.fc37.noarch is already installed.
Package python3-devel-3.11.4-1.fc37.x86_64 is already installed.
Package python3-setuptools-62.6.0-3.fc37.noarch is already installed.
Package selinux-policy-devel-37.22-1.fc37.noarch is already installed.
Package systemd-devel-251.14-2.fc37.x86_64 is already installed.
Package systemd-rpm-macros-251.14-2.fc37.noarch is already installed.
Dependencies resolved.
Nothing to do.
Complete!
Installing rpmbuild/SRPMS/bluechi-0.6.0-0.202309141036.git68fd4bd.fc37.src.rpm
setting SOURCE_DATE_EPOCH=1693785600
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.6dUQhj
Executing(%build): /bin/sh -e /var/tmp/rpm-tmp.TvLNpn

0 comments on commit ba51bfe

Please sign in to comment.