forked from TiejunMS/nf-interpreter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
binutils.FreeRTOS.cmake
219 lines (149 loc) · 6.76 KB
/
binutils.FreeRTOS.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
#
# Copyright (c) .NET Foundation and Contributors
# See LICENSE file in the project root for full license information.
#
function(NF_SET_OPTIMIZATION_OPTIONS TARGET)
target_compile_options(${TARGET} PRIVATE
$<$<CONFIG:Debug>:-Og -femit-class-debug-always -g3 -ggdb>
$<$<CONFIG:Release>:-O3 -flto -fuse-linker-plugin -fno-fat-lto-objects>
$<$<CONFIG:MinSizeRel>:-Os -flto -fuse-linker-plugin -fno-fat-lto-objects>
$<$<CONFIG:RelWithDebInfo>:-Os -femit-class-debug-always -g3 -ggdb>
)
endfunction()
function(NF_SET_LINK_MAP TARGET)
# need to remove the .elf suffix from target name
string(FIND ${TARGET} "." TARGET_EXTENSION_DOT_INDEX)
string(SUBSTRING ${TARGET} 0 ${TARGET_EXTENSION_DOT_INDEX} TARGET_SHORT)
# add linker flags to generate map file
set_property(TARGET ${TARGET_SHORT}.elf APPEND_STRING PROPERTY LINK_FLAGS " -Wl,-Map=${CMAKE_SOURCE_DIR}/build/${TARGET_SHORT}.map")
endfunction()
function(NF_SET_LINKER_FILE TARGET LINKER_FILE_NAME)
# set linker file name
set_target_properties(${TARGET} PROPERTIES LINK_FLAGS "-T${LINKER_FILE_NAME}")
endfunction()
function(NF_SET_COMPILER_DEFINITIONS TARGET)
# definition for platform
# (always ARM here)
target_compile_definitions(${TARGET} PUBLIC "-DPLATFORM_ARM")
# build types that have debugging capabilities AND are NOT RTM have to have the define 'NANOCLR_ENABLE_SOURCELEVELDEBUGGING'
if((NOT NF_BUILD_RTM) OR NF_FEATURE_DEBUGGER)
target_compile_definitions(${TARGET} PUBLIC "-DNANOCLR_ENABLE_SOURCELEVELDEBUGGING ")
endif()
# set compiler definition for RTM build option
if(NF_BUILD_RTM)
target_compile_definitions(${TARGET} PUBLIC -DBUILD_RTM)
endif()
# set compiler definition for using Application Domains feature
if(NF_FEATURE_USE_APPDOMAINS)
target_compile_definitions(${TARGET} PUBLIC -DNANOCLR_USE_APPDOMAINS)
endif()
# set compiler definition for implementing (or not) CRC32 in Wire Protocol
if(NF_WP_IMPLEMENTS_CRC32)
target_compile_definitions(${TARGET} PUBLIC -DWP_IMPLEMENTS_CRC32)
endif()
# set definition for Wire Protocol trace mask
target_compile_definitions(${TARGET} PUBLIC -DTRACE_MASK=${WP_TRACE_MASK})
# set compiler definition regarding inclusion of trace messages and checks on CLR
if(NF_PLATFORM_NO_CLR_TRACE)
target_compile_definitions(${TARGET} PUBLIC -DPLATFORM_NO_CLR_TRACE=1)
endif()
# set compiler definition regarding CLR IL inlining
if(NF_CLR_NO_IL_INLINE)
target_compile_definitions(${TARGET} PUBLIC -DNANOCLR_NO_IL_INLINE=1)
endif()
# include any extra compiler definitions comming from extra args
target_compile_definitions(${TARGET} PUBLIC ${ARGN})
endfunction()
# Add packages that are common to FreeRTOS platform builds
# To be called from target CMakeList.txt
macro(NF_ADD_PLATFORM_PACKAGES)
find_package(FreeRTOS REQUIRED)
find_package(CMSIS REQUIRED)
# nF feature: networking
if(USE_NETWORKING_OPTION)
find_package(LWIP REQUIRED)
endif()
if(USE_FILESYSTEM_OPTION)
find_package(FATFS REQUIRED)
endif()
endmacro()
# Add FreeRTOS platform dependencies to a specific CMake target
# To be called from target CMakeList.txt
macro(NF_ADD_PLATFORM_DEPENDENCIES TARGET)
# sources specific to nanoBooter
if(${TARGET} STREQUAL ${NANOBOOTER_PROJECT_NAME})
# add dependency from FreeRTOS (this is required to make sure the FreeRTOS repo is downloaded before the build starts)
add_dependencies(${TARGET}.elf FreeRTOS CMSIS)
endif()
# sources specific to nanoCRL
if(${TARGET} STREQUAL ${NANOCLR_PROJECT_NAME})
# add dependency from FreeRTOS (this is required to make sure the FreeRTOS repo is downloaded before the build starts)
add_dependencies(${TARGET}.elf FreeRTOS CMSIS LWIP)
endif()
endmacro()
# Add FreeRTOS platform include directories to a specific CMake target
# To be called from target CMakeList.txt
macro(NF_ADD_PLATFORM_INCLUDE_DIRECTORIES TARGET)
target_include_directories(${TARGET}.elf PUBLIC
${TARGET_FREERTOS_COMMON_INCLUDE_DIRS}
${TARGET_NXP_COMMON_INCLUDE_DIRS}
${FreeRTOS_INCLUDE_DIRS}
${CMSIS_INCLUDE_DIRS}
)
# includes specific to nanoBooter
if(${TARGET} STREQUAL ${NANOBOOTER_PROJECT_NAME})
target_include_directories(${TARGET}.elf PUBLIC
${TARGET_CMSIS_NANOBOOTER_INCLUDE_DIRS}
${TARGET_FREERTOS_NANOBOOTER_INCLUDE_DIRS}
)
endif()
# includes specific to nanoCRL
if(${TARGET} STREQUAL ${NANOCLR_PROJECT_NAME})
target_include_directories(${TARGET}.elf PUBLIC
${TARGET_NXP_NANOCLR_INCLUDE_DIRS}
${NANOCLR_PROJECT_INCLUDE_DIRS}
${TARGET_FREERTOS_NANOCLR_INCLUDE_DIRS}
${LWIP_INCLUDE_DIRS}
${CMAKE_CURRENT_SOURCE_DIR}/nanoCLR/fatfs
${FATFS_INCLUDE_DIRS}
)
endif()
endmacro()
# Add FreeRTOS platform target sources to a specific CMake target
# To be called from target CMakeList.txt
macro(NF_ADD_PLATFORM_SOURCES TARGET)
# add header files with common OS definitions and board definitions
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/target_common.h.in
${CMAKE_CURRENT_BINARY_DIR}/target_common.h @ONLY)
# sources common to both builds
target_sources(${TARGET}.elf PUBLIC
${TARGET_CMSIS_COMMON_SOURCES}
${FreeRTOS_SOURCES}
)
# sources specific to nanoBooter
if(${TARGET} STREQUAL ${NANOBOOTER_PROJECT_NAME})
# add header files with common OS definitions and board definitions
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/nanoBooter/target_board.h.in
${CMAKE_CURRENT_BINARY_DIR}/nanoBooter/target_board.h @ONLY)
target_sources(${TARGET}.elf PUBLIC
${TARGET_NXP_NANOBOOTER_SOURCES}
${CMAKE_SOURCE_DIR}/src/PAL/BlockStorage/nanoPAL_BlockStorage.c
# need to add configuration manager to allow get/store configuration blocks
${CMAKE_SOURCE_DIR}/src/HAL/nanoHAL_ConfigurationManager_stubs.c
)
endif()
# sources specific to nanoCRL
if(${TARGET} STREQUAL ${NANOCLR_PROJECT_NAME})
# add header files with common OS definitions and board definitions
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/nanoCLR/target_board.h.in
${CMAKE_CURRENT_BINARY_DIR}/nanoCLR/target_board.h @ONLY)
target_sources(${TARGET}.elf PUBLIC
${TARGET_FREERTOS_COMMON_SOURCES}
${TARGET_FREERTOS_NANOCLR_SOURCES}
${TARGET_NXP_COMMON_SOURCES}
${TARGET_NXP_NANOCLR_SOURCES}
${FATFS_SOURCES}
${LWIP_SOURCES}
)
endif()
endmacro()