Skip to content

Commit abe0cdf

Browse files
committed
examples/sotest: add matching CMake fixture support
1 parent 2a6c59d commit abe0cdf

3 files changed

Lines changed: 98 additions & 16 deletions

File tree

examples/sotest/main/CMakeLists.txt

Lines changed: 48 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,27 +21,59 @@
2121
# ##############################################################################
2222

2323
if(CONFIG_EXAMPLES_SOTEST)
24+
set(SOTEST_SYMTAB ${CMAKE_CURRENT_BINARY_DIR}/sotest_symtab.c)
25+
set(SOTEST_ROMFS_IMG ${CMAKE_CURRENT_BINARY_DIR}/sotest_romfs.img)
26+
set(SOTEST_ROMFS_SRC ${CMAKE_CURRENT_BINARY_DIR}/sotest_romfs.c)
27+
set(SOTEST_MODPRINT_ELF ${CMAKE_BINARY_DIR}/bin/modprint)
28+
set(SOTEST_SHARED_ELF ${CMAKE_BINARY_DIR}/bin/sotest)
2429

25-
# FIXME: fix all empty a after the kernel build is implemented
2630
add_custom_command(
27-
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/sotest_symtab.c
31+
OUTPUT ${SOTEST_SYMTAB}
2832
COMMAND
29-
${NUTTX_APPS_DIR}/tools/mksymtab.sh ${CMAKE_CURRENT_BINARY_DIR}/empty
30-
g_sot > ${CMAKE_CURRENT_BINARY_DIR}/sotest_symtab.c)
33+
sh -c "\"${NUTTX_APPS_DIR}/tools/mksymtab.sh\" \"${SOTEST_MODPRINT_ELF}\" \"${SOTEST_SHARED_ELF}\" g_sot > \"${SOTEST_SYMTAB}\""
34+
DEPENDS modprint sotest
35+
VERBATIM)
3136

32-
add_custom_target(
33-
sotest_romfs
34-
COMMAND genromfs -f sotest_romfs.img -d empty
35-
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
37+
set(SOTEST_SRCS sotest_main.c ${SOTEST_SYMTAB})
3638

37-
add_custom_command(
38-
OUTPUT sotest_romfs.c
39-
COMMAND xxd -i sotest_romfs.img > sotest_romfs.c
40-
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
41-
DEPENDS sotest_romfs)
39+
if(CONFIG_EXAMPLES_SOTEST_BUILTINFS)
40+
set(SOTEST_ROMFS_DEPS modprint sotest)
41+
42+
if(CONFIG_SYSTEM_NXPKG)
43+
set(SOTEST_SHARED_INDEX ${CMAKE_BINARY_DIR}/bin/shared-index.json)
44+
set(SOTEST_SHARED_SCRIPT ${CMAKE_BINARY_DIR}/bin/pkgsotest.nsh)
45+
46+
add_custom_command(
47+
OUTPUT ${SOTEST_SHARED_INDEX} ${SOTEST_SHARED_SCRIPT}
48+
COMMAND
49+
${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/mk_pkg_fixture_shared.py
50+
${SOTEST_MODPRINT_ELF} ${SOTEST_SHARED_ELF} ${SOTEST_SHARED_INDEX}
51+
${SOTEST_SHARED_SCRIPT} ${CONFIG_ARCH} ${CONFIG_ARCH_BOARD}
52+
DEPENDS
53+
modprint
54+
sotest
55+
${CMAKE_CURRENT_SOURCE_DIR}/mk_pkg_fixture_shared.py
56+
VERBATIM)
57+
58+
list(APPEND SOTEST_ROMFS_DEPS ${SOTEST_SHARED_INDEX}
59+
${SOTEST_SHARED_SCRIPT})
60+
endif()
61+
62+
add_custom_command(
63+
OUTPUT ${SOTEST_ROMFS_IMG}
64+
COMMAND genromfs -f ${SOTEST_ROMFS_IMG} -d ${CMAKE_BINARY_DIR}/bin
65+
DEPENDS ${SOTEST_ROMFS_DEPS}
66+
VERBATIM)
67+
68+
add_custom_command(
69+
OUTPUT ${SOTEST_ROMFS_SRC}
70+
COMMAND
71+
sh -c "echo '#include <nuttx/compiler.h>' > \"${SOTEST_ROMFS_SRC}\" && xxd -i \"${SOTEST_ROMFS_IMG}\" | sed -e 's/^unsigned char/const unsigned char aligned_data(4)/g' >> \"${SOTEST_ROMFS_SRC}\""
72+
DEPENDS ${SOTEST_ROMFS_IMG}
73+
VERBATIM)
4274

43-
nuttx_add_application(
44-
NAME sotest SRCS sotest_main.c ${CMAKE_CURRENT_BINARY_DIR}/sotest_symtab.c
45-
${CMAKE_CURRENT_BINARY_DIR}/sotest_romfs.c)
75+
list(APPEND SOTEST_SRCS ${SOTEST_ROMFS_SRC})
76+
endif()
4677

78+
nuttx_add_application(NAME sotest SRCS ${SOTEST_SRCS})
4779
endif()
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# ##############################################################################
2+
# apps/examples/sotest/modprint/CMakeLists.txt
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
7+
# license agreements. See the NOTICE file distributed with this work for
8+
# additional information regarding copyright ownership. The ASF licenses this
9+
# file to you under the Apache License, Version 2.0 (the "License"); you may not
10+
# use this file except in compliance with the License. You may obtain a copy of
11+
# the License at
12+
#
13+
# http://www.apache.org/licenses/LICENSE-2.0
14+
#
15+
# Unless required by applicable law or agreed to in writing, software
16+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
18+
# License for the specific language governing permissions and limitations under
19+
# the License.
20+
#
21+
# ##############################################################################
22+
23+
if(CONFIG_EXAMPLES_SOTEST)
24+
nuttx_add_application(NAME modprint SRCS modprint.c DYNLIB y)
25+
endif()
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# ##############################################################################
2+
# apps/examples/sotest/sotest/CMakeLists.txt
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
7+
# license agreements. See the NOTICE file distributed with this work for
8+
# additional information regarding copyright ownership. The ASF licenses this
9+
# file to you under the Apache License, Version 2.0 (the "License"); you may not
10+
# use this file except in compliance with the License. You may obtain a copy of
11+
# the License at
12+
#
13+
# http://www.apache.org/licenses/LICENSE-2.0
14+
#
15+
# Unless required by applicable law or agreed to in writing, software
16+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
18+
# License for the specific language governing permissions and limitations under
19+
# the License.
20+
#
21+
# ##############################################################################
22+
23+
if(CONFIG_EXAMPLES_SOTEST)
24+
nuttx_add_application(NAME sotest SRCS sotest.c DYNLIB y)
25+
endif()

0 commit comments

Comments
 (0)