Skip to content

Commit

Permalink
build: increase readability via shortcut variables
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: David Marchand <[email protected]>
Acked-by: Luca Boccassi <[email protected]>
  • Loading branch information
bruce-richardson authored and tmonjalo committed Apr 17, 2019
1 parent b458c29 commit adf93ca
Show file tree
Hide file tree
Showing 44 changed files with 55 additions and 49 deletions.
2 changes: 1 addition & 1 deletion app/meson.build
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion buildtools/meson.build
Original file line number Diff line number Diff line change
@@ -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

Expand Down
14 changes: 10 additions & 4 deletions config/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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('.')
Expand Down Expand Up @@ -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 = ''
Expand All @@ -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)
Expand Down Expand Up @@ -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)
2 changes: 1 addition & 1 deletion config/x86/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion doc/guides/contributing/coding_style.rst
Original file line number Diff line number Diff line change
Expand Up @@ -856,7 +856,7 @@ build

.. code-block:: python
if host_machine.system() != 'linux'
if not is_linux
build = false
endif
Expand Down
2 changes: 1 addition & 1 deletion drivers/bus/dpaa/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

version = 2

if host_machine.system() != 'linux'
if not is_linux
build = false
endif

Expand Down
2 changes: 1 addition & 1 deletion drivers/bus/fslmc/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

version = 2

if host_machine.system() != 'linux'
if not is_linux
build = false
endif

Expand Down
2 changes: 1 addition & 1 deletion drivers/bus/pci/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion drivers/bus/vmbus/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion drivers/common/dpaax/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

allow_experimental_apis = true

if host_machine.system() != 'linux'
if not is_linux
build = false
endif

Expand Down
2 changes: 1 addition & 1 deletion drivers/crypto/caam_jr/meson.build
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion drivers/crypto/ccp/meson.build
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion drivers/crypto/dpaa2_sec/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

version = 2

if host_machine.system() != 'linux'
if not is_linux
build = false
endif

Expand Down
2 changes: 1 addition & 1 deletion drivers/crypto/dpaa_sec/meson.build
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion drivers/crypto/octeontx/meson.build
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion drivers/event/dpaa/meson.build
Original file line number Diff line number Diff line change
@@ -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']
Expand Down
2 changes: 1 addition & 1 deletion drivers/event/dpaa2/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down
2 changes: 1 addition & 1 deletion drivers/mempool/dpaa/meson.build
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion drivers/mempool/dpaa2/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

version = 2

if host_machine.system() != 'linux'
if not is_linux
build = false
endif

Expand Down
2 changes: 1 addition & 1 deletion drivers/meson.build
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion drivers/net/af_packet/meson.build
Original file line number Diff line number Diff line change
@@ -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')
2 changes: 1 addition & 1 deletion drivers/net/avp/meson.build
Original file line number Diff line number Diff line change
@@ -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')
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/axgbe/meson.build
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion drivers/net/dpaa/meson.build
Original file line number Diff line number Diff line change
@@ -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']
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/dpaa2/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

version = 2

if host_machine.system() != 'linux'
if not is_linux
build = false
endif

Expand Down
2 changes: 1 addition & 1 deletion drivers/net/enetc/meson.build
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion drivers/net/failsafe/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/nfp/meson.build
Original file line number Diff line number Diff line change
@@ -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',
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/softnic/meson.build
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/tap/meson.build
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2018 Luca Boccassi <[email protected]>

if host_machine.system() != 'linux'
if not is_linux
build = false
endif
sources = files(
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/vdev_netvsc/meson.build
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright(c) 2018 Luca Boccassi <[email protected]>

if host_machine.system() != 'linux'
if not is_linux
build = false
endif
sources = files('vdev_netvsc.c')
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/virtio/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion examples/l3fwd-power/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion examples/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion examples/tep_termination/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down
4 changes: 2 additions & 2 deletions examples/vdpa/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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'
)
)
2 changes: 1 addition & 1 deletion examples/vhost/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion examples/vhost_scsi/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion kernel/meson.build
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright(c) 2017 Intel Corporation

subdir(host_machine.system())
subdir(exec_env)
2 changes: 1 addition & 1 deletion lib/librte_eventdev/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
version = 6
allow_experimental_apis = true

if host_machine.system() == 'linux'
if is_linux
cflags += '-DLINUX'
else
cflags += '-DBSD'
Expand Down
Loading

0 comments on commit adf93ca

Please sign in to comment.