first version of working cmake
This commit is contained in:
parent
32b9cc78b4
commit
f419b1a3e6
@ -1,7 +1,8 @@
|
||||
cmake_minimum_required(VERSION 3.12)
|
||||
project(bsp C)
|
||||
add_subdirectory(libwrap)
|
||||
message(STATUS " liu here")
|
||||
add_subdirectory(env)
|
||||
message(STATUS " in bsp with ${CMAKE_CXX_FLAGS}")
|
||||
message(STATUS " SUPPORTED_BOARDS= ${SUPPORTED_BOARDS}")
|
||||
add_library(${PROJECT_NAME} INTERFACE)
|
||||
target_include_directories(${PROJECT_NAME} INTERFACE
|
||||
|
79
env/CMakeLists.txt
vendored
79
env/CMakeLists.txt
vendored
@ -1,39 +1,64 @@
|
||||
project(bsp_env)
|
||||
message(STATUS " here in bsp_env")
|
||||
project(env)
|
||||
message(STATUS " here in bsp/env")
|
||||
message(STATUS " BOARD: ${BOARD}")
|
||||
# Enable ASM language
|
||||
enable_language(ASM)
|
||||
set(LIB_SOURCES
|
||||
set(ASM_SOURCES
|
||||
entry.S
|
||||
start.S
|
||||
)
|
||||
|
||||
# Set ASM compile options
|
||||
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -march=${RISCV_ARCH}_zicsr_zifencei -mabi=${RISCV_ABI}")
|
||||
|
||||
|
||||
add_library(asm_obj OBJECT ${LIB_SOURCES})
|
||||
add_subdirectory(${BOARD})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Include the ISS board configuration
|
||||
set(ISS_SOURCE_DIR "${CMAKE_SOURCE_DIR}/bare-metal-bsp/env/iss")
|
||||
set(ISS_BINARY_DIR "${CMAKE_BINARY_DIR}/iss_build")
|
||||
|
||||
add_subdirectory(${ISS_SOURCE_DIR} ${ISS_BINARY_DIR})
|
||||
|
||||
|
||||
add_library(asm_obj OBJECT ${ASM_SOURCES})
|
||||
set_target_properties(asm_obj PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bare-metal-bsp/${PROJECT_NAME})
|
||||
target_include_directories(asm_obj PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${BSP_BASE}/include
|
||||
#include/
|
||||
${BSP_BASE}/env
|
||||
${BSP_BASE}/env/${BOARD}
|
||||
${BSP_BASE}/drivers
|
||||
)
|
||||
|
||||
# Export variables for hello-world to use
|
||||
set(ENV_OBJECTS
|
||||
$<TARGET_OBJECTS:env_entry>
|
||||
$<TARGET_OBJECTS:env_start>
|
||||
$<TARGET_OBJECTS:asm_obj>
|
||||
|
||||
PARENT_SCOPE
|
||||
)
|
||||
|
||||
|
||||
set(BOARD_LIB_NAME ${BOARD})
|
||||
message(STATUS " BOARD_LIB_NAME: ${BOARD_LIB_NAME}")
|
||||
set(BOARD_LIB_SRC
|
||||
${BOARD}/init.c
|
||||
${BOARD}/write.c
|
||||
)
|
||||
add_library(${BOARD_LIB_NAME} STATIC ${BOARD_LIB_SRC})
|
||||
set_target_properties(${BOARD_LIB_NAME} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bare-metal-bsp/${PROJECT_NAME})
|
||||
|
||||
# Set ASM compile options
|
||||
#set(CMAKE_ASM_COMPILER riscv64-unknown-elf-as)
|
||||
#set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -march=${RISCV_ARCH}_zicsr_zifencei -mabi=${RISCV_ABI}")
|
||||
|
||||
#add_subdirectory(${BOARD})
|
||||
|
||||
|
||||
|
||||
target_include_directories(${BOARD_LIB_NAME} PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${BSP_BASE}/include
|
||||
${BSP_BASE}/libwrap/sys
|
||||
${BSP_BASE}/env
|
||||
${BSP_BASE}/env/${BOARD}
|
||||
${BSP_BASE}/drivers
|
||||
)
|
||||
|
||||
# Include the ISS board configuration
|
||||
#set(ISS_SOURCE_DIR "${CMAKE_SOURCE_DIR}/bare-metal-bsp/env/iss")
|
||||
#set(ISS_BINARY_DIR "${CMAKE_BINARY_DIR}/iss_build")
|
||||
|
||||
#add_subdirectory(${ISS_SOURCE_DIR} ${ISS_BINARY_DIR})
|
||||
|
||||
|
||||
|
||||
# Export board library
|
||||
set(BOARD_LIB board_iss PARENT_SCOPE)
|
||||
#set(BOARD_LIB board_iss PARENT_SCOPE)
|
||||
|
4
env/iss/CMakeLists.txt
vendored
4
env/iss/CMakeLists.txt
vendored
@ -1,3 +1,7 @@
|
||||
#cmake_minimum_required(VERSION 3.12)
|
||||
project(iss)
|
||||
message(STATUS " here in iss")
|
||||
|
||||
# Create library for ISS board support
|
||||
add_library(board_iss STATIC
|
||||
init.c
|
||||
|
38
env/iss/write.c
vendored
Normal file
38
env/iss/write.c
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
/* See LICENSE of license details. */
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "platform.h"
|
||||
#include "stub.h"
|
||||
#include "weak_under_alias.h"
|
||||
#if defined(SEMIHOSTING)
|
||||
#include "semihosting.h"
|
||||
#endif
|
||||
|
||||
ssize_t __wrap_write(int fd, const void *ptr, size_t len) {
|
||||
const uint8_t *current = (const uint8_t *)ptr;
|
||||
#if defined(SEMIHOSTING)
|
||||
if (isatty(fd)) {
|
||||
for (size_t jj = 0; jj < len; jj++) {
|
||||
sh_writec(current[jj]);
|
||||
}
|
||||
return len;
|
||||
} else {
|
||||
sh_write(current, fd);
|
||||
return len;
|
||||
}
|
||||
// return len;
|
||||
#endif
|
||||
if (isatty(fd)) {
|
||||
for (size_t jj = 0; jj < len; jj++) {
|
||||
*((uint32_t *)0xFFFF0000) = current[jj];
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
return _stub(EBADF);
|
||||
}
|
||||
weak_under_alias(write);
|
1
env/start.S
vendored
1
env/start.S
vendored
@ -1,3 +1,4 @@
|
||||
#include "encoding.h"
|
||||
// See LICENSE for license details.
|
||||
|
||||
.section .init
|
||||
|
@ -1,6 +1,9 @@
|
||||
#cmake_minimum_required(VERSION 3.12)
|
||||
project(libwrap)
|
||||
|
||||
message(STATUS " here 2 in libwrap")
|
||||
set(LIBRARY_NAME libwrap)
|
||||
set(STATIC_LIBRARY_FLAGS "rcs")
|
||||
|
||||
# Create object library for libwrap
|
||||
set(LIB_SOURCES
|
||||
@ -24,7 +27,7 @@ set(LIB_SOURCES
|
||||
sys/times.c
|
||||
sys/unlink.c
|
||||
sys/wait.c
|
||||
sys/write.c
|
||||
# sys/write.c
|
||||
# Standard library
|
||||
stdlib/malloc.c
|
||||
# Miscellaneous
|
||||
@ -38,11 +41,20 @@ if(SEMIHOSTING)
|
||||
|
||||
endif()
|
||||
|
||||
add_library(${PROJECT_NAME} OBJECT ${LIB_SOURCES})
|
||||
#add_library(${LIBRARY_NAME} OBJECT ${LIB_SOURCES})
|
||||
add_library(${LIBRARY_NAME} STATIC ${LIB_SOURCES})
|
||||
set_target_properties(${LIBRARY_NAME} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bare-metal-bsp/${PROJECT_NAME})
|
||||
|
||||
message(STATUS " CMAKE_BINARY_DIR: ${CMAKE_BINARY_DIR} ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
|
||||
|
||||
# Retrieve the output directory for the library
|
||||
get_target_property(LIBRARY_PATH ${LIBRARY_NAME} ARCHIVE_OUTPUT_DIRECTORY)
|
||||
|
||||
# Print the path to the console (for debugging purposes)
|
||||
message(STATUS "The library output path is: ${LIBRARY_PATH}")
|
||||
|
||||
# Include directories
|
||||
target_include_directories(${PROJECT_NAME} PRIVATE
|
||||
target_include_directories(${LIBRARY_NAME} PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${BSP_BASE}/include
|
||||
include/
|
||||
@ -51,10 +63,10 @@ target_include_directories(${PROJECT_NAME} PRIVATE
|
||||
${BSP_BASE}/drivers
|
||||
)
|
||||
|
||||
# Compile options
|
||||
|
||||
|
||||
#link global_compile_options to this libraries
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE global_compile_options)
|
||||
#target_link_libraries(${PROJECT_NAME} PRIVATE global_compile_options)
|
||||
|
||||
# Compile definitions
|
||||
#target_compile_definitions(libwrap_objects PRIVATE
|
||||
@ -62,4 +74,4 @@ target_link_libraries(${PROJECT_NAME} PRIVATE global_compile_options)
|
||||
#)
|
||||
|
||||
# Export objects to parent scope
|
||||
set(LIBWRAP_OBJECTS $<TARGET_OBJECTS:${PROJECT_NAME}> PARENT_SCOPE)
|
||||
#set(LIBWRAP_OBJECTS $<TARGET_OBJECTS:${PROJECT_NAME}> PARENT_SCOPE)
|
||||
|
Loading…
Reference in New Issue
Block a user