File: meson.build

package info (click to toggle)
numpy 1%3A2.2.4%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 83,420 kB
  • sloc: python: 248,499; asm: 232,365; ansic: 216,874; cpp: 135,657; f90: 1,540; sh: 938; fortran: 558; makefile: 409; sed: 139; xml: 109; java: 92; perl: 79; cs: 54; javascript: 53; objc: 29; lex: 13; yacc: 9
file content (70 lines) | stat: -rw-r--r-- 2,313 bytes parent folder | download | duplicates (5)
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
project('try compile', 'c', 'cpp')

code = '''#include<stdio.h>
void func(void) { printf("Something.\n"); }
'''

breakcode = '''#include<nonexisting.h>
void func(void) { printf("This won't work.\n"); }
'''

warncode = '''#warning This is a warning
int main(void) { return 0; }
'''

configure_file(
  input: 'foo.h.in',
  output: 'foo.h',
  configuration: {},
)

header_code = '#include "foo.h"'

foreach lang : ['c', 'cpp']
  compiler = meson.get_compiler(lang)

  assert(not compiler.compiles(header_code, name: 'Should not include . by default'))
  assert(compiler.compiles(header_code, name: 'Should include builddir',
    include_directories: include_directories('.'),
  ))

  if compiler.compiles(code, name : 'code should succeed') == false
    error('Compiler ' + compiler.get_id() + ' is fail.')
  endif

  if compiler.compiles(files('valid.c'), name : 'file should succeed') == false
    error('Compiler ' + compiler.get_id() + ' is fail.')
  endif

  copied = configure_file(input: 'valid.c', output: lang + '-valid-copy.c', copy: true)
  if compiler.compiles(copied, name : 'built file should succeed') == false
    error('Compiler ' + compiler.get_id() + ' is fail.')
  endif

  if compiler.compiles(breakcode, name : 'code should fail')
    error('Compiler ' + compiler.get_id() + ' returned true on broken code.')
  endif

  if compiler.compiles(files('invalid.c'), name : 'file should fail')
    error('Compiler ' + compiler.get_id() + ' returned true on broken code.')
  endif

  # MSVC does not support #warning instruction
  if compiler.get_id() != 'msvc'
    # First check that all tests pass without werror, then check they fail with it.
    foreach with_werror : [false, true]
      expect_success = not with_werror
      assert(compiler.compiles(warncode,
        name: f'code with warning compiles with werror=@with_werror@',
        werror: with_werror) == expect_success)
      assert(compiler.links(warncode,
        name: f'code with warning links with werror=@with_werror@',
        werror: with_werror) == expect_success)
      if meson.can_run_host_binaries()
        assert((compiler.run(warncode,
          name: f'code with warning runs with werror=@with_werror@',
          werror: with_werror).returncode() == 0) == expect_success)
      endif
    endforeach
  endif
endforeach