meson.build 2.76 KB
Newer Older
1 2 3 4 5 6 7 8
project('panloader', 'c',
        default_options: ['c_std=gnu11'])

if get_option('c_std') != 'gnu11'
    error('This project requires c_std be in gnu11 mode')
endif

cc = meson.get_compiler('c')
9
is_android = cc.get_define('__ANDROID__') == '1'
10 11

test_cc_flags = [
12
    '-O3',
13
    '-Wall',
14 15
    '-Wno-unused-parameter',
    '-Wno-sign-compare',
16
    '-Wextra',
17
    '-Werror-implicit-function-declaration',
18
    '-Werror-incompatible-pointer-types-discards-qualifiers',
19
    '-Werror-int-conversion',
Alyssa Rosenzweig's avatar
Alyssa Rosenzweig committed
20
    '-mfp16-format=ieee',
Alyssa Rosenzweig's avatar
Alyssa Rosenzweig committed
21
    '-U_FILE_OFFSET_BITS',
22 23 24 25 26 27 28
]
foreach flag: test_cc_flags
    if cc.has_argument(flag)
        add_global_arguments(flag, language: 'c')
    endif
endforeach

29 30 31 32 33
# Android only runs pie binaries
common_exec_largs = []
if is_android
    common_exec_largs += ['-pie']
endif
34
common_exec_largs += ['-pg']
35

36
m_dep = cc.find_library('m', required: true)
37
dl_dep = cc.find_library('dl', required: false)
Connor Abbott's avatar
Connor Abbott committed
38
pthread_dep = dependency('threads')
39

40 41 42
libpanfrost_decode_dep = cc.find_library('libpanfrost_decode', dirs : meson.current_source_dir() + '/../../../../build/src/panfrost/pandecode')
libpanfrost_midgard_dep = cc.find_library('libpanfrost_midgard', dirs : meson.current_source_dir() + '/../../../../build/src/panfrost/midgard')
libpanfrost_bifrost_dep = cc.find_library('libpanfrost_bifrost', dirs : meson.current_source_dir() + '/../../../../build/src/panfrost/bifrost')
43
libpanfrost_encoder_dep = cc.find_library('libpanfrost_encoder', dirs : meson.current_source_dir() + '/../../../../build/src/panfrost/encoder')
44 45
util_dep = cc.find_library('libmesa_util', dirs : meson.current_source_dir() + '/../../../../build/src/util')

46 47
common_dep = [
    m_dep,
48
    dl_dep,
Alyssa Rosenzweig's avatar
Alyssa Rosenzweig committed
49
    pthread_dep,
50 51 52
    libpanfrost_decode_dep,
    libpanfrost_midgard_dep,
    libpanfrost_bifrost_dep,
53
    libpanfrost_encoder_dep,
54
    util_dep
55 56
]

57 58 59 60
if not cc.has_argument('-Werror=attributes')
    error('Compiler does not support -Werror=attributes')
endif

61 62
test_c_srcs = [
    ['__attribute__((packed))',
63
     'struct s { int a; } __attribute__((packed));'],
64
    ['__attribute__((constructor))',
65
     'void __attribute__((constructor)) f(){}'],
66
    ['__attribute__((format))',
67
     'void __attribute__((format (printf, 1, 2))) f(const char *, ...);'],
68 69
    ['__attribute__((nonnull))',
     'void __attribute__((nonnull(1))) f(void *);'],
70 71
    ['__attribute__((noreturn))',
     'void __attribute__((noreturn)) f(void);'],
72 73
    ['__builtin_offsetof()',
     'struct s { int a; }; int o = __builtin_offsetof(struct s, a);'],
74
]
75 76
foreach t: test_c_srcs
    _feat = t[0]
77
    _src = t[1]
78
    if not cc.compiles(_src, name: _feat + ' test', args: '-Werror=attributes')
79
        error('Compiler does not support ' + _feat)
80 81 82
    endif
endforeach

83 84 85 86
inc = [
        include_directories('include'),
        include_directories('..'),
]
87

88
subdir('include')
89
subdir('panwrap')