Libraries are now generated automatically, Startup, Driver and Peripherals have now their own declaration listsa and corresponding librabiries list

master
key 3 years ago
parent 7e777c575a
commit d8007fb1e3

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.15)
include(config/cmakeProjectConfig.cmake)
@ -6,11 +6,17 @@ set(CSL_DIR ${CMAKE_SOURCE_DIR}/csl/${CSL_USED})
set(CSL_SOURCES ${CMAKE_SOURCE_DIR}/csl/${CSL_USED}/Src)
if(EXISTS ${CSL_DIR}) # Cheking if the directory exists
message("${BoldGreen}Compiling for ${CSL_USED} ${ColourReset}")
set(COMPILER_DEFS config/compiler.cmake)
message("${Green}")
message("+-------------------------------+")
message("Compiling for ${CSL_USED}")
message("+-------------------------------+")
message("${ColourReset}")
set(COMPILER_DEFS ${CMAKE_SOURCE_DIR}/config/compiler.cmake)
set(PROJECT_DEFS ${CSL_DIR}/config.cmake)
else()
message( FATAL_ERROR "${BoldRed}Please Select a valid CSL, CMake will exit.${ColourReset}" )
message("${Red}")
message( FATAL_ERROR "\nPlease Select a valid CSL, CMake will exit\n")
message("${ColourReset}")
endif()
include(${COMPILER_DEFS})
@ -38,43 +44,77 @@ add_subdirectory(csl)
add_subdirectory(drivers)
add_subdirectory(periferals)
####################################################################################################
#Sartupt uCode Definition
####################################################################################################
list(APPEND STARTUP_UCODE sub::startup)
####################################################################################################
#Peripehral definitions
####################################################################################################
set(PERIPHERALS_LIST deviceSetup delay usart timer spi i2c pin)
set(NEW_ELEMENT null)
addPeripheral("deviceSetup") # TODO: this point needs to be discussed. How should it work and what should it do?
addPeripheral("timer")
addPeripheral("usart")
addPeripheral("spi")
addPeripheral("i2c")
addPeripheral("delay")
addPeripheral("pin")
message("${BoldYellow}")
message("+-------------------------------+")
message("Cheking Periferals")
message("+-------------------------------+")
foreach(X IN LISTS PERIPHERALS_LIST)
addPeripheral("${X}" "NEW_ELEMENT")
list(APPEND PERIPHERAL_LIBS ${NEW_ELEMENT})
endforeach()
message("+-------------------------------+")
message("${ColourReset}")
####################################################################################################
#Driver definitions
####################################################################################################
set(DRIVERS_LIST max7219)
message("${BoldYellow}")
message("+-------------------------------+")
message("Cheking Drivers")
message("+-------------------------------+")
message("${BoldBlue}Project Info ${ColourReset}")
message("${Blue} |--> Exec Name \t: ${EXECUTABLE} ${ColourReset}")
message("${Blue} |--> Compiler Def\t: ${COMPILER_DEFS} ${ColourReset}")
message("${Blue} |--> Project Def\t: ${PROJECT_DEFS} ${ColourReset}")
message("${Blue} |--> Interfaces Dir\t: ${INTERFACES_DIR} ${ColourReset}")
message("${Blue} |--> Libs used\t\t: ${EXTRA_LIBS} ${ColourReset}")
foreach(X IN LISTS DRIVERS_LIST)
list(APPEND DRIVER_LIBS sub::${X})
endforeach()
message("+-------------------------------+")
message("${ColourReset}")
####################################################################################################
#Library definitions
#Overview
####################################################################################################
list(APPEND EXTRA_LIBS sub::startup)
list(APPEND EXTRA_LIBS sub::delay)
list(APPEND EXTRA_LIBS sub::usart)
list(APPEND EXTRA_LIBS sub::timer)
list(APPEND EXTRA_LIBS sub::deviceSetup)
list(APPEND EXTRA_LIBS sub::max7219)
list(APPEND EXTRA_LIBS sub::spi)
list(APPEND EXTRA_LIBS sub::i2c)
list(APPEND EXTRA_LIBS sub::pin)
message("${BoldBlue}")
message("+-------------------------------+")
message("Project Info")
message("+-------------------------------+")
message(" |--> Executable's Name\t\t\t : ${EXECUTABLE}")
message(" |--> Compiler Definition file\t\t : ${COMPILER_DEFS}")
message(" |--> Project's cmake configuration\t : ${PROJECT_DEFS}")
message(" |--> Chip Support Layer Dir.\t\t : ${CSL_DIR}")
message(" |--> Driver Dir\t\t\t : ${DRIVERS_DIR}")
message(" |--> Periferal Definition Dir\t\t : ${PERIFERALS_DIR}")
message(" |--> Periferal Implementation Dir\t : ${CSL_SOURCES}")
message(" |--> Startup uCode Submodule:")
message(" |->${STARTUP_UCODE}")
message(" |--> Periferals Submodules:")
foreach(X IN LISTS PERIPHERAL_LIBS)
message(" |->${X}")
endforeach()
message(" |--> Driver Submodules:")
foreach(X IN LISTS DRIVER_LIBS)
message(" |->${X}")
endforeach()
message("+-------------------------------+")
message("${ColourReset}")
####################################################################################################
#EXECUTABLE
@ -87,17 +127,27 @@ target_include_directories(${EXECUTABLE} PUBLIC ${MAIN_INCLUDES})
####################################################################################################
#LINKING EXECUTEABLE
####################################################################################################
message("${Cyan}")
message("+-------------------------------+")
message("Linker & Compiler Info")
message("+-------------------------------+")
if(IS_NO_SYS)
message("${Cyan}Using specifier Linker script ${ColourReset}")
message("${Cyan} |--> ${LINKER} ${ColourReset}")
target_link_libraries(${EXECUTABLE} ${EXTRA_LIBS})
target_link_libraries(${EXECUTABLE} ${STARTUP_UCODE} ${PERIPHERAL_LIBS} ${DRIVER_LIBS})
target_link_options(${EXECUTABLE} PRIVATE ${LINKER_FLAGS})
else ()
message("${Cyan}Using systems linker ${ColourReset}")
target_link_libraries(${EXECUTABLE} ${EXTRA_LIBS})
endif()
message(" |--> LINKER: ${LINKER}")
message(" |--> CMAKE_C_COMPILER: ${CMAKE_C_COMPILER}")
message(" |--> CMAKE_CXX_COMPILER: ${CMAKE_CXX_COMPILER}")
message(" |--> CMAKE_ASM_COMPILER: ${CMAKE_ASM_COMPILER}")
message(" |--> CMAKE_OBJCOPY: ${CMAKE_OBJCOPY}")
message(" |--> CMAKE_SIZE: ${CMAKE_SIZE}")
message(" |--> CMAKE_EXE_LINKER_FLAGS: ${CMAKE_EXE_LINKER_FLAGS}") #AS we provide our own linker nad not using the one from the curren OS (system)
message("+-------------------------------+")
message("${ColourReset}")
####################################################################################################
#CUSTOM COMMANDS
####################################################################################################

@ -1,8 +1,10 @@
function(addPeripheral alias)
function(addPeripheral alias _currentPripheral)
if(EXISTS ${CSL_SOURCES}/imp_${alias}.c) # Checks if the desired peripheral is implemented for the desired CSL.
message("Chip has usart >>imp_${alias}.c was found<<")
message(" --> Peripheral: ${alias} = FOUND")
message(" |-> Drirectory: ${CSL_SOURCES}/imp_${alias}.c")
if(EXISTS ${PERIFERALS_DIR}/${alias}.c) # Cheks if generic funtions are awailable. this is useful for standars as SPI i2c etc...
message("${alias}.c generic functions library extits")
message(" --> Generic Library ${alias}.c for imp_${alias}.c = FOUND")
message(" |-> DIRECTORY: ${PERIFERALS_DIR}/${alias}.c")
add_library(${alias}_submodule ${PERIFERALS_DIR}/${alias}.c ${CSL_SOURCES}/imp_${alias}.c)
else()
add_library(${alias}_submodule ${CSL_SOURCES}/imp_${alias}.c)
@ -12,9 +14,11 @@ function(addPeripheral alias)
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)
else() # optional block
message("${BoldRed}Chip has no usart periferal >>imp_usart.c was not found<<")
message("${BoldRed}Compilation Aborted")
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