Cmake's main functionalities are fully implmeneted now the error handler should be optimized

master
kerem yollu 2 years ago
parent c893a9584e
commit 36be0a0f9e

@ -60,8 +60,13 @@ set(PERIPHERAL_LIBS)#Declared empty because it will be filled automaticaly after
# Directory for the libraries -> "Common to all CSL"
set(LIBRARIES_DIR ${CMAKE_SOURCE_DIR}/libraries)
set(LIBRARIES_HEADERS_DIR ${CMAKE_SOURCE_DIR}/libraries)
set(LIBRARIES_HEADERS_DIR)#Declared empty because it will be filled automaticaly afterwards
set(LIBRARIES_LIBS)#Declared empty because it will be filled automaticaly afterwards
# Directory for the SYSTEM -> "Common to all CSL"
set(SYSTEM_DIR ${CMAKE_SOURCE_DIR}/system)
set(SYSTEM_HEADERS_DIR)#Declared empty because it will be filled automaticaly afterwards
set(SYSTEM_LIBS)#Declared empty because it will be filled automaticaly afterwards
####################################################################################################
# INCLUDES ####################################################################################################
@ -80,9 +85,15 @@ include(${PROJECT_CONFIG_FILE})
# Here is the include fopr the awailable peripheral headers and standart libraries.
include(${PERIPHERALS_DIR}/CMakeLists.txt)
# Here is the include fopr the awailable peripheral headers and standart libraries.
# Here is the include fopr the awailable drivers headers and standart libraries.
include(${DRIVERS_DIR}/CMakeLists.txt)
# Here is the include fopr the awailable libraries headers and standart libraries.
include(${LIBRARIES_DIR}/CMakeLists.txt)
# Here is the include fopr the awailable system headers and standart libraries.
include(${SYSTEM_DIR}/CMakeLists.txt)
# Include the config fiel where the compilers to use ar defined
include(${COMPILER_DEFS})
@ -91,77 +102,56 @@ include(${COMPILER_DEFS})
include(${CSL_CONFIG_FILE})
####################################################################################################
# HEADERS : ALL Header Definitions and calls MSUT be made here to be able to propagate them through
# HEADERS : ALL Header Definitions and calls MUST be made here to be able to propagate them through
# all the modules
####################################################################################################
message("${BoldBlue}")
message("+-------------------------------+")
message("Adding Header Directories")
message("+-------------------------------+")
message("-->For Drivers")
message("|-->For Drivers")
createHeaderDirList("${DRIVERS_DIR}" "${DRIVERS_LIST}" "DRIVERS_HEADERS_DIR")
message("-->For Peripherals")
message("${BoldBlue}|-->For Peripherals")
createHeaderDirList("${PERIPHERALS_DIR}" "${PERIPHERALS_LIST}" "PERIPHERALS_HEADERS_DIR")
message("+-------------------------------+")
message("${BoldBlue}|-->For Libraries")
createHeaderDirList("${LIBRARIES_DIR}" "${LIBRARIES_LIST}" "LIBRARIES_HEADERS_DIR")
message("${BoldBlue}|-->For Project")
checkDirectories("${PROJECT_HEADERS_DIR}")
message("${BoldBlue}|-->For System")
createHeaderDirList("${SYSTEM_DIR}" "${SYSTEM_LIST}" "SYSTEM_HEADERS_DIR")
message("${BoldBlue}+-------------------------------+${ColourReset}")
set (COMMON_HEADERS ${CSL_HEADERS_DIR}
${PERIPHERALS_HEADERS_DIR}
${DRIVERS_HEADERS_DIR}
${LIBRARIES_HEADERS_DIR}
${PROJECT_HEADERS_DIR})
${PROJECT_HEADERS_DIR}
${SYSTEM_HEADERS_DIR})
####################################################################################################
# Driver definitions
# Making Modules
####################################################################################################
message("Cheking Drivers ")
message("+-------------------------------+")
foreach(X IN LISTS DRIVERS_LIST)
addDriver("${X}" "NEW_DRIVER")
list(APPEND DRIVER_LIBS ${NEW_DRIVER})
endforeach()
message("+-------------------------------+")
message("${ColourReset}")
####################################################################################################
# Peripehral definitions
####################################################################################################
message("${BoldYellow}")
message("${BoldBlue}")
message("+-------------------------------+")
message("Cheking Periferals")
message("Making Submolues")
message("+-------------------------------+")
message("|-->For Drivers")
makeSubmodules("${DRIVERS_DIR}" "${DRIVERS_LIST}" "DRIVER_LIBS")
message("${BoldBlue}|-->For Peripherals")
makeSubmodules("${PERIPHERALS_DIR}" "${PERIPHERALS_LIST}" "PERIPHERAL_LIBS")
message("${BoldBlue}|-->For Libraries")
makeSubmodules("${LIBRARIES_DIR}" "${LIBRARIES_LIST}" "LIBRARIES_LIBS")
message("${BoldBlue}|-->For Project")
makeSubmodules("${PROJECT_DIR}" "${PROJECT_SOURCES_DIR_LIST}" "PROJECT_LIBS")
message("${BoldBlue}|-->For System")
makeSubmodules("${SYSTEM_DIR}" "${SYSTEM_LIST}" "SYSTEM_LIBS")
message("${BoldBlue}+-------------------------------+${ColourReset}")
message("+-------------------------------+")
message("${ColourReset}")
####################################################################################################
# User's project definitions
####################################################################################################
message("${BoldMagenta}")
message("+-------------------------------+")
message("Cheking User's Project")
message("+-------------------------------+")
message("Included Project Headers :")
checkDirectories("${PROJECT_HEADERS_DIR}")
message("Included Project Sources :")
checkDirectories("${PROJECT_SOURCES_DIR}")
message("Declared sources :")
printList("|-->" "${PROJECT_SOURCES_DIR_LIST}")
message("Creating Libraries for declared sources :")
foreach(X IN LISTS PROJECT_SOURCES_DIR_LIST)
projectAddItem("${X}" "NEW_PROJECT_ITEM")
list(APPEND PROJECT_LIBS ${NEW_PROJECT_ITEM})
endforeach()
message("+-------------------------------+")
message("${ColourReset}")
####################################################################################################
# Stick All the libraries together, only for code redability futher down.
####################################################################################################
foreach(X IN LISTS STARTUP_UCODE PROJECT_LIBS PERIPHERAL_LIBS DRIVER_LIBS)
foreach(X IN LISTS STARTUP_UCODE PROJECT_LIBS PERIPHERAL_LIBS DRIVER_LIBS LIBRARIES_LIBS SYSTEM_LIBS)
list(APPEND GENERATED_LIBRARIES ${X})
endforeach()
@ -206,7 +196,7 @@ message("${ColourReset}")
####################################################################################################
# EXECUTABLE
####################################################################################################
add_executable(${EXECUTABLE} ${PROJECT_DIR}/main.c)
add_executable(${EXECUTABLE} ${PROJECT_DIR}/main.${PL})
target_compile_options(${EXECUTABLE} PRIVATE ${MAIN_FLAGS})
target_compile_definitions(${EXECUTABLE} PRIVATE ${MAIN_DEFS})
target_include_directories(${EXECUTABLE} PUBLIC ${COMMON_HEADERS})

@ -1,16 +1,16 @@
####################################################################################################
# Project function for cheking header files source files and generating libraries from them.
# DIRECTORY CHECKS
####################################################################################################
#Searching if the given header and/or sources directory exists if not we brake the compilation
function(checkDirectories _directoryList)
foreach(DIR IN LISTS _directoryList)
if(EXISTS ${DIR})
message("|--> ${DIR} : INCLUDED")
message("${BoldMagenta} |-> Added : ${DIR}")
else()
errorDirNotFound()
endif()
endforeach()
message("${ColourReset}")
endfunction()
function(checkDirectory _directory)
@ -20,102 +20,39 @@ function(checkDirectory _directory)
endif()
endfunction()
####################################################################################################
# HEADER MANAGEMENT
####################################################################################################
# This function goes an searches for directories containing header files and return the corresponding directory.
function(createHeaderDirList _directory _list _headersList)
set(_newheaderDirList)
foreach(DIR IN LISTS _list)
checkDirectory("${_directory}/${DIR}")
list(APPEND _newheaderDirList ${_directory}/${DIR})
message(" |-> Header Directory : ${_directory}/${DIR} = ADDED")
message("${BoldMagenta} |-> Added : ${_directory}/${DIR}")
endforeach()
set(${_headersList} ${_newheaderDirList} PARENT_SCOPE)
endfunction()
####################################################################################################
# Peripheral function for generating libraries from them.
####################################################################################################
function(addPeripheral alias _currentPripheral)
if(EXISTS ${CSL_SOURCES_DIR}/imp_${alias}.${PL}) # Checks if the desired peripheral is implemented for the desired CSL.
message(" --> Peripheral: ${alias} = FOUND")
message(" |-> Drirectory: ${CSL_SOURCES_DIR}/imp_${alias}.${PL}")
if(EXISTS ${PERIPHERALS_HEADERS_DIR}/${alias}.${PL}) # Cheks if generic funtions are awailable. this is useful for standars as SPI i2c etc...
message(" --> Generic Library ${alias}.${PL} for imp_${alias}.${PL} = FOUND")
message(" |-> DIRECTORY: ${PERIPHERALS_HEADERS_DIR}/${alias}.${PL}")
add_library(${alias}_submodule ${PERIPHERALS_HEADERS_DIR}/${alias}.${PL} ${CSL_SOURCES_DIR}/imp_${alias}.${PL})
else()
add_library(${alias}_submodule ${CSL_SOURCES_DIR}/imp_${alias}.${PL})
endif()
target_compile_options(${alias}_submodule PRIVATE ${MAIN_FLAGS})
target_compile_definitions(${alias}_submodule PRIVATE ${MAIN_DEFS})
target_include_directories(${alias}_submodule PUBLIC ${COMMON_HEADERS})
add_library(sub::${alias} ALIAS ${alias}_submodule)
set(${_currentPripheral} sub::${alias} PARENT_SCOPE)
else ()
message("${BoldRed}")
message(FATAL_ERROR "\nThe Included <<${alias}>> peripheral was NOT found ### COMPILATION ABORTED ###\n")
message("${ColourReset}")
endif()
endfunction()
####################################################################################################
# Driver function for generating libraries from them.
####################################################################################################
function(addDriver alias _currentDriver)
if(EXISTS ${DRIVERS_DIR}/${alias} ) # Checks if the desired peripheral is implemented for the desired CSL.
message(" --> Driver directory : ${DRIVERS_DIR}/${alias} = FOUND")
if(EXISTS ${DRIVERS_DIR}/${alias}/${alias}.${PL})
message(" |-> Source File : ${DRIVERS_DIR}/${alias}/${alias}.${PL} = FOUND")
if(EXISTS ${DRIVERS_DIR}/${alias}/${alias}.h)
message(" |-> Header File : ${DRIVERS_DIR}/${alias}/${alias}.h = FOUND")
add_library(${alias}_submodule ${DRIVERS_DIR}/${alias}/${alias}.${PL})
target_compile_options(${alias}_submodule PRIVATE ${MAIN_FLAGS})
target_compile_definitions(${alias}_submodule PRIVATE ${MAIN_DEFS})
target_include_directories(${alias}_submodule PUBLIC ${COMMON_HEADERS})
add_library(sub::${alias} ALIAS ${alias}_submodule)
set(${_currentDriver} sub::${alias} PARENT_SCOPE)
else ()
message("${BoldRed}")
message(FATAL_ERROR "\nThe Included <<${alias}>> Driver's Header file was NOT found ### COMPILATION ABORTED ###\n")
message("${ColourReset}")
endif()
else ()
message("${BoldRed}")
message(FATAL_ERROR "\nThe Included <<${alias}>> Driver's Source file was NOT found ### COMPILATION ABORTED ###\n")
message("${ColourReset}")
endif()
else ()
message("${BoldRed}")
message(FATAL_ERROR "\nThe Included <<${alias}>> Driver was NOT found ### COMPILATION ABORTED ###\n")
message("${ColourReset}")
endif()
set(${_headersList} ${_newheaderDirList} PARENT_SCOPE)
endfunction()
####################################################################################################
# PRINT FUNCTIONS
# SUBMODULE MANAGEMENT
####################################################################################################
function(printList _txt _list)
foreach(X IN LISTS _list)
message("${_txt}${X}")
endforeach()
endfunction()
function(makeSubmodules _directory _aliasList _submoduleList)
set(_newSubmoduleList)
foreach(alias IN LISTS _aliasList)
checkDirectory("${_directory}/${alias}")
if(EXISTS ${CSL_SOURCES_DIR}/imp_${alias}.${PL})
message(" |->Submodule CSL Implementation for : ${alias} : FOUND")
message(" |-> DIR: ${CSL_SOURCES_DIR}/imp_${alias}.${PL}")
message("${BoldYellow} |-> Target Found : ${alias} ")
if(EXISTS ${_directory}/${alias}/${alias}.${PL})
message(" |->Submodule Source File : ${alias}.c : FOUND")
message(" |-> DIR: ${_directory}/${alias}/${alias}.${PL}")
message(" |-> Imp source : ${CSL_SOURCES_DIR}/imp_${alias}.${PL}")
message(" |-> Lib Source : ${_directory}/${alias}/${alias}.${PL} ")
add_library(${alias}_submodule ${_directory}/${alias}/${alias}.${PL} ${CSL_SOURCES_DIR}/imp_${alias}.${PL})
else()
message(" |-> Imp source : ${CSL_SOURCES_DIR}/imp_${alias}.${PL}")
add_library(${alias}_submodule ${CSL_SOURCES_DIR}/imp_${alias}.${PL})
endif()
message(" |-> Name : sub::${alias}")
target_compile_options(${alias}_submodule PRIVATE ${MAIN_FLAGS})
target_compile_definitions(${alias}_submodule PRIVATE ${MAIN_DEFS})
target_include_directories(${alias}_submodule PUBLIC ${COMMON_HEADERS})
@ -123,8 +60,9 @@ function(makeSubmodules _directory _aliasList _submoduleList)
list(APPEND _newSubmoduleList sub::${alias})
else()
if(EXISTS ${_directory}/${alias}/${alias}.${PL})
message(" |->Submodule Source File : ${alias}.c : FOUND")
message(" |-> DIR: ${_directory}/${alias}/${alias}.${PL}")
message("${BoldYellow} |-> Target Found : ${alias} ")
message(" |-> Source : ${_directory}/${alias}/${alias}.${PL}")
message(" |-> Name : sub::${alias}")
add_library(${alias}_submodule ${_directory}/${alias}/${alias}.${PL})
target_compile_options(${alias}_submodule PRIVATE ${MAIN_FLAGS})
target_compile_definitions(${alias}_submodule PRIVATE ${MAIN_DEFS})
@ -132,10 +70,21 @@ function(makeSubmodules _directory _aliasList _submoduleList)
add_library(sub::${alias} ALIAS ${alias}_submodule)
list(APPEND _newSubmoduleList sub::${alias})
else()
message(" |->No Source File Found : Only headers will be added")
message("${BoldMagenta} |-> No Source file for target : ${alias}")
message(" |-> Only headers will be added")
endif()
endif()
endforeach()
printList("_newSubmoduleList = " ${_newSubmoduleList})
message("${ColourReset}")
set(${_submoduleList} ${_newSubmoduleList} PARENT_SCOPE)
endfunction()
####################################################################################################
# PRINT FUNCTIONS
####################################################################################################
function(printList _txt _list)
foreach(X IN LISTS _list)
message("${_txt}${X}")
endforeach()
endfunction()

@ -1 +1 @@
set(LIBRARIES_LIST)
set(LIBRARIES_LIST uart font)

@ -1,2 +1,2 @@
set(PERIPHERALS_LIST deviceSetup delay usart timer spi i2c pin interrupt)
set(PERIPHERALS_LIST deviceSetup delay usart timer spi i2c pin)

@ -0,0 +1,2 @@
set(SYSTEM_LIST interrupt)
Loading…
Cancel
Save