Skip to content

Commit

Permalink
Add support from cromfs generation
Browse files Browse the repository at this point in the history
  • Loading branch information
David Sidrane committed Jan 25, 2019
1 parent f220817 commit 5036a09
Showing 1 changed file with 46 additions and 10 deletions.
56 changes: 46 additions & 10 deletions ROMFS/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 5036a09

Please sign in to comment.