build: add more tests to build system
This commit is contained in:
parent
2f559823a6
commit
9d41ac2f7b
12 changed files with 107 additions and 17 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,4 +1,3 @@
|
||||||
*
|
|
||||||
!*/
|
!*/
|
||||||
!*.h
|
!*.h
|
||||||
!*.c
|
!*.c
|
||||||
|
@ -13,3 +12,4 @@ _*
|
||||||
*~
|
*~
|
||||||
build/
|
build/
|
||||||
!.gitignore
|
!.gitignore
|
||||||
|
out/
|
||||||
|
|
|
@ -3,14 +3,15 @@ cmake_minimum_required(VERSION 3.22)
|
||||||
project(am-kernels)
|
project(am-kernels)
|
||||||
set(CMAKE_C_STANDARD 11)
|
set(CMAKE_C_STANDARD 11)
|
||||||
enable_language(C ASM)
|
enable_language(C ASM)
|
||||||
|
|
||||||
include(CheckPIESupported)
|
include(CheckPIESupported)
|
||||||
|
include(GNUInstallDirs)
|
||||||
|
|
||||||
|
find_package(am-${ARCH})
|
||||||
|
find_package(klib)
|
||||||
|
|
||||||
check_pie_supported()
|
check_pie_supported()
|
||||||
|
|
||||||
if(${PLATFORM} MATCHES "native")
|
|
||||||
set(ARCH "native")
|
|
||||||
else()
|
|
||||||
set(ARCH ${ISA}-${PLATFORM})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
add_subdirectory(tests/cpu-tests)
|
add_subdirectory(tests/cpu-tests)
|
||||||
|
# add_subdirectory(tests/alu-tests)
|
||||||
|
add_subdirectory(benchmarks/microbench)
|
||||||
|
add_subdirectory(kernels)
|
||||||
|
|
3
benchmarks/microbench/CMakeLists.txt
Normal file
3
benchmarks/microbench/CMakeLists.txt
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
include_directories(include)
|
||||||
|
|
||||||
|
add_subdirectory(src)
|
23
benchmarks/microbench/src/CMakeLists.txt
Normal file
23
benchmarks/microbench/src/CMakeLists.txt
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
add_executable(bench
|
||||||
|
qsort/qsort.c
|
||||||
|
ssort/ssort.cc
|
||||||
|
queen/queen.c
|
||||||
|
sieve/sieve.c
|
||||||
|
bf/bf.c
|
||||||
|
15pz/15pz.cc
|
||||||
|
dinic/dinic.cc
|
||||||
|
lzip/lzip.c
|
||||||
|
lzip/quicklz.c
|
||||||
|
md5/md5.c
|
||||||
|
bench.c
|
||||||
|
fib/fib.c
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(bench am-${ARCH} klib npcgcc)
|
||||||
|
|
||||||
|
# -- Extract binary file from ELF
|
||||||
|
add_custom_command(TARGET bench
|
||||||
|
COMMAND ${CMAKE_OBJCOPY} ARGS -S --set-section-flags .bss=alloc,contents -O binary bench bench.bin)
|
||||||
|
|
||||||
|
install(TARGETS bench RUNTIME DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/am-kernels)
|
||||||
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/bench.bin DESTINATION ${CMAKE_INSTALL_DATADIR}/am-kernels)
|
2
kernels/CMakeLists.txt
Normal file
2
kernels/CMakeLists.txt
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
add_subdirectory(hello)
|
||||||
|
add_subdirectory(demo)
|
1
kernels/demo/CMakeLists.txt
Normal file
1
kernels/demo/CMakeLists.txt
Normal file
|
@ -0,0 +1 @@
|
||||||
|
add_subdirectory(src)
|
|
@ -1,6 +1,6 @@
|
||||||
#ifndef __DRAW_H__
|
#ifndef __DRAW_H__
|
||||||
|
|
||||||
#define HAS_GUI
|
// #define HAS_GUI
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <am.h>
|
#include <am.h>
|
||||||
|
|
20
kernels/demo/src/CMakeLists.txt
Normal file
20
kernels/demo/src/CMakeLists.txt
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
add_executable(demo
|
||||||
|
aclock/aclock.c
|
||||||
|
ant/ant.c
|
||||||
|
bf/bf.c
|
||||||
|
cmatrix/cmatrix.c
|
||||||
|
donut/donut.c
|
||||||
|
galton/galton.c
|
||||||
|
hanoi/hanoi.c
|
||||||
|
life/life.c
|
||||||
|
main.c
|
||||||
|
)
|
||||||
|
target_include_directories(demo PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../include)
|
||||||
|
target_link_libraries(demo PRIVATE am-${ARCH} klib npcgcc)
|
||||||
|
|
||||||
|
# -- Extract binary file from ELF
|
||||||
|
add_custom_command(TARGET demo
|
||||||
|
COMMAND ${CMAKE_OBJCOPY} ARGS -S --set-section-flags .bss=alloc,contents -O binary demo demo.bin)
|
||||||
|
|
||||||
|
install(TARGETS demo RUNTIME DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/am-kernels)
|
||||||
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/demo.bin DESTINATION ${CMAKE_INSTALL_DATADIR}/am-kernels)
|
14
kernels/hello/CMakeLists.txt
Normal file
14
kernels/hello/CMakeLists.txt
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
add_executable(hello
|
||||||
|
hello.c
|
||||||
|
)
|
||||||
|
target_include_directories(hello PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../include)
|
||||||
|
target_link_libraries(hello PRIVATE am-${ARCH} klib npcgcc)
|
||||||
|
target_compile_options(hello PRIVATE -nostdlib -nodefaultlibs)
|
||||||
|
target_link_options(hello PRIVATE -nostdlib -nodefaultlibs)
|
||||||
|
|
||||||
|
# -- Extract binary file from ELF
|
||||||
|
add_custom_command(TARGET hello
|
||||||
|
COMMAND ${CMAKE_OBJCOPY} ARGS -S --set-section-flags .bss=alloc,contents -O binary hello hello.bin)
|
||||||
|
|
||||||
|
install(TARGETS hello RUNTIME DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/am-kernels)
|
||||||
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/hello.bin DESTINATION ${CMAKE_INSTALL_DATADIR}/am-kernels)
|
29
tests/alu-tests/CMakeLists.txt
Normal file
29
tests/alu-tests/CMakeLists.txt
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
# TODO: CMake does not support multiple toolchain in one run. We need a seperate
|
||||||
|
# project for native binary compilation
|
||||||
|
|
||||||
|
# cmake_minimum_required(VERSION 3.22)
|
||||||
|
|
||||||
|
# project(alu-tests)
|
||||||
|
# set(CMAKE_C_STANDARD 11)
|
||||||
|
# enable_language(C ASM)
|
||||||
|
# include(GNUInstallDirs)
|
||||||
|
|
||||||
|
# add_executable(gen_alu_test gen_alu_test.c)
|
||||||
|
|
||||||
|
# add_custom_command(TARGET gen_alu_test POST_BUILD
|
||||||
|
# BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/alu_test.c
|
||||||
|
# COMMAND $<TARGET_FILE:gen_alu_test> > alu_test.c)
|
||||||
|
|
||||||
|
add_executable(alu_test alu_test.c)
|
||||||
|
|
||||||
|
target_include_directories(alu_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../include)
|
||||||
|
target_link_libraries(alu_test PRIVATE am-${ARCH} klib npcgcc)
|
||||||
|
target_compile_options(alu_test PRIVATE -nostdlib -nodefaultlibs)
|
||||||
|
target_link_options(alu_test PRIVATE -nostdlib -nodefaultlibs)
|
||||||
|
|
||||||
|
# -- Extract binary file from ELF
|
||||||
|
add_custom_command(TARGET alu_test
|
||||||
|
COMMAND ${CMAKE_OBJCOPY} ARGS -S --set-section-flags .bss=alloc,contents -O binary alu_test alu_test.bin)
|
||||||
|
|
||||||
|
install(TARGETS alu_test RUNTIME DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/am-kernels)
|
||||||
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/alu_test.bin DESTINATION ${CMAKE_INSTALL_DATADIR}/am-kernels)
|
|
@ -114,7 +114,7 @@ int exclude(type t, char* op, int x, int y)
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
printf("#include <stdio.h>\n");
|
printf("#include <stdio.h>\n");
|
||||||
printf("int main(void) {\n");
|
printf("int main(const char *) {\n");
|
||||||
printf(" int exit_code = 0;\n");
|
printf(" int exit_code = 0;\n");
|
||||||
|
|
||||||
FOR_SET_ALL(signed int, vsi);
|
FOR_SET_ALL(signed int, vsi);
|
||||||
|
|
|
@ -1,6 +1,3 @@
|
||||||
find_package(am-${ARCH})
|
|
||||||
find_package(klib)
|
|
||||||
|
|
||||||
set(SOURCES
|
set(SOURCES
|
||||||
add.c
|
add.c
|
||||||
add-longlong.c
|
add-longlong.c
|
||||||
|
@ -42,12 +39,12 @@ foreach(SOURCE IN LISTS SOURCES)
|
||||||
get_filename_component(SOURCE_NAME ${SOURCE} NAME_WLE)
|
get_filename_component(SOURCE_NAME ${SOURCE} NAME_WLE)
|
||||||
add_executable(${SOURCE_NAME}
|
add_executable(${SOURCE_NAME}
|
||||||
${SOURCE})
|
${SOURCE})
|
||||||
target_link_libraries(${SOURCE_NAME} PRIVATE am-${ARCH})
|
target_link_libraries(${SOURCE_NAME} PRIVATE am-${ARCH} klib)
|
||||||
|
|
||||||
# -- Extract binary file from ELF
|
# -- Extract binary file from ELF
|
||||||
add_custom_command(TARGET ${SOURCE_NAME}
|
add_custom_command(TARGET ${SOURCE_NAME}
|
||||||
COMMAND ${CMAKE_OBJCOPY} ARGS -S --set-section-flags .bss=alloc,contents -O binary ${SOURCE_NAME} ${SOURCE_NAME}.bin)
|
COMMAND ${CMAKE_OBJCOPY} ARGS -S --set-section-flags .bss=alloc,contents -O binary ${SOURCE_NAME} ${SOURCE_NAME}.bin)
|
||||||
|
|
||||||
install(TARGETS ${SOURCE_NAME} RUNTIME DESTINATION ${CMAKE_INSTALL_DATADIR}/elf)
|
install(TARGETS ${SOURCE_NAME} RUNTIME DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/am-kernels)
|
||||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${SOURCE_NAME}.bin DESTINATION ${CMAKE_INSTALL_DATADIR}/binary)
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${SOURCE_NAME}.bin DESTINATION ${CMAKE_INSTALL_DATADIR}/am-kernels)
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
Loading…
Reference in a new issue