summaryrefslogtreecommitdiff
path: root/tests/test_util.py
blob: 3ac3886befa405d8b7476a85c93fb33c803c261a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#------------------------------------------------------------------------------
# pycparser: test_util.py
#
# Utility code for tests.
#
# Eli Bendersky [https://eli.thegreenplace.net/]
# This file contributed by vit9696@users.noreply.github.com
# License: BSD
#------------------------------------------------------------------------------
import platform


def cpp_supported():
    """Is cpp (the C preprocessor) supported as a native command?"""
    return platform.system() == 'Linux' or platform.system() == 'Darwin'


def cpp_path():
    """Path to cpp command."""
    if platform.system() == 'Darwin':
        return 'gcc'
    return 'cpp'


def cpp_args(args=[]):
    """Turn args into a suitable format for passing to cpp."""
    if isinstance(args, str):
        args = [args]
    if platform.system() == 'Darwin':
        return ['-E'] + args
    return args