-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
Copy pathsdp.cmake
89 lines (70 loc) · 3.09 KB
/
sdp.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
#
# Copyright (c) 2024 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#
function(sdp_assembly_generate hrt_srcs)
set(hrt_msg "Generating ASM files for Hard Real Time files.")
set(hrt_opts -g0 -fno-ident -fno-verbose-asm)
# Compiler does not know how to build for this platform so we export
# all the flags used in this zephyr build to the external build system.
zephyr_get_compile_options_for_lang(C options)
zephyr_get_compile_definitions_for_lang(C defines)
zephyr_get_include_directories_for_lang(C includes)
zephyr_get_system_include_directories_for_lang(C sys_includes)
# Replace "-I" with "-isystem" to treat all Zephyr headers as system headers
# that do not trigger -Werror.
string(REPLACE "-I" "-isystem" includes "${includes}")
set(compiler_options ${defines} ${options} ${includes} ${sys_includes})
if(TARGET asm_gen)
message(FATAL_ERROR "sdp_assembly_generate() already called, please note that
sdp_assembly_generate() must be called only once with a list of all source files."
)
endif()
# Define the asm_gen target that depends on all generated assembly files
add_custom_target(asm_gen
COMMENT ${hrt_msg}
)
foreach(hrt_src ${hrt_srcs})
if(IS_DIRECTORY ${hrt_src})
message(FATAL_ERROR "sdp_assembly_generate() was called on a directory")
endif()
get_filename_component(src_filename ${hrt_src} NAME_WE) # filename without extension
add_custom_command(TARGET asm_gen
PRE_BUILD
BYPRODUCTS ${src_filename}-temp.s
COMMAND ${CMAKE_C_COMPILER} ${compiler_options} ${hrt_opts} -S ${hrt_src} -o ${src_filename}-temp.s
COMMAND ${PYTHON_EXECUTABLE} ${ZEPHYR_NRF_MODULE_DIR}/scripts/sdp/remove_comments.py ${src_filename}-temp.s
COMMAND_EXPAND_LISTS
COMMENT "Generating ASM file for ${hrt_src}"
)
endforeach()
add_dependencies(asm_gen syscall_list_h_target)
endfunction()
function(sdp_assembly_check hrt_srcs)
set(asm_check_msg "Checking if ASM files for Hard Real Time have changed.")
if(TARGET asm_check)
message(FATAL_ERROR "sdp_assembly_check() already called, please note that
sdp_assembly_check() must be called only once with a list of all source files."
)
endif()
string(REPLACE ";" "$<SEMICOLON>" hrt_srcs_semi "${hrt_srcs}")
add_custom_target(asm_check
COMMAND ${CMAKE_COMMAND} -D hrt_srcs="${hrt_srcs_semi}" -P ${ZEPHYR_NRF_MODULE_DIR}/cmake/sdp_asm_check.cmake
COMMENT ${asm_check_msg}
)
add_dependencies(asm_check asm_gen)
endfunction()
function(sdp_assembly_prepare_install hrt_srcs)
set(asm_install_msg "Updating ASM files for Hard Real Time.")
if(TARGET asm_install)
message(FATAL_ERROR "sdp_assembly_prepare_install() already called, please note that
sdp_assembly_prepare_install() must be called only once with a list of all source files."
)
endif()
string(REPLACE ";" "$<SEMICOLON>" hrt_srcs_semi "${hrt_srcs}")
add_custom_target(asm_install
COMMAND ${CMAKE_COMMAND} -D hrt_srcs="${hrt_srcs_semi}" -P ${ZEPHYR_NRF_MODULE_DIR}/cmake/sdp_asm_install.cmake
COMMENT ${asm_install_msg}
)
endfunction()