fw_image = 'fw.bin' decl = 'const char * const %s = "%s";\n' if get_option('fwbuild') espmake = find_program('espmake') printf = find_program('printf') cat = find_program('cat') cp = find_program('cp') fw_filenames = ['main.ino'] fw_true_sources = files(fw_filenames) 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 : [espmake, '-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