cmake: rename variables related to kernel objects
This renames the variables related to the generation of kernel object hashes, and simply makes them more descriptive. Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This commit is contained in:
parent
365be4540b
commit
28c35120e0
1 changed files with 64 additions and 44 deletions
108
CMakeLists.txt
108
CMakeLists.txt
|
@ -801,11 +801,11 @@ if(CONFIG_USERSPACE)
|
||||||
set(GEN_KOBJ_LIST ${ZEPHYR_BASE}/scripts/gen_kobject_list.py)
|
set(GEN_KOBJ_LIST ${ZEPHYR_BASE}/scripts/gen_kobject_list.py)
|
||||||
set(PROCESS_GPERF ${ZEPHYR_BASE}/scripts/process_gperf.py)
|
set(PROCESS_GPERF ${ZEPHYR_BASE}/scripts/process_gperf.py)
|
||||||
|
|
||||||
set(OBJ_LIST kobject_hash.gperf)
|
set(KOBJECT_HASH_LIST kobject_hash.gperf)
|
||||||
set(OUTPUT_SRC_PRE kobject_hash_preprocessed.c)
|
set(KOBJECT_HASH_OUTPUT_SRC_PRE kobject_hash_preprocessed.c)
|
||||||
set(OUTPUT_SRC kobject_hash.c)
|
set(KOBJECT_HASH_OUTPUT_SRC kobject_hash.c)
|
||||||
set(OUTPUT_OBJ kobject_hash.c.obj)
|
set(KOBJECT_HASH_OUTPUT_OBJ kobject_hash.c.obj)
|
||||||
set(OUTPUT_OBJ_RENAMED kobject_hash_renamed.o)
|
set(KOBJECT_HASH_OUTPUT_OBJ_RENAMED kobject_hash_renamed.o)
|
||||||
|
|
||||||
# Essentially what we are doing here is extracting some information
|
# Essentially what we are doing here is extracting some information
|
||||||
# out of the nearly finished elf file, generating the source code
|
# out of the nearly finished elf file, generating the source code
|
||||||
|
@ -815,112 +815,132 @@ if(CONFIG_USERSPACE)
|
||||||
|
|
||||||
# Use the script GEN_KOBJ_LIST to scan the kernel binary's
|
# Use the script GEN_KOBJ_LIST to scan the kernel binary's
|
||||||
# (${ZEPHYR_PREBUILT_EXECUTABLE}) DWARF information to produce a table of kernel
|
# (${ZEPHYR_PREBUILT_EXECUTABLE}) DWARF information to produce a table of kernel
|
||||||
# objects (OBJ_LIST) which we will then pass to gperf
|
# objects (KOBJECT_HASH_LIST) which we will then pass to gperf
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
OUTPUT ${OBJ_LIST}
|
OUTPUT ${KOBJECT_HASH_LIST}
|
||||||
COMMAND
|
COMMAND
|
||||||
${PYTHON_EXECUTABLE}
|
${PYTHON_EXECUTABLE}
|
||||||
${GEN_KOBJ_LIST}
|
${GEN_KOBJ_LIST}
|
||||||
--kernel $<TARGET_FILE:${ZEPHYR_PREBUILT_EXECUTABLE}>
|
--kernel $<TARGET_FILE:${ZEPHYR_PREBUILT_EXECUTABLE}>
|
||||||
--gperf-output ${OBJ_LIST}
|
--gperf-output ${KOBJECT_HASH_LIST}
|
||||||
${gen_kobject_list_include_args}
|
${gen_kobject_list_include_args}
|
||||||
$<$<BOOL:${CMAKE_VERBOSE_MAKEFILE}>:--verbose>
|
$<$<BOOL:${CMAKE_VERBOSE_MAKEFILE}>:--verbose>
|
||||||
DEPENDS
|
DEPENDS
|
||||||
${ZEPHYR_PREBUILT_EXECUTABLE}
|
${ZEPHYR_PREBUILT_EXECUTABLE}
|
||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||||
)
|
)
|
||||||
add_custom_target(obj_list DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${OBJ_LIST})
|
add_custom_target(
|
||||||
|
kobj_hash_list
|
||||||
|
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${KOBJECT_HASH_LIST}
|
||||||
|
)
|
||||||
|
|
||||||
# Use gperf to generate C code (OUTPUT_SRC_PRE) which implements a
|
# Use gperf to generate C code (KOBJECT_HASH_OUTPUT_SRC_PRE) which implements a
|
||||||
# perfect hashtable based on OBJ_LIST
|
# perfect hashtable based on KOBJECT_HASH_LIST
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
OUTPUT ${OUTPUT_SRC_PRE}
|
OUTPUT ${KOBJECT_HASH_OUTPUT_SRC_PRE}
|
||||||
COMMAND
|
COMMAND
|
||||||
${GPERF}
|
${GPERF}
|
||||||
--output-file ${OUTPUT_SRC_PRE}
|
--output-file ${KOBJECT_HASH_OUTPUT_SRC_PRE}
|
||||||
${OBJ_LIST}
|
${KOBJECT_HASH_LIST}
|
||||||
DEPENDS obj_list ${OBJ_LIST}
|
DEPENDS kobj_hash_list ${KOBJECT_HASH_LIST}
|
||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||||
)
|
)
|
||||||
add_custom_target(output_src_pre DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_SRC_PRE})
|
add_custom_target(
|
||||||
|
kobj_hash_output_src_pre
|
||||||
|
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${KOBJECT_HASH_OUTPUT_SRC_PRE}
|
||||||
|
)
|
||||||
|
|
||||||
# For our purposes the code/data generated by gperf is not optimal.
|
# For our purposes the code/data generated by gperf is not optimal.
|
||||||
#
|
#
|
||||||
# The script PROCESS_GPERF creates a new c file OUTPUT_SRC based on
|
# The script PROCESS_GPERF creates a new c file KOBJECT_HASH_OUTPUT_SRC based on
|
||||||
# OUTPUT_SRC_PRE to greatly reduce the amount of code/data generated
|
# KOBJECT_HASH_OUTPUT_SRC_PRE to greatly reduce the amount of code/data generated
|
||||||
# since we know we are always working with pointer values
|
# since we know we are always working with pointer values
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
OUTPUT ${OUTPUT_SRC}
|
OUTPUT ${KOBJECT_HASH_OUTPUT_SRC}
|
||||||
COMMAND
|
COMMAND
|
||||||
${PYTHON_EXECUTABLE}
|
${PYTHON_EXECUTABLE}
|
||||||
${PROCESS_GPERF}
|
${PROCESS_GPERF}
|
||||||
-i ${OUTPUT_SRC_PRE}
|
-i ${KOBJECT_HASH_OUTPUT_SRC_PRE}
|
||||||
-o ${OUTPUT_SRC}
|
-o ${KOBJECT_HASH_OUTPUT_SRC}
|
||||||
-p "struct z_object"
|
-p "struct z_object"
|
||||||
$<$<BOOL:${CMAKE_VERBOSE_MAKEFILE}>:--verbose>
|
$<$<BOOL:${CMAKE_VERBOSE_MAKEFILE}>:--verbose>
|
||||||
DEPENDS output_src_pre ${OUTPUT_SRC_PRE}
|
DEPENDS kobj_hash_output_src_pre ${KOBJECT_HASH_OUTPUT_SRC_PRE}
|
||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||||
)
|
)
|
||||||
add_custom_target(output_src DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_SRC})
|
add_custom_target(
|
||||||
|
kobj_hash_output_src
|
||||||
|
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${KOBJECT_HASH_OUTPUT_SRC}
|
||||||
|
)
|
||||||
|
|
||||||
# We need precise control of where generated text/data ends up in the final
|
# We need precise control of where generated text/data ends up in the final
|
||||||
# kernel image. Disable function/data sections and use objcopy to move
|
# kernel image. Disable function/data sections and use objcopy to move
|
||||||
# generated data into special section names
|
# generated data into special section names
|
||||||
add_library(output_lib STATIC
|
add_library(
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_SRC}
|
kobj_hash_output_lib
|
||||||
|
STATIC ${CMAKE_CURRENT_BINARY_DIR}/${KOBJECT_HASH_OUTPUT_SRC}
|
||||||
)
|
)
|
||||||
|
|
||||||
set_source_files_properties(${OUTPUT_SRC} PROPERTIES COMPILE_FLAGS
|
set_source_files_properties(${KOBJECT_HASH_OUTPUT_SRC}
|
||||||
|
PROPERTIES COMPILE_FLAGS
|
||||||
"${NO_COVERAGE_FLAGS} -fno-function-sections -fno-data-sections")
|
"${NO_COVERAGE_FLAGS} -fno-function-sections -fno-data-sections")
|
||||||
|
|
||||||
set_source_files_properties(${OUTPUT_SRC}
|
set_source_files_properties(${KOBJECT_HASH_OUTPUT_SRC}
|
||||||
PROPERTIES COMPILE_DEFINITIONS "${compile_definitions_interface}")
|
PROPERTIES COMPILE_DEFINITIONS "${compile_definitions_interface}")
|
||||||
|
|
||||||
# Turn off -ffunction-sections, etc.
|
# Turn off -ffunction-sections, etc.
|
||||||
# NB: Using a library instead of target_compile_options(output_lib
|
# NB: Using a library instead of target_compile_options(kobj_hash_output_lib
|
||||||
# [...]) because a library's options have precedence
|
# [...]) because a library's options have precedence
|
||||||
add_library(output_lib_interface INTERFACE)
|
add_library(kobj_hash_output_lib_interface INTERFACE)
|
||||||
|
|
||||||
target_link_libraries(output_lib output_lib_interface)
|
target_link_libraries(kobj_hash_output_lib kobj_hash_output_lib_interface)
|
||||||
|
|
||||||
foreach(incl ${include_dir_in_interface})
|
foreach(incl ${include_dir_in_interface})
|
||||||
target_include_directories(output_lib_interface INTERFACE ${incl})
|
target_include_directories(kobj_hash_output_lib_interface INTERFACE ${incl})
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
foreach(incl ${sys_include_dir_in_interface})
|
foreach(incl ${sys_include_dir_in_interface})
|
||||||
target_include_directories(output_lib_interface SYSTEM INTERFACE ${incl})
|
target_include_directories(kobj_hash_output_lib_interface SYSTEM INTERFACE ${incl})
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
set(OUTPUT_OBJ_PATH ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/output_lib.dir/${OUTPUT_OBJ})
|
set(
|
||||||
|
KOBJECT_HASH_OUTPUT_OBJ_PATH
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/kobj_hash_output_lib.dir/${KOBJECT_HASH_OUTPUT_OBJ}
|
||||||
|
)
|
||||||
|
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_OBJ_RENAMED}
|
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${KOBJECT_HASH_OUTPUT_OBJ_RENAMED}
|
||||||
COMMAND $<TARGET_PROPERTY:bintools,elfconvert_command>
|
COMMAND $<TARGET_PROPERTY:bintools,elfconvert_command>
|
||||||
$<TARGET_PROPERTY:bintools,elfconvert_flag>
|
$<TARGET_PROPERTY:bintools,elfconvert_flag>
|
||||||
$<TARGET_PROPERTY:bintools,elfconvert_flag_section_rename>.data=.kobject_data.data
|
$<TARGET_PROPERTY:bintools,elfconvert_flag_section_rename>.data=.kobject_data.data
|
||||||
$<TARGET_PROPERTY:bintools,elfconvert_flag_section_rename>.text=.kobject_data.text
|
$<TARGET_PROPERTY:bintools,elfconvert_flag_section_rename>.text=.kobject_data.text
|
||||||
$<TARGET_PROPERTY:bintools,elfconvert_flag_section_rename>.rodata=.kobject_data.rodata
|
$<TARGET_PROPERTY:bintools,elfconvert_flag_section_rename>.rodata=.kobject_data.rodata
|
||||||
$<TARGET_PROPERTY:bintools,elfconvert_flag_infile>${OUTPUT_OBJ_PATH}
|
$<TARGET_PROPERTY:bintools,elfconvert_flag_infile>${KOBJECT_HASH_OUTPUT_OBJ_PATH}
|
||||||
$<TARGET_PROPERTY:bintools,elfconvert_flag_outfile>${OUTPUT_OBJ_RENAMED}
|
$<TARGET_PROPERTY:bintools,elfconvert_flag_outfile>${KOBJECT_HASH_OUTPUT_OBJ_RENAMED}
|
||||||
$<TARGET_PROPERTY:bintools,elfconvert_flag_final>
|
$<TARGET_PROPERTY:bintools,elfconvert_flag_final>
|
||||||
DEPENDS output_lib
|
DEPENDS kobj_hash_output_lib
|
||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||||
COMMAND_EXPAND_LISTS
|
COMMAND_EXPAND_LISTS
|
||||||
)
|
)
|
||||||
add_custom_target(output_obj_renamed DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_OBJ_RENAMED})
|
add_custom_target(
|
||||||
|
kobj_hash_output_obj_renamed
|
||||||
|
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${KOBJECT_HASH_OUTPUT_OBJ_RENAMED}
|
||||||
|
)
|
||||||
|
|
||||||
add_library(output_obj_renamed_lib STATIC IMPORTED GLOBAL)
|
add_library(kobj_hash_output_obj_renamed_lib STATIC IMPORTED GLOBAL)
|
||||||
set_property(
|
set_property(
|
||||||
TARGET output_obj_renamed_lib
|
TARGET kobj_hash_output_obj_renamed_lib
|
||||||
PROPERTY
|
PROPERTY
|
||||||
IMPORTED_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_OBJ_RENAMED}
|
IMPORTED_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/${KOBJECT_HASH_OUTPUT_OBJ_RENAMED}
|
||||||
)
|
)
|
||||||
add_dependencies(
|
add_dependencies(
|
||||||
output_obj_renamed_lib
|
kobj_hash_output_obj_renamed_lib
|
||||||
output_obj_renamed
|
kobj_hash_output_obj_renamed
|
||||||
)
|
)
|
||||||
|
|
||||||
set_property(GLOBAL APPEND PROPERTY GENERATED_KERNEL_OBJECT_FILES output_obj_renamed_lib)
|
set_property(
|
||||||
|
GLOBAL APPEND PROPERTY
|
||||||
|
GENERATED_KERNEL_OBJECT_FILES kobj_hash_output_obj_renamed_lib
|
||||||
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Read global variables into local variables
|
# Read global variables into local variables
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue