aboutsummaryrefslogtreecommitdiff
path: root/meson.build
blob: b445e94be75cde7596d4fb9c35ee621da938ccb7 (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
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
project(
	'hdass',
	'c',
	version: '0.1.0',
	license: 'MIT',
	meson_version: '>=1.0.0',
	default_options: [
		'c_std=c17',
		'warning_level=3',
		'b_sanitize=address,undefined',
		'b_lundef=false',
	],
)

cc = meson.get_compiler('c')

add_project_arguments(
	cc.get_supported_arguments(
		'-Wconversion',
		'-Wsign-conversion',
		'-Wshadow',
		'-Wstrict-prototypes',
		'-Wmissing-prototypes',
		'-fno-omit-frame-pointer',
	),
	language: 'c',
)

src_inc = include_directories('src')

core = static_library(
	'hdass_core',
	files(
		'src/args.c',
		'src/ast.c',
		'src/diag.c',
		'src/file.c',
		'src/lexer.c',
		'src/nasm.c',
		'src/parser.c',
		'src/sema.c',
	),
	include_directories: src_inc,
)

executable(
	'hdass',
	'src/main.c',
	include_directories: src_inc,
	link_with: core,
)

tests = executable(
	'tests',
	files(
		'tests/main.c',
		'tests/codegen_test.c',
		'tests/lexer_test.c',
		'tests/parser_test.c',
		'tests/sema_test.c',
	),
	include_directories: [src_inc, include_directories('tests')],
	link_with: core,
)

test('unit', tests)

cppcheck = find_program('cppcheck', required: false)
if cppcheck.found()
	run_target(
		'cppcheck',
		command: [
			cppcheck,
			'--project=@0@'.format(meson.project_build_root() / 'compile_commands.json'),
			'--enable=warning,style,performance,portability',
			'--error-exitcode=1',
		],
	)
endif