-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmeson.build
103 lines (80 loc) · 3.37 KB
/
meson.build
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
project('mCc', 'c',
default_options: [
'buildtype=debug',
'c_std=c11',
'cpp_std=c++14',
'warning_level=2'
],
meson_version: '>=0.44.0'
)
# ------------------------------------------------------------------ GENERATORS
flex = find_program('flex')
lgen = generator(flex,
output: ['@[email protected]', '@[email protected]'],
arguments: [ '--outfile=@OUTPUT0@',
'--header-file=@OUTPUT1@',
'@INPUT@' ])
bison = find_program('bison')
pgen = generator(bison,
output: ['@[email protected]', '@[email protected]'],
arguments: [ '-Wall',
'--report=all',
'--output=@OUTPUT0@',
'--defines=@OUTPUT1@',
'@INPUT@' ])
# --------------------------------------------------------------------- LIBRARY
mCc_inc = include_directories('include')
mCc_src = [ 'src/ast.c',
'src/ast_print.c',
'src/tac_print.c',
'src/ast_visit.c',
'src/tac.c',
'src/assembler.c',
'src/ast_symbol_table.c',
'src/ast_type_checking.c',
'src/error_manager.c',
'src/symbol_table.c',
'src/ast_function_return_check.c',
lgen.process('src/scanner.l'),
pgen.process('src/parser.y') ]
mCc_lib = library('mCc', mCc_src,
c_args: ['-D_POSIX_C_SOURCE=200809L ', '-Wno-unused'],
include_directories: mCc_inc)
mCc_lib_test = library('mCc_test', mCc_src,
c_args: ['-D_POSIX_C_SOURCE=200809L', '-D_UNIT_TESTS__', '-Wno-unused'],
include_directories: mCc_inc)
# ----------------------------------------------------------------- EXECUTABLES
mCc_exes = [ 'mCc', 'mC_to_dot', 'mC_to_cfg' ]
foreach exe : mCc_exes
executable(exe, 'src/bin/' + exe + '.c',
include_directories: mCc_inc,
link_with: mCc_lib)
endforeach
# ----------------------------------------------------------------- TEST EXEC
mCc_test_exes = [ ['mCc_test', 'mCc'], ['mC_to_dot_test', 'mC_to_dot'] ]
foreach exe : mCc_test_exes
executable(exe[0], 'src/bin/' + exe[1] + '.c',
include_directories: mCc_inc,
link_with: mCc_lib_test)
endforeach
# ------------------------------------------------------------------ UNIT TESTS
gtest = dependency('gtest', fallback: ['gtest', 'gtest_main_dep'])
mCc_uts = [ 'parser', 'symbol_table', 'return_check', 'type_checking', 'tac', 'assembler' ]
foreach ut : mCc_uts
t = executable('ut_' + ut.underscorify(), 'test/' + ut + '.cpp',
include_directories: mCc_inc,
link_with: mCc_lib_test,
dependencies: gtest)
test(ut, t)
endforeach
# --------------------------------------------------------------------- DOXYGEN
doxygen = find_program('doxygen', required: false)
if doxygen.found()
doxyconf = configuration_data()
doxyconf.set('ROOT', meson.source_root())
doxyconf.set('BUILDDIR', meson.build_root())
doxyfile = configure_file(input: '.doxyfile',
output: 'doxyfile',
configuration: doxyconf)
html_doc = run_target('doc', command: [doxygen, doxyfile])
endif