1# SPDX-License-Identifier: Apache-2.0 2 3zephyr_library() 4 5if(CONFIG_X86) 6 zephyr_linker_sources(ROM_START SORT_KEY 0x1bindesc bindesc_no_vt.ld) 7 zephyr_library_sources(x86/bindesc_skip.S) 8else() 9 zephyr_linker_sources(ROM_START SORT_KEY 0x1bindesc bindesc.ld) 10endif() 11 12macro(gen_str_definition def_name value) 13 if(CONFIG_BINDESC_${def_name}) 14 zephyr_library_compile_definitions(${def_name}="${value}") 15 endif() 16endmacro() 17 18if(CONFIG_BINDESC_DEFINE_BUILD_TIME) 19 zephyr_library_sources(bindesc_build_time.c) 20 21 set(gen_header ${PROJECT_BINARY_DIR}/include/generated/bindesc_build_time.h) 22 23 if(CONFIG_BINDESC_BUILD_TIME_USE_LOCAL_TIME) 24 set(BUILD_TIME "LOCAL") 25 else() 26 set(BUILD_TIME "UTC") 27 endif() 28 29 set(GEN_COMMAND ${CMAKE_COMMAND} 30 -DIN_FILE=${CMAKE_CURRENT_LIST_DIR}/bindesc_build_time.h.in 31 -DOUT_FILE=${gen_header} 32 -DBUILD_TIME_TYPE="${BUILD_TIME}" 33 -DBUILD_DATE_TIME_STRING_FORMAT="${CONFIG_BINDESC_BUILD_DATE_TIME_STRING_FORMAT}" 34 -DBUILD_DATE_STRING_FORMAT="${CONFIG_BINDESC_BUILD_DATE_STRING_FORMAT}" 35 -DBUILD_TIME_STRING_FORMAT="${CONFIG_BINDESC_BUILD_TIME_STRING_FORMAT}" 36 -P ${CMAKE_CURRENT_LIST_DIR}/gen_bindesc_build_time_h.cmake) 37 38 if(CONFIG_BINDESC_BUILD_TIME_ALWAYS_REBUILD) 39 add_custom_target(gen_bindesc_build_time 40 COMMAND ${GEN_COMMAND} 41 BYPRODUCTS ${gen_header} 42 ) 43 else() 44 add_custom_command(OUTPUT ${gen_header} 45 COMMAND ${GEN_COMMAND} 46 ) 47 add_custom_target(gen_bindesc_build_time DEPENDS ${gen_header}) 48 endif() 49 50 zephyr_library_add_dependencies(gen_bindesc_build_time) 51endif() 52 53if(CONFIG_BINDESC_DEFINE_VERSION) 54 zephyr_library_sources(bindesc_version.c) 55 if(EXISTS ${APPLICATION_SOURCE_DIR}/VERSION) 56 zephyr_library_compile_definitions(HAS_APP_VERSION=1) 57 endif() 58endif() 59 60if(CONFIG_BINDESC_DEFINE_HOST_INFO) 61 cmake_host_system_information(RESULT hostname QUERY HOSTNAME) 62 zephyr_library_sources(bindesc_host_info.c) 63 gen_str_definition(HOST_NAME ${hostname}) 64 gen_str_definition(C_COMPILER_NAME ${CMAKE_C_COMPILER_ID}) 65 gen_str_definition(C_COMPILER_VERSION ${CMAKE_C_COMPILER_VERSION}) 66 gen_str_definition(CXX_COMPILER_NAME ${CMAKE_CXX_COMPILER_ID}) 67 gen_str_definition(CXX_COMPILER_VERSION ${CMAKE_CXX_COMPILER_VERSION}) 68endif() 69