cmake:add romfs/unionfs/tcpblaster/udpblaster exmaple app CMake build

Signed-off-by: xuxin19 <xuxin19@xiaomi.com>
This commit is contained in:
xuxin19 2024-08-16 11:13:27 +08:00 committed by Xiang Xiao
parent cc200c301c
commit 190926b467
6 changed files with 234 additions and 14 deletions

View file

@ -20,26 +20,37 @@
if(CONFIG_EXAMPLES_ROMFS)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/romfs_testdir.h
COMMAND tar zxf ${CMAKE_CURRENT_LIST_DIR}/testdir.tar.gz
COMMAND genromfs -f testdir.img -d testdir -V "ROMFS_Test"
COMMAND xxd -i testdir.img romfs_testdir.h
add_custom_target(
testdir
COMMAND ${CMAKE_COMMAND} -E tar zxf ${CMAKE_CURRENT_LIST_DIR}/testdir.tar.gz
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS ${CMAKE_CURRENT_LIST_DIR}/testdir.tar.gz)
add_custom_target(testromfs
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/romfs_testdir.h)
DEPENDS ${CMAKE_CURRENT_LIST_DIR}/testdir.tar.gz
COMMENT "EXAMPLES ROMFS Extracting testdir.tar.gz...")
add_custom_target(
testdir_img
COMMAND genromfs -f testdir.img -d testdir -V "ROMFS_Test"
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS testdir
COMMENT "EXAMPLES ROMFS Generating testdir.img...")
add_custom_target(
romfs_testdir_h
COMMAND xxd -i testdir.img > romfs_testdir.h
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS testdir_img
COMMENT "EXAMPLES ROMFS Generating romfs_testdir.h...")
nuttx_add_application(
NAME
romfs
MODULE
${CONFIG_EXAMPLES_ROMFS}
SRCS
romfs_main.c
INCLUDE_DIRECTORIES
${CMAKE_CURRENT_BINARY_DIR}
DEPENDS
testromfs
SRCS
romfs_main.c)
romfs_testdir_h)
endif()

View file

@ -19,5 +19,67 @@
# ##############################################################################
if(CONFIG_EXAMPLES_TCPBLASTER)
nuttx_add_application(NAME tcpblaster)
if(NOT CONFIG_EXAMPLES_TCPBLASTER_TARGET2
AND NOT CONFIG_EXAMPLES_TCPBLASTER_LOOPBACK)
include(tcpblaster_host.cmake)
endif()
# Basic TCP networking test
set(CSRCS tcpblaster_cmdline.c)
if(CONFIG_EXAMPLES_TCPBLASTER_INIT)
list(APPEND CSRCS tcpblaster_netinit.c)
endif()
# Target 1 Files
if(CONFIG_EXAMPLES_TCPBLASTER_LOOPBACK)
list(APPEND CSRCS tcpblaster_server.c tcpblaster_client.c)
elseif(CONFIG_EXAMPLES_TCPBLASTER_SERVER)
list(APPEND CSRCS tcpblaster_server.c)
else()
list(APPEND CSRCS tcpblaster_client.c)
endif()
nuttx_add_application(
NAME
${CONFIG_EXAMPLES_TCPBLASTER_PROGNAME1}
PRIORITY
${CONFIG_EXAMPLES_TCPBLASTER_PRIORITY1}
STACKSIZE
${CONFIG_EXAMPLES_TCPBLASTER_STACKSIZE1}
MODULE
${CONFIG_EXAMPLES_TCPBLASTER}
INCLUDE_DIRECTORIES
${CMAKE_BINARY_DIR}/include/nuttx
SRCS
tcpblaster_target1.c
${CSRCS})
# Target 2 Files
if(CONFIG_EXAMPLES_TCPBLASTER_TARGET2)
if(CONFIG_EXAMPLES_TCPBLASTER_SERVER)
list(APPEND CSRCS tcpblaster_client.c)
else()
list(APPEND CSRCS tcpblaster_server.c)
endif()
nuttx_add_application(
NAME
${CONFIG_EXAMPLES_TCPBLASTER_PROGNAME2}
PRIORITY
${CONFIG_EXAMPLES_TCPBLASTER_PRIORITY2}
STACKSIZE
${CONFIG_EXAMPLES_TCPBLASTER_STACKSIZE2}
MODULE
${CONFIG_EXAMPLES_TCPBLASTER}
INCLUDE_DIRECTORIES
${CMAKE_BINARY_DIR}/include/nuttx
SRCS
tcpblaster_target2.c
${CSRCS})
endif()
endif()

View file

@ -0,0 +1,55 @@
# ##############################################################################
# apps/examples/tcpblaster/tcpblaster_host.cmake
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
# Configure project
cmake_minimum_required(VERSION 3.16)
project(tcpblaster_host LANGUAGES C)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE
"Release"
CACHE STRING "Build type" FORCE)
endif()
message(STATUS "NuttX apps examples tcpblaster host")
include_directories(${CMAKE_BINARY_DIR}/include/nuttx)
add_compile_definitions(TCPBLASTER_HOST=1)
if(CONFIG_EXAMPLES_TCPBLASTER_SERVER)
add_compile_definitions(CONFIG_EXAMPLES_TCPBLASTER_SERVER=1)
add_compile_definitions(
CONFIG_EXAMPLES_TCPBLASTER_SERVERIP=${CONFIG_EXAMPLES_TCPBLASTER_SERVERIP})
endif()
add_library(tcpblaster)
target_sources(tcpblaster PRIVATE tcpblaster_cmdline.c)
if(CONFIG_EXAMPLES_TCPBLASTER_SERVER)
target_sources(tcpblaster PRIVATE tcpblaster_client.c)
add_executable(tcpclient tcpblaster_host.c)
target_link_libraries(tcpclient PRIVATE tcpblaster)
install(TARGETS tcpclient DESTINATION bin)
else()
target_sources(tcpblaster PRIVATE tcpblaster_server.c)
add_executable(tcpserver tcpblaster_host.c)
target_link_libraries(tcpserver PRIVATE tcpblaster)
install(TARGETS tcpserver DESTINATION bin)
endif()

View file

@ -19,5 +19,22 @@
# ##############################################################################
if(CONFIG_EXAMPLES_UDPBLASTER)
nuttx_add_application(NAME udpblaster)
if(NOT CONFIG_EXAMPLES_TCPBLASTER_LOOPBACK)
include(udpblaster_host.cmake)
endif()
nuttx_add_application(
NAME
${CONFIG_EXAMPLES_UDPBLASTER_PROGNAME}
PRIORITY
${CONFIG_EXAMPLES_UDPBLASTER_PRIORITY}
STACKSIZE
${CONFIG_EXAMPLES_UDPBLASTER_STACKSIZE}
MODULE
${CONFIG_EXAMPLES_UDPBLASTER}
SRCS
udpblaster_target.c
udpblaster_text.c)
endif()

View file

@ -0,0 +1,39 @@
# ##############################################################################
# apps/examples/udpblaster/udpblaster.cmake
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
# Configure project
cmake_minimum_required(VERSION 3.16)
project(udpblaster_host LANGUAGES C)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE
"Release"
CACHE STRING "Build type" FORCE)
endif()
message(STATUS "NuttX apps examples udpblaster host")
include_directories(${CMAKE_BINARY_DIR}/include/nuttx)
add_compile_definitions(UDPBLASTER_HOST=1)
add_library(udpblaster)
target_sources(udpblaster PRIVATE udpblaster_text.c)
add_executable(host udpblaster_host.c)
target_link_libraries(host PRIVATE udpblaster)
install(TARGETS host DESTINATION bin)

View file

@ -19,5 +19,41 @@
# ##############################################################################
if(CONFIG_EXAMPLES_UNIONFS)
nuttx_add_application(NAME unionfs)
add_custom_target(
testdir
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_CURRENT_LIST_DIR}/atestdir atestdir
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_CURRENT_LIST_DIR}/btestdir btestdir
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "EXAMPLES UNIONFS Copy test dir...")
add_custom_target(
testdir_img
COMMAND genromfs -f atestdir.img -d atestdir -V "UNIONFS_FS1"
COMMAND genromfs -f btestdir.img -d btestdir -V "UNIONFS_FS2"
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS testdir
COMMENT "EXAMPLES UNIONFS Generating testdir.img...")
add_custom_target(
romfs_testdir_h
COMMAND xxd -i atestdir.img > romfs_atestdir.h
COMMAND xxd -i btestdir.img > romfs_btestdir.h
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS testdir_img
COMMENT "EXAMPLES UNIONFS Generating romfs_testdir.h...")
nuttx_add_application(
NAME
unionfs
MODULE
${CONFIG_EXAMPLES_UNIONFS}
SRCS
unionfs_main.c
INCLUDE_DIRECTORIES
${CMAKE_CURRENT_BINARY_DIR}
DEPENDS
romfs_testdir_h)
endif()