contrib/rpm: support building with meson

Add support for building with meson, enabled by '--with meson' so that
we can regularly test the whole build+test+install procedure with
meson. I compared the RPM contents of NM, NM-libnm, NM-libnm-devel
packages and they match the autotools ones. It's also faster:

  $ time contrib/fedora/rpm/build_clean.sh -g -Q -f

  real    3m54.239s
  user    11m15.000s
  sys     1m28.456s

  $ time contrib/fedora/rpm/build_clean.sh -g -Q -f -w meson

  real    3m9.938s
  user    9m5.225s
  sys     1m4.392s

(cherry picked from commit 295b9d5b81)
This commit is contained in:
Beniamino Galvani 2018-09-21 22:49:20 +02:00
parent d04dd3385c
commit c762160692

View file

@ -45,6 +45,7 @@
###############################################################################
%bcond_with meson
%bcond_without adsl
%bcond_without bluetooth
%bcond_without wwan
@ -144,8 +145,12 @@ Conflicts: kde-plasma-networkmanagement < 1:0.9-0.49.20110527git.nm09
BuildRequires: gcc
BuildRequires: libtool
BuildRequires: pkgconfig
%if %{with meson}
BuildRequires: meson
%else
BuildRequires: automake
BuildRequires: autoconf
%endif
BuildRequires: intltool
BuildRequires: gettext-devel
@ -453,6 +458,99 @@ by nm-connection-editor and nm-applet in a non-graphical environment.
%build
%if %{with meson}
%meson \
-Ddhcpcanon=no \
-Ddhcpcd=no \
-Dconfig_dhcp_default=%{dhcp_default} \
%if %{with crypto_gnutls}
-Dcrypto=gnutls \
%else
-Dcrypto=nss \
%endif
%if %{with debug}
-Dmore_logging=true \
-Dmore_asserts=10000 \
%else
-Dmore_logging=false \
-Dmore_asserts=0 \
%endif
-Dld_gc=true \
-Dlibaudit=yes-disabled-by-default \
%if 0%{?with_modem_manager_1}
-Dmodem_manager=true \
%else
-Dmodem_manager=false \
%endif
%if %{with wifi}
-Dwifi=true \
%if 0%{?fedora}
-Dwext=true \
%else
-Dwext=false \
%endif
%else
-Dwifi=false \
%endif
%if %{with iwd}
-Diwd=true \
%else
-Diwd=false \
%endif
-Dvapi=true \
-Dintrospection=true \
%if %{with regen_docs}
-Ddocs=true \
%else
-Ddocs=false \
%endif
%if %{with team}
-Dteamdctl=true \
%else
-Dteamdctl=false \
%endif
%if %{with ovs}
-Dovs=true \
%else
-Dovs=false \
%endif
-Dselinux=true \
-Dpolkit=yes \
-Dpolkit_agent=true \
-Dmodify_system=true \
-Dconcheck=true \
%if 0%{?fedora}
-Dlibpsl=true \
%else
-Dlibpsl=false \
%endif
-Dsession_tracking=systemd \
-Dsuspend_resume=systemd \
-Dsystemdsystemunitdir=%{systemd_dir} \
-Dsystem_ca_path=/etc/pki/tls/cert.pem \
-Ddbus_conf_dir=%{dbus_sys_dir} \
-Dtests=yes \
-Dvalgrind=no \
-Difcfg_rh=true \
%if %{with ppp}
-Dpppd_plugin_dir=%{_libdir}/pppd/%{ppp_version} \
-Dppp=true \
%endif
-Ddist_version=%{version}-%{release} \
-Dconfig_plugins_default='ifcfg-rh' \
-Dconfig_dns_rc_manager_default=symlink \
-Dconfig_logging_backend_default=journal \
-Djson_validation=true \
%if %{with libnm_glib}
-Dlibnm_glib=true
%else
-Dlibnm_glib=false
%endif
%meson_build
%else
# autotools
%if %{with regen_docs}
gtkdocize
%endif
@ -565,10 +663,14 @@ intltoolize --automake --copy --force
make %{?_smp_mflags}
%endif # end autotools
%install
# install NM
%if %{with meson}
%meson_install
%else
make install DESTDIR=%{buildroot}
%endif
cp %{SOURCE1} %{buildroot}%{_sysconfdir}/%{name}/
@ -604,11 +706,20 @@ touch %{buildroot}%{_sbindir}/ifup %{buildroot}%{_sbindir}/ifdown
%check
%if %{with meson}
%if %{with test}
%meson_test
%else
%ninja_test -C %{_vpath_builddir} || :
%endif
%else
# autotools
%if %{with test}
make -k %{?_smp_mflags} check
%else
make -k %{?_smp_mflags} check || :
%endif
%endif # end autotools
%pre