HAL_ChibiOS: embed ROMFS files from hwdef directory

this allows for a scripts/ directory under hwdef board directory to
embed lua scripts
This commit is contained in:
Andrew Tridgell 2020-03-07 12:14:55 +11:00
parent 28082774b6
commit ea57b7b3cd
1 changed files with 15 additions and 0 deletions

View File

@ -1815,6 +1815,19 @@ def romfs_wildcard(pattern):
if fnmatch.fnmatch(f, pattern):
romfs[f] = os.path.join(pattern_dir, f)
def romfs_add_dir(subdirs):
'''add a filesystem directory to ROMFS'''
for dirname in subdirs:
romfs_dir = os.path.join(os.path.dirname(args.hwdef), dirname)
if not args.bootloader and os.path.exists(romfs_dir):
for root, d, files in os.walk(romfs_dir):
for f in files:
if fnmatch.fnmatch(f, '*~'):
# skip editor backup files
continue
fullpath = os.path.join(root, f)
relpath = os.path.normpath(os.path.join(dirname, os.path.relpath(root, romfs_dir), f))
romfs[relpath] = fullpath
def process_line(line):
'''process one line of pin definition file'''
@ -1966,6 +1979,8 @@ write_hwdef_header(os.path.join(outdir, "hwdef.h"))
# write out ldscript.ld
write_ldscript(os.path.join(outdir, "ldscript.ld"))
romfs_add_dir(['scripts'])
write_ROMFS(outdir)
# copy the shared linker script into the build directory; it must