Skip to content

Commit b813585

Browse files
authored
restructured project to allow using libs in tests (#109)
1 parent 731e46d commit b813585

89 files changed

Lines changed: 294 additions & 508 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ build-tests/
6464
# Disk images
6565
*.img
6666
*.iso
67+
# Keep .img files in tests/
68+
!tests/
69+
!tests/**/*.img
6770

6871
# Compiler commands
6972
compile_commands.json

CMake/TestsConfig.cmake

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
function(SETUP_UNIT_TEST name)
2+
add_executable(${name})
3+
SETUP_COMMON(${name})
4+
5+
file(GLOB_RECURSE SOURCES CONFIGURE_DEPENDS *.c)
6+
file(GLOB_RECURSE HEADERS CONFIGURE_DEPENDS *.h)
7+
8+
target_sources(${name}
9+
PRIVATE
10+
${SOURCES}
11+
${ARGN}
12+
PRIVATE
13+
FILE_SET HEADERS
14+
BASE_DIRS .
15+
FILES ${HEADERS}
16+
)
17+
18+
target_link_libraries(${name} PRIVATE unity)
19+
20+
add_test(NAME ${name} COMMAND ${name})
21+
22+
set_tests_properties(${name} PROPERTIES
23+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/
24+
)
25+
endfunction()

CMake/preset-mixins.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@
1717
"hidden": true,
1818
"toolchainFile": "${sourceDir}/CMake/toolchains/riscv64-clang.cmake"
1919
},
20+
{
21+
"name": "host-clang",
22+
"hidden": true,
23+
"cacheVariables": {
24+
"CMAKE_C_COMPILER": "clang"
25+
}
26+
},
2027
{
2128
"name": "compile-commands",
2229
"hidden": true,

CMakeLists.txt

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,16 @@ set_property(GLOBAL PROPERTY USE_FOLDERS ON)
66
include_directories(SYSTEM external/include)
77
include_directories(include)
88

9+
include(CMake/CommonConfig.cmake)
10+
911
option(BIGOS_BUILD_TESTS "Build unit tests (native host only)" OFF)
1012
if(BIGOS_BUILD_TESTS)
11-
enable_testing()
12-
add_subdirectory(tests)
13+
include(CMake/TestsConfig.cmake)
14+
enable_testing()
15+
add_subdirectory(tests)
16+
add_subdirectory(src/libcore)
17+
add_subdirectory(src/libboot)
1318
else()
14-
include(CMake/Linters.cmake)
15-
include(CMake/CommonConfig.cmake)
16-
add_subdirectory(src)
19+
include(CMake/Linters.cmake)
20+
add_subdirectory(src)
1721
endif()

CMakePresets.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,12 @@
229229
},
230230
{
231231
"name": "tests-unit",
232-
"inherits": ["native-host-tests", "compile-commands", "debug-type"],
232+
"inherits": [
233+
"host-clang",
234+
"native-host-tests",
235+
"compile-commands",
236+
"debug-type"
237+
],
233238
"displayName": "Unit Tests",
234239
"description": "Native host build for unit tests"
235240
}

docs/doxygen/groups.dox

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
@defgroup palloc Physical memory allocator
66
@defgroup kinit Kernel initialization
77
@defgroup hal Hardware abstraction layer
8-
@defgroup dt Device tree
9-
@defgroup stdbigos
8+
@defgroup libboot_dt
9+
@defgroup libcore
1010
@defgroup sbi
11-
@defgroup csr
11+
@defgroup error
1212
@defgroup types
1313
@defgroup string
1414
@defgroup bitutils

docs/source/pages/api/libs/index.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Bigos Libraries
44

55
.. toctree::
66
:maxdepth: 1
7+
:glob:
78

8-
dt
9-
trap
10-
stdbigos/index
9+
libcore/index
10+
libboot/index
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Device Tree API
66
Public API
77
----------
88

9-
.. doxygengroup:: dt
9+
.. doxygengroup:: libboot_dt
1010
:members:
1111

1212
---------
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
=======
2+
Libboot
3+
=======
4+
5+
.. toctree::
6+
:maxdepth: 1
7+
:glob:
8+
9+
*
File renamed without changes.

0 commit comments

Comments
 (0)