mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 13:45:38 +00:00
spec: indent %if to make it easier to see conditions
Nested conditionals are hard to read if they are not indented. We can't add arbitrary whitespace to everything in spec files, but we CAN add spaces before %if and %define. Use this trick, plus a fancy sed script that rewrites a spec file into a C file, so we can use cppi to keep our spec file nice. For reference, the sed script converts code like: |# RHEL-5 builds are client-only for s390, ppc |%if 0%{?rhel} == 5 | %ifnarch %{ix86} x86_64 ia64 | %define client_only 1 | %endif |%endif into the following for cppi: |// # RHEL-5 builds are client-only for s390, ppc |#if a // 0%{?rhel} == 5 |# if a // %{ix86} x86_64 ia64 |# define client_only 1 |# endif |#endif and errors from 'make syntax-check' look like: spec_indentation cppi: mingw-libvirt.spec.in: line 130: not properly indented maint.mk: incorrect preprocessor indentation * libvirt.spec.in: Add some indentation to make it easier to follow various conditionals. * mingw-libvirt-spec.in: Likewise. * cfg.mk (sc_spec_indentation): New syntax check to enforce it.
This commit is contained in:
parent
790f912b46
commit
c8f79c9b29
19
cfg.mk
19
cfg.mk
@ -1,5 +1,5 @@
|
||||
# Customize Makefile.maint. -*- makefile -*-
|
||||
# Copyright (C) 2008-2012 Red Hat, Inc.
|
||||
# Copyright (C) 2008-2013 Red Hat, Inc.
|
||||
# Copyright (C) 2003-2008 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
@ -623,6 +623,23 @@ sc_preprocessor_indentation:
|
||||
echo '$(ME): skipping test $@: cppi not installed' 1>&2; \
|
||||
fi
|
||||
|
||||
# Enforce similar spec file indentation style, by running cppi on a
|
||||
# (comment-only) C file that mirrors the same layout as the spec file.
|
||||
sc_spec_indentation:
|
||||
@if cppi --version >/dev/null 2>&1; then \
|
||||
for f in $$($(VC_LIST_EXCEPT) | grep '\.spec\.in$$'); do \
|
||||
sed -e 's|#|// #|; s|%ifn*\(arch\)* |#if a // |' \
|
||||
-e 's/%\(else\|endif\|define\)/#\1/' \
|
||||
-e 's/^\( *\)\1\1\1#/#\1/' \
|
||||
-e 's|^\( *[^#/ ]\)|// \1|; s|^\( */[^/]\)|// \1|' $$f \
|
||||
| cppi -a -c 2>&1 | sed "s|standard input|$$f|"; \
|
||||
done | { if grep . >&2; then false; else :; fi; } \
|
||||
|| { echo '$(ME): incorrect preprocessor indentation' 1>&2; \
|
||||
exit 1; }; \
|
||||
else \
|
||||
echo '$(ME): skipping test $@: cppi not installed' 1>&2; \
|
||||
fi
|
||||
|
||||
sc_copyright_format:
|
||||
@require='Copyright .*Red 'Hat', Inc\.' \
|
||||
containing='Copyright .*Red 'Hat \
|
||||
|
854
libvirt.spec.in
854
libvirt.spec.in
File diff suppressed because it is too large
Load Diff
@ -17,9 +17,9 @@
|
||||
|
||||
# RHEL ships ESX but not PowerHypervisor, HyperV, or libxenserver (xenapi)
|
||||
%if 0%{?rhel}
|
||||
%define with_phyp 0
|
||||
%define with_xenapi 0
|
||||
%define with_hyperv 0
|
||||
%define with_phyp 0
|
||||
%define with_xenapi 0
|
||||
%define with_hyperv 0
|
||||
%endif
|
||||
|
||||
Name: mingw-libvirt
|
||||
@ -111,23 +111,23 @@ MinGW Windows libvirt virtualization library, static version.
|
||||
|
||||
%build
|
||||
%if ! %{with_phyp}
|
||||
%define _without_phyp --without-phyp
|
||||
%define _without_phyp --without-phyp
|
||||
%endif
|
||||
|
||||
%if ! %{with_esx}
|
||||
%define _without_esx --without-esx
|
||||
%define _without_esx --without-esx
|
||||
%endif
|
||||
|
||||
%if ! %{with_hyperv}
|
||||
%define _without_hyperv --without-hyperv
|
||||
%define _without_hyperv --without-hyperv
|
||||
%endif
|
||||
|
||||
%if ! %{with_xenapi}
|
||||
%define _without_xenapi --without-xenapi
|
||||
%define _without_xenapi --without-xenapi
|
||||
%endif
|
||||
|
||||
%if ! %{with_parallels}
|
||||
%define _without_parallels --without-parallels
|
||||
%define _without_parallels --without-parallels
|
||||
%endif
|
||||
|
||||
%if 0%{?enable_autotools}
|
||||
|
Loading…
Reference in New Issue
Block a user