]> git.droids-corp.org - dpdk.git/commitdiff
build: increase readability via shortcut variables
authorBruce Richardson <bruce.richardson@intel.com>
Tue, 9 Apr 2019 10:55:36 +0000 (11:55 +0100)
committerThomas Monjalon <thomas@monjalon.net>
Wed, 17 Apr 2019 16:09:52 +0000 (18:09 +0200)
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>
44 files changed:
app/meson.build
buildtools/meson.build
config/meson.build
config/x86/meson.build
doc/guides/contributing/coding_style.rst
drivers/bus/dpaa/meson.build
drivers/bus/fslmc/meson.build
drivers/bus/pci/meson.build
drivers/bus/vmbus/meson.build
drivers/common/dpaax/meson.build
drivers/crypto/caam_jr/meson.build
drivers/crypto/ccp/meson.build
drivers/crypto/dpaa2_sec/meson.build
drivers/crypto/dpaa_sec/meson.build
drivers/crypto/octeontx/meson.build
drivers/event/dpaa/meson.build
drivers/event/dpaa2/meson.build
drivers/mempool/dpaa/meson.build
drivers/mempool/dpaa2/meson.build
drivers/meson.build
drivers/net/af_packet/meson.build
drivers/net/avp/meson.build
drivers/net/axgbe/meson.build
drivers/net/dpaa/meson.build
drivers/net/dpaa2/meson.build
drivers/net/enetc/meson.build
drivers/net/failsafe/meson.build
drivers/net/nfp/meson.build
drivers/net/softnic/meson.build
drivers/net/tap/meson.build
drivers/net/vdev_netvsc/meson.build
drivers/net/virtio/meson.build
examples/l3fwd-power/meson.build
examples/meson.build
examples/tep_termination/meson.build
examples/vdpa/meson.build
examples/vhost/meson.build
examples/vhost_scsi/meson.build
kernel/meson.build
lib/librte_eventdev/meson.build
lib/librte_kni/meson.build
lib/librte_power/meson.build
lib/librte_vhost/meson.build
lib/meson.build

index e949624b701d9b427e663f1b4cd129f17597ef84..2b9fdef74be064d7f9c2ebbb87bc9e1850b8a9a4 100644 (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
 
index 0209bec8fe832e2ba208a88edd639062befc2f8a..0d3a42c018421a3eaa40bd3663178f1cae1076ff 100644 (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
 
index ce6af2595a9806e83885a8388a0fd9562aaf5f57..f8aded6edb7bd5ec92ebc9085e1d0ef4177552a0 100644 (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)
index 558edfda99f4ea62a12fd13191b11250eed45d14..2b2d06281245f3484a74da478fd285fb05a75211 100644 (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')
index 656563dde93d75498469a346f97ef99d54448942..a5d5897f392cb9ca930ce1bf1e42328c21b45440 100644 (file)
@@ -856,7 +856,7 @@ build
 
 .. code-block:: python
 
-       if host_machine.system() != 'linux'
+       if not is_linux
                build = false
        endif
 
index 1fcb4e91378d66beff7663501cd9b93cc8faa1e2..1c8ca8c9a424e57daedac0dcb9ea8cadab1fbc96 100644 (file)
@@ -3,7 +3,7 @@
 
 version = 2
 
-if host_machine.system() != 'linux'
+if not is_linux
         build = false
 endif
 
index 4b0521577d60322e6ef3c84352a17415d28a8edc..04624c36346ed7dd9c470a1310239104b8160409 100644 (file)
@@ -3,7 +3,7 @@
 
 version = 2
 
-if host_machine.system() != 'linux'
+if not is_linux
         build = false
 endif
 
index a3140ff9773b14ed6032c432a7ff9238569bbe94..a312ecc034c43059bcd424f60370f7bae74ca43b 100644 (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')
index 0e4d058ee4859ba25493339c001620fa16247282..9fd430dae25b92b73a6128f60b193e5ee55f085e 100644 (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')
index 98a1bdd488bacd9ad4cd5dd295294228910dac6a..78378e2a691306d06881885284bc80b4a997b4f1 100644 (file)
@@ -3,7 +3,7 @@
 
 allow_experimental_apis = true
 
-if host_machine.system() != 'linux'
+if not is_linux
         build = false
 endif
 
index 99b71aef15e1d34039fb7d52c6419c2e516c2bf9..e61a13c25037a9ef384478aa7ae9e30123924ac4 100644 (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
 
index 915c4c854a6b30a13d873f9e8196894a51a9ac68..071ccc5e728a7b62eaf05a734b02807b43aead99 100644 (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)
index 8fa4827edb3379949c65c7f0005b26b3679376dc..d197cda1afda47a763a40b3a2eaa8b2a90818d59 100644 (file)
@@ -3,7 +3,7 @@
 
 version = 2
 
-if host_machine.system() != 'linux'
+if not is_linux
         build = false
 endif
 
index 8a5709846ef0d5839881721391d9e3768fe79780..134af88da7a0f9557b3330f8954711240b33fd5f 100644 (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
 
index 423737ee1b5ac9ed98f162fd77893c0461796c5e..a9f2d3157f00559a167cb551ab6a58c88eab0307 100644 (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
 
index 0914f858ef952e3d52a2464905235c0c184e00e5..11b1fe669dff8ca4d1a97327d9830f61f1c78d00 100644 (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']
index a0db6fc21e142072df78d6edc847dafc0fded4aa..a94bc5643bf5b85a9282e67cf69fc37b27953282 100644 (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']
index 9163b3db31d7880971d2cd8a1ca0ddc73342b287..c4c8ebc09e1490f0be38b7ddcb5d0d8744260e6c 100644 (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
 
index 6b6ead617ee7a8f42f1af4dc8ff12c2bfd2f4aa6..9a8b28d7c4e3956abf5aeb10d29c5257ee8b79a1 100644 (file)
@@ -3,7 +3,7 @@
 
 version = 2
 
-if host_machine.system() != 'linux'
+if not is_linux
         build = false
 endif
 
index 7520a16e326d07f929038b9069d27ef54078e54c..4c444f495bfc1b0874debc7c464ff2059701a73e 100644 (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
 
index 92f6a971503c6cdc23c2acf7cafacefae7f6d638..92c306c7317d5d1a6a6f94c207e481ddd0ba878c 100644 (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')
index b7ffdfc80bfaa6746ff03f8c026d35af72263112..8138cb22dcdaa00358d3dd646abae8a89de2a30d 100644 (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')
index 548ffff7a4ac86c0093763b80fd4dfe6f1b1b16e..6decb25d4fc27771fcd0b923869b7709235c4c95 100644 (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
 
index 62dec7b04d5514ddabd6d9d5105e556c3b028f1d..8e5418bd6482936bd20cec0c5473560f64aed26b 100644 (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']
index 53e1d81890d080cacfec1a72fd2c8fbc81ee7301..a0ea992386ce0e8029a09fb8b652dd02086fe33a 100644 (file)
@@ -3,7 +3,7 @@
 
 version = 2
 
-if host_machine.system() != 'linux'
+if not is_linux
         build = false
 endif
 
index 733156bbf57987c674e973c3745ca8fdbc9186c5..7d0c2ffe7fd23a5f0b7aa0b5f854ef987c9a034a 100644 (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
 
index a249ff4af37f76ae19ddae9b2ef2b543fd44a6b3..dfd4067cbd24cf199ec354d339aa7ef1d1afde9c 100644 (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'
index ba6a22e8b97cc0b799b4edda58017f0bbc150058..ea51ac3c36d7f1b42f4ec19019c05e1aa2166258 100644 (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',
index da249c068decf2118cda82c0aa15039533159a77..dd1d610ea54a3f7f71d160dc3c5db1a4ad31426a 100644 (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
index 9cb7142a0901f03af3adfcb0686e92520747438f..c407a1f354a09176421790e0e7dfe6d5d3edf714 100644 (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(
index d3ada878a762252282ab34a4d7d8f4eab7cf0b8b..6655859f8ec5e840d95fc0c10631cd5ccd633384 100644 (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')
index e43ce6bbc0a2c5b990aeafbc9ec24ff353e80a21..794905401db09af90b14003c8ab61622241468b9 100644 (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',
index a3c5c2f14fef1eab4f494079ee8a8ca5f300e6c1..2c84123b658adffc4f70a779b2227a37cafc1da0 100644 (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
index d72382fca7231fb98c7b21cf034b26af6d106ddb..e4babf6bf93ee75b8e6ede253b2bef2ea28f1d08 100644 (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)
index 6d3636243148c37448089824739834005ad573e0..a75cc7100f08130c7190089e3075754f7b38191f 100644 (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']
index 2e38a069fead8abf55a1556f4732fe8c28c01900..73f129cd913986dc73f295d200f2f23d6413283b 100644 (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'
-)
\ No newline at end of file
+)
index 7b498076cfb0a5736be7ed2b793d6ffcaa203f27..872d511539102eea3c0222f99b73683cd2e8192c 100644 (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'
index ca1248023167233214700988f4a8e84adaf8dd22..2e9339aa73c78f09c0dcb078b90cd0485cbb7f8a 100644 (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
 
index 2c8fa76d063fff0f6a9ffb398f04d68ea975eea9..b247e2df42f1396d195ea4f53ddc655624e320b9 100644 (file)
@@ -1,4 +1,4 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2017 Intel Corporation
 
-subdir(host_machine.system())
+subdir(exec_env)
index 6becfe86de9ab9e96fb7d3bffd400d8c3e8ca993..6cfe60e1f51f1471690a661ea2af45313265c980 100644 (file)
@@ -4,7 +4,7 @@
 version = 6
 allow_experimental_apis = true
 
-if host_machine.system() == 'linux'
+if is_linux
        cflags += '-DLINUX'
 else
        cflags += '-DBSD'
index 055ae12270fde9771c69cae05b31bc6ebca23dd8..400af9a4d3b2ec045d38bb99d41f5518444e1f00 100644 (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
index 02e0337ced566053c1e032a6c31c1f0f137138a2..cc6c30075deda1b5c920e6042770a89853c33782 100644 (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',
index e33e6fc162ddc43e5d421986940c51e56afc8d0e..3090bbe085cf737551a5ca9502f4f16c69110ed8 100644 (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
index 595314d7d13099a4d8a936c6b2c29f6a3e120bd1..a379dd682c13e4f9b76187643f93d23a2fca5001 100644 (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]