refactor: use cmake macros to do objcopy, install and tests
All checks were successful
Build nix packages / build-matrix (am-kernels) (push) Successful in 2m26s
Build nix packages / build-matrix (rv32Cross.am-kernels-nemu) (push) Successful in 2m23s
Build nix packages / build-matrix (rv32Cross.am-kernels-npc) (push) Successful in 2m21s

This commit is contained in:
xinyangli 2024-08-15 17:52:04 +08:00
parent f6c3a13e7f
commit 8630fe7667
Signed by: xin
SSH key fingerprint: SHA256:qZ/tzd8lYRtUFSrfBDBMcUqV4GHKxqeqRA3huItgvbk
12 changed files with 64 additions and 54 deletions

View file

@ -41,10 +41,6 @@ foreach(SOURCE IN LISTS SOURCES)
${SOURCE})
target_link_libraries(${SOURCE_NAME} PRIVATE am-${ARCH} klib)
# -- Extract binary file from ELF
add_custom_command(TARGET ${SOURCE_NAME}
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_LIBEXECDIR}/am-kernels)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${SOURCE_NAME}.bin DESTINATION ${CMAKE_INSTALL_DATADIR}/am-kernels)
create_binary(${SOURCE_NAME})
install_target_and_binary(${SOURCE_NAME})
endforeach()

View file

@ -3,14 +3,15 @@
char buf[128];
int main() {
sprintf(buf, "%s", "Hello world!\n");
check(strcmp(buf, "Hello world!\n") == 0);
sprintf(buf, "%s", "Hello world!\n");
check(strcmp(buf, "Hello world!\n") == 0);
sprintf(buf, "%d + %d = %d\n", 1, 1, 2);
check(strcmp(buf, "1 + 1 = 2\n") == 0);
sprintf(buf, "%d + %d = %d\n", 1, 1, 2);
check(strcmp(buf, "1 + 1 = 2\n") == 0);
sprintf(buf, "%d + %d = %d\n", 2, 10, 12);
check(strcmp(buf, "2 + 10 = 12\n") == 0);
sprintf(buf, "%d + %d = %d\n", 2, 10, 12);
printf(buf);
check(strcmp(buf, "2 + 10 = 12\n") == 0);
return 0;
return 0;
}