build: increase readability via shortcut variables

Define variables for "is_linux", "is_freebsd" and "is_windows"
to make the code shorter for comparisons and more readable.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Reviewed-by: David Marchand <david.marchand@redhat.com>
Acked-by: Luca Boccassi <bluca@debian.org>
This commit is contained in:
Bruce Richardson 2019-04-09 11:55:36 +01:00 committed by Thomas Monjalon
parent b458c2927a
commit adf93ca564
44 changed files with 55 additions and 49 deletions

View File

@ -1,7 +1,7 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright(c) 2017-2019 Intel Corporation
if host_machine.system() == 'windows'
if is_windows
subdir_done()
endif

View File

@ -1,7 +1,7 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright(c) 2017-2019 Intel Corporation
if host_machine.system() == 'windows'
if is_windows
subdir_done()
endif

View File

@ -8,6 +8,12 @@ if not supported_exec_envs.contains(exec_env)
error('unsupported system type "@0@"'.format(exec_env))
endif
# define a handy variable for checking which OS we have.
# gives us "is_windows", "is_freebsd" and "is_linux"
foreach env:supported_exec_envs
set_variable('is_' + env, exec_env == env)
endforeach
# set the major version, which might be used by drivers and libraries
# depending on the configuration options
pver = meson.project_version().split('.')
@ -95,9 +101,9 @@ if cc.find_library('libm', required : false).found()
endif
# for linux link against dl, for bsd execinfo
if host_machine.system() == 'linux'
if is_linux
link_lib = 'dl'
elif host_machine.system() == 'freebsd'
elif is_freebsd
link_lib = 'execinfo'
else
link_lib = ''
@ -120,7 +126,7 @@ if numa_dep.found() and cc.has_header('numaif.h')
endif
# check for strlcpy
if host_machine.system() == 'linux'
if is_linux
libbsd = dependency('libbsd', required: false)
if libbsd.found()
dpdk_conf.set('RTE_USE_LIBBSD', 1)
@ -175,4 +181,4 @@ dpdk_conf.set_quoted('RTE_EAL_PMD_PATH', eal_pmd_path)
install_headers('rte_config.h', subdir: get_option('include_subdir_arch'))
# enable VFIO only if it is linux OS
dpdk_conf.set('RTE_EAL_VFIO', host_machine.system() == 'linux')
dpdk_conf.set('RTE_EAL_VFIO', is_linux)

View File

@ -5,7 +5,7 @@
march_opt = ['-march=@0@'.format(machine)]
# get binutils version for the workaround of Bug 97
if host_machine.system() != 'windows'
if not is_windows
ldver = run_command('ld', '-v').stdout().strip()
if ldver.contains('2.30')
if cc.has_argument('-mno-avx512f')

View File

@ -856,7 +856,7 @@ build
.. code-block:: python
if host_machine.system() != 'linux'
if not is_linux
build = false
endif

View File

@ -3,7 +3,7 @@
version = 2
if host_machine.system() != 'linux'
if not is_linux
build = false
endif

View File

@ -3,7 +3,7 @@
version = 2
if host_machine.system() != 'linux'
if not is_linux
build = false
endif

View File

@ -8,7 +8,7 @@ install_headers('rte_bus_pci.h')
sources = files('pci_common.c',
'pci_common_uio.c',
'pci_params.c')
if host_machine.system() == 'linux'
if is_linux
sources += files('linux/pci.c',
'linux/pci_uio.c',
'linux/pci_vfio.c')

View File

@ -11,7 +11,7 @@ sources = files('vmbus_common.c',
'vmbus_bufring.c',
'vmbus_common_uio.c')
if host_machine.system() == 'linux'
if is_linux
sources += files('linux/vmbus_bus.c',
'linux/vmbus_uio.c')
includes += include_directories('linux')

View File

@ -3,7 +3,7 @@
allow_experimental_apis = true
if host_machine.system() != 'linux'
if not is_linux
build = false
endif

View File

@ -1,7 +1,7 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2018 NXP
if host_machine.system() != 'linux'
if not is_linux
build = false
endif

View File

@ -1,7 +1,7 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright(c) 2018 Advanced Micro Devices, Inc. All rights reserved.
if host_machine.system() != 'linux'
if not is_linux
build = false
endif
dep = dependency('libcrypto', required: false)

View File

@ -3,7 +3,7 @@
version = 2
if host_machine.system() != 'linux'
if not is_linux
build = false
endif

View File

@ -1,7 +1,7 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2018 NXP
if host_machine.system() != 'linux'
if not is_linux
build = false
endif

View File

@ -1,6 +1,6 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright(c) 2018 Cavium, Inc
if host_machine.system() != 'linux'
if not is_linux
build = false
endif

View File

@ -1,7 +1,7 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2018 NXP
if host_machine.system() != 'linux'
if not is_linux
build = false
endif
deps += ['pmd_dpaa']

View File

@ -3,7 +3,7 @@
version = 2
if host_machine.system() != 'linux'
if not is_linux
build = false
endif
deps += ['bus_vdev', 'pmd_dpaa2', 'pmd_dpaa2_sec']

View File

@ -1,7 +1,7 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2018 NXP
if host_machine.system() != 'linux'
if not is_linux
build = false
endif

View File

@ -3,7 +3,7 @@
version = 2
if host_machine.system() != 'linux'
if not is_linux
build = false
endif

View File

@ -1,7 +1,7 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright(c) 2017-2019 Intel Corporation
if host_machine.system() == 'windows'
if is_windows
subdir_done()
endif

View File

@ -1,7 +1,7 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright(c) 2017 Intel Corporation
if host_machine.system() != 'linux'
if not is_linux
build = false
endif
sources = files('rte_eth_af_packet.c')

View File

@ -1,7 +1,7 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright(c) 2018 Intel Corporation
if host_machine.system() != 'linux'
if not is_linux
build = false
endif
sources = files('avp_ethdev.c')

View File

@ -1,7 +1,7 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright (c) 2018 Advanced Micro Devices, Inc. All rights reserved.
if host_machine.system() != 'linux'
if not is_linux
build = false
endif

View File

@ -1,7 +1,7 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2018 NXP
if host_machine.system() != 'linux'
if not is_linux
build = false
endif
deps += ['mempool_dpaa']

View File

@ -3,7 +3,7 @@
version = 2
if host_machine.system() != 'linux'
if not is_linux
build = false
endif

View File

@ -1,7 +1,7 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2018 NXP
if host_machine.system() != 'linux'
if not is_linux
build = false
endif

View File

@ -5,7 +5,7 @@ cflags += '-std=gnu99'
cflags += '-D_DEFAULT_SOURCE'
cflags += '-D_XOPEN_SOURCE=700'
cflags += '-pedantic'
if host_machine.system() == 'linux'
if is_linux
cflags += '-DLINUX'
else
cflags += '-DBSD'

View File

@ -1,7 +1,7 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright(c) 2018 Intel Corporation
if host_machine.system() != 'linux'
if not is_linux
build = false
endif
sources = files('nfpcore/nfp_cpp_pcie_ops.c',

View File

@ -1,7 +1,7 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright(c) 2018 Intel Corporation
if host_machine.system() != 'linux'
if not is_linux
build = false
endif
allow_experimental_apis = true

View File

@ -1,7 +1,7 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2018 Luca Boccassi <bluca@debian.org>
if host_machine.system() != 'linux'
if not is_linux
build = false
endif
sources = files(

View File

@ -1,7 +1,7 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright(c) 2018 Luca Boccassi <bluca@debian.org>
if host_machine.system() != 'linux'
if not is_linux
build = false
endif
sources = files('vdev_netvsc.c')

View File

@ -15,7 +15,7 @@ elif arch_subdir == 'arm' and host_machine.cpu_family().startswith('aarch64')
sources += files('virtio_rxtx_simple_neon.c')
endif
if host_machine.system() == 'linux'
if is_linux
dpdk_conf.set('RTE_VIRTIO_USER', 1)
sources += files('virtio_user_ethdev.c',

View File

@ -6,7 +6,7 @@
# To build this example as a standalone application with an already-installed
# DPDK instance, use 'make'
if host_machine.system() != 'linux'
if not is_linux
build = false
endif
allow_experimental_apis = true

View File

@ -36,7 +36,7 @@ foreach example: examples
ext_deps = [execinfo]
includes = [include_directories(example)]
deps = ['eal', 'mempool', 'net', 'mbuf', 'ethdev', 'cmdline']
if host_machine.system() == 'windows'
if is_windows
deps = ['eal'] # only supported lib on Windows currently
endif
subdir(example)

View File

@ -6,7 +6,7 @@
# To build this example as a standalone application with an already-installed
# DPDK instance, use 'make'
if host_machine.system() != 'linux'
if not is_linux
build = false
endif
deps += ['hash', 'vhost']

View File

@ -6,11 +6,11 @@
# To build this example as a standalone application with an already-installed
# DPDK instance, use 'make'
if host_machine.system() != 'linux'
if not is_linux
build = false
endif
deps += 'vhost'
allow_experimental_apis = true
sources = files(
'main.c'
)
)

View File

@ -6,7 +6,7 @@
# To build this example as a standalone application with an already-installed
# DPDK instance, use 'make'
if host_machine.system() != 'linux'
if not is_linux
build = false
endif
deps += 'vhost'

View File

@ -6,7 +6,7 @@
# To build this example as a standalone application with an already-installed
# DPDK instance, use 'make'
if host_machine.system() != 'linux'
if not is_linux
build = false
endif

View File

@ -1,4 +1,4 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright(c) 2017 Intel Corporation
subdir(host_machine.system())
subdir(exec_env)

View File

@ -4,7 +4,7 @@
version = 6
allow_experimental_apis = true
if host_machine.system() == 'linux'
if is_linux
cflags += '-DLINUX'
else
cflags += '-DBSD'

View File

@ -1,7 +1,7 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright(c) 2017 Intel Corporation
if host_machine.system() != 'linux' or not dpdk_conf.get('RTE_ARCH_64')
if not is_linux or not dpdk_conf.get('RTE_ARCH_64')
build = false
endif
version = 2

View File

@ -1,7 +1,7 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright(c) 2017 Intel Corporation
if host_machine.system() != 'linux'
if not is_linux
build = false
endif
sources = files('rte_power.c', 'power_acpi_cpufreq.c',

View File

@ -1,7 +1,7 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright(c) 2017-2018 Intel Corporation
if host_machine.system() != 'linux'
if not is_linux
build = false
endif
if has_libnuma == 1

View File

@ -30,7 +30,7 @@ libraries = [
# flow_classify lib depends on pkt framework table lib
'flow_classify', 'bpf', 'telemetry']
if host_machine.system() == 'windows'
if is_windows
libraries = ['kvargs','eal'] # only supported libraries for windows
endif
@ -123,7 +123,7 @@ foreach l:libraries
meson.current_source_dir(), dir_name, name)
exports = []
implib = dir_name + '.dll.a'
if host_machine.system() == 'windows'
if is_windows
exports = '@0@/@1@/rte_@2@_exports.def'.format(
meson.current_source_dir(), dir_name, name)
lk_args = ['-Wl,/def:' + exports, '-Wl,/implib:lib\\' + implib]