Skip to content

Commit

Permalink
configure: move environment-specific defaults to config-meson.cross
Browse files Browse the repository at this point in the history
Store the -Werror and SMBD defaults in the machine file, which still allows
them to be overridden on the command line and enables automatic parsing
of the related options.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
  • Loading branch information
bonzini committed Oct 18, 2023
1 parent c36dd41 commit 090a188
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 24 deletions.
37 changes: 14 additions & 23 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,6 @@ skip_meson=no
use_containers="yes"
gdb_bin=$(command -v "gdb-multiarch" || command -v "gdb")
gdb_arches=""
werror=""

# Don't accept a target_list environment variable.
unset target_list
Expand Down Expand Up @@ -314,7 +313,6 @@ objcopy="${OBJCOPY-${cross_prefix}objcopy}"
ld="${LD-${cross_prefix}ld}"
ranlib="${RANLIB-${cross_prefix}ranlib}"
nm="${NM-${cross_prefix}nm}"
smbd="$SMBD"
strip="${STRIP-${cross_prefix}strip}"
widl="${WIDL-${cross_prefix}widl}"
windres="${WINDRES-${cross_prefix}windres}"
Expand Down Expand Up @@ -651,8 +649,6 @@ for opt do
;;
--ninja=*) ninja="$optarg"
;;
--smbd=*) smbd="$optarg"
;;
--extra-cflags=*)
;;
--extra-cxxflags=*)
Expand Down Expand Up @@ -744,10 +740,6 @@ for opt do
;;
--disable-pie) pie="no"
;;
--enable-werror) werror="yes"
;;
--disable-werror) werror="no"
;;
--enable-cfi) cfi=true
;;
--disable-cfi) cfi=false
Expand Down Expand Up @@ -879,15 +871,13 @@ Advanced options (experts only):
--cross-prefix-ARCH=PREFIX cross compiler prefix when building ARCH guest test cases
--python=PYTHON use specified python [$python]
--ninja=NINJA use specified ninja [$ninja]
--smbd=SMBD use specified smbd [$smbd]
--static enable static build [$static]
--without-default-features default all --enable-* options to "disabled"
--without-default-devices do not include any device that is not needed to
start the emulator (only use if you are including
desired devices in configs/devices/)
--with-devices-ARCH=NAME override default configs/devices
--enable-debug enable common debug build options
--disable-werror disable compilation abort on warning
--cpu=CPU Build for host CPU [$cpu]
--disable-containers don't use containers for cross-building
--container-engine=TYPE which container engine to use [$container_engine]
Expand Down Expand Up @@ -1011,17 +1001,6 @@ if test -z "$ninja"; then
fi
fi

# Consult white-list to determine whether to enable werror
# by default. Only enable by default for git builds
if test -z "$werror" ; then
if test -e "$source_path/.git" && \
{ test "$targetos" = linux || test "$targetos" = "windows"; }; then
werror="yes"
else
werror="no"
fi
fi

if test "$targetos" = "bogus"; then
# Now that we know that we're not printing the help and that
# the compiler works (so the results of the check_defines we used
Expand Down Expand Up @@ -1764,6 +1743,20 @@ if test "$skip_meson" = no; then
test -n "$objcc" && echo "objc_args = [$(meson_quote $OBJCFLAGS $EXTRA_OBJCFLAGS)]" >> $cross
echo "c_link_args = [$(meson_quote $CFLAGS $LDFLAGS $EXTRA_CFLAGS $EXTRA_LDFLAGS)]" >> $cross
echo "cpp_link_args = [$(meson_quote $CXXFLAGS $LDFLAGS $EXTRA_CXXFLAGS $EXTRA_LDFLAGS)]" >> $cross

# Only enable by default for git builds and on select OSes
echo "# environment defaults, can still be overridden on " >> $cross
echo "# the command line" >> $cross
if test -e "$source_path/.git" && \
{ test "$targetos" = linux || test "$targetos" = "windows"; }; then
echo 'werror = true' >> $cross
fi
echo "[project options]" >> $cross
if test "$SMBD" != ''; then
echo "smbd = $(meson_quote "$SMBD")" >> $cross
fi

echo >> $cross
echo "[binaries]" >> $cross
echo "c = [$(meson_quote $cc $CPU_CFLAGS)]" >> $cross
test -n "$cxx" && echo "cpp = [$(meson_quote $cxx $CPU_CFLAGS)]" >> $cross
Expand Down Expand Up @@ -1818,14 +1811,12 @@ if test "$skip_meson" = no; then
test "$default_feature" = no && meson_option_add -Dauto_features=disabled
test "$static" = yes && meson_option_add -Dprefer_static=true
test "$pie" = no && meson_option_add -Db_pie=false
test "$werror" = yes && meson_option_add -Dwerror=true

# QEMU options
test "$cfi" != false && meson_option_add "-Dcfi=$cfi" "-Db_lto=$cfi"
test "$docs" != auto && meson_option_add "-Ddocs=$docs"
test -n "${LIB_FUZZING_ENGINE+xxx}" && meson_option_add "-Dfuzzing_engine=$LIB_FUZZING_ENGINE"
test "$plugins" = yes && meson_option_add "-Dplugins=true"
test "$smbd" != '' && meson_option_add "-Dsmbd=$smbd"
test "$tcg" != enabled && meson_option_add "-Dtcg=$tcg"
run_meson() {
NINJA=$ninja $meson setup "$@" "$PWD" "$source_path"
Expand Down
3 changes: 2 additions & 1 deletion scripts/meson-buildoptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
SKIP_OPTIONS = {
"default_devices",
"fuzzing_engine",
"smbd",
}

OPTION_NAMES = {
Expand All @@ -47,6 +46,7 @@
# Options that configure autodetects, even though meson defines them as boolean
AUTO_OPTIONS = {
"plugins",
"werror",
}

BUILTIN_OPTIONS = {
Expand All @@ -64,6 +64,7 @@
"prefix",
"strip",
"sysconfdir",
"werror",
}

LINE_WIDTH = 76
Expand Down
5 changes: 5 additions & 0 deletions scripts/meson-buildoptions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ meson_options_help() {
printf "%s\n" ' --localstatedir=VALUE Localstate data directory [/var/local]'
printf "%s\n" ' --mandir=VALUE Manual page directory [share/man]'
printf "%s\n" ' --prefix=VALUE Installation prefix [/usr/local]'
printf "%s\n" ' --smbd=VALUE Path to smbd for slirp networking'
printf "%s\n" ' --sysconfdir=VALUE Sysconf data directory [etc]'
printf "%s\n" ' --tls-priority=VALUE Default TLS protocol/cipher priority string'
printf "%s\n" ' [NORMAL]'
Expand Down Expand Up @@ -205,6 +206,7 @@ meson_options_help() {
printf "%s\n" ' vpc vpc image format support'
printf "%s\n" ' vte vte support for the gtk UI'
printf "%s\n" ' vvfat vvfat image format support'
printf "%s\n" ' werror Treat warnings as errors'
printf "%s\n" ' whpx WHPX acceleration support'
printf "%s\n" ' xen Xen backend support'
printf "%s\n" ' xen-pci-passthrough'
Expand Down Expand Up @@ -453,6 +455,7 @@ _meson_option_parse() {
--disable-slirp-smbd) printf "%s" -Dslirp_smbd=disabled ;;
--enable-smartcard) printf "%s" -Dsmartcard=enabled ;;
--disable-smartcard) printf "%s" -Dsmartcard=disabled ;;
--smbd=*) quote_sh "-Dsmbd=$2" ;;
--enable-snappy) printf "%s" -Dsnappy=enabled ;;
--disable-snappy) printf "%s" -Dsnappy=disabled ;;
--enable-sndio) printf "%s" -Dsndio=enabled ;;
Expand Down Expand Up @@ -529,6 +532,8 @@ _meson_option_parse() {
--disable-vte) printf "%s" -Dvte=disabled ;;
--enable-vvfat) printf "%s" -Dvvfat=enabled ;;
--disable-vvfat) printf "%s" -Dvvfat=disabled ;;
--enable-werror) printf "%s" -Dwerror=true ;;
--disable-werror) printf "%s" -Dwerror=false ;;
--enable-whpx) printf "%s" -Dwhpx=enabled ;;
--disable-whpx) printf "%s" -Dwhpx=disabled ;;
--enable-xen) printf "%s" -Dxen=enabled ;;
Expand Down

0 comments on commit 090a188

Please sign in to comment.