-
-
Notifications
You must be signed in to change notification settings - Fork 37
/
meson.build
101 lines (81 loc) · 2.41 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
project('fak', 'c')
cc_args = ['--opt-code-size']
inc_dirs = ['src', 'src/inc']
sources_common = [
'src/main.c',
'src/time.c',
'src/bootloader.c',
]
sources_central = [
'src/usb.c',
'src/split_central.c',
'src/keymap.c',
'src/key_event_queue.c',
]
sources_peripheral = [
'src/split_peripheral.c',
]
###
cc = find_program('sdcc', required : true)
nickel = find_program('nickel', required : true)
python = find_program('python', required : true)
wchisp = find_program('wchisp', required : false, disabler : true)
sides = ['central']
if get_option('split')
sides += ['peripheral']
endif
foreach side : sides
side_h = custom_target(side + '.h',
input : 'fak.py',
output : side + '.h',
capture : true,
command : [python, '@INPUT@', 'query_ncl', side + '.h'],
depend_files : ['.eval.json'],
)
side_c = custom_target(side + '.c',
input : 'fak.py',
output : side + '.c',
capture : true,
command : [python, '@INPUT@', 'query_ncl', side + '.c'],
depend_files : ['.eval.json'],
)
dir_base = meson.current_source_dir()
cc_incs = ['--include', side_h.full_path()]
foreach dir : inc_dirs
cc_incs += '-I' + join_paths(dir_base, dir)
endforeach
compiler = generator(cc,
output : '@[email protected]',
arguments : cc_args + cc_incs + ['-c', '@INPUT@', '-o', '@OUTPUT@'],
depends : [side_c, side_h],
)
sources = sources_common + [side_c]
if side == 'central'
sources += sources_central
extra_sources = get_option('extra_sources').strip()
if extra_sources != ''
sources += extra_sources.split(',')
endif
elif side == 'peripheral'
sources += sources_peripheral
extra_periph_sources = get_option('extra_periph_sources').strip()
if extra_periph_sources != ''
sources += extra_periph_sources.split(',')
endif
endif
rel = compiler.process(sources)
ihx = custom_target(side + '.ihx',
input : rel,
output : side + '.ihx',
install : true,
install_dir : 'firmware',
command : [cc, cc_args, '-o', '@OUTPUT@', '@INPUT@'],
)
flash = run_target('flash_' + side,
command : [wchisp, 'flash', ihx.full_path()],
depends : ihx,
)
endforeach
wchisp_info = run_target('wchisp_info',
command : [wchisp, 'info'],
)