-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
83f1563
commit 2c6d7d8
Showing
4 changed files
with
62 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ | |
# OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
# PERFORMANCE OF THIS SOFTWARE. | ||
|
||
# Author: Juan Sapriza ([email protected]) | ||
# Author: Jose Miranda, Juan Sapriza (jose.mirandacalero / juan.sapriza @epfl.ch) | ||
|
||
cmake_minimum_required(VERSION 3.15) | ||
|
||
|
@@ -154,7 +154,9 @@ ENDFOREACH() | |
|
||
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # | ||
# If the app was not found, look into the root project | ||
# Before re-setting SOURCE_PATH, save it so we can look later for external defined files | ||
|
||
SET(ORIGIN_SRCPATH ${SOURCE_PATH}) | ||
if( app_found EQUAL 0 ) | ||
SET(SOURCE_PATH ${ROOT_PROJECT}) | ||
|
||
|
@@ -185,9 +187,9 @@ if( app_found EQUAL 0 ) | |
string(REPLACE ";" "" c_dir_list ${c_dir_list}) | ||
endif() | ||
|
||
ENDFOREACH() | ||
endif() | ||
ENDFOREACH() | ||
endif() | ||
|
||
LIST(REMOVE_DUPLICATES c_dir_list) | ||
|
||
|
||
|
@@ -204,6 +206,11 @@ else() | |
message( "${Magenta}External application${ColourReset}") | ||
endif() | ||
|
||
####################################################################### | ||
# ADD CUSTOM DEFINITIONS | ||
####################################################################### | ||
add_compile_definitions($ENV{CDEFS}) | ||
|
||
####################################################################### | ||
# FIND CRT FILES TO BE INCLUDED | ||
####################################################################### | ||
|
@@ -219,15 +226,27 @@ SET(LIB_VCTR_P "${ROOT_PROJECT}device/lib/crt/vectors.S") | |
|
||
SET(CRTO "INTERNAL_CRTO") | ||
SET( LIB_CRT_EXT_P "" ) | ||
if( internal_app EQUAL 0 ) | ||
FILE(GLOB_RECURSE new_list FOLLOW_SYMLINKS "${SOURCE_PATH}/external/lib/crt/*.S") | ||
FILE(GLOB_RECURSE new_list FOLLOW_SYMLINKS "${SOURCE_PATH}/external/lib/crt/*.S") | ||
FOREACH(file_path IN LISTS new_list) | ||
if(${file_path} MATCHES "external_crt0.S") | ||
SET( CRTO "EXTERNAL_CRTO" ) | ||
SET( LIB_CRT_EXT_P "${file_path}" ) | ||
GET_FILENAME_COMPONENT(dir_path ${file_path} PATH) | ||
SET(INCLUDE_FOLDERS "${INCLUDE_FOLDERS} -I ${dir_path}") | ||
SET(h_dir_list_ ${h_dir_list_} "${dir_path}") | ||
endif() | ||
ENDFOREACH() | ||
|
||
#In case the application is internal, but there is still an external CRT | ||
if(NOT ${ORIGIN_SRCPATH} MATCHES ${SOURCE_PATH}) | ||
FILE(GLOB_RECURSE new_list FOLLOW_SYMLINKS "${ORIGIN_SRCPATH}external/lib/crt/*.S") | ||
FOREACH(file_path IN LISTS new_list) | ||
if(${file_path} MATCHES "external_crt0.S") | ||
SET( CRTO "EXTERNAL_CRTO" ) | ||
SET( LIB_CRT_EXT_P "${file_path}" ) | ||
GET_FILENAME_COMPONENT(dir_path ${file_path} PATH) | ||
SET(INCLUDE_FOLDERS "${INCLUDE_FOLDERS} -I ${dir_path}") | ||
SET(h_dir_list_ ${h_dir_list_} "${dir_path}") | ||
SET( CRTO "EXTERNAL_CRTO" ) | ||
SET( LIB_CRT_EXT_P "${file_path}" ) | ||
GET_FILENAME_COMPONENT(dir_path ${file_path} PATH) | ||
SET(INCLUDE_FOLDERS "${INCLUDE_FOLDERS} -I ${dir_path}") | ||
SET(h_dir_list_ ${h_dir_list_} "${dir_path}") | ||
endif() | ||
ENDFOREACH() | ||
endif() | ||
|
@@ -262,6 +281,7 @@ else() | |
message( FATAL_ERROR "Linker specification is not correct" ) | ||
endif() | ||
|
||
if (${VERBOSE} MATCHES "true") | ||
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # | ||
# Debug messages to check the paths | ||
|
||
|
@@ -271,10 +291,10 @@ message( "${Magenta}Root project: ${ROOT_PROJECT}${ColourReset}") | |
message( "${Magenta}Source path: ${SOURCE_PATH}${ColourReset}") | ||
message( "${Magenta}LIB_CRT PATH for Cmake: ${LIB_CRT_P}${ColourReset}") | ||
message( "${Magenta}LINKER File for Cmake: ${LINK_FILE}${ColourReset}") | ||
message( "${Magenta}LIB_DRIVERS PATH for Cmake: ${LIB_DRIVERS}${ColourReset}") | ||
message( "${Magenta}Targetting folder: ${INC_FOLDERS}${ColourReset}") | ||
message( "${Magenta}Target: ${TARGET}${ColourReset}") | ||
|
||
endif() | ||
|
||
|
||
####################################################################### | ||
# SET LINKER PROPERTIES | ||
|
@@ -289,7 +309,9 @@ SET(LINKED_FILES "${LIB_CRT_P} \ | |
${LIB_CRT_EXT_P} \ | ||
${c_dir_list}") | ||
|
||
message( "${Magenta}Linked files: ${LINKED_FILES}${ColourReset}") | ||
if (${VERBOSE} MATCHES "true") | ||
message( "${Magenta}Linked files: ${LINKED_FILES}${ColourReset}") | ||
endif() | ||
|
||
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # | ||
# Free-RTOS configurations | ||
|
@@ -413,7 +435,11 @@ SET(CMAKE_EXE_LINKER_FLAGS "-T ${LINKER_SCRIPT} \ | |
-ffunction-sections -fdata-sections -specs=nano.specs") | ||
message( "${Magenta}Lib Folder RISCV-GCC: ${RISCV}/${COMPILER_PREFIX}elf/lib${ColourReset}") | ||
|
||
SET(CMAKE_VERBOSE_MAKEFILE on) | ||
if (${VERBOSE} MATCHES "true") | ||
SET(CMAKE_VERBOSE_MAKEFILE ON) | ||
else() | ||
SET(CMAKE_VERBOSE_MAKEFILE OFF) | ||
endif() | ||
|
||
# To make sure that .obj files are created and fetched from the same path. | ||
# When setting an inner path to add_executable, .obj files are stored in ${MAINFILE}.elf.dir/<relative path> | ||
|
@@ -434,7 +460,7 @@ if (${COMPILER} MATCHES "clang") | |
_deps/freertos_kernel-build/libfreertos_kernel.a \ _deps/freertos_kernel-build/portable/libfreertos_kernel_port.a \ _deps/freertos_kernel-build/libfreertos_kernel.a \ _deps/freertos_kernel-build/portable/libfreertos_kernel_port.a \ | ||
") | ||
else() | ||
set( CMAKE_C_LINK_EXECUTABLE "${CMAKE_LINKER} ${COMPILER_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS} \ | ||
set( CMAKE_C_LINK_EXECUTABLE "${CMAKE_LINKER} ${COMPILER_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS} \ | ||
${SOURCE_PATH}build/CMakeFiles/${MAINFILE}.elf.dir/${OBJ_PATH}applications/${PROJECT}/${MAINFILE}.c.obj \ | ||
-o ${MAINFILE}.elf") | ||
endif() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ | |
# OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
# PERFORMANCE OF THIS SOFTWARE. | ||
|
||
# Author: Juan Sapriza ([email protected]) | ||
# Author: Jose Miranda, Juan Sapriza (jose.mirandacalero / juan.sapriza @epfl.ch) | ||
|
||
MAKE = make | ||
|
||
|
@@ -40,6 +40,8 @@ ARCH ?= rv32imc | |
# Path relative from the location of sw/Makefile from which to fetch source files. The directory of that file is the default value. | ||
SOURCE ?= $(".") | ||
|
||
VERBOSE ?= false | ||
|
||
# riscv toolchain install path | ||
RISCV ?= ~/.riscv | ||
RISCV_EXE_PREFIX = $(RISCV)/bin/${COMPILER_PREFIX}elf- | ||
|
@@ -48,13 +50,14 @@ RISCV_GDB_PATH = $(RISCV_EXE_PREFIX)gdb | |
# Get the absolute path | ||
mkfile_path := $(shell dirname "$(realpath $(firstword $(MAKEFILE_LIST)))") | ||
|
||
# Check the absolute path | ||
$(info $$You are executing from: $(mkfile_path)) | ||
|
||
# Get the absolute path of where to fetch sources | ||
source_path := $(realpath $(mkfile_path)/$(SOURCE)) | ||
$(info $$You are fetching sources from $(source_path) ) | ||
|
||
ifeq ($(ARG), value1) | ||
$(info $$You are executing from: $(mkfile_path)) | ||
else ifeq ($(ARG), value2) | ||
$(info $$You are fetching sources from $(source_path) ) | ||
endif | ||
|
||
SOURCE_PATH = $(source_path)/ | ||
ROOT_PROJECT = $(mkfile_path)/ | ||
|
@@ -64,6 +67,7 @@ LINK_FOLDER ?= $(mkfile_path)/linker | |
# CMake keyword | ||
CMAKE_DIR=cmake | ||
|
||
# to distinguish between cmake distros | ||
ifeq (, $(shell which cmake3)) # cmake3 is not defined | ||
CMAKE=cmake | ||
else | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,17 +13,17 @@ | |
# OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
# PERFORMANCE OF THIS SOFTWARE. | ||
|
||
# Author: Juan Sapriza ([email protected]) | ||
# Author: Jose Miranda, Juan Sapriza (jose.mirandacalero / juan.sapriza @epfl.ch) | ||
|
||
build : build/Makefile | ||
@echo Build | ||
${MAKE} -C build | ||
${MAKE} -s -C build | ||
|
||
setup : build/Makefile | ||
|
||
build/Makefile : CMakeLists.txt ${CMAKE_DIR}/riscv.cmake | ||
if [ ! -d build ] ; then mkdir build ; fi | ||
cd build; \ | ||
@if [ ! -d build ] ; then mkdir build ; fi | ||
@cd build; \ | ||
${CMAKE} \ | ||
-G "Unix Makefiles" \ | ||
-DCMAKE_TOOLCHAIN_FILE=../${CMAKE_DIR}/riscv.cmake \ | ||
|
@@ -32,11 +32,11 @@ build/Makefile : CMakeLists.txt ${CMAKE_DIR}/riscv.cmake | |
-DTARGET=${TARGET} \ | ||
-DPROJECT:STRING=${PROJECT} \ | ||
-DRISCV:STRING=${RISCV} \ | ||
-DINC_FOLDERS:STRING=${INC_FOLDERS} \ | ||
-DLINK_FOLDER:STRING=${LINK_FOLDER} \ | ||
-DLINKER:STRING=${LINKER} \ | ||
-DCOMPILER:STRING=${COMPILER} \ | ||
-DCOMPILER_PREFIX:STRING=${COMPILER_PREFIX} \ | ||
-DVERBOSE:STRING=${VERBOSE} \ | ||
../ | ||
|
||
clean: | ||
|