Moved library generation functions and driver generation function in to cmakeCore.cmake todo : give the project path trought run.sh the "../" can be confusing

master
Kerem Yollu 2 years ago
parent fce1f42f88
commit 5ef339c5bb

@ -25,6 +25,8 @@ set(PROJECT_CONFIG_FILE ${PROJECT_DIR}/projectDefinitions.cmake)
include(${CMAKE_CORE_DIR}/cmakeCore.cmake) #All the library and submodule funtions and definitions are written here
include(${CMAKE_CORE_DIR}/errorHandler.cmake) #For Detailed error messages.
include(${PROJECT_CONFIG_FILE}) #Here is the include Where the user sould define his project sources and headers
include(${PERIFERALS_DIR}/CMakeLists.txt) #Here is the include fopr the awailable peripheral headers and standart libraries.
include(${DRIVERS_DIR}/CMakeLists.txt) #Here is the include fopr the awailable peripheral headers and standart libraries.
####################################################################################################
# Cheking if the choosen CSL exists, this i redundant because run.sh makes that alredy but makes the
@ -69,9 +71,6 @@ set(STARTUP_UCODE sub::startup)
####################################################################################################
#Peripehral definitions
####################################################################################################
set(PERIPHERALS_LIST deviceSetup delay usart timer spi i2c pin)
set(NEW_PERIPHERAL null)
message("${BoldYellow}")
message("+-------------------------------+")
@ -89,7 +88,6 @@ message("${ColourReset}")
####################################################################################################
#Driver definitions
####################################################################################################
set(DRIVERS_LIST max7219 max31865)
message("${BoldBlue}")
message("+-------------------------------+")

@ -65,3 +65,69 @@ function(projectAddItem alias _currentItem)
endif()
endforeach()
endfunction()
####################################################################################################
# Peripheral function for generating libraries from them.
####################################################################################################
function(addPeripheral alias _currentPripheral)
if(EXISTS ${CSL_SOURCES}/imp_${alias}.${PL}) # Checks if the desired peripheral is implemented for the desired CSL.
message(" --> Peripheral: ${alias} = FOUND")
message(" |-> Drirectory: ${CSL_SOURCES}/imp_${alias}.${PL}")
if(EXISTS ${PERIFERALS_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: ${PERIFERALS_DIR}/${alias}.${PL}")
add_library(${alias}_submodule ${PERIFERALS_DIR}/${alias}.${PL} ${CSL_SOURCES}/imp_${alias}.${PL})
else()
add_library(${alias}_submodule ${CSL_SOURCES}/imp_${alias}.${PL})
endif()
target_compile_options(${alias}_submodule PRIVATE ${C_FLAGS})
target_compile_definitions(${alias}_submodule PRIVATE ${C_DEFS})
target_include_directories(${alias}_submodule PUBLIC ${PERIFERALS_DIR} ${CSL_INCLUDES})
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_subdirectory(${DRIVERS_DIR}/${alias})
add_library(${alias}_submodule ${DRIVERS_DIR}/${alias}/${alias}.${PL})
target_compile_options(${alias}_submodule PRIVATE ${C_FLAGS})
target_compile_definitions(${alias}_submodule PRIVATE ${C_DEFS})
target_include_directories(${alias}_submodule PUBLIC ${PERIFERALS_DIR} ${CSL_INCLUDES})
add_library(sub::${alias} ALIAS ${alias}_submodule)
set(${_currentPripheral} 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()
endfunction()

@ -1,4 +1,4 @@
function(errorHeaderDirNotFound)
function(errorDetected)
message("${Red}\n")
message("#########################################")
message("#\t@@@@ @@@ @@@ @@ @@@ \t#")
@ -7,10 +7,17 @@ function(errorHeaderDirNotFound)
message("#\t@ @ @ @ @ @ @ @ @ \t#")
message("#\t@@@@ @ @ @ @ @@ @ @ \t#")
message("#########################################")
message("#################################")
message("#\tAN ERROR HAS OCCURED\t#")
message("#################################")
message(" |-->HEADER DIRECTORY NOT FOUND")
message("#\tAN ERROR HAS OCCURED\t\t#")
message("#########################################")
endfunction()
function(errorOut)
message("#########################################\n\n")
endfunction()
function(errorHeaderDirNotFound)
errorDetected()
message(" |-->PROJECT HEADER DIRECTORY NOT FOUND")
message(" |-> Given dir : ${DIR}")
message("!!! Possible Reasons !!!")
message(" |--> Did you give corect path in ${PROJECT_CONFIG_FILE} ??")
@ -19,22 +26,13 @@ function(errorHeaderDirNotFound)
message(" |-> you can also use the \$\{PROJECT_DIR\} variable")
message(" |-> \$\{PROJECT_DIR\} = ${PROJECT_DIR}")
message(" |-> list(APPEND PROJECT_HEADERS_DIR \$\{PROJECT_DIR\}/path_to_your_directory")
message("################################################\n\n")
errorOut()
message(FATAL_ERROR "Header directory ${DIR} : NOT FOUND")
endfunction()
function(errorSourceDirNotFound)
message("${Red}\n")
message("#########################################")
message("#\t@@@@ @@@ @@@ @@ @@@ \t#")
message("#\t@ @ @ @ @ @ @ @ @ \t#")
message("#\t@@@ @@@ @@@ @ @ @@@ \t#")
message("#\t@ @ @ @ @ @ @ @ @ \t#")
message("#\t@@@@ @ @ @ @ @@ @ @ \t#")
message("#########################################")
message("#\tAN ERROR HAS OCCURED\t\t#")
message("#########################################")
message(" |-->SOURCE DIRECTORY NOT FOUND")
errorDetected()
message(" |--> PROJECT SOURCE DIRECTORY NOT FOUND")
message(" |-> Given dir : ${DIR}")
message("!!! Possible Reasons !!!")
message(" |--> Did you give corect path in ${PROJECT_CONFIG_FILE} ??")
@ -43,8 +41,7 @@ function(errorSourceDirNotFound)
message(" |-> you can also use the \$\{PROJECT_DIR\} variable")
message(" |-> \$\{PROJECT_DIR\} = ${PROJECT_DIR}")
message(" |-> list(APPEND PROJECT_SOURCES_DIR \$\{PROJECT_DIR\}/path_to_your_directory")
message("#########################################")
message("")
errorOut()
message(FATAL_ERROR "Source directory ${DIR} : NOT FOUND")
endfunction()

@ -1,34 +1 @@
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_subdirectory(${DRIVERS_DIR}/${alias})
add_library(${alias}_submodule ${DRIVERS_DIR}/${alias}/${alias}.${PL})
target_compile_options(${alias}_submodule PRIVATE ${C_FLAGS})
target_compile_definitions(${alias}_submodule PRIVATE ${C_DEFS})
target_include_directories(${alias}_submodule PUBLIC ${PERIFERALS_DIR} ${CSL_INCLUDES})
add_library(sub::${alias} ALIAS ${alias}_submodule)
set(${_currentPripheral} 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()
endfunction()
set(DRIVERS_LIST max7219 max31865)

@ -1,24 +1,2 @@
function(addPeripheral alias _currentPripheral)
if(EXISTS ${CSL_SOURCES}/imp_${alias}.${PL}) # Checks if the desired peripheral is implemented for the desired CSL.
message(" --> Peripheral: ${alias} = FOUND")
message(" |-> Drirectory: ${CSL_SOURCES}/imp_${alias}.${PL}")
if(EXISTS ${PERIFERALS_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: ${PERIFERALS_DIR}/${alias}.${PL}")
add_library(${alias}_submodule ${PERIFERALS_DIR}/${alias}.${PL} ${CSL_SOURCES}/imp_${alias}.${PL})
else()
add_library(${alias}_submodule ${CSL_SOURCES}/imp_${alias}.${PL})
endif()
set(PERIPHERALS_LIST deviceSetup delay usart timer spi i2c pin)
target_compile_options(${alias}_submodule PRIVATE ${C_FLAGS})
target_compile_definitions(${alias}_submodule PRIVATE ${C_DEFS})
target_include_directories(${alias}_submodule PUBLIC ${PERIFERALS_DIR} ${CSL_INCLUDES})
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()

Loading…
Cancel
Save