adds first version of cmake
This commit is contained in:
parent
5eac63d773
commit
32b9cc78b4
10
CMakeLists.txt
Normal file
10
CMakeLists.txt
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.12)
|
||||||
|
project(bsp C)
|
||||||
|
add_subdirectory(libwrap)
|
||||||
|
message(STATUS " liu here")
|
||||||
|
message(STATUS " SUPPORTED_BOARDS= ${SUPPORTED_BOARDS}")
|
||||||
|
add_library(${PROJECT_NAME} INTERFACE)
|
||||||
|
target_include_directories(${PROJECT_NAME} INTERFACE
|
||||||
|
include/
|
||||||
|
env/${BOARD}
|
||||||
|
env/)
|
39
env/CMakeLists.txt
vendored
Normal file
39
env/CMakeLists.txt
vendored
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
project(bsp_env)
|
||||||
|
message(STATUS " here in bsp_env")
|
||||||
|
# Enable ASM language
|
||||||
|
enable_language(ASM)
|
||||||
|
set(LIB_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})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Export variables for hello-world to use
|
||||||
|
set(ENV_OBJECTS
|
||||||
|
$<TARGET_OBJECTS:env_entry>
|
||||||
|
$<TARGET_OBJECTS:env_start>
|
||||||
|
PARENT_SCOPE
|
||||||
|
)
|
||||||
|
|
||||||
|
# Export board library
|
||||||
|
set(BOARD_LIB board_iss PARENT_SCOPE)
|
2
env/common-gcc.mk
vendored
2
env/common-gcc.mk
vendored
@ -16,6 +16,7 @@ BOARD?=iss
|
|||||||
|
|
||||||
ASM_SRCS += $(ENV_DIR)/start.S $(ENV_DIR)/entry.S
|
ASM_SRCS += $(ENV_DIR)/start.S $(ENV_DIR)/entry.S
|
||||||
C_SRCS += $(PLATFORM_DIR)/init.c
|
C_SRCS += $(PLATFORM_DIR)/init.c
|
||||||
|
C_SRCS += $(PLATFORM_DIR)/write.c
|
||||||
|
|
||||||
LINKER_SCRIPT ?= $(PLATFORM_DIR)/$(LINK_TARGET).lds
|
LINKER_SCRIPT ?= $(PLATFORM_DIR)/$(LINK_TARGET).lds
|
||||||
|
|
||||||
@ -23,6 +24,7 @@ INCLUDES += -I$(BSP_BASE)/include
|
|||||||
INCLUDES += -I$(BSP_BASE)/drivers/
|
INCLUDES += -I$(BSP_BASE)/drivers/
|
||||||
INCLUDES += -I$(ENV_DIR)
|
INCLUDES += -I$(ENV_DIR)
|
||||||
INCLUDES += -I$(PLATFORM_DIR)
|
INCLUDES += -I$(PLATFORM_DIR)
|
||||||
|
INCLUDES += -I$(BSP_BASE)/libwrap/sys/
|
||||||
|
|
||||||
LDFLAGS += -march=$(RISCV_ARCH) -mabi=$(RISCV_ABI)
|
LDFLAGS += -march=$(RISCV_ARCH) -mabi=$(RISCV_ABI)
|
||||||
LDFLAGS += -L$(ENV_DIR)
|
LDFLAGS += -L$(ENV_DIR)
|
||||||
|
26
env/iss/CMakeLists.txt
vendored
Normal file
26
env/iss/CMakeLists.txt
vendored
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
# Create library for ISS board support
|
||||||
|
add_library(board_iss STATIC
|
||||||
|
init.c
|
||||||
|
write.c
|
||||||
|
)
|
||||||
|
|
||||||
|
# Include directories
|
||||||
|
target_include_directories(board_iss PUBLIC
|
||||||
|
${BSP_BASE}/include
|
||||||
|
${BSP_BASE}/env
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
# Set compile options
|
||||||
|
target_compile_options(board_iss PRIVATE
|
||||||
|
-march=${RISCV_ARCH}_zicsr_zifencei
|
||||||
|
-mabi=${RISCV_ABI}
|
||||||
|
-mcmodel=medany
|
||||||
|
-ffunction-sections
|
||||||
|
-fdata-sections
|
||||||
|
)
|
||||||
|
|
||||||
|
# Add compile definitions
|
||||||
|
target_compile_definitions(board_iss PRIVATE
|
||||||
|
BOARD_${BOARD}
|
||||||
|
)
|
@ -1,55 +1,65 @@
|
|||||||
|
project(libwrap)
|
||||||
|
|
||||||
IF(NOT DEFINED _MK_LIBWRAP)
|
message(STATUS " here 2 in libwrap")
|
||||||
|
|
||||||
SET(_MK_LIBWRAP TRUE)
|
# Create object library for libwrap
|
||||||
|
set(LIB_SOURCES
|
||||||
SET(LIBWRAP_DIR ${CMAKE_CURRENT_LIST_DIR})
|
sys/_exit.c
|
||||||
|
sys/close.c
|
||||||
SET(LIBWRAP_SRCS
|
sys/execve.c
|
||||||
${LIBWRAP_DIR}/stdlib/malloc.c
|
sys/fork.c
|
||||||
${LIBWRAP_DIR}/sys/open.c
|
sys/fstat.c
|
||||||
${LIBWRAP_DIR}/sys/lseek.c
|
sys/getpid.c
|
||||||
${LIBWRAP_DIR}/sys/read.c
|
sys/isatty.c
|
||||||
${LIBWRAP_DIR}/sys/write.c
|
sys/kill.c
|
||||||
${LIBWRAP_DIR}/sys/fstat.c
|
sys/link.c
|
||||||
${LIBWRAP_DIR}/sys/stat.c
|
sys/lseek.c
|
||||||
${LIBWRAP_DIR}/sys/close.c
|
sys/open.c
|
||||||
${LIBWRAP_DIR}/sys/link.c
|
sys/openat.c
|
||||||
${LIBWRAP_DIR}/sys/unlink.c
|
sys/printf.c
|
||||||
${LIBWRAP_DIR}/sys/execve.c
|
sys/puts.c
|
||||||
${LIBWRAP_DIR}/sys/fork.c
|
sys/read.c
|
||||||
${LIBWRAP_DIR}/sys/getpid.c
|
sys/sbrk.c
|
||||||
${LIBWRAP_DIR}/sys/kill.c
|
sys/stat.c
|
||||||
${LIBWRAP_DIR}/sys/wait.c
|
sys/times.c
|
||||||
${LIBWRAP_DIR}/sys/isatty.c
|
sys/unlink.c
|
||||||
${LIBWRAP_DIR}/sys/times.c
|
sys/wait.c
|
||||||
${LIBWRAP_DIR}/sys/sbrk.c
|
sys/write.c
|
||||||
${LIBWRAP_DIR}/sys/_exit.c
|
# Standard library
|
||||||
${LIBWRAP_DIR}/misc/write_hex.c
|
stdlib/malloc.c
|
||||||
${LIBWRAP_DIR}/sys/printf.c
|
# Miscellaneous
|
||||||
${LIBWRAP_DIR}/sys/puts.c
|
misc/write_hex.c
|
||||||
)
|
|
||||||
IF(${SEMIHOSTING})
|
|
||||||
SET(LIBWRAP_SRCS ${LIBWRAP_SRCS} ${LIBWRAP_DIR}/semihosting/semihosting.c ${LIBWRAP_DIR}/semihosting/trap.c)
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
SET(LIBWRAP_SYMS malloc free open lseek read write fstat stat close link unlink execve fork getpid jukk wait isatty times sbrk _exit printf puts)
|
|
||||||
# Includes
|
|
||||||
INCLUDE_DIRECTORIES(
|
|
||||||
${LIBWRAP_DIR}
|
|
||||||
${LIBWRAP_DIR}/../include
|
|
||||||
${LIBWRAP_DIR}/../drivers
|
|
||||||
${LIBWRAP_DIR}/../env
|
|
||||||
${LIBWRAP_DIR}/../env/iss
|
|
||||||
)
|
)
|
||||||
|
|
||||||
ADD_LIBRARY(LIBWRAP_TGC STATIC ${LIBWRAP_SRCS})
|
if(SEMIHOSTING)
|
||||||
TARGET_COMPILE_OPTIONS(LIBWRAP_TGC PRIVATE -march=${RISCV_ARCH}_zicsr_zifencei -mabi=${RISCV_ABI} "-DBOARD_${BOARD}")
|
list(APPEND LIB_SOURCES
|
||||||
|
semihosting/semihosting.c
|
||||||
|
semihosting/trap.c )
|
||||||
|
|
||||||
FOREACH(SYM ${LIBWRAP_SYMS})
|
endif()
|
||||||
LIST(APPEND WRAP_LDFLAGS "-Wl,--wrap=${SYM}")
|
|
||||||
ENDFOREACH()
|
|
||||||
|
|
||||||
SET(LIBWRAP_TGC_LDFLAGS ${WRAP_LDFLAGS} "-Wl,--start-group" "-Wl,--end-group" "-L. -lLIBWRAP_TGC")
|
add_library(${PROJECT_NAME} OBJECT ${LIB_SOURCES})
|
||||||
|
|
||||||
ENDIF(NOT DEFINED _MK_LIBWRAP)
|
|
||||||
|
# Include directories
|
||||||
|
target_include_directories(${PROJECT_NAME} PRIVATE
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
${BSP_BASE}/include
|
||||||
|
include/
|
||||||
|
${BSP_BASE}/env
|
||||||
|
${BSP_BASE}/env/${BOARD}
|
||||||
|
${BSP_BASE}/drivers
|
||||||
|
)
|
||||||
|
|
||||||
|
# Compile options
|
||||||
|
|
||||||
|
#link global_compile_options to this libraries
|
||||||
|
target_link_libraries(${PROJECT_NAME} PRIVATE global_compile_options)
|
||||||
|
|
||||||
|
# Compile definitions
|
||||||
|
#target_compile_definitions(libwrap_objects PRIVATE
|
||||||
|
# BOARD_${BOARD}
|
||||||
|
#)
|
||||||
|
|
||||||
|
# Export objects to parent scope
|
||||||
|
set(LIBWRAP_OBJECTS $<TARGET_OBJECTS:${PROJECT_NAME}> PARENT_SCOPE)
|
||||||
|
@ -9,7 +9,6 @@ LIBWRAP_SRCS := \
|
|||||||
sys/open.c \
|
sys/open.c \
|
||||||
sys/lseek.c \
|
sys/lseek.c \
|
||||||
sys/read.c \
|
sys/read.c \
|
||||||
sys/write.c \
|
|
||||||
sys/fstat.c \
|
sys/fstat.c \
|
||||||
sys/stat.c \
|
sys/stat.c \
|
||||||
sys/close.c \
|
sys/close.c \
|
||||||
|
Loading…
Reference in New Issue
Block a user