Add support from cromfs generation

This commit is contained in:
David Sidrane 2018-11-29 15:05:51 -08:00
parent f2208171d5
commit 5036a09e22
1 changed files with 46 additions and 10 deletions

View File

@ -189,17 +189,53 @@ add_custom_command(OUTPUT romfs.img romfs.txt
COMMENT "ROMFS: generating image"
)
# create nsh_romfsimg.c
find_program(XXD xxd)
if(NOT XXD)
message(FATAL_ERROR "xxd not found")
if(CONFIG_FS_CROMFS)
#TODO:build gencromfs tool from nuttx and path to it.
find_program(GENCROMFS gencromfs)
if(NOT GENCROMFS)
message(FATAL_ERROR "gencromfs not found")
endif()
# create nsh_romfsimg.c
add_custom_command(OUTPUT nsh_romfsimg.c
COMMAND ${CMAKE_COMMAND} -E remove -f nsh_romfsimg.c
COMMAND ${GENCROMFS} ${romfs_gen_root_dir} nsh_romfsimg.c
DEPENDS
${romfs_gen_root_dir}/init.d/rcS
${romfs_gen_root_dir}/init.d/rc.autostart
romfs_extras.stamp
romfs_pruned.stamp
COMMENT "ROMFS: generating image"
)
else()
find_program(GENROMFS genromfs)
if(NOT GENROMFS)
message(FATAL_ERROR "genromfs not found")
endif()
# create romfs.img
add_custom_command(OUTPUT romfs.img romfs.txt
COMMAND ${CMAKE_COMMAND} -E remove -f romfs.img romfs.txt
COMMAND ${GENROMFS} -f romfs.img -d ${romfs_gen_root_dir} -V "NSHInitVol" -v > romfs.txt 2>&1
DEPENDS
${romfs_gen_root_dir}/init.d/rcS
${romfs_gen_root_dir}/init.d/rc.autostart
romfs_extras.stamp
COMMENT "ROMFS: generating image"
)
# create nsh_romfsimg.c
find_program(XXD xxd)
if(NOT XXD)
message(FATAL_ERROR "xxd not found")
endif()
add_custom_command(OUTPUT nsh_romfsimg.c
COMMAND ${CMAKE_COMMAND} -E remove -f nsh_romfsimg.c
COMMAND ${XXD} -i romfs.img nsh_romfsimg.c
COMMAND sed 's/unsigned/const unsigned/g' nsh_romfsimg.c > nsh_romfsimg.c.tmp && ${CMAKE_COMMAND} -E rename nsh_romfsimg.c.tmp nsh_romfsimg.c
DEPENDS romfs.img
)
endif()
add_custom_command(OUTPUT nsh_romfsimg.c
COMMAND ${CMAKE_COMMAND} -E remove -f nsh_romfsimg.c
COMMAND ${XXD} -i romfs.img nsh_romfsimg.c
COMMAND sed 's/unsigned/const unsigned/g' nsh_romfsimg.c > nsh_romfsimg.c.tmp && ${CMAKE_COMMAND} -E rename nsh_romfsimg.c.tmp nsh_romfsimg.c
DEPENDS romfs.img
)
add_library(romfs STATIC nsh_romfsimg.c)
add_dependencies(romfs prebuild_targets)