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
|
fw_image = 'fw.bin'
decl = 'const char * const %s = "%s";\n'
oledlibnames = ['SSD1306Wire.h', 'OLEDDisplay.h', 'OLEDDisplay.cpp', 'OLEDDisplayFonts.h']
if get_option('fwbuild')
libpath = get_option('oledlib')
assert((libpath != ''), 'path to oled lib is empty')
mkesppath = get_option('makeesparduino')
assert((mkesppath != ''), 'path to directory with makeEspArduino.mk is empty')
esplib = get_option('esplib')
assert((esplib != ''), 'path esplib is empty')
board = get_option('board')
oledlib = []
foreach i : oledlibnames
oledlib += files(libpath + '/' + i)
endforeach
mkespard = files(mkesppath + '/makeEspArduino.mk')
assert((oledlib != []), 'oled lib not found in the supplied lib directory')
espmake = find_program('espmake')
printf = find_program('printf')
cat = find_program('cat')
cp = find_program('cp')
make = find_program('make')
nproc = find_program('nproc')
nproc_out = run_command(nproc)
cpus = nproc_out.stdout().strip()
fw_filenames = ['main.ino',
'DejaVu_Sans_Mono_13.h',
'device_network.cpp',
'device_network.h']
fw_true_sources += files(fw_filenames)
fw_filenames += oledlibnames
fw_true_sources += oledlib
sourcedir = meson.current_source_dir()
builddir = meson.current_build_dir()
fw_conf_ssid = custom_target('fw_conf_ssid',
output : ['conf_ssid'],
capture : true,
command : [printf, decl, 'ssid', get_option('ssid')])
fw_conf_pass = custom_target('fw_conf_pass',
output : ['conf_pass'],
capture : true,
command : [printf, decl, 'password', get_option('password')])
fw_conf = custom_target('fw_conf',
output : ['conf.c'],
capture : true,
command : [cat, fw_conf_ssid, fw_conf_pass])
fw_sources = custom_target('fw_sources',
output : fw_filenames,
input : fw_true_sources,
command : [cp, '@INPUT@', '@OUTDIR@/'])
fw = custom_target('fw',
output : fw_image,
input : [fw_sources, fw_conf],
command : [make,
'-f',
mkespard,
'ESP_ROOT=' + esplib,
'BOARD=' + board, '-j' + cpus,
'-C',
builddir,
'&&',
cp,
'/tmp/mkESP/main_d1_mini/main.bin',
'@OUTDIR@/' + fw_image],
install : true,
install_dir : resource_dir)
if get_option('fwflash')
esptool = find_program('esptool.py')
run_target('flash_fw',
depends : fw,
command : [esptool, 'write_flash', '0x0', fw])
endif
endif
|